Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Media keys have wrong keycode in XRDP session #1725

Closed
noorez opened this issue Nov 16, 2020 · 4 comments · Fixed by #3022 · May be fixed by neutrinolabs/xorgxrdp#303
Closed

Media keys have wrong keycode in XRDP session #1725

noorez opened this issue Nov 16, 2020 · 4 comments · Fixed by #3022 · May be fixed by neutrinolabs/xorgxrdp#303
Labels

Comments

@noorez
Copy link

noorez commented Nov 16, 2020

OS: Lubuntu 20.04
Hyper-V vsock connection

It appears that the media keys have the wrong key codes when using the xrdp session (but they work fine with the basic session in Hyper-V)...

in the xrdp session the keycodes received for the media keys are wrong

xev | sed -n 's/^.*state \([0-9].*\), keycode *\([0-9]\+\) *\(.*\), .*$/keycode \2 = \3, state = \1/p'
keycode 40 = (keysym 0x64, d), state = 0x10   <---Mute Key
keycode 40 = (keysym 0x64, d), state = 0x10
keycode 54 = (keysym 0x63, c), state = 0x10 <-- Volume Down
keycode 54 = (keysym 0x63, c), state = 0x10
keycode 56 = (keysym 0x62, b), state = 0x10 <-- Volume UP
keycode 56 = (keysym 0x62, b), state = 0x10
keycode 24 = (keysym 0x71, q), state = 0x10 <-- Back
keycode 24 = (keysym 0x71, q), state = 0x10
keycode 42 = (keysym 0x67, g), state = 0x10 <-- Play/Pause
keycode 42 = (keysym 0x67, g), state = 0x10
keycode 33 = (keysym 0x70, p), state = 0x10 <-- Forward
keycode 33 = (keysym 0x70, p), state = 0x10

The xrdp-genkeymap (in the xrdp session) command generated a new .ini file which was not the same as the default km-**409.ini that came by default, however this still did not work.

I attempted to set the key codes manually in the km-**409.ini file based on the output of 'xmodmap -pk' (in a basic session),

 121         0x1008ff12 (XF86AudioMute)      0x0000 (NoSymbol)       0x1008ff12 (XF86AudioMute)
 122         0x1008ff11 (XF86AudioLowerVolume)       0x0000 (NoSymbol)       0x1008ff11 (XF86AudioLowerVolume)
 123         0x1008ff13 (XF86AudioRaiseVolume)       0x0000 (NoSymbol)       0x1008ff13 (XF86AudioRaiseVolume)

and

Key121=269025042:0
Key122=269025041:0
Key123=269025043:0

I don't know how to fix the wrong keycode issue for this..

@noorez
Copy link
Author

noorez commented Nov 16, 2020

It appears that this might be the case because the rdpKeyboard.c file does not contain the XF86keysym.h file is not defined there. Would it be possible to add this file and recompile from source? It simply looks like a list of definitions but I'm not sure if they will be picked up automatically or if something else needs to use them?... (by C programming is quite rusty since I haven't used it in quite a long time :( )

@Mingun
Copy link

Mingun commented Dec 2, 2020

I faced with similar problem with keycodes in xRDP session in Ubuntu 18.04/20.04 in microsoft/vscode#111579. VSCode wiki suggests that it is probaly wrong mapping on the xRDP side. For example, corresponding output from VSCode build-in Developer: Toggle Keyboard Shortcuts Troubleshooting command when I press Divide on Numpad and then PageUp:

[KeybindingService]: / Received  keydown event - modifiers: [], code: PageUp, keyCode: 111, key: /
[KeybindingService]: | Converted keydown event - modifiers: [], code: PageUp, keyCode: 108 ('NumPad_Divide')
[KeybindingService]: | Resolving NumPad_Divide
[KeybindingService]: \ No keybinding entries.
[KeybindingService]: / Received  keydown event - modifiers: [], code: Lang4, keyCode: 33, key: PageUp
[KeybindingService]: | Converted keydown event - modifiers: [], code: Lang4, keyCode: 11 ('PageUp')
[KeybindingService]: | Resolving PageUp
[KeybindingService]: \ From 5 keybinding entries, matched cursorPageUp, when: textInputFocus, source: built-in.

xev output for the same keys:

$ xev
Outer window is 0x3a00001, inner window is 0x3a00002

