libevdev  0.1
A wrapper library for evdev devices
 All Files Functions Typedefs Enumerations Enumerator Groups
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().

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

if (libevdev_has_event_type(dev, EV_ABS) &&
libevdev_has_event_code(dev, EV_ABS, c) &&
slot < device->number_of_slots)
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, zero 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)
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_value