Bug 766

Summary: Certain NEWT keyPressed events (e.g. VK_UP, while VK_DOWN is down) don't fire on Windows.
Product: [JogAmp] Newt Reporter: mike <msiggy>
Component: coreAssignee: Sven Gothel <sgothel>
Status: RESOLVED DUPLICATE    
Severity: major CC: andreas, gouessej, jerome.jouvie, msiggy
Priority: ---    
Version: 1   
Hardware: pc_x86_64   
OS: windows   
Type: --- SCM Refs:
Workaround: ---

Description mike 2013-06-25 04:14:49 CEST
The keyPressed(KeyEvent e) input listener seems to miss certain key press events. 

I can most reliably reproduce it by pressing and holding down VK_RIGHT, then pressing VK_UP. The initial VK_UP pressed event never fires. Although subsequent VK_UP auto-repeat will fire. This seems to happen with any Action Key event. 

I don't remember this problem existing in rc10, so it must have arisen with the recent input handling changes
Comment 1 Julien Gouesse 2013-06-26 14:06:27 CEST
Please can you try some post RC11 aggregated builds to determine when this regression (if any) appeared?
Comment 2 mike 2013-06-27 02:07:30 CEST
Update: I tested this in an awt frame and it correctly fired the keyPressed event. That rules out any keyboard limitation or operating system limitation. So it must be a problem in NEWT somewhere. 

I will try to narrow down what release this started happening in.
Comment 3 Sven Gothel 2013-07-03 18:53:45 CEST
I have tested w/ latest and I do receive e.g. VK_UP if VK_DOWN is being hold,
maybe fixed w/ 460ad9822b2509865691258be851e62b85626677 for Bug 768.
Comment 4 Sven Gothel 2013-07-03 18:54:16 CEST
.. testing further now .. w/ signed applets and NewtCanvasAWT, etc.
Comment 5 mike 2013-07-03 19:16:16 CEST
I am on Windows 7 64 bit, it could be a platform specific thing? When I get home I will try latest and see if its fixed.
Comment 6 mike 2013-07-03 19:26:16 CEST
It could be that the first VK_UP keyPressed event is being incorrectly marked as isAutoRepeat. Which would make the first keypress and the subsequent autorepeat presses indistinguishable.

Just shooting out some ideas.
Comment 7 jouvieje 2013-07-03 21:38:12 CEST
This seem related to my 'bugreport' post at jogamp forum:
http://forum.jogamp.org/NEWT-key-pressed-event-sended-twice-for-some-keys-td4029506.html

On windows, newt is not able to detect correctly arrow, page up, etc keys due to keyCode being undefined and generates extra preesed event with autorepet mask (see my post for more details).
Comment 8 Sven Gothel 2013-07-03 23:35:52 CEST
(In reply to comment #7)
> This seem related to my 'bugreport' post at jogamp forum:
> http://forum.jogamp.org/NEWT-key-pressed-event-sended-twice-for-some-keys-
> td4029506.html
> 
> On windows, newt is not able to detect correctly arrow, page up, etc keys
> due to keyCode being undefined and generates extra preesed event with
> autorepet mask (see my post for more details).

I'm using lastest 2.0.2 rc12 on windows 7 x64.

There is a problem with auto-repeat for the arrow keys (left, up, down, right) in newt. When one of these keys is pressed and release quickly (so the key auto-repeated should not appear), the events received by newt are:
 1) pressed at t0
 2) pressed at t1 with modifier autorepeat mask
 3) released at t1
Obviously, the event 2 should not be send by newt in this case.

This only happens with arrow keys, and other keys does not receives this extra pressed event.
As far as I can see, this extra event is send by WindowDriver.sendKeyEvent, and by breakpointing, both WindowDriver.repeatKey and keyCode being 0 (ie VK_UNDEFINED).
This bug therefore exists for all other key event with an undefined keyCode (page up, ...).