PropertyNotify event, serial 8, synthetic NO, window 0x3a00001,
    atom 0x27 (WM_NAME), time 179519024, state PropertyNewValue

PropertyNotify event, serial 9, synthetic NO, window 0x3a00001,
    atom 0x22 (WM_COMMAND), time 179519024, state PropertyNewValue

PropertyNotify event, serial 10, synthetic NO, window 0x3a00001,
    atom 0x28 (WM_NORMAL_HINTS), time 179519024, state PropertyNewValue

CreateNotify event, serial 11, synthetic NO, window 0x3a00001,
    parent 0x3a00001, window 0x3a00002, (10,10), width 50, height 50
border_width 4, override NO

PropertyNotify event, serial 14, synthetic NO, window 0x3a00001,
    atom 0xef (WM_PROTOCOLS), time 179519024, state PropertyNewValue

MapNotify event, serial 15, synthetic NO, window 0x3a00001,
    event 0x3a00001, window 0x3a00002, override NO

ConfigureNotify event, serial 28, synthetic NO, window 0x3a00001,
    event 0x3a00001, window 0x3a00001, (0,0), width 178, height 178,
    border_width 0, above 0x80000b, override NO

PropertyNotify event, serial 28, synthetic NO, window 0x3a00001,
    atom 0x180 (_NET_WM_ALLOWED_ACTIONS), time 179519034, state PropertyNewValue

ReparentNotify event, serial 29, synthetic NO, window 0x3a00001,
    event 0x3a00001, window 0x3a00001, parent 0x800a91,
    (0,0), override NO

PropertyNotify event, serial 29, synthetic NO, window 0x3a00001,
    atom 0x103 (_NET_FRAME_EXTENTS), time 179519040, state PropertyNewValue

ConfigureNotify event, serial 29, synthetic NO, window 0x3a00001,
    event 0x3a00001, window 0x3a00001, (10,45), width 178, height 178,
    border_width 0, above 0x0, override NO

PropertyNotify event, serial 29, synthetic NO, window 0x3a00001,
    atom 0x15c (_GTK_EDGE_CONSTRAINTS), time 179519040, state PropertyNewValue

PropertyNotify event, serial 31, synthetic NO, window 0x3a00001,
    atom 0x106 (_NET_WM_DESKTOP), time 179519042, state PropertyNewValue

PropertyNotify event, serial 32, synthetic NO, window 0x3a00001,
    atom 0xf2 (WM_STATE), time 179519044, state PropertyNewValue

PropertyNotify event, serial 32, synthetic NO, window 0x3a00001,
    atom 0x10b (_NET_WM_STATE), time 179519044, state PropertyNewValue

PropertyNotify event, serial 32, synthetic NO, window 0x3a00001,
    atom 0x15c (_GTK_EDGE_CONSTRAINTS), time 179519044, state PropertyNewValue

PropertyNotify event, serial 34, synthetic NO, window 0x3a00001,
    atom 0x15c (_GTK_EDGE_CONSTRAINTS), time 179519045, state PropertyNewValue

PropertyNotify event, serial 34, synthetic NO, window 0x3a00001,
    atom 0x15c (_GTK_EDGE_CONSTRAINTS), time 179519055, state PropertyNewValue

PropertyNotify event, serial 34, synthetic NO, window 0x3a00001,
    atom 0x10b (_NET_WM_STATE), time 179519056, state PropertyNewValue

PropertyNotify event, serial 34, synthetic NO, window 0x3a00001,
    atom 0x15c (_GTK_EDGE_CONSTRAINTS), time 179519056, state PropertyNewValue

MapNotify event, serial 34, synthetic NO, window 0x3a00001,
    event 0x3a00001, window 0x3a00001, override NO

VisibilityNotify event, serial 34, synthetic NO, window 0x3a00001,
    state VisibilityUnobscured

Expose event, serial 34, synthetic NO, window 0x3a00001,
    (0,0), width 178, height 10, count 3

Expose event, serial 34, synthetic NO, window 0x3a00001,
    (0,10), width 10, height 58, count 2

Expose event, serial 34, synthetic NO, window 0x3a00001,
    (68,10), width 110, height 58, count 1

Expose event, serial 34, synthetic NO, window 0x3a00001,
    (0,68), width 178, height 110, count 0

