Input Subsystem¶
The Linux input subsystem is used for devices that report user input events, such as keys, buttons, touch sensors, rotary encoders, and gesture-like controls.
What Problem It Solves¶
Without the input subsystem, each button or touch device could require a custom character device and a custom user-space protocol. The input subsystem provides a standard event ABI through /dev/input/eventX.
Core Concepts¶
| Concept | Description |
|---|---|
input_dev |
Input device object registered by the driver. |
| Event type | Class of event, such as EV_KEY, EV_ABS, or EV_REL. |
| Event code | Specific key, axis, or event identifier. |
input_report_*() |
Reports a value change. |
input_sync() |
Terminates one event frame. |
| evdev | User-space event interface exposed as /dev/input/eventX. |
Typical Driver Flow¶
probe()
↓
allocate input_dev
↓
set supported event bits
↓
register input device
↓
IRQ / workqueue reports input events
A GPIO button event usually looks like this:
Common Event Types¶
| Event Type | Typical Use |
|---|---|
EV_KEY |
Buttons, keys, simple touch detection |
EV_ABS |
Absolute values, touch coordinates, pressure |
EV_REL |
Relative movement, mouse-like deltas |
EV_SW |
Switch state, lid state, docking state |
Design Notes¶
- Use
EV_KEYfor button-like events and simple touch actions. - Use
EV_ABSwhen the device reports position, pressure, or absolute sensor values. - Call
input_sync()after reporting one logical event frame. - Keep gesture recognition policy clear: driver-side gesture recognition is useful for simple hardware-specific events, but complex UX logic may belong in user space.
Related API Reference¶
- devm_input_allocate_device()
- input_register_device()
- input_set_capability()
- input_report_key()
- input_sync()