EDIT: this seem to be related to bugzilla #766 https://jogamp.org/bugzilla/show_bug.cgi?id=766
Comment 9 Sven Gothel 2013-07-03 23:36:16 CEST
(In reply to comment #7)
> This seem related to my 'bugreport' post at jogamp forum:
> http://forum.jogamp.org/NEWT-key-pressed-event-sended-twice-for-some-keys-
> td4029506.html
> 
> On windows, newt is not able to detect correctly arrow, page up, etc keys
> due to keyCode being undefined and generates extra preesed event with
> autorepet mask (see my post for more details).

next time, pls copy/paste .. but thank you!
Comment 10 Sven Gothel 2013-07-03 23:47:14 CEST
(In reply to comment #8)
> (In reply to comment #7)
> > This seem related to my 'bugreport' post at jogamp forum:
> > http://forum.jogamp.org/NEWT-key-pressed-event-sended-twice-for-some-keys-
> > td4029506.html
> > 
> > On windows, newt is not able to detect correctly arrow, page up, etc keys
> > due to keyCode being undefined and generates extra preesed event with
> > autorepet mask (see my post for more details).
> 
> I'm using lastest 2.0.2 rc12 on windows 7 x64.
> 
> There is a problem with auto-repeat for the arrow keys (left, up, down,
> right) in newt. When one of these keys is pressed and release quickly (so
> the key auto-repeated should not appear), the events received by newt are:
>  1) pressed at t0
>  2) pressed at t1 with modifier autorepeat mask
>  3) released at t1
> Obviously, the event 2 should not be send by newt in this case.
> 
> This only happens with arrow keys, and other keys does not receives this
> extra pressed event.
> As far as I can see, this extra event is send by WindowDriver.sendKeyEvent,
> and by breakpointing, both WindowDriver.repeatKey and keyCode being 0 (ie
> VK_UNDEFINED).
> This bug therefore exists for all other key event with an undefined keyCode
> (page up, ...).
> 
> EDIT: this seem to be related to bugzilla #766
> https://jogamp.org/bugzilla/show_bug.cgi?id=766

I have pressed: left, then down + right .. and similar timings combinations, see below.

So bug 766 was the culprit, due to the '0' keyCode value ..

Please do a git-pull compile and test - or wait for next aggregated build.

+++

consumeKeyEvent(usr): KeyEvent[EVENT_KEY_PRESSED, code 0x95, sym 0x95, char '' (0x0), printable false, modifier false, action true, InputEvent[modifiers: [], NEWTEvent[source:jogamp.newt.driver.windows.WindowDriver, consumed false, when:1372887579633 d 0ms]]], consumed: false
consumeKeyEvent(usr): KeyEvent[EVENT_KEY_RELEASED, code 0x95, sym 0x95, char '' (0x0), printable false, modifier false, action true, InputEvent[modifiers: [], NEWTEvent[source:jogamp.newt.driver.windows.WindowDriver, consumed false, when:1372887579883 d 0ms]]], consumed: false
consumeKeyEvent(usr): KeyEvent[EVENT_KEY_PRESSED, code 0x98, sym 0x98, char '' (0x0), printable false, modifier false, action true, InputEvent[modifiers: [], NEWTEvent[source:jogamp.newt.driver.windows.WindowDriver, consumed false, when:1372887580053 d 0ms]]], consumed: false
consumeKeyEvent(usr): KeyEvent[EVENT_KEY_PRESSED, code 0x97, sym 0x97, char '' (0x0), printable false, modifier false, action true, InputEvent[modifiers: [], NEWTEvent[source:jogamp.newt.driver.windows.WindowDriver, consumed false, when:1372887580313 d 0ms]]], consumed: false
consumeKeyEvent(usr): KeyEvent[EVENT_KEY_RELEASED, code 0x98, sym 0x98, char '' (0x0), printable false, modifier false, action true, InputEvent[modifiers: [], NEWTEvent[source:jogamp.newt.driver.windows.WindowDriver, consumed false, when:1372887580333 d 0ms]]], consumed: false
consumeKeyEvent(usr): KeyEvent[EVENT_KEY_RELEASED, code 0x97, sym 0x97, char '' (0x0), printable false, modifier false, action true, InputEvent[modifiers: [], NEWTEvent[source:jogamp.newt.driver.windows.WindowDriver, consumed false, when:1372887580598 d 0ms]]], consumed: false

*** This bug has been marked as a duplicate of bug 768 ***
Comment 11 mike 2013-07-04 18:40:46 CEST
I can confirm this bug was resolved. Events are now firing properly on my machine with the latest build. Thanks Sven!
Comment 12 Andreas Drewke 2014-01-04 12:19:03 CET
Hi,

i have problems with missing input events in my java/jogl/newt application on mac os x, whereas the same code works  perfectly on windows.

is it possible that the fix was only applied to windows specific code?

looking forward to hear from you!

i hesitate to set the change the status of the bug anyway.