...
Code Block |
---|
|
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.
Code | Name | Description |
---|
0x1 | DEV_SET | Events 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. |
0x2 | DEV_CONF | This 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. |
0x3 | DEV_RESET | This 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
Code | Name | Description |
---|
0x0 | SYN_REPORT | This 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. |
0x2 | SYN_MT_REPORT | This is used for less able multitouch devices, to separate multiple sets of X/Y coordinates. We currently have no devices which do this. |
0x3 | SYN_DROPPED | This 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
Code | Name | Description |
---|
0x00 | REL_X | Movement on the X axis. |
0x01 | REL_Y | Movement on the Y axis. |
0x08 | REL_WHEEL | Vertical wheel movement. |
Type 0x3 ABS: Absolute
Code | Name | Description |
---|
0x00 | ABS_X | Position on the X axis. |
0x01 | ABS_Y | Position on the Y axis. |
0x18 | ABS_PRESSURE | The pressure the pen/tool is being applied. |
0x2f | ABS_MT_SLOT | Each 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. |
0x35 | ABS_MT_POSITION_X | X coordinate for the current slot. (Finger/pen) |
0x36 | ABS_MT_POSITION_Y | Y coordinate for the current slot. (Finger/pen) |
0x39 | ABS_MT_TRACKING_ID | Unique ID of initiated contact, a value of -1 indicates finger/pen released. |
Type 0x01 KEY: Key/Button
Code | Name | Description |
---|
0x110 | BTN_LEFT | The left button on a mouse. |
0x111 | BTN_RIGHT | The right button on a mouse. |
0x112 | BTN_MIDDLE | The middle button on a mouse. |
0x113 | BTN_SIDE | The side button on a mouse. |
0x114 | BTN_EXTRA | The extra button on a mouse. |
0x115 | BTN_FORWARD | The forward button on a mouse. |
0x116 | BTN_BACK | The back button on a mouse. |
0x117 | BTN_TASK | The task button on a mouse. |
0x140 | BTN_TOOL_PEN | The current tool is now a pen. |
0x141 | BTN_TOOL_RUBBER | The current tool is now a rubber. |
0x145 | BTN_TOOL_FINGER | The current tool is now a finger. |
0x146 | BTN_TOOL_MOUSE | The current tool is now a mouse. |
0x14a | BTN_TOUCH | The current tool touched the surface. |
0x14b | BTN_STYLUS | The first button on the stylus was pressed. |
0x14c | BTN_STYLUS2 | The second button on the stylus was pressed. |
Example
A stream might look as follows:
Code Block |
---|
|
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 |