Skip to main content

Basics

Devices

Wacom tablets generally create one or more of the following three types of kernel devices:

  • Pen devices that represent features from Wacom styli
  • Touch Devices that represent touches from a single finger or multiple fingers
  • Pad Devices that cover the features on the tablets, such as Expresskeys, touch rings, touch keys, etc.

Events

You get values from an input device in the form of events. In the Linux kernel source you can find that an input event has the struct format:

struct input_event {

struct timeval time;

__u16 type;

__u16 code;

__s32 value;

};

So in Linux, tablet events are interpreted by the kernel and those events are emitted as input_events.

Beyond their timestamp, events have three components: types, codes and values. The constants which label the values in an input_event are found in the kernel source tree at include/uapi/linux/input-event-codes.h.

Types

Types are broad categories. Here is an annotated list of types from input-event-codes.h:

#define EV_SYN            0x00 (Sync Events denote event boundaries)

#define EV_KEY 0x01 (Key Events)

#define EV_REL 0x02 (Relative events)

#define EV_ABS 0x03 (Absolute events)

#define EV_MSC 0x04 (Miscellaneous events)

#define EV_SW 0x05 (Switch events)

#define EV_LED 0x11

#define EV_SND 0x12

#define EV_REP 0x14

#define EV_FF 0x15

#define EV_PWR 0x16

#define EV_FF_STATUS 0x17

#define EV_MAX 0x1f

For Wacom tablet devices, EV_KEY events give you information about which type of tool is being used on the tablet (Pen, Eraser, Airbrush etc.). Information about the position of the device is given using EV_ABS events. Some of these include x/y coordinates, and pressure.

Codes

Codes let you know how to interpret the values you get from the kernel. If you have a Wacom tablet, a quick way to familiarize yourself with tablet event codes is to use the utility evtest with a Wacom device attached. (evtest is available in most Linux distributions). Here is an example list of codes for one professional opaque tablet. We know it is an opaque tablet since it supports BTN_TOOL_MOUSE and BTN_TOOL_LENS, which display tablets do not support. We know it is professional tablet since it supports BTN_TOOL_AIRBRUSH, which non-pro ones do not support.

  Event type 0 (EV_SYN)

Event type 1 (EV_KEY)

Event code 272 (BTN_LEFT)

Event code 273 (BTN_RIGHT)

Event code 274 (BTN_MIDDLE)

Event code 275 (BTN_SIDE)

Event code 276 (BTN_EXTRA)

Event code 320 (BTN_TOOL_PEN)

Event code 321 (BTN_TOOL_RUBBER)

Event code 322 (BTN_TOOL_BRUSH)

Event code 323 (BTN_TOOL_PENCIL)

Event code 324 (BTN_TOOL_AIRBRUSH)

Event code 326 (BTN_TOOL_MOUSE)

Event code 327 (BTN_TOOL_LENS)

Event code 330 (BTN_TOUCH)

Event code 331 (BTN_STYLUS)

Event code 332 (BTN_STYLUS2)

Event type 2 (EV_REL)

Event code 8 (REL_WHEEL)

Event type 3 (EV_ABS)

Event code 0 (ABS_X)

Event code 1 (ABS_Y)

Event code 2 (ABS_Z)

Event code 5 (ABS_RZ)

Event code 6 (ABS_THROTTLE)

Event code 8 (ABS_WHEEL)

Event code 24 (ABS_PRESSURE)

Event code 25 (ABS_DISTANCE)

Event code 26 (ABS_TILT_X)

Event code 27 (ABS_TILT_Y)

Event code 40 (ABS_MISC)

Event type 4 (EV_MSC)

Event code 0 (MSC_SERIAL)

The codes supported differ from device to device too. For example, an airbrush pen would support ABS_X, ABS_Y, ABS_PRESSURE, ABS_WHEEL, ABS_TILT_X, ABS_TILT_Y, etc. A full set of event codes and a detailed explanation of the event types can be found at Input Event Codes.

Values

Values have a Minimum and a Maximum which can be read from the kernel. Here's the example values for device at code (ABS_X).

  Event type 3 (EV_ABS)

Event code 0 (ABS_X)

Value 0 (Latest Reported Value)

Min 0 (Minimum Value)

Max 44704 (Maximum Value)

Fuzz 4 (Fuzz Value that filters noise from the event stream)

Flat 0 (Values that are within Flat are discarded by joydev devices)

Resolution 200 (Resolution of the Value)

Where Fuzz = 4 means the current value is ignored if the absolute difference between the current value and the last one reported is less than 4;

Flat doesn't apply to tablet;

Resolution = 200 means the ABS_X value is reported with a resolution of 200 units/mm.

The above struct is defined by input_absinfo at include/uapi/linux/input.h in the kernel.