mouse API clarification

Started by willdenniss, December 01, 2004, 02:25:01

Previous topic - Next topic

willdenniss

Hi,

I was reading though the Mouse javadocs and some threads related to grabbing, and I'm a bit confused.  Is there any other documentation that I have missed?

I am currently using AWT events but wish to create an input abstraction API so I can use either AWT or LWJGL depending on what Xith3D renderer I am using at the time.

To provide some background, this is what I am currently doing for my game with AWT:  The cursor is hidden.  Every time a mouse event is recieved, I grab the delta, then move the mouse back to the center.  The reason I do this is that the X axis is for turning, and it simply wraps around.  The Y axis is for aiming and has an upper and lower limit.

With LWJGL in this scenario, would I go into grabbed mode and use the getDX/Y methods?

How do I move the cursor back to the center in LWJGL, or does one not need to do this in grabbed mode?

In un-grabbed mode, is it possible to move the cursor around (I use java.awt.Robot with AWT to do this)?

Does getX/Y still work in grabbed mode?


Thanks in advance,


Will.

PS.  I get a 404 from the Wiki link on this page: http://lwjgl.org/documentation.php

elias

Quote from: "willdenniss"Hi,

I was reading though the Mouse javadocs and some threads related to grabbing, and I'm a bit confused.  Is there any other documentation that I have missed?

I am currently using AWT events but wish to create an input abstraction API so I can use either AWT or LWJGL depending on what Xith3D renderer I am using at the time.

To provide some background, this is what I am currently doing for my game with AWT:  The cursor is hidden.  Every time a mouse event is recieved, I grab the delta, then move the mouse back to the center.  The reason I do this is that the X axis is for turning, and it simply wraps around.  The Y axis is for aiming and has an upper and lower limit.

With LWJGL in this scenario, would I go into grabbed mode and use the getDX/Y methods?

How do I move the cursor back to the center in LWJGL, or does one not need to do this in grabbed mode?

In un-grabbed mode, is it possible to move the cursor around (I use java.awt.Robot with AWT to do this)?

Does getX/Y still work in grabbed mode?


Thanks in advance,


Will.

PS.  I get a 404 from the Wiki link on this page: http://lwjgl.org/documentation.php

You don't need to reset the cursor position in grabbed mode.

GetX()/Y() work in grabbed mode, by simply adding the returned deltas to the current x/y.

You can't move the cursor in un-grabbed mode, sorry.

EDIT: I'm sure Matzon will come by and fix the wiki link :)

- elias

Matzon

Quote from: "elias"EDIT: I'm sure Matzon will come by and fix the wiki link :)
oops - yeah, will fix later - for now just use http://wiki.lwjgl.org

willdenniss

thanks.

Well I must say that I am very impressed with LWJGL.  It is really does achieve its goal of being great for games (and better than JOGL/AWT).

The delta-mouse mode is actually real and is pixel accurate.  AWT in comparison is hopeless, there is not such mouse mode, so one must program it in manually (get a mouse moved event, calculate the delta, then move the mouse back into position).  The AWT mouse sample rate is horrible, sometimes if you move fast enough an event isn't even fired (in OS X at least) until you move it again.  With LWJGL, you can sample as often as you like ;D

Programming an AWT "grabbed" mouse isn't so fun either.  You have to hide the cursor, then use the Robot class to move it back into position.   The catch is that Robot uses Screen coordinates, where as the mouse events are Contianer relitive.  Thus you have to either calculate the screen coordinates (complicated when when the frame is decorated) or calibrate the mouse.

I'm very impressed with the LWJGL OS X port, no bugs that I have noticed thus far.  It also outclasses JOGL in that I can have true full screen 3D apps.  Great work!

Cheers,

Will.