If you run something like
sudo evtest /dev/input/event7
where event7 corresponds to (say) a keyboard and you press a key, you get a report like:
Event: time 1725511187.487035, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70004
Event: time 1725511187.487035, type 1 (EV_KEY), code 30 (KEY_A), value 1
Event: time 1725511187.487035, -------------- SYN_REPORT ------------
for an a key press
and
Event: time 1725511187.543033, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70004
Event: time 1725511187.543033, type 1 (EV_KEY), code 30 (KEY_A), value 0
Event: time 1725511187.543033, -------------- SYN_REPORT ------------
for an a key release.
I'm interested in the value for MSC_SCAN (presumably these are evdev scancodes), where those (hexademical) values are something like 70004, 70005, 70006, 10086, c0224, etc.
These values seem to be directly related to USB HID keycodes, where:
- values
xin theKeyboard/Keypad Page (0x07)are0x70000 | x(eg. the USB HID keycode forais0x04, and0x70000 | 0x04is0x70004) - System Control values
xare0x10000 | x - values
xin theConsumer Page (0x0c)are0xc0000 | x
So my question is: where do the "base values" 0x70000, 0x10000, and 0xc0000 come from, and where does the 0x70000 | x logic come from?
Eg. (on Ubuntu 20) the value for KEY_A is 30 (decimal), and the 30 comes from /usr/include/linux/input-event-codes.h, where there's a #define KEY_A 30.
(I'm writing firmware for a USB HID device and I'm writing the USB HID Report Descriptors, and so far I can add Keyboard/Keypad keys (USB HID Page 0x07), System Control keys (USB HID Page 0x01), Consumer Control keys (USB HID Page 0x0c), and a mouse, and I'm trying add the Unicode page as well (USB HID Page 0x10), but for some reason evdev isn't recognizing it.)
''value'' is the value the event carries. Either a relative change for EV_REL, absolute new value for EV_ABS (joysticks ...), or 0 for EV_KEY for release, 1 for keypress and 2 for autorepeat.EV_KEYis0for a key press and1for a key release is somewhat clear in my question. What I'm asking about is thevalueforMSC_SCAN(which is not just0or1).if (event.type == EV_MSC && event.code == MSC_SCAN && event.value == 0xdead) ....