2

To send letter 'a', a HID device sends this scan code: 00 00 04 00 00 00 00 00.

Value which corresponds to character 'a' is <AC01> (found in /usr/share/X11/xkb/symbols/us). According to /usr/share/X11/xkb/keycodes/evdev, <AC01> is mapped to by button code 38 (this is what we must get from the device).

evtest /dev/input/event# shows code 30. Why?

Igor Liferenko
  • 1,499
  • 1
  • 13
  • 28

1 Answers1

7

Keycode in /usr/share/X11/xkb/keycodes/evdev is keycode from evtest + 8 (see MIN_KEYCODE in evdev.c).

This is how to find scancode corresponding to a given keycode:

https://source.android.com/devices/input/keyboard-devices#hid-keyboard-and-keypad-page-0x07

NOTE: scancodes are used in addition to keycodes for the following reason:

The Linux internal event subsystem has defined a standard set of key codes that are hardware independant, able to represent any scan code from any type of keyboard whether AT, XT or USB. There are names assigned to the key codes based on the common US ASCII key cap labels. The key codes are defined in /usr/include/linux/input-event-codes.h. For an example #define KEY_A 30.

Igor Liferenko
  • 1,499
  • 1
  • 13
  • 28