libevdev  1.4.1
A wrapper library for evdev devices
Functions
Querying device capabilities

Abstraction functions to handle device capabilities, specificially device properties such as the name of the device and the bits representing the events suppported by this device. More...

Functions

const char * libevdev_get_name (const struct libevdev *dev)
 Retrieve the device's name, either as set by the caller or as read from the kernel. More...
 
const char * libevdev_get_phys (const struct libevdev *dev)
 Retrieve the device's physical location, either as set by the caller or as read from the kernel. More...
 
const char * libevdev_get_uniq (const struct libevdev *dev)
 Retrieve the device's unique identifier, either as set by the caller or as read from the kernel. More...
 
int libevdev_get_id_product (const struct libevdev *dev)
 
int libevdev_get_id_vendor (const struct libevdev *dev)
 
int libevdev_get_id_bustype (const struct libevdev *dev)
 
int libevdev_get_id_version (const struct libevdev *dev)
 
int libevdev_get_driver_version (const struct libevdev *dev)
 
int libevdev_has_property (const struct libevdev *dev, unsigned int prop)
 
int libevdev_has_event_type (const struct libevdev *dev, unsigned int type)
 
int libevdev_has_event_code (const struct libevdev *dev, unsigned int type, unsigned int code)
 
int libevdev_get_abs_minimum (const struct libevdev *dev, unsigned int code)
 Get the minimum axis value for the given axis, as advertised by the kernel. More...
 
int libevdev_get_abs_maximum (const struct libevdev *dev, unsigned int code)
 Get the maximum axis value for the given axis, as advertised by the kernel. More...
 
int libevdev_get_abs_fuzz (const struct libevdev *dev, unsigned int code)
 Get the axis fuzz for the given axis, as advertised by the kernel. More...
 
int libevdev_get_abs_flat (const struct libevdev *dev, unsigned int code)
 Get the axis flat for the given axis, as advertised by the kernel. More...
 
int libevdev_get_abs_resolution (const struct libevdev *dev, unsigned int code)
 Get the axis resolution for the given axis, as advertised by the kernel. More...
 
const struct input_absinfo * libevdev_get_abs_info (const struct libevdev *dev, unsigned int code)
 Get the axis info for the given axis, as advertised by the kernel. More...
 
int libevdev_get_event_value (const struct libevdev *dev, unsigned int type, unsigned int code)
 Behaviour of this function is undefined if the device does not provide the event. More...
 
int libevdev_fetch_event_value (const struct libevdev *dev, unsigned int type, unsigned int code, int *value)
 Fetch the current value of the event type. More...
 
int libevdev_get_repeat (const struct libevdev *dev, int *delay, int *period)
 Get the repeat delay and repeat period values for this device. More...
 

Detailed Description

Abstraction functions to handle device capabilities, specificially device properties such as the name of the device and the bits representing the events suppported by this device.

The logical state returned may lag behind the physical state of the device. libevdev queries the device state on libevdev_set_fd() and then relies on the caller to parse events through libevdev_next_event(). If a caller does not use libevdev_next_event(), libevdev will not update the internal state of the device and thus returns outdated values.

Function Documentation

int libevdev_fetch_event_value ( const struct libevdev *  dev,
unsigned int  type,
unsigned int  code,
int *  value 
)

Fetch the current value of the event type.

This is a shortcut for

1 if (libevdev_has_event_type(dev, t) && libevdev_has_event_code(dev, t, c))
2  val = libevdev_get_event_value(dev, t, c);
Parameters
devThe evdev device, already initialized with libevdev_set_fd()
typeThe event type for the code to query (EV_SYN, EV_REL, etc.)
codeThe event code to query for, one of ABS_X, REL_X, etc.
[out]valueThe current value of this axis returned.
Returns
If the device supports this event type and code, the return value is non-zero and value is set to the current value of this axis. Otherwise, 0 is returned and value is unmodified.
Note
This function is signal-safe.
The value for ABS_MT_ events is undefined, use libevdev_fetch_slot_value() instead
See also
libevdev_fetch_slot_value
int libevdev_get_abs_flat ( const struct libevdev *  dev,
unsigned int  code 
)

Get the axis flat for the given axis, as advertised by the kernel.

Parameters
devThe evdev device, already initialized with libevdev_set_fd()
codeThe EV_ABS event code to query for, one of ABS_X, ABS_Y, etc.
Returns
axis flat for the given axis or 0 if the axis is invalid
Note
This function is signal-safe.
int libevdev_get_abs_fuzz ( const struct libevdev *  dev,
unsigned int  code 
)

Get the axis fuzz for the given axis, as advertised by the kernel.

Parameters
devThe evdev device, already initialized with libevdev_set_fd()
codeThe EV_ABS event code to query for, one of ABS_X, ABS_Y, etc.
Returns
axis fuzz for the given axis or 0 if the axis is invalid
Note
This function is signal-safe.
const struct input_absinfo* libevdev_get_abs_info ( const struct libevdev *  dev,
unsigned int  code 
)

Get the axis info for the given axis, as advertised by the kernel.

Parameters
devThe evdev device, already initialized with libevdev_set_fd()
codeThe EV_ABS event code to query for, one of ABS_X, ABS_Y, etc.
Returns
The input_absinfo for the given code, or NULL if the device does not support this event code.
Note
This function is signal-safe.
int libevdev_get_abs_maximum ( const struct libevdev *  dev,
unsigned int  code 
)

Get the maximum axis value for the given axis, as advertised by the kernel.

