Every registered input device is represented by a /dev/input/event<X> char device, from which we can read the event from the user space. An application reading this file will receive event packets in the struct input_event format:
struct input_event { struct timeval time; __u16 type; __u16 code; __s32 value; }
Let's see the meaning of each element in the structure:
- time is the timestamp. It returns the time at which the event happened.
- type is the event type, for example, EV_KEY for a key press or release, EV_REL for relative moment, or EV_ABS for an absolute one. More types are defined in include/linux/input-event-codes.h.
- code is the event code, for example, REL_X or KEY_BACKSPACE; again a complete list is in include/linux/input-event-codes.h.
- value is the value that the event carries. For the EV_REL event type, it carries...