Newt Mouse Event

classic Classic list List threaded Threaded
33 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Newt Mouse Event

gsxruk
Hi,

I have an application that uses a mouse listener attached to a GLWindow.  All the mouse events appear to work fine except for the method mouseWheelMoved.  Every time the mouse wheel is moved, the method is called (which you would expect), however what I don't understand is why for most of the events, calling getWheelRotation() returns 0?  Surely if this method returns an integer and has been called (i.e. the wheel has been moved), you would expect to receive either 1 or -1 as a minimum?  Or am I missing something?

Thanks,
Reply | Threaded
Open this post in threaded view
|

Re: Newt Mouse Event

gouessej
Administrator
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Newt Mouse Event

gsxruk
Hi,

I don't understand. The method has the signature:

public int getWheelRotation()

So surely it returns an integer?

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Newt Mouse Event

gouessej
Administrator
You're right, sorry. Can you tell me more about your configuration? Which operating system do you use?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Newt Mouse Event

gsxruk
Hi,

It's Windows 7 x64.  Also, I'm using the JOGL builds from yesterday so they're fairly recent.

I tried turning up the sensitivity of the mouse driver and this helped a little, but I still receive mainly 0's.  The mouse is a Microsoft wireless mouse.

Is there any more information that would help?

Thanks,
Reply | Threaded
Open this post in threaded view
|

Re: Newt Mouse Event

gsxruk
Hi,

Been looking into this a little more.  It appears that the AWT mouse event also returns 0 for the getWheelRotation() method.  However, there is a difference as follows:

On the AWT mouse listener:

1. There is an additional method getPreciseWheelRotation() that returns a double.
2. If the mouse wheel is turned very slowly, this method returns 0.25 or -0.25 for each step of wheel rotation.  For each of these  getWheelRotation returns 0.
3. On each 4th turn, getWheelRotation returns a 1 or -1.  This happens every time so it appears to represent the addition of the precise wheel rotation.

On the Newt mouse listener:

1. There is no method getPreciseWheelRotation() (at least that is accessible).
2. Again, if the mouse wheel is turned very slowly, a mouse event is received and getWheelRotation returns 0.
3. If the mouse wheel is turned slowly continuously, getWheelRotation continues to return 0. It appears to completely ignore all turns it deems too slow.

I think this seems like strange behaviour on the Newt listener?

Thanks,
Reply | Threaded
Open this post in threaded view
|

Re: Newt Mouse Event

gouessej
Administrator
It seems like a bug in Windows implementation of NEWT, you should report it, the instructions are here.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Newt Mouse Event

Sven Gothel
Administrator
In reply to this post by gsxruk
On 11/11/2012 09:41 PM, gsxruk [via jogamp] wrote:

> Hi,
>
> Been looking into this a little more.  It appears that the AWT mouse event
> also returns 0 for the getWheelRotation() method.  However, there is a
> difference as follows:
>
> On the AWT mouse listener:
>
> 1. There is an additional method getPreciseWheelRotation() that returns a double.
> 2. If the mouse wheel is turned very slowly, this method returns 0.25 or -0.25
> for each step of wheel rotation.  For each of these  getWheelRotation returns 0.
> 3. On each 4th turn, getWheelRotation returns a 1 or -1.  This happens every
> time so it appears to represent the addition of the precise wheel rotation.
>
> On the Newt mouse listener:
>
> 1. There is no method getPreciseWheelRotation() (at least that is accessible).
> 2. Again, if the mouse wheel is turned very slowly, a mouse event is received
> and getWheelRotation returns 0.
> 3. If the mouse wheel is turned slowly continuously, getWheelRotation
> continues to return 0. It appears to completely ignore all turns it deems too
> slow.
>
> I think this seems like strange behaviour on the Newt listener?
>
The following unit test / demo uses the mouse rotation to zoom
and it works on native NEWT on Linux/Windows here:
  <http://jogamp.org/deployment/jogamp-current/jogl-applet-runner-newt-GraphUISceneDemo01-napplet.html>

On OSX w/ CALayer, it does not - a bug in the AWT->NEWT mouse event translation,
read: simply missing.

