Skip to content

Commit

Permalink
Update usr_share_X11_xkb_to_hwdb.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
diyism authored Jul 27, 2024
1 parent faea432 commit e447740
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions usr_share_X11_xkb_to_hwdb.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@ and then exec:

finally, test it with "sudo evtest", and the key code has been changed from 106 to 97. And the problem in google IDX monaco editor has been resolved.

scancode(700f4, or e04d) --> keycode(RGHT, Right, KEY_RIGHT, or 106) --> keysyms(RCTL, Control_R, KEY_RIGHTCTRL, or 97)

linux default scancode --> keycode, for example: 70045 --> key_f12
ref: https://github.com/torvalds/linux/blob/master/drivers/hid/bpf/progs/hid_report_helpers.h#L528
#define Usage_KK_KeyboardF12 Usage_i8(0x45)
ref: https://github.com/torvalds/linux/blob/master/drivers/hid/hid-debug.c#L380
{ 0x07, 0x0045, "KeyboardF12" },
scancode(700f4, KeyboardRightArrow) --> keycode(106, KEY_RIGHT) --> keysyms(97, Control_R)

linux内核默认映射scancode --> keycode, 例如: 7004f(KeyboardRightArrow) --> 106(KEY_RIGHT)
linux内核默认映射代码: https://github.com/torvalds/linux/blob/master/drivers/hid/hid-input.c 里面的 static const unsigned char hid_keyboard[256] = { ... } 映射表
比如 hid_keyboard[256] 第5行第16列 编号就是4f, 则scancode就是7004f, 映射表该位置的值是十进制的106就是keycode
ref:
scancode名称可以查: https://github.com/torvalds/linux/blob/master/drivers/hid/hid-debug.c#L380
{ 0x07, 0x004f, "KeyboardRightArrow" },
keycode名称可以查: grep -i grep -i 106 /usr/include/linux/input-event-codes.h
#define KEY_RIGHT 106

cat ./showkeys.sh:
#!/bin/bash
Expand Down

0 comments on commit e447740

Please sign in to comment.