Modifying the set of events reported by this device. More...
Enumerations | |
enum | libevdev_led_value { LIBEVDEV_LED_ON , LIBEVDEV_LED_OFF } |
Functions | |
void | libevdev_set_name (struct libevdev *dev, const char *name) |
Change the device's name as returned by libevdev_get_name(). More... | |
void | libevdev_set_phys (struct libevdev *dev, const char *phys) |
Change the device's physical location as returned by libevdev_get_phys(). More... | |
void | libevdev_set_uniq (struct libevdev *dev, const char *uniq) |
Change the device's unique identifier as returned by libevdev_get_uniq(). More... | |
void | libevdev_set_id_product (struct libevdev *dev, int product_id) |
void | libevdev_set_id_vendor (struct libevdev *dev, int vendor_id) |
void | libevdev_set_id_bustype (struct libevdev *dev, int bustype) |
void | libevdev_set_id_version (struct libevdev *dev, int version) |
int | libevdev_enable_property (struct libevdev *dev, unsigned int prop) |
int | libevdev_disable_property (struct libevdev *dev, unsigned int prop) |
int | libevdev_set_event_value (struct libevdev *dev, unsigned int type, unsigned int code, int value) |
Set the value for a given event type and code. More... | |
int | libevdev_set_slot_value (struct libevdev *dev, unsigned int slot, unsigned int code, int value) |
Set the value for a given code for the given slot. More... | |
void | libevdev_set_abs_minimum (struct libevdev *dev, unsigned int code, int val) |
Change the minimum for the given EV_ABS event code, if the code exists. More... | |
void | libevdev_set_abs_maximum (struct libevdev *dev, unsigned int code, int val) |
Change the maximum for the given EV_ABS event code, if the code exists. More... | |
void | libevdev_set_abs_fuzz (struct libevdev *dev, unsigned int code, int val) |
Change the fuzz for the given EV_ABS event code, if the code exists. More... | |
void | libevdev_set_abs_flat (struct libevdev *dev, unsigned int code, int val) |
Change the flat for the given EV_ABS event code, if the code exists. More... | |
void | libevdev_set_abs_resolution (struct libevdev *dev, unsigned int code, int val) |
Change the resolution for the given EV_ABS event code, if the code exists. More... | |
void | libevdev_set_abs_info (struct libevdev *dev, unsigned int code, const struct input_absinfo *abs) |
Change the abs info for the given EV_ABS event code, if the code exists. More... | |
int | libevdev_enable_event_type (struct libevdev *dev, unsigned int type) |
Forcibly enable an event type on this device, even if the underlying device does not support it. More... | |
int | libevdev_disable_event_type (struct libevdev *dev, unsigned int type) |
Forcibly disable an event type on this device, even if the underlying device provides it. More... | |
int | libevdev_enable_event_code (struct libevdev *dev, unsigned int type, unsigned int code, const void *data) |
Forcibly enable an event code on this device, even if the underlying device does not support it. More... | |
int | libevdev_disable_event_code (struct libevdev *dev, unsigned int type, unsigned int code) |
Forcibly disable an event code on this device, even if the underlying device provides it. More... | |
int | libevdev_kernel_set_abs_info (struct libevdev *dev, unsigned int code, const struct input_absinfo *abs) |
Set the device's EV_ABS axis to the value defined in the abs parameter. More... | |
int | libevdev_kernel_set_led_value (struct libevdev *dev, unsigned int code, enum libevdev_led_value value) |
Turn an LED on or off. More... | |
int | libevdev_kernel_set_led_values (struct libevdev *dev,...) |
Turn multiple LEDs on or off simultaneously. More... | |
int | libevdev_set_clock_id (struct libevdev *dev, int clockid) |
Set the clock ID to be used for timestamps. More... | |
Detailed Description
Modifying the set of events reported by this device.
By default, the libevdev device mirrors the kernel device, enabling only those bits exported by the kernel. This set of functions enable or disable bits as seen from the caller.
Enabling an event type or code does not affect event reporting - a software-enabled event will not be generated by the physical hardware. Disabling an event will prevent libevdev from routing such events to the caller. Enabling and disabling event types and codes is at the library level and thus only affects the caller.
If an event type or code is enabled at kernel-level, future users of this device will see this event enabled. Currently there is no option of disabling an event type or code at kernel-level.
Enumeration Type Documentation
◆ libevdev_led_value
enum libevdev_led_value |
Function Documentation
◆ libevdev_disable_event_code()
int libevdev_disable_event_code | ( | struct libevdev * | dev, |
unsigned int | type, | ||
unsigned int | code | ||
) |
Forcibly disable an event code on this device, even if the underlying device provides it.
This effectively mutes the respective set of events. libevdev will filter any events matching this type and code and none will reach the caller. libevdev_has_event_code() will return false for this code.
Disabling all event codes for a given type will not disable the event type. Use libevdev_disable_event_type() for that.
This is a local modification only affecting only this representation of this device.
Disabling codes of type EV_SYN will not work. Don't shoot yourself in the foot. It hurts.
- Parameters
-
dev The evdev device, already initialized with libevdev_set_fd() type The event type to disable (EV_ABS, EV_KEY, ...) code The event code to disable (ABS_X, REL_X, etc.)
- Returns
- 0 on success or -1 otherwise
◆ libevdev_disable_event_type()
int libevdev_disable_event_type | ( | struct libevdev * | dev, |
unsigned int | type | ||
) |
Forcibly disable an event type on this device, even if the underlying device provides it.
This effectively mutes the respective set of events. libevdev will filter any events matching this type and none will reach the caller. libevdev_has_event_type() will return false for this type.
In most cases, a caller likely only wants to disable a single code, not the whole type. Use libevdev_disable_event_code() for that.
Disabling EV_SYN will not work. Don't shoot yourself in the foot. It hurts.
This is a local modification only affecting only this representation of this device.
- Parameters
-
dev The evdev device, already initialized with libevdev_set_fd() type The event type to disable (EV_ABS, EV_KEY, ...)
- Returns
- 0 on success or -1 otherwise
◆ libevdev_disable_property()
int libevdev_disable_property | ( | struct libevdev * | dev, |
unsigned int | prop | ||
) |
- Parameters
-
dev The evdev device prop The input property to disable, one of INPUT_PROP_...
- Returns
- 0 on success or -1 on failure
◆ libevdev_enable_event_code()
int libevdev_enable_event_code | ( | struct libevdev * | dev, |
unsigned int | type, | ||
unsigned int | code, | ||
const void * | data | ||
) |
Forcibly enable an event code on this device, even if the underlying device does not support it.
While this cannot make the device actually report such events, it will now return true for libevdev_has_event_code().
The last argument depends on the type and code:
- If type is EV_ABS, data must be a pointer to a struct input_absinfo containing the data for this axis.
- If type is EV_REP, data must be a pointer to a int containing the data for this axis
- For all other types, the argument must be NULL.
This function calls libevdev_enable_event_type() if necessary.
This is a local modification only affecting only this representation of this device.
If this function is called with a type of EV_ABS and EV_REP on a device that already has the given event code enabled, the values in data overwrite the previous values.
- Parameters
-
dev The evdev device, already initialized with libevdev_set_fd() type The event type to enable (EV_ABS, EV_KEY, ...) code The event code to enable (ABS_X, REL_X, etc.) data If type is EV_ABS, data points to a struct input_absinfo. If type is EV_REP, data points to an integer. Otherwise, data must be NULL.
- Returns
- 0 on success or -1 otherwise
- See also
- libevdev_enable_event_type
◆ libevdev_enable_event_type()
int libevdev_enable_event_type | ( | struct libevdev * | dev, |
unsigned int | type | ||
) |
Forcibly enable an event type on this device, even if the underlying device does not support it.
While this cannot make the device actually report such events, it will now return true for libevdev_has_event_type().
This is a local modification only affecting only this representation of this device.
- Parameters
-
dev The evdev device, already initialized with libevdev_set_fd() type The event type to enable (EV_ABS, EV_KEY, ...)
- Returns
- 0 on success or -1 otherwise
- See also
- libevdev_has_event_type
◆ libevdev_enable_property()
int libevdev_enable_property | ( | struct libevdev * | dev, |
unsigned int | prop | ||
) |
- Parameters
-
dev The evdev device prop The input property to enable, one of INPUT_PROP_...
- Returns
- 0 on success or -1 on failure
- Note
- This function may be called before libevdev_set_fd(). A call to libevdev_set_fd() will overwrite any previously set value.
◆ libevdev_kernel_set_abs_info()
int libevdev_kernel_set_abs_info | ( | struct libevdev * | dev, |
unsigned int | code, | ||
const struct input_absinfo * | abs | ||
) |
Set the device's EV_ABS axis to the value defined in the abs parameter.
This will be written to the kernel.
- Parameters
-
dev The evdev device, already initialized with libevdev_set_fd() code The EV_ABS event code to modify, one of ABS_X, ABS_Y, etc. abs Axis info to set the kernel axis to
- Returns
- 0 on success, or a negative errno on failure
- See also
- libevdev_enable_event_code
◆ libevdev_kernel_set_led_value()
int libevdev_kernel_set_led_value | ( | struct libevdev * | dev, |
unsigned int | code, | ||
enum libevdev_led_value | value | ||
) |
Turn an LED on or off.
Convenience function, if you need to modify multiple LEDs simultaneously, use libevdev_kernel_set_led_values() instead.
- Note
- enabling an LED requires write permissions on the device's file descriptor.
- Parameters
-
dev The evdev device, already initialized with libevdev_set_fd() code The EV_LED event code to modify, one of LED_NUML, LED_CAPSL, ... value Specifies whether to turn the LED on or off
- Returns
- 0 on success, or a negative errno on failure
◆ libevdev_kernel_set_led_values()
int libevdev_kernel_set_led_values | ( | struct libevdev * | dev, |
... | |||
) |
Turn multiple LEDs on or off simultaneously.
This function expects a pair of LED codes and values to set them to, terminated by a -1. For example, to switch the NumLock LED on but the CapsLock LED off, use:
If any LED code or value is invalid, this function returns -EINVAL and no LEDs are modified.
- Note
- enabling an LED requires write permissions on the device's file descriptor.
- Parameters
-
dev The evdev device, already initialized with libevdev_set_fd() ... A pair of LED_* event codes and libevdev_led_value_t, followed by -1 to terminate the list.
- Returns
- 0 on success, or a negative errno on failure
◆ libevdev_set_abs_flat()
void libevdev_set_abs_flat | ( | struct libevdev * | dev, |
unsigned int | code, | ||
int | val | ||
) |
Change the flat for the given EV_ABS event code, if the code exists.
This function has no effect if libevdev_has_event_code() returns false for this code.
- Parameters
-
dev The evdev device, already initialized with libevdev_set_fd() code One of ABS_X, ABS_Y, ... val The new flat for this axis
◆ libevdev_set_abs_fuzz()
void libevdev_set_abs_fuzz | ( | struct libevdev * | dev, |
unsigned int | code, | ||
int | val | ||
) |
Change the fuzz for the given EV_ABS event code, if the code exists.
This function has no effect if libevdev_has_event_code() returns false for this code.
- Parameters
-
dev The evdev device, already initialized with libevdev_set_fd() code One of ABS_X, ABS_Y, ... val The new fuzz for this axis
◆ libevdev_set_abs_info()
void libevdev_set_abs_info | ( | struct libevdev * | dev, |
unsigned int | code, | ||
const struct input_absinfo * | abs | ||
) |
Change the abs info for the given EV_ABS event code, if the code exists.
This function has no effect if libevdev_has_event_code() returns false for this code.
- Parameters
-
dev The evdev device, already initialized with libevdev_set_fd() code One of ABS_X, ABS_Y, ... abs The new absolute axis data (min, max, fuzz, flat, resolution)
◆ libevdev_set_abs_maximum()
void libevdev_set_abs_maximum | ( | struct libevdev * | dev, |
unsigned int | code, | ||
int | val | ||
) |
Change the maximum for the given EV_ABS event code, if the code exists.
This function has no effect if libevdev_has_event_code() returns false for this code.
- Parameters
-
dev The evdev device, already initialized with libevdev_set_fd() code One of ABS_X, ABS_Y, ... val The new maxium for this axis
◆ libevdev_set_abs_minimum()
void libevdev_set_abs_minimum | ( | struct libevdev * | dev, |
unsigned int | code, | ||
int | val | ||
) |
Change the minimum for the given EV_ABS event code, if the code exists.
This function has no effect if libevdev_has_event_code() returns false for this code.
- Parameters
-
dev The evdev device, already initialized with libevdev_set_fd() code One of ABS_X, ABS_Y, ... val The new minimum for this axis
◆ libevdev_set_abs_resolution()
void libevdev_set_abs_resolution | ( | struct libevdev * | dev, |
unsigned int | code, | ||
int | val | ||
) |
Change the resolution for the given EV_ABS event code, if the code exists.
This function has no effect if libevdev_has_event_code() returns false for this code.
- Parameters
-
dev The evdev device, already initialized with libevdev_set_fd() code One of ABS_X, ABS_Y, ... val The new axis resolution
◆ libevdev_set_clock_id()
int libevdev_set_clock_id | ( | struct libevdev * | dev, |
int | clockid | ||
) |
Set the clock ID to be used for timestamps.
Further events from this device will report an event time based on the given clock.
This is a modification only affecting this representation of this device.
- Parameters
-
dev The evdev device, already initialized with libevdev_set_fd() clockid The clock to use for future events. Permitted values are CLOCK_MONOTONIC and CLOCK_REALTIME (the default).
- Returns
- 0 on success, or a negative errno on failure
◆ libevdev_set_event_value()
int libevdev_set_event_value | ( | struct libevdev * | dev, |
unsigned int | type, | ||
unsigned int | code, | ||
int | value | ||
) |
Set the value for a given event type and code.
This only makes sense for some event types, e.g. setting the value for EV_REL is pointless.
This is a local modification only affecting only this representation of this device. A future call to libevdev_get_event_value() will return this value, unless the value was overwritten by an event.
If the device supports ABS_MT_SLOT, the value set for any ABS_MT_* event code is the value of the currently active slot. You should use libevdev_set_slot_value() instead.
If the device supports ABS_MT_SLOT and the type is EV_ABS and the code is ABS_MT_SLOT, the value must be a positive number less then the number of slots on the device. Otherwise, libevdev_set_event_value() returns -1.
- Parameters
-
dev The evdev device, already initialized with libevdev_set_fd() type The event type for the code to query (EV_SYN, EV_REL, etc.) code The event code to set the value for, one of ABS_X, LED_NUML, etc. value The new value to set
- Returns
- 0 on success, or -1 on failure.
- Return values
-
-1 - the device does not have the event type or
- code enabled, or the code is outside the, or
- the code is outside the allowed limits for the given type, or
- the type cannot be set, or
- the value is not permitted for the given code.
◆ libevdev_set_id_bustype()
void libevdev_set_id_bustype | ( | struct libevdev * | dev, |
int | bustype | ||
) |
- Parameters
-
dev The evdev device bustype The bustype to assign to this device
- Note
- This function may be called before libevdev_set_fd(). A call to libevdev_set_fd() will overwrite any previously set value. Even though the function accepts an int for bustype the value is truncated at 16 bits.
◆ libevdev_set_id_product()
void libevdev_set_id_product | ( | struct libevdev * | dev, |
int | product_id | ||
) |
- Parameters
-
dev The evdev device product_id The product ID to assign to this device
- Note
- This function may be called before libevdev_set_fd(). A call to libevdev_set_fd() will overwrite any previously set value. Even though the function accepts an int for product_id the value is truncated at 16 bits.
◆ libevdev_set_id_vendor()
void libevdev_set_id_vendor | ( | struct libevdev * | dev, |
int | vendor_id | ||
) |
- Parameters
-
dev The evdev device vendor_id The vendor ID to assign to this device
- Note
- This function may be called before libevdev_set_fd(). A call to libevdev_set_fd() will overwrite any previously set value. Even though the function accepts an int for vendor_id the value is truncated at 16 bits.
◆ libevdev_set_id_version()
void libevdev_set_id_version | ( | struct libevdev * | dev, |
int | version | ||
) |
- Parameters
-
dev The evdev device version The version to assign to this device
- Note
- This function may be called before libevdev_set_fd(). A call to libevdev_set_fd() will overwrite any previously set value. Even though the function accepts an int for version the value is truncated at 16 bits.
◆ libevdev_set_name()
void libevdev_set_name | ( | struct libevdev * | dev, |
const char * | name | ||
) |
Change the device's name as returned by libevdev_get_name().
This function destroys the string previously returned by libevdev_get_name(), a caller must take care that no references are kept.
- Parameters
-
dev The evdev device name The new, non-NULL, name to assign to this device.
- Note
- This function may be called before libevdev_set_fd(). A call to libevdev_set_fd() will overwrite any previously set value.
◆ libevdev_set_phys()
void libevdev_set_phys | ( | struct libevdev * | dev, |
const char * | phys | ||
) |
Change the device's physical location as returned by libevdev_get_phys().
This function destroys the string previously returned by libevdev_get_phys(), a caller must take care that no references are kept.
- Parameters
-
dev The evdev device phys The new phys to assign to this device.
- Note
- This function may be called before libevdev_set_fd(). A call to libevdev_set_fd() will overwrite any previously set value.
◆ libevdev_set_slot_value()
int libevdev_set_slot_value | ( | struct libevdev * | dev, |
unsigned int | slot, | ||
unsigned int | code, | ||
int | value | ||
) |
Set the value for a given code for the given slot.
This is a local modification only affecting only this representation of this device. A future call to libevdev_get_slot_value() will return this value, unless the value was overwritten by an event.
This function does not set event values for axes outside the ABS_MT range, use libevdev_set_event_value() instead.
- Parameters
-
dev The evdev device, already initialized with libevdev_set_fd() slot The numerical slot number, must be smaller than the total number of slots on this device code The event code to set the value for, one of ABS_MT_POSITION_X, etc. value The new value to set
- Returns
- 0 on success, or -1 on failure.
- Return values
-
-1 - the device does not have the event code enabled, or
- the code is outside the allowed limits for multitouch events, or
- the slot number is outside the limits for this device, or
- the device does not support multitouch events.
◆ libevdev_set_uniq()
void libevdev_set_uniq | ( | struct libevdev * | dev, |
const char * | uniq | ||
) |
Change the device's unique identifier as returned by libevdev_get_uniq().
This function destroys the string previously returned by libevdev_get_uniq(), a caller must take care that no references are kept.
- Parameters
-
dev The evdev device uniq The new uniq to assign to this device.
- Note
- This function may be called before libevdev_set_fd(). A call to libevdev_set_fd() will overwrite any previously set value.