The useless release events are generated in the native level by XOrg, this is its default behavior. It means that a release event is generated just before the next press event for the same key or mouse button. NEWT is quite low level, this behavior is platform-dependent but as it is a Java API, developers may expect the same behavior for the same feature on all supported platforms which is not currently the case as Microsoft Windows do not generate these useless release events. There are three options: - do not modify the API - allow to enable or disable the auto-repeat - mark "useless" release events as auto-repeat events The first option is not satisfying as each developer working on higher level APIs will have to implement some "tricks" to ignore these events and it is more difficult when you cannot access them in the native code. The second option is nice for gaming in full screen mode but not for general applications as it is impossible to set this value for a single program but rather for the whole session (XAutoRepeatOff or XkbSetDetectableAutorepeat). Maybe some developers don't know how to use a shutdown hook. The third solution is the safest one, existing applications require no change, it won't change the way events are delivered, the same approach is used in Qt (see QKeyEvent::isAutoRepeat()). This example might be helpful: http://stackoverflow.com/posts/3220822/revisions Maybe it should be done only in JOGL 2.1 to avoid changing the public API now.
How about we do solution 3 + add these useless auto-repeat events on other platforms ? Then we would also have the same behavior .. and the information required. How about OSX ? On Windows we can simply inject the release event as auto-repeat, on X11 as done in you link. Good stuff ~Sven
(In reply to comment #1) > How about we do solution 3 + add these useless auto-repeat events on other > platforms ? > Then we would also have the same behavior .. and the information required. That's better, good idea, it would be more consistent. > > How about OSX ? > I don't know Mac OS X a lot. I can investigate tomorrow if you want. > On Windows we can simply inject the release event as auto-repeat, > on X11 as done in you link. Why not injecting them as "useful" events under Windows instead of marking them all useless? > > Good stuff > > ~Sven Thanks. Maybe there are auto-repeat mechanisms under Windows for accessibility but I don't know its APIs a lot.
http://jogamp.org/git/?p=jogl.git;a=commit;h=646714d3dab87396b9a3119bf90ca26e0b1c97ce com.jogamp.newt.event.KeyEvent: Key events are delivered in the following order: 1 EVENT_KEY_PRESSED 2 EVENT_KEY_RELEASED 3 EVENT_KEY_TYPED In case the native platform does not deliver keyboard events in the above order or skip events, the NEWT driver will reorder and inject synthetic events if required. Besides regular modifiers like InputEvent##SHIFT_MASK etc., the InputEvent.AUTOREPEAT_MASK bit is added if repetition is detected. Hope this suits us .. and matches your expectations.
Completed .. w/ commit 8777a6f0b8d5aa7c97643c68c4641593c6fa2c46
(In reply to comment #4) > Completed .. w/ commit 8777a6f0b8d5aa7c97643c68c4641593c6fa2c46 Thank you very much. I will look at the modifications, test them and modify Ardor3D (remove our dirty hacks).
We have figured out that the event sequence w/ auto-repeat is not consistent. Note Event order: EVENT_KEY_PRESSED EVENT_KEY_RELEASED EVENT_KEY_TYPED D = pressed, U = released, T = typed 0 = normal, 1 = auto-repeat D(0), [ U(1), T(1), D(1), U(1) T(1) ..], U(0) T(0) The idea is if you mask out auto-repeat in your event listener you just get one long pressed key D/U/T triple.
Adding unit tests for typed key order w/ and w/o auto repeat. Incl. fix for Windows. Auto-Repeat tests recognizes whether auto-repeat could be triggered by AWT Robot. The latter is not possible on Windows, hence manual testing was required on this platform. Impact: X11, Windows and OSX produce proper key sequence incl. auto-repeat modifier mask. http://jogamp.org/git/?p=jogl.git;a=commit;h=b008de41549e38aebdfcb7b094046235a8dde72f
Enhanced w/ multiple key support, see Bug 631 and: <http://jogamp.org/git/?p=jogl.git;a=commit;h=2f9c77a347b76bebdadd4bec1ac92aa7ab72365f>