Can you please produce a unit test exposing the bug you claim ?
This will make things much more clear.

Also pls add the mentioned detailed information Wiki/FAQ/Bugreport.

~Sven

> Thanks,


signature.asc (907 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Newt Mouse Event

gouessej
Administrator
Reply | Threaded
Open this post in threaded view
|

Re: Newt Mouse Event

gouessej
Administrator
If GET_WHEEL_DELTA_WPARAM(wParam) is lower than 120, zero is used as a wheel rotation (the result of the division is truncated). It can occur, especially on finer-resolution freely-rotating wheels without notch.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Newt Mouse Event

Sven Gothel
Administrator
On 11/11/2012 10:44 PM, gouessej [via jogamp] wrote:
> If GET_WHEEL_DELTA_WPARAM(wParam) is lower than 120, zero is used as a wheel
> rotation (the result of the division is truncated). It can occur, especially
> on finer-resolution freely-rotating wheels without notch.

great - looking fwd to your fix, thank you!

> On OSX w/ CALayer, it does not - a bug in the AWT->NEWT mouse event translation,
> read: simply missing.
>

Well, I just double checked. It is there in NewtCanvasAWT.
Have to check w/ OSX CALayer mouse wheel ..

~Sven



signature.asc (907 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Newt Mouse Event

gouessej
Administrator
I have no such mouse to test and there is no way to detect whether a wheel is freely rotating or not (I'm not sure of that). I don't know how MouseEvent.getUnitsToScroll() and MouseEvent.getScrollAmount() are implemented. I have to investigate more in order to find a smart solution.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Newt Mouse Event

gsxruk
In reply to this post by Sven Gothel
You've lost me guys!

Do you still require me to submit anything?

Sven, the applet you posted does work but I observe the same issue.  If I turn the mouse wheel slowly, the zoom does not occur.  I can turn at that slow speed for ages, and it never zooms.

Thanks for the help.
Reply | Threaded
Open this post in threaded view
|

Re: Newt Mouse Event

gouessej
Administrator
Yes please write a small bug report, be as accurate as possible, mention your mouse, your OS, etc...

I have just read that, I still don't understand how to get the scroll amount.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Newt Mouse Event

gouessej
Administrator
In reply to this post by gsxruk
gsxruk wrote
1. There is an additional method getPreciseWheelRotation() that returns a double.
2. If the mouse wheel is turned very slowly, this method returns 0.25 or -0.25 for each step of wheel rotation.  For each of these  getWheelRotation returns 0.
There is no such method:
http://docs.oracle.com/javase/6/docs/api/index.html?java/awt/event/MouseWheelEvent.html
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Newt Mouse Event

gsxruk
In reply to this post by gouessej
OK no problem.  I'll submit a report tomorrow as it's getting late here.

I've just read that.  It sounds like the AWT listener works in the same way, where the remainders are carried over until they amount to enough for the method to return a whole number.

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Newt Mouse Event

gouessej
Administrator
You're welcome. Maybe we could expose a more accurate value with another method but we have to look at other implementations too. It's late here too.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Newt Mouse Event

gouessej
Administrator
In my humble opinion, JInput is better for such a use case, I'm not sure we should treat that in NEWT.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Newt Mouse Event

gsxruk
In reply to this post by gouessej
gouessej wrote
gsxruk wrote
1. There is an additional method getPreciseWheelRotation() that returns a double.
2. If the mouse wheel is turned very slowly, this method returns 0.25 or -0.25 for each step of wheel rotation.  For each of these  getWheelRotation returns 0.
There is no such method:
http://docs.oracle.com/javase/6/docs/api/index.html?java/awt/event/MouseWheelEvent.html
It appears the getPreciseWheelRotation() method was introduced in JDK7.  I'm using JDK7.  The javadoc here http://docs.oracle.com/javase/7/docs/api/

Sorry, should of mentioned that originally.
Reply | Threaded
Open this post in threaded view
|

Re: Newt Mouse Event

gouessej
Administrator
Ok thanks, it just returns the same value than getWheelRotation but it does not cast it to int.

@Sven adding such a method in NEWT is trivial, isn't it?
Julien Gouesse | Personal blog | Website
12