libevdev  1.5.6
A wrapper library for evdev devices
 All Files Functions Typedefs Enumerations Enumerator Macros Modules Pages
Functions
Multi-touch related functions

Functions for querying multi-touch-related capabilities. More...

Functions

int libevdev_get_slot_value (const struct libevdev *dev, unsigned int slot, unsigned int code)
 Return the current value of the code for the given slot. More...
 
int libevdev_fetch_slot_value (const struct libevdev *dev, unsigned int slot, unsigned int code, int *value)
 Fetch the current value of the code for the given slot. More...
 
int libevdev_get_num_slots (const struct libevdev *dev)
 Get the number of slots supported by this device. More...
 
int libevdev_get_current_slot (const struct libevdev *dev)
 Get the currently active slot. More...
 

Detailed Description

Functions for querying multi-touch-related capabilities.

MT devices following the kernel protocol B (using ABS_MT_SLOT) provide multiple touch points through so-called slots on the same axis. The slots are enumerated, a client reading from the device will first get an ABS_MT_SLOT event, then the values of axes changed in this slot. Multiple slots may be provided in before an EV_SYN event.

As with Querying device capabilities, the logical state of the device as seen by the library depends on the caller using libevdev_next_event().

The Linux kernel requires all axes on a device to have a semantic meaning, matching the axis names in linux/input.h. Some devices merely export a number of axes beyond the available axis list. For those devices, the multitouch information is invalid. Specifically, if a device provides the ABS_MT_SLOT axis AND also the (ABS_MT_SLOT - 1) axis, the device is not treated as multitouch device. No slot information is available and the ABS_MT axis range for these devices is treated as all other EV_ABS axes.

Note that because of limitations in the kernel API, such fake multitouch devices can not be reliably synced after a SYN_DROPPED event. libevdev ignores all ABS_MT axis values during the sync process and instead relies on the device to send the current axis value with the first event after SYN_DROPPED.

Function Documentation

int libevdev_fetch_slot_value ( const struct libevdev *  dev,
unsigned int  slot,
unsigned int  code,
int *  value 
)

Fetch the current value of the code for the given slot.

This is a shortcut for

1 if (libevdev_has_event_type(dev, EV_ABS) &&
2  libevdev_has_event_code(dev, EV_ABS, c) &&
3  slot < device->number_of_slots)
4  val = libevdev_get_slot_value(dev, slot, c);
Parameters
devThe evdev device, already initialized with libevdev_set_fd()
slotThe numerical slot number, must be smaller than the total number of slots on this * device
[out]valueThe current value of this axis returned.
codeThe event code to query for, one of ABS_MT_POSITION_X, etc.
Returns
If the device supports this event code, the return value is non-zero and value is set to the current value of this axis. Otherwise, or if the event code is not an ABS_MT_* event code, 0 is returned and value is unmodified.
Note
This function is signal-safe.
int libevdev_get_current_slot ( const struct libevdev *  dev)

Get the currently active slot.

This may differ from the value an ioctl may return at this time as events may have been read off the fd since changing the slot value but those events are still in the buffer waiting to be processed. The returned value is the value a caller would see if it were to process events manually one-by-one.

Parameters
devThe evdev device, already initialized with libevdev_set_fd()
Returns
the currently active slot (logically)
Note
This function is signal-safe.
int libevdev_get_num_slots ( const struct libevdev *  dev)

Get the number of slots supported by this device.

Parameters
devThe evdev device, already initialized with libevdev_set_fd()
Returns
The number of slots supported, or -1 if the device does not provide any slots
Note
A device may provide ABS_MT_SLOT but a total number of 0 slots. Hence the return value of -1 for "device does not provide slots at all"
int libevdev_get_slot_value ( const struct libevdev *  dev,
unsigned int  slot,
unsigned int  code 
)

Return the current value of the code for the given slot.

The return value is undefined for a slot exceeding the available slots on the device, for a code that is not in the permitted ABS_MT range or for a device that does not have slots.

Parameters
devThe evdev device, already initialized with libevdev_set_fd()
slotThe numerical slot number, must be smaller than the total number of slots on this device
codeThe event code to query for, one of ABS_MT_POSITION_X, etc.
Note
This function is signal-safe.
The value for events other than ABS_MT_ is undefined, use libevdev_fetch_value() instead
See also
libevdev_get_event_value