[Haskell-cafe] How do you change the mouse position?

Stephen Sinclair radarsat1 at gmail.com
Thu Aug 12 22:57:28 EDT 2010

On Thu, Aug 12, 2010 at 10:50 PM, Eitan Goldshtrom
<thesourceofx at gmail.com> wrote:
> In C++, maybe Java, I remember using a Robot to change the location of the
> mouse on the screen. My intention is to do something like in an FPS game
> where the mouse is always centered to make sure it doesn't run into the
> edges of the screen. How can I do that in Haskell? I'm using OpenGL, so if
> there is a utility that specifically works with OpenGL then I believe that
> would be the most helpful.

This is to do with your choice of windowing for OpenGL.  This is often
either SDL or GLUT.  In GLUT, you'd use glutWarpPointer().  Looking in
the Hackage documentation, you can find a function called


pointerPosition :: SettableStateVar Position	Source
Setting pointerPosition warps the window system's pointer to a new
location relative to the origin of the current window by the specified
pixel offset, which may be negative. The warp is done immediately.

If the pointer would be warped outside the screen's frame buffer
region, the location will be clamped to the nearest screen edge. The
window system is allowed to further constrain the pointer's location
in window system dependent ways.


More information about the Haskell-Cafe mailing list