UmeshChoudhari / jnativehook

Automatically exported from code.google.com/p/jnativehook
0 stars 0 forks source link

AltGr returns keyCode:0 on Linux #68

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
Just attach a listener and press AltGr.

What is the expected output? What do you see instead?
Zero seems to be (is?) an invalid key code.

What version of the product are you using? On what operating system?
1.1.4, Debian 7, Gnome3 sesktop

Please provide any additional information below.
I'm using laptop with Hungarian keyboard.

Original issue reported on code.google.com by vbence-g...@freemail.hu on 20 Sep 2013 at 9:49

GoogleCodeExporter commented 9 years ago
I only have access to U.S. Keyboards.  Can you use xev to grab the key up and 
down information and paste it here?  It should look something like:

KeyPress event, serial 40, synthetic NO, window 0x3200001,
    root 0x2f7, subw 0x0, time 17302391, (-1123,-23), root:(343,0),
    state 0x10, keycode 38 (keysym 0x61, a), same_screen YES,
    XLookupString gives 1 bytes: (61) "a"
    XmbLookupString gives 1 bytes: (61) "a"
    XFilterEvent returns: False

KeyRelease event, serial 40, synthetic NO, window 0x3200001,
    root 0x2f7, subw 0x0, time 17302497, (-1123,-23), root:(343,0),
    state 0x10, keycode 38 (keysym 0x61, a), same_screen YES,
    XLookupString gives 1 bytes: (61) "a"
    XFilterEvent returns: False

Original comment by a...@1stleg.com on 20 Sep 2013 at 10:05

GoogleCodeExporter commented 9 years ago

Original comment by a...@1stleg.com on 20 Sep 2013 at 10:07

GoogleCodeExporter commented 9 years ago
Thanks for your quick answer. 

Here is the output for AltGr. A quck note: besides keyCode being 0, I indeed 
receive the rawKeyCode 108.

KeyPress event, serial 37, synthetic NO, window 0x2000001,
    root 0x14f, subw 0x0, time 363696, (601,-46), root:(603,45),
    state 0x0, keycode 108 (keysym 0xfe03, ISO_Level3_Shift), same_screen YES,
    XKeysymToKeycode returns keycode: 92
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 37, synthetic NO, window 0x2000001,
    root 0x14f, subw 0x0, time 363749, (601,-46), root:(603,45),
    state 0x80, keycode 108 (keysym 0xfe03, ISO_Level3_Shift), same_screen YES,
    XKeysymToKeycode returns keycode: 92
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

I also noticed the same (receiving 0 keycode) for keys with accent (for example 
"á"):

KeyPress event, serial 38, synthetic NO, window 0x2000001,
    root 0x14f, subw 0x0, time 793536, (483,-45), root:(485,46),
    state 0x0, keycode 48 (keysym 0xe1, aacute), same_screen YES,
    XLookupString gives 1 bytes: (e1) "�"
    XmbLookupString gives 1 bytes: (e1) "�"
    XFilterEvent returns: False

KeyRelease event, serial 38, synthetic NO, window 0x2000001,
    root 0x14f, subw 0x0, time 793604, (483,-45), root:(485,46),
    state 0x0, keycode 48 (keysym 0xe1, aacute), same_screen YES,
    XLookupString gives 1 bytes: (e1) "�"
    XFilterEvent returns: False

Original comment by vbence-g...@freemail.hu on 21 Sep 2013 at 8:41

GoogleCodeExporter commented 9 years ago
Please test with 1.2 and let me know if the problem is still the same.  

Original comment by a...@1stleg.com on 12 May 2014 at 3:16

Attachments:

GoogleCodeExporter commented 9 years ago
Unfortunately, it is still the same. I'm pressing an 'a' and then an 'á' key. 
Here is the log:

Auto Repeat Rate: 500
Auto Repeat Delay: 30
Double Click Time: 200
Pointer Sensitivity: 2
Pointer Acceleration Multiplier: 1
Pointer Acceleration Threshold: 1
NATIVE_KEY_PRESSED,keyCode=65,keyText=A,keyChar=Undefined,keyLocation=KEY_LOCATI
ON_STANDARD,rawCode=38
NATIVE_KEY_TYPED,keyCode=0,keyText=Undefined,keyChar='a',keyLocation=KEY_LOCATIO
N_STANDARD,rawCode=38
NATIVE_KEY_RELEASED,keyCode=65,keyText=A,keyChar=Undefined,keyLocation=KEY_LOCAT
ION_STANDARD,rawCode=38
NATIVE_KEY_PRESSED,keyCode=0,keyText=Undefined,keyChar=Undefined,keyLocation=KEY
_LOCATION_UNKNOWN,rawCode=48
NATIVE_KEY_TYPED,keyCode=0,keyText=Undefined,keyChar='á',keyLocation=KEY_LOCATI
ON_UNKNOWN,rawCode=48
NATIVE_KEY_RELEASED,keyCode=0,keyText=Undefined,keyChar=Undefined,keyLocation=KE
Y_LOCATION_UNKNOWN,rawCode=48

Original comment by vbence-g...@freemail.hu on 12 May 2014 at 10:12

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I have verified the issue and identified the cause, but I am not sure how to 
'fix' it.  What scan code should we expect the right alt key to produce when it 
is used as an altgr key?  