PropertyNotify event, serial 34, synthetic NO, window 0x3a00001,
    atom 0x15c (_GTK_EDGE_CONSTRAINTS), time 179519276, state PropertyNewValue

PropertyNotify event, serial 34, synthetic NO, window 0x3a00001,
    atom 0x15c (_GTK_EDGE_CONSTRAINTS), time 179519567, state PropertyNewValue

FocusIn event, serial 34, synthetic NO, window 0x3a00001,
    mode NotifyNormal, detail NotifyNonlinear

KeymapNotify event, serial 34, synthetic NO, window 0x0,
    keys:  68  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   
           0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   

PropertyNotify event, serial 34, synthetic NO, window 0x3a00001,
    atom 0x10b (_NET_WM_STATE), time 179522928, state PropertyNewValue

PropertyNotify event, serial 34, synthetic NO, window 0x3a00001,
    atom 0x15c (_GTK_EDGE_CONSTRAINTS), time 179522928, state PropertyNewValue

PropertyNotify event, serial 34, synthetic NO, window 0x3a00001,
    atom 0x10b (_NET_WM_STATE), time 179522928, state PropertyNewValue

PropertyNotify event, serial 34, synthetic NO, window 0x3a00001,
    atom 0x15c (_GTK_EDGE_CONSTRAINTS), time 179522928, state PropertyNewValue

KeyPress event, serial 34, synthetic NO, window 0x3a00001,
    root 0x38a, subw 0x0, time 179525920, (-25,746), root:(44,810),
    state 0x10, keycode 112 (keysym 0xffaf, KP_Divide), same_screen YES,
    XLookupString gives 1 bytes: (2f) "/"
    XmbLookupString gives 1 bytes: (2f) "/"
    XFilterEvent returns: False

KeyRelease event, serial 37, synthetic NO, window 0x3a00001,
    root 0x38a, subw 0x0, time 179525994, (-25,746), root:(44,810),
    state 0x10, keycode 112 (keysym 0xffaf, KP_Divide), same_screen YES,
    XLookupString gives 1 bytes: (2f) "/"
    XFilterEvent returns: False

KeyPress event, serial 37, synthetic NO, window 0x3a00001,
    root 0x38a, subw 0x0, time 179528764, (-25,746), root:(44,810),
    state 0x10, keycode 99 (keysym 0xff55, Prior), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 37, synthetic NO, window 0x3a00001,
    root 0x38a, subw 0x0, time 179528857, (-25,746), root:(44,810),
    state 0x10, keycode 99 (keysym 0xff55, Prior), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

ClientMessage event, serial 37, synthetic YES, window 0x3a00001,
    message_type 0xef (WM_PROTOCOLS), format 32, message 0xee (WM_DELETE_WINDOW)
$

xrdp is using km-00000409.ini which is shipped with it (the content is equal to https://github.com/neutrinolabs/xrdp/blob/c654c862064db49766835c9af37f6fce9f2f8929/instfiles/km-00000409.ini)

My RDP client is standard Windows 10 RDP client (mstsc.exe)

Unfortunally, I can't check output when I physically sitting in front of my keyboard but I'll update this comment when I do (but probable that will not be soon).

@tim-gromeyer
Copy link

Any update on this? I have the same issue with Ubuntu 20.04 and Hyper-V's advanced session (which uses RDP)

@matt335672
Copy link
Member

No significant progress, but I'll report what I've found so I can pick up on it later.

Logging into the console of an Ubuntu VM with an X server gives me the following keycodes and keysyms according to xev:-

Key code keysym
Mute 121 XF86AudioMute
Volume Up 123 XF86AudioRaiseVolume
Volume Down 122 XF86AudioLowerVolume

In an xrdp session, the same keys give me this:-

Key code keysym
Mute 40 'd'
Volume Up 56 'c'
Volume Down 54 'b'

Stepping through the code, I'm getting the following values from the Windows client in TS_FP_KEYBOARD_EVENT PDUs:-

Key scancode FASTPATH_INPUT_KBDFLAGS_EXTENDED set ?
Mute 32 yes
Volume Up 48 yes
Volume Down 46 yes

So it looks like the processing of the FASTPATH_INPUT_KBDFLAGS_EXTENDED is somehow going wrong.

Sorry I can't be more help at present.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants