I've been playing around with capturing the input from my keyboard device:
/dev/input/by-path/platform-i8042-serio-0-event-kbd
for me, and I was wondering if there was any specification for what it returns, using
od -tx1 /dev/input/by-path/platform-i8042-serio-0-event-kbd
to listen. I'm curious mostly due to the behavior of certain keys; the meta, arrow keys, numpad forward slash.
0520300 ac 9d 86 4c 6b 0f 04 00 04 00 04 00 (db) 00 00 00
0520320 ac 9d 86 4c 8c 0f 04 00 01 00 (7d) 00 00 00 00 00
0520340 ac 9d 86 4c 95 0f 04 00 00 00 00 00 00 00 00 00
Every other key I've looked at so far has the two bytes in parentheses as matching values, is there any reason these are special?
/dev/input/by-path/platform-i8042-serio-0-event-kbd
is just a symlink to /dev/input/eventX
event device file. Data can be read from event device files as
struct input_event {
struct timeval time;
__u16 type;
__u16 code;
__s32 value;
};
defined in /usr/include/linux/input.h
.
Possible values of type
are prefixed with EV_
.
Possible values of code
depend on type
. They are prefixed with KEY_
or BTN_
or REL_
or so on.
Possible values of value
depend on both type
and code
. For example for key-press events value
equals 1
and for key-release events 0
.
You can examine event data with:
evtest /dev/input/eventX
where X
is the event device number of your keyboard (or any other event device). One key press or release normally emits three events (EV_MSC
, EV_KEY
and EV_SYN
).