Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagecpp
uint16 type  // Type of record, including KEY (key/button), REL (relative scalar), ABS (absolute scalar), SYN (Synchronization events.) or DEV (Device change events).
uint16 code  // This indicated which item (be it a key or axis) this record represents.
uint32 value // This is the new value for the item indicated by two field above. For a button or key, this would be a Boolean.

The records above are able to accommodate a huge number of different types of event. Furthermore, events are aggregated to form more complex events. Each input device will only be able to send a small subset of the possible events. DEV (device) events are used to indicate which device is emitting the following events, as well as indicating which events are possible. For example a tablet stylus can emit absolute X and Y events, while a traditional mouse emits relative X and Y events.

Below is a small subset of events that are possible. This list should probably be considered the minimum to set to implement. A fuller list can be found here with descriptions here. Detail on the multitouch protocol here.

Type 0x6 DEV: Device

These events describe actions relating to the device emmiting the remaining events. DEV events are not subject to Synchronization events.

CodeNameDescription
0x1DEV_SETEvents after this event belong to the device indicated by <value>. A value of -1 indicates that it is from an unknown source. This number may be referred to as the device's slot number.
0x2DEV_CONFThis indicates that a new device has been created, which from here shall be referred to as <value>. The provided slot number ( <value> ) can be used to find a description of this device, in the configuration space, described later. This information is expected to be considered before attempting to decode events for this device.
0x3DEV_RESETThis indicates that device <value> is no longer valid, and any resources associated with this may be freed. If <value> is 0xFFFF, then all devices are existing invalid - such event is used on start up.

Type 0x0 SYN: Synchronization

CodeNameDescription
0x0SYN_REPORTThis is used as a barrier to indicate that all events of other types (excluding DEV), which occur between the same set of SYN:REPORT events, occurred at the same time. That is to say, events between pairs of SYN:REPORT events are to be aggregated. For example, when moving a mouse, it is common for both the X and Y coordinate to change together, and so an event for each would be emitted, and because they where emmited between a pair of SYN:REPORT events, they would be aggregated. If however, only one axis changed, then only an event for that axis would be emitted. After this event has been added to the buffer, and interrupt is generated.
0x2SYN_MT_REPORTThis is used for less able multitouch devices, to separate multiple sets of X/Y coordinates. We currently have no devices which do this.
0x3SYN_DROPPEDThis informs the client when input events have been dropped from the evdev input buffer due to a buffer overrun.

The client should use this event as a hint to reset its state or ignore all following events until the next packet begins. Client should ignore all events up to and including next SYN_REPORT.

Type 0x2 REL: Relative

CodeNameDescription
0x00REL_XMovement on the X axis.
0x01REL_YMovement on the Y axis.
0x08REL_WHEELVertical wheel movement.

Type 0x3 ABS: Absolute

CodeNameDescription
0x00ABS_XPosition on the X axis.
0x01ABS_YPosition on the Y axis.
0x18ABS_PRESSUREThe pressure the pen/tool is being applied.
0x2fABS_MT_SLOTEach finger/pen in contact with the screen is given a slot number, and this is maintained until it is released. Multitouch events, on the current device, are henceforth for this slot. If only one finger/pen is in contact with the screen, then only one slot in required, and so this event may be omitted. If multiple fingers/pens are in contact with the screen, it would be common for may slot changes to occur during one pair SYN:REPORT events, to indicate each finger moved at the same time.
0x35ABS_MT_POSITION_XX coordinate for the current slot. (Finger/pen)
0x36ABS_MT_POSITION_YY coordinate for the current slot. (Finger/pen)
0x39ABS_MT_TRACKING_IDUnique ID of initiated contact, a value of -1 indicates finger/pen released.

Type 0x01 KEY: Key/Button

CodeNameDescription
0x110BTN_LEFTThe left button on a mouse.
0x111BTN_RIGHTThe right button on a mouse.
0x112BTN_MIDDLEThe middle button on a mouse.
0x113BTN_SIDEThe side button on a mouse.
0x114BTN_EXTRAThe extra button on a mouse.
0x115BTN_FORWARDThe forward button on a mouse.
0x116BTN_BACKThe back button on a mouse.
0x117BTN_TASKThe task button on a mouse.
0x140BTN_TOOL_PENThe current tool is now a pen.
0x141BTN_TOOL_RUBBERThe current tool is now a rubber.
0x145BTN_TOOL_FINGERThe current tool is now a finger.
0x146BTN_TOOL_MOUSEThe current tool is now a mouse.
0x14aBTN_TOUCHThe current tool touched the surface.
0x14bBTN_STYLUSThe first button on the stylus was pressed.
0x14cBTN_STYLUS2The second button on the stylus was pressed.

Example

A stream might look as follows:

Code Block
languagecpp
DEV_RESET 0xFFFF
DEV_CONF 4              /* The config associated indicates its a stylus */
DEV_CONF 7              /* The config associated indicates its an multi-touch device */
DEV_SET 4

ABS_X 345
ABS_Y 987
BTN_TOOL_PEN 1         /* Pen is hovering over the surface*/
SYN_REPORT

ABS_X 346
SYN_REPORT

ABS_Y 986
SNY_REPORT

ABS_X 344
ABS_Y 985
ABS_PRUSSURE 45
BTN_TOUCH 1          /* Pen touches the surface */
SYN_REPORT

ABS_PRESSURE 48
SYN_REPORT

ABS_X 300
ABS_PRESSURE 20
SYN_REPORT

BTN_TOUCH 0          /* Pen is no longer touching surface */
ABS_X 388
SYN_REPORT

ABS_Y 810
ABS_X 320
BTN_TOOL_PEN 0      /* Pen is no longer hovering over the surface */
SYN_REPORT

DEV_SET 7


ABS_MT_SLOT 0                  /* First finger goes down */
ABS_MT_TRACKING_ID 45
ABS_MT_POSITION_X 200
ABS_MT_POSITION_Y 300
SYN_REPORT

ABS_MT_POSITION_X 210          /* Still slot 0 */
SYN_REPORT

ABS_MT_POSITION_X 220
ABS_MT_POSITION_Y 302
SYN_REPORT

ABS_MT_POSITION_X 225
ABS_MT SLOT 1                  /* Second finger goes down */
ABS_MT_TRACKING_ID 46
ABS_MT_POSITION_X 700
ABS_MT_POSITION_Y 800
SYN_REPORT

ABS_MT_SLOT 0
ABS_MT_POSITION_X 226
ABS_MT_POSITION_Y 308
ABS_MT_SLOT 1
ABS_MT_POSITION_Y 810
SYN_REPORT

ABS_MT_POSITION_Y 815          /* Still on slot 1! */
ABS_MT_POSITION_X 720
SYN_REPORT

ABS_MT_SLOT 0                  /* first finger lifted */
ABS_MT_TRACKING_ID -1
ABS_MT_SLOT 1
ABS_MT_POSITION_X 725
SYN_REPORT

ABS_MT_POSITION_Y 816          /* Still on slot 1! */
ABS_MT_POSITION_X 740
SYN_REPORT

ABS_MT_TRACKING_ID -1          /* Second finger is lifted */
ABS_MT_POSITION_X 741
SYN_REPORT