The simplest solution would be to produce an alt scan code regardless of altgr 
status.  The other option would be to rewrite the scan code translate to take 
into account the keysym in addition to the keycode when determining a scan code 
for special keys like altgr.  The altgr and deadkey behavior is a bit different 
on each platform, for example when pressing the altgr key on Windows, you will 
receive ctrl + alt as a sort of macro making it more of a key combination 
instead of a unique altgr key.

Let me know what behavior you would expect and if the alt being sent would be 
an acceptable solution.  Thanks! 

Original comment by a...@1stleg.com on 14 May 2014 at 8:58

GoogleCodeExporter commented 9 years ago
Thanks for working on this issue.

The project I want to use this functionality is a Synergy-like remote 
controlled keyboard and mouse solution. Jnativehook is used to catch the events 
on the machine with the keyboard and mouse. Robot is used on the other machines 
to simulate the same actions.

The ideal codes could be fed to Robot on the other side.

Original comment by vbence-g...@freemail.hu on 14 May 2014 at 10:11

GoogleCodeExporter commented 9 years ago
I have implemented the simpler solution as of 
https://github.com/kwhat/libuiohook/commit/b47372658f67831f1e0c5f9306402b0ac6a8b
ff6 ; I will attach a nightly for evaluation tonight.

Original comment by a...@1stleg.com on 14 May 2014 at 10:27

GoogleCodeExporter commented 9 years ago
Ok, so here is what you will probably end up doing: 1.2 includes a function 
called GlobalScreen.postNativeEvent() that takes a NativeInputEvent object and 
inserts it into the host event queue.  Now, I have no idea how that is actually 
going to work with the altgr, but the goal is exactly what you outlined.  

The postNativeEvent function probably has the most bugs in it at this point.  
If you don't mind doing the testing an reporting bugs to github, I don't mind 
making the fixes ;)  There are some junit tests that attempt to check for 
correct key codes, but these tests are very difficult to get full coverage on 
for multiple platforms.

Original comment by a...@1stleg.com on 14 May 2014 at 11:22

GoogleCodeExporter commented 9 years ago
Attached is a nightly that includes the changes from today.  I did a little 
more reading and it looks like I may need to make a few more adjustments.  Let 
me know how the jar works out.

Original comment by a...@1stleg.com on 15 May 2014 at 5:19

Attachments:

GoogleCodeExporter commented 9 years ago
It looks OK this far. I'm getting the following for pressing [a] [á] [Left 
Alt] [AltGr] one at a time.

Auto Repeat Rate: 30
Auto Repeat Delay: 500
Double Click Time: 200
Pointer Sensitivity: 2
Pointer Acceleration Multiplier: 1
Pointer Acceleration Threshold: 1
NATIVE_KEY_PRESSED,keyCode=30,keyText=A,keyChar=Undefined,keyLocation=KEY_LOCATI
ON_STANDARD,rawCode=97
NATIVE_KEY_TYPED,keyCode=0,keyText=Undefined,keyChar='a',keyLocation=KEY_LOCATIO
N_STANDARD,rawCode=97
NATIVE_KEY_RELEASED,keyCode=30,keyText=A,keyChar=Undefined,keyLocation=KEY_LOCAT
ION_STANDARD,rawCode=97
NATIVE_KEY_PRESSED,keyCode=40,keyText=Quote,keyChar=Undefined,keyLocation=KEY_LO
CATION_STANDARD,rawCode=225
NATIVE_KEY_TYPED,keyCode=0,keyText=Undefined,keyChar='á',keyLocation=KEY_LOCATI
ON_STANDARD,rawCode=225
NATIVE_KEY_RELEASED,keyCode=40,keyText=Quote,keyChar=Undefined,keyLocation=KEY_L
OCATION_STANDARD,rawCode=225
NATIVE_KEY_PRESSED,keyCode=56,keyText=Alt,keyChar=Undefined,modifiers=Alt,keyLoc
ation=KEY_LOCATION_LEFT,rawCode=65513
NATIVE_KEY_RELEASED,keyCode=56,keyText=Alt,keyChar=Undefined,keyLocation=KEY_LOC
ATION_LEFT,rawCode=65513
NATIVE_KEY_PRESSED,keyCode=3640,keyText=Alt,keyChar=Undefined,modifiers=Alt,keyL
ocation=KEY_LOCATION_RIGHT,rawCode=65027
NATIVE_KEY_RELEASED,keyCode=3640,keyText=Alt,keyChar=Undefined,keyLocation=KEY_L
OCATION_RIGHT,rawCode=65027

I will check how Robot reacts later today.

Original comment by vbence-g...@freemail.hu on 15 May 2014 at 8:18

GoogleCodeExporter commented 9 years ago
Is this bug still a problem with the nightly attached here:  
https://code.google.com/p/jnativehook/issues/detail?id=43#c46 

Original comment by a...@1stleg.com on 24 Aug 2014 at 6:26

GoogleCodeExporter commented 9 years ago
I am calling this done.  If it comes back or is still a problem with RC4, 
please reopen here or open a new report on GitHub.

Original comment by a...@1stleg.com on 3 Dec 2014 at 3:55