Parameters
devThe evdev device, already initialized with libevdev_set_fd()
codeThe EV_ABS event code to query for, one of ABS_X, ABS_Y, etc.
Returns
axis maximum for the given axis or 0 if the axis is invalid
Note
This function is signal-safe.
int libevdev_get_abs_minimum ( const struct libevdev *  dev,
unsigned int  code 
)

Get the minimum axis value for the given axis, as advertised by the kernel.

Parameters
devThe evdev device, already initialized with libevdev_set_fd()
codeThe EV_ABS event code to query for, one of ABS_X, ABS_Y, etc.
Returns
axis minimum for the given axis or 0 if the axis is invalid
Note
This function is signal-safe.
int libevdev_get_abs_resolution ( const struct libevdev *  dev,
unsigned int  code 
)

Get the axis resolution for the given axis, as advertised by the kernel.

Parameters
devThe evdev device, already initialized with libevdev_set_fd()
codeThe EV_ABS event code to query for, one of ABS_X, ABS_Y, etc.
Returns
axis resolution for the given axis or 0 if the axis is invalid
Note
This function is signal-safe.
int libevdev_get_driver_version ( const struct libevdev *  dev)
Parameters
devThe evdev device, already initialized with libevdev_set_fd()
Returns
The driver version for this device
Note
This function is signal-safe.
int libevdev_get_event_value ( const struct libevdev *  dev,
unsigned int  type,
unsigned int  code 
)

Behaviour of this function is undefined if the device does not provide the event.

If the device supports ABS_MT_SLOT, the value returned for any ABS_MT_* event code is the value of the currently active slot. You should use libevdev_get_slot_value() instead.

Parameters
devThe evdev device, already initialized with libevdev_set_fd()
typeThe event type for the code to query (EV_SYN, EV_REL, etc.)
codeThe event code to query for, one of ABS_X, REL_X, etc.
Returns
The current value of the event.
Note
This function is signal-safe.
The value for ABS_MT_ events is undefined, use libevdev_get_slot_value() instead
See also
libevdev_get_slot_value
int libevdev_get_id_bustype ( const struct libevdev *  dev)
Parameters
devThe evdev device, already initialized with libevdev_set_fd()
Returns
The device's bus type
Note
This function is signal-safe.
int libevdev_get_id_product ( const struct libevdev *  dev)
Parameters
devThe evdev device, already initialized with libevdev_set_fd()
Returns
The device's product ID
Note
This function is signal-safe.
int libevdev_get_id_vendor ( const struct libevdev *  dev)
Parameters
devThe evdev device, already initialized with libevdev_set_fd()
Returns
The device's vendor ID
Note
This function is signal-safe.
int libevdev_get_id_version ( const struct libevdev *  dev)
Parameters
devThe evdev device, already initialized with libevdev_set_fd()
Returns
The device's firmware version
Note
This function is signal-safe.
const char* libevdev_get_name ( const struct libevdev *  dev)

Retrieve the device's name, either as set by the caller or as read from the kernel.

The string returned is valid until libevdev_free() or until libevdev_set_name(), whichever comes earlier.

Parameters
devThe evdev device, already initialized with libevdev_set_fd()
Returns
The device name as read off the kernel device. The name is never NULL but it may be the empty string.
Note
This function is signal-safe.
const char* libevdev_get_phys ( const struct libevdev *  dev)

Retrieve the device's physical location, either as set by the caller or as read from the kernel.

The string returned is valid until libevdev_free() or until libevdev_set_phys(), whichever comes earlier.

Virtual devices such as uinput devices have no phys location.

Parameters
devThe evdev device, already initialized with libevdev_set_fd()
Returns
The physical location of this device, or NULL if there is none
Note
This function is signal safe.
int libevdev_get_repeat ( const struct libevdev *  dev,
int *  delay,
int *  period 
)

Get the repeat delay and repeat period values for this device.

This function is a convenience function only, EV_REP is supported by libevdev_get_event_value().

Parameters
devThe evdev device, already initialized with libevdev_set_fd()
delayIf not null, set to the repeat delay value
periodIf not null, set to the repeat period value
Returns
0 on success, -1 if this device does not have repeat settings.
Note
This function is signal-safe
See also
libevdev_get_event_value
const char* libevdev_get_uniq ( const struct libevdev *  dev)

Retrieve the device's unique identifier, either as set by the caller or as read from the kernel.

The string returned is valid until libevdev_free() or until libevdev_set_uniq(), whichever comes earlier.

Parameters
devThe evdev device, already initialized with libevdev_set_fd()
Returns
The unique identifier for this device, or NULL if there is none
Note
This function is signal safe.
int libevdev_has_event_code ( const struct libevdev *  dev,
unsigned int  type,
unsigned int  code 
)
Parameters
devThe evdev device, already initialized with libevdev_set_fd()
typeThe event type for the code to query (EV_SYN, EV_REL, etc.)
codeThe event code to query for, one of ABS_X, REL_X, etc.
Returns
1 if the device supports this event type and code, or 0 otherwise.
Note
This function is signal-safe.
int libevdev_has_event_type ( const struct libevdev *  dev,
unsigned int  type 
)
Parameters
devThe evdev device, already initialized with libevdev_set_fd()
typeThe event type to query for, one of EV_SYN, EV_REL, etc.
Returns
1 if the device supports this event type, or 0 otherwise.
Note
This function is signal-safe.
int libevdev_has_property ( const struct libevdev *  dev,
unsigned int  prop 
)
Parameters
devThe evdev device, already initialized with libevdev_set_fd()
propThe input property to query for, one of INPUT_PROP_...
Returns
1 if the device provides this input property, or 0 otherwise.
Note
This function is signal-safe