Mouse Coordinates

Hi all, me again! ;D

Can I get an absolute coordinate when the mouse moves, directly, or I need to calculate it with the relative coordinates that the Mouse.Ball’s x and y axes give me? (At least it looks like that these axes are always returning an relative value, and I haven’t found any method to change this behavior).

Thanks :smiley:

Hi
JInput is lower level than the mouse system in AWT/windows, a mouse by itself has no idea of pointer location on a screen as a mouse knows nothing about a screen.
You might be able to do something by getting the location of the mouse with awt then tracking it, but I wouldn’t like to say how portable that would be. If yoy really do want just pointer positions, use AWT (for the mouse), if you want to use use it as a controller (mouse look in quake) then jinput would be ideal. In theory you could mix the two for using the mouse in game menus and in the game itself.

HTH

Endolf

i would suggest that if you want to avoid using AWT/Swing and you’re going fullscreen with opengl or something, you might as well make your own mouse system & draw your own pointer, keep it’s location in memory, and hide the OS’s mouse.

if you’re going windowed, use the mouse setup of whatever windowing api you are using, and if you’re going fullscreen 2d with java2D, you could use either but i’d recommend swing/awt. that way the users mouse pointer works exactly the same in the game as in their OS.

Hi
for pointing at things in a menu/window system in non fullscreen mode I would agree to use AWT, otherwise use Jinput, and if using the mouse as a controller rather than a pointer I would again suggest JInput, but then I might be a little bias :wink:

Endolf

Actualy I need to point things in a menu in fullscreen mode. Maybe I’ll have to mix jinput / awt, but I really wanted to use jinput for all input handling…
I’m using the MVC pattern and jinput is working great in the controller layer (at least for keyboard input…)

Hi
If you are doing it in fullscreen mode then you can just use JInput, start the mouse at the middle of the screen and then store that position and modify it when you get relative data from the mouse axis, you’ll probably need the old mouse speed/ration multiplyer that all the old games used to have to control the mouse speed in the game, you might also need to take into accound the screen res, if I move the mouse 4" across my desk I still expect the same % of the screen moved wether I’m in 800x600 or 1600x1200. You will still have to disable the windows mouse pointer, otherwise you will end up with two of them, AWT is needed to do that.

HTH

Endolf

I wonder what the problem is: Just write your own mouse pointer. Have a look at unreal tournament and co. this approach gives you much more flexibility and you can use it the same way in fullscreen and windowed mode.

and (sorry endolf i think you’re reading this a hundred times now :slight_smile: ) in linux you can easily have multiple mouse pointers controlled by different mice.

the only thing you should now worry is how to make the ‘real’ mouse cursor invisible. but thats an easy one as well: just have a look at java.awt.Toolkit.createCustomCursor() and java.awt.Component.setCursor().