Input Subsystem¶
The Linux input subsystem is used for handling input devices such as:
- Keyboard
- Mouse
- Touchscreen
- GPIO buttons
It provides a standard interface between kernel drivers and userspace.
Architecture¶
Input Driver
↓
Input Core
↓
Event Handler (evdev)
↓
/dev/input/eventX
↓
Userspace (evtest / application)
Key Components¶
1. input_dev¶
Represents an input device.
2. Capability¶
Defines what events the device can generate.
3. Event Reporting¶
input_report_key(input, KEY_ENTER, 1); // press
input_sync(input);
input_report_key(input, KEY_ENTER, 0); // release
input_sync(input);
4. input_event (userspace)¶
Event Model¶
| Value | Meaning |
|---|---|
| 1 | Key press |
| 0 | Key release |
| 2 | Auto-repeat |
SYN_REPORT¶
input_sync() generates:
It indicates the end of one event frame.
Design Philosophy¶
Input vs IIO¶
| Feature | Input | IIO |
|---|---|---|
| Data type | Event | Streaming data |
| Example | Button | ADC / sensor |
| Model | Event-driven | Buffered |
| Userspace | evdev | iio buffer |