How do you change the mouse position?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How do you change the mouse position?

Eitan Goldshtrom
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.

-Eitan

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: How do you change the mouse position?

Stephen Sinclair
On Thu, Aug 12, 2010 at 10:50 PM, Eitan Goldshtrom
<[hidden email]> 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:

http://hackage.haskell.org/packages/archive/GLUT/2.2.2.0/doc/html/Graphics-UI-GLUT-Window.html

---------------------
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.
---------------------

Steve
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: How do you change the mouse position?

Eitan Goldshtrom
Thanks. That is exactly what I was looking for. I really appreciate the
help.

-Eitan
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe