LWJGL Forum

Programming => Bug Reports / RFE => Topic started by: Caironater on October 24, 2011, 00:47:00

Title: [BUG]Mouse.getDX() returns 0;
Post by: Caironater on October 24, 2011, 00:47:00
The topic says pretty much everything. getDY() returns 0 too.
Title: Re: [MAYBE BUG]Mouse.getDX() returns 0;
Post by: kappa on October 24, 2011, 08:52:58
That sounds like normal behaviour, it should only change when moving the mouse and will report the movement of the mouse since the last type Mouse.getDX() was called, so if it doesn't move it will be 0. Maybe you need Mouse.getX() instead?
Title: Re: [MAYBE BUG]Mouse.getDX() returns 0;
Post by: Caironater on October 24, 2011, 09:47:02
That sounds like normal behaviour, it should only change when moving the mouse and will report the movement of the mouse since the last type Mouse.getDX() was called, so if it doesn't move it will be 0. Maybe you need Mouse.getX() instead?

I'm moving the mouse.
But, seeing as I couldn't get it to work, I've just decided to use mouseX - prevMouseX instead :/
Title: Re: [MAYBE BUG]Mouse.getDX() returns 0;
Post by: avm1979 on October 24, 2011, 16:41:00
You're not on a Mac by any chance, are you? I noticed that Mouse.getDX()/Mouse.getDY() worked fine on Windows and Linux, but always returned zero in OSX.

Actually, I don't 100% remember it was always 0 - I think it actually *wasn't*. It was usually 0, but occasionally you'd get some non-zero values, enough to make things twitch. Was about 2 years ago, so it's hard to remember exactly :) I do remember having to switch away from using it, though.
Title: Re: [MAYBE BUG]Mouse.getDX() returns 0;
Post by: Caironater on October 24, 2011, 22:18:59
You're not on a Mac by any chance, are you? I noticed that Mouse.getDX()/Mouse.getDY() worked fine on Windows and Linux, but always returned zero in OSX.

Actually, I don't 100% remember it was always 0 - I think it actually *wasn't*. It was usually 0, but occasionally you'd get some non-zero values, enough to make things twitch. Was about 2 years ago, so it's hard to remember exactly :) I do remember having to switch away from using it, though.

Nah, I'm using Windows 7 + LWJGL 2.8.1;
Title: Re: [BUG]Mouse.getDX() returns 0;
Post by: gutomarzagao on February 21, 2012, 21:20:37
I'm using Windows 7 and getting the same problem.
And it's not always 0. If I move the mouse as fast as I can, it returns some values.
Title: Re: [BUG]Mouse.getDX() returns 0;
Post by: Matzon on February 21, 2012, 21:37:00
congratulations - you've acquired a mouse that shows the problem. Now debug it for us and provide a patch  :-*
Title: Re: [BUG]Mouse.getDX() returns 0;
Post by: princec on February 21, 2012, 22:12:55
I wonder if running a loop as fast as possible - eg. for (;;) { Display.update(); } - on a grabbed mouse in Windows wouldn't actually be expecting this behaviour, actually, having just been monkeying around in the code. The mouse is recentered every update(), which if you're running it at 1600Hz, means it probably never gets to move, and the movement is how we currently get the delta values.

I think we need a better way to get mouse deltas than this.

I seem to recall a long time ago when I first had JGLIB/LWJGL early alphas we used DirectInput for the mouse. Maybe we should look into using it again for delta values on Windows.

Cas :)
Title: Re: [BUG]Mouse.getDX() returns 0;
Post by: Matzon on February 21, 2012, 22:41:16
I think there could be an issue with this .. theoretically ... for people with the issue, does it also happen on sync(60) ?
Title: Re: [BUG]Mouse.getDX() returns 0;
Post by: sliders_alpha on April 15, 2012, 13:32:02
I'm having the same bug D:

I'm under windows7 64b and using eclipse 32b with the last LWJGL.
it doesn't matter how fast I move the mouse it never returns anything.

It does happen on sync(60)
Title: Re: [BUG]Mouse.getDX() returns 0;
Post by: mighty_archemedes on April 06, 2015, 20:04:52
I'm running into the same issue on Ubuntu Mate 15.04. It almost looks like something is being accidentally cast to an int and floored to zero somewhere. In the meanwhile, my workaround is to store each mouse position (which does update properly) in a record variable, and then determine the differential, each refresh, with a function or a binding.