Documentation/input/event-codes.rst

Source file repositories/reference/linux-study-clean/Documentation/input/event-codes.rst

File Facts

System
Linux kernel
Corpus path
Documentation/input/event-codes.rst
Extension
.rst
Size
18606 bytes
Lines
485
Domain
Support Tooling And Documentation
Bucket
Documentation
Inferred role
Support Tooling And Documentation: documentation
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

.. _input-event-codes:

=================
Input event codes
=================


The input protocol uses a map of types and codes to express input device values
to userspace. This document describes the types and codes and how and when they
may be used.

A single hardware event generates multiple input events. Each input event
contains the new value of a single data item. A special event type, EV_SYN, is
used to separate input events into packets of input data changes occurring at
the same moment in time. In the following, the term "event" refers to a single
input event encompassing a type, code, and value.

The input protocol is a stateful protocol. Events are emitted only when values
of event codes have changed. However, the state is maintained within the Linux
input subsystem; drivers do not need to maintain the state and may attempt to
emit unchanged values without harm. Userspace may obtain the current state of
event code values using the EVIOCG* ioctls defined in linux/input.h. The event
reports supported by a device are also provided by sysfs in
class/input/event*/device/capabilities/, and the properties of a device are
provided in class/input/event*/device/properties.

Event types
===========

Event types are groupings of codes under a logical input construct. Each
type has a set of applicable codes to be used in generating events. See the
Codes section for details on valid codes for each type.

* EV_SYN:

  - Used as markers to separate events. Events may be separated in time or in
    space, such as with the multitouch protocol.

* EV_KEY:

  - Used to describe state changes of keyboards, buttons, or other key-like
    devices.

* EV_REL:

  - Used to describe relative axis value changes, e.g. moving the mouse 5 units
    to the left.

* EV_ABS:

  - Used to describe absolute axis value changes, e.g. describing the
    coordinates of a touch on a touchscreen.

* EV_MSC:

  - Used to describe miscellaneous input data that do not fit into other types.

* EV_SW:

  - Used to describe binary state input switches.

* EV_LED:

  - Used to turn LEDs on devices on and off.

* EV_SND:

  - Used to output sound to devices.

* EV_REP:

Annotation

Implementation Notes