Functions for printing or querying event ranges. More...
Functions | |
int | libevdev_event_is_type (const struct input_event *ev, unsigned int type) |
Helper function to check if an event is of a specific type. | |
int | libevdev_event_is_code (const struct input_event *ev, unsigned int type, unsigned int code) |
Helper function to check if an event is of a specific type and code. | |
const char * | libevdev_event_type_get_name (unsigned int type) |
const char * | libevdev_event_code_get_name (unsigned int type, unsigned int code) |
const char * | libevdev_event_value_get_name (unsigned int type, unsigned int code, int value) |
This function resolves the event value for a code. | |
const char * | libevdev_property_get_name (unsigned int prop) |
int | libevdev_event_type_get_max (unsigned int type) |
int | libevdev_event_type_from_name (const char *name) |
Look up an event-type by its name. | |
int | libevdev_event_type_from_name_n (const char *name, size_t len) |
Look up an event-type by its name. | |
int | libevdev_event_code_from_name (unsigned int type, const char *name) |
Look up an event code by its type and name. | |
int | libevdev_event_code_from_name_n (unsigned int type, const char *name, size_t len) |
Look up an event code by its type and name. | |
int | libevdev_event_value_from_name (unsigned int type, unsigned int code, const char *name) |
Look up an event value by its type, code and name. | |
int | libevdev_event_type_from_code_name (const char *name) |
Look up an event type for a event code name. | |
int | libevdev_event_type_from_code_name_n (const char *name, size_t len) |
Look up an event type for a event code name. | |
int | libevdev_event_code_from_code_name (const char *name) |
Look up an event code by its name. | |
int | libevdev_event_code_from_code_name_n (const char *name, size_t len) |
Look up an event code by its name. | |
int | libevdev_event_value_from_name_n (unsigned int type, unsigned int code, const char *name, size_t len) |
Look up an event value by its type, code and name. | |
int | libevdev_property_from_name (const char *name) |
Look up an input property by its name. | |
int | libevdev_property_from_name_n (const char *name, size_t len) |
Look up an input property by its name. | |
Detailed Description
Functions for printing or querying event ranges.
The list of names is compiled into libevdev and is independent of the run-time kernel. Likewise, the max for each event type is compiled in and does not check the kernel at run-time.
Function Documentation
◆ libevdev_event_code_from_code_name()
int libevdev_event_code_from_code_name | ( | const char * | name | ) |
Look up an event code by its name.
For example, the name "ABS_Y" returns 1. For the lookup to succeed, the name must be unique, which is the case for all defines as of kernel 5.0 and likely to be the case in the future.
This is equivalent to libevdev_event_code_from_name() without the need for knowing the event type.
- Parameters
-
name A non-NULL string describing an input-event value ("ABS_X", "REL_Y", "KEY_A", ...)
- Returns
- The given event code for the name or -1 if not found.
◆ libevdev_event_code_from_code_name_n()
int libevdev_event_code_from_code_name_n | ( | const char * | name, |
size_t | len | ||
) |
Look up an event code by its name.
For example, the name "ABS_Y" returns 1. For the lookup to succeed, the name must be unique, which is the case for all defines as of kernel 5.0 and likely to be the case in the future.
This is equivalent to libevdev_event_code_from_name_n() without the need for knowing the event type.
- Parameters
-
name A non-NULL string describing an input-event value ("ABS_X", "REL_Y", "KEY_A", ...) len The length of the passed string excluding any terminating 0 character.
- Returns
- The given event code for the name or -1 if not found.
◆ libevdev_event_code_from_name()
int libevdev_event_code_from_name | ( | unsigned int | type, |
const char * | name | ||
) |
Look up an event code by its type and name.
Event codes start with a fixed prefix followed by their name (eg., "ABS_X"). The prefix must be included in the name. It returns the constant assigned to the event code or -1 if not found.
You have to pass the event type where to look for the name. For instance, to resolve "ABS_X" you need to pass EV_ABS as type and "ABS_X" as string. Supported event codes are codes starting with SYN_, KEY_, BTN_, REL_, ABS_, MSC_, SND_, SW_, LED_, REP_, FF_.
- Parameters
-
type The event type (EV_* constant) where to look for the name. name A non-NULL string describing an input-event code ("KEY_A", "ABS_X", "BTN_Y", ...), zero-terminated.
- Returns
- The given code constant for the passed name or -1 if not found.
◆ libevdev_event_code_from_name_n()
int libevdev_event_code_from_name_n | ( | unsigned int | type, |
const char * | name, | ||
size_t | len | ||
) |
Look up an event code by its type and name.
Event codes start with a fixed prefix followed by their name (eg., "ABS_X"). The prefix must be included in the name. It returns the constant assigned to the event code or -1 if not found.
You have to pass the event type where to look for the name. For instance, to resolve "ABS_X" you need to pass EV_ABS as type and "ABS_X" as string. Supported event codes are codes starting with SYN_, KEY_, BTN_, REL_, ABS_, MSC_, SND_, SW_, LED_, REP_, FF_.
- Parameters
-
type The event type (EV_* constant) where to look for the name. name A non-NULL string describing an input-event code ("KEY_A", "ABS_X", "BTN_Y", ...). len The length of the string in name
excluding any terminating 0 character.
- Returns
- The given code constant for the name or -1 if not found.
◆ libevdev_event_code_get_name()
const char * libevdev_event_code_get_name | ( | unsigned int | type, |
unsigned int | code | ||
) |
- Parameters
-
type The event type for the code to query (EV_SYN, EV_REL, etc.) code The event code to return the name for (e.g. ABS_X)
- Returns
- The name of the given event code (e.g. ABS_X) or NULL for an invalid type or code
- Note
- The list of names is compiled into libevdev. If the kernel adds new defines for new event codes, libevdev will not automatically pick these up.
◆ libevdev_event_is_code()
int libevdev_event_is_code | ( | const struct input_event * | ev, |
unsigned int | type, | ||
unsigned int | code | ||
) |
Helper function to check if an event is of a specific type and code.
This is virtually the same as:
ev->type == type && ev->code == code
with the exception that some sanity checks are performed to ensure type and code are valid.
- Note
- The ranges for types and codes are compiled into libevdev. If the kernel changes the max value, libevdev will not automatically pick these up.
- Parameters
-
ev The input event to check type Input event type to compare the event against (EV_REL, EV_ABS, etc.) code Input event code to compare the event against (ABS_X, REL_X, etc.)
- Returns
- 1 if the event type matches the given type and code, 0 otherwise (or if type/code are invalid)
◆ libevdev_event_is_type()
int libevdev_event_is_type | ( | const struct input_event * | ev, |
unsigned int | type | ||
) |
Helper function to check if an event is of a specific type.
This is virtually the same as:
ev->type == type
with the exception that some sanity checks are performed to ensure type is valid.
- Note
- The ranges for types are compiled into libevdev. If the kernel changes the max value, libevdev will not automatically pick these up.
- Parameters
-
ev The input event to check type Input event type to compare the event against (EV_REL, EV_ABS, etc.)
- Returns
- 1 if the event type matches the given type, 0 otherwise (or if type is invalid)
◆ libevdev_event_type_from_code_name()
int libevdev_event_type_from_code_name | ( | const char * | name | ) |
Look up an event type for a event code name.
For example, the name "ABS_Y" returns EV_ABS. For the lookup to succeed, the name must be unique, which is the case for all defines as of kernel 5.0 and likely to be the case in the future.
This is equivalent to libevdev_event_type_from_name() but takes the code name instead of the type name.
- Parameters
-
name A non-NULL string describing an input-event value ("ABS_X", "REL_Y", "KEY_A", ...)
- Returns
- The given event code for the name or -1 if not found.
◆ libevdev_event_type_from_code_name_n()
int libevdev_event_type_from_code_name_n | ( | const char * | name, |
size_t | len | ||
) |
Look up an event type for a event code name.
For example, the name "ABS_Y" returns EV_ABS. For the lookup to succeed, the name must be unique, which is the case for all defines as of kernel 5.0 and likely to be the case in the future.
This is equivalent to libevdev_event_type_from_name_n() but takes the code name instead of the type name.
- Parameters
-
name A non-NULL string describing an input-event value ("ABS_X", "REL_Y", "KEY_A", ...) len The length of the passed string excluding any terminating 0 character.
- Returns
- The given event code for the name or -1 if not found.
◆ libevdev_event_type_from_name()
int libevdev_event_type_from_name | ( | const char * | name | ) |
Look up an event-type by its name.
Event-types start with "EV_" followed by the name (eg., "EV_ABS"). The "EV_" prefix must be included in the name. It returns the constant assigned to the event-type or -1 if not found.
- Parameters
-
name A non-NULL string describing an input-event type ("EV_KEY", "EV_ABS", ...), zero-terminated.
- Returns
- The given type constant for the passed name or -1 if not found.
- Note
- EV_MAX is also recognized.
◆ libevdev_event_type_from_name_n()
int libevdev_event_type_from_name_n | ( | const char * | name, |
size_t | len | ||
) |
Look up an event-type by its name.
Event-types start with "EV_" followed by the name (eg., "EV_ABS"). The "EV_" prefix must be included in the name. It returns the constant assigned to the event-type or -1 if not found.
- Parameters
-
name A non-NULL string describing an input-event type ("EV_KEY", "EV_ABS", ...). len The length of the passed string excluding any terminating 0 character.
- Returns
- The given type constant for the passed name or -1 if not found.
- Note
- EV_MAX is also recognized.
◆ libevdev_event_type_get_max()
int libevdev_event_type_get_max | ( | unsigned int | type | ) |
- Parameters
-
type The event type to return the maximum for (EV_ABS, EV_REL, etc.). No max is defined for EV_SYN.
- Returns
- The max value defined for the given event type, e.g. ABS_MAX for a type of EV_ABS, or -1 for an invalid type.
- Note
- The max value is compiled into libevdev. If the kernel changes the max value, libevdev will not automatically pick these up.
◆ libevdev_event_type_get_name()
const char * libevdev_event_type_get_name | ( | unsigned int | type | ) |
- Parameters
-
type The event type to return the name for.
- Returns
- The name of the given event type (e.g. EV_ABS) or NULL for an invalid type
- Note
- The list of names is compiled into libevdev. If the kernel adds new defines for new event types, libevdev will not automatically pick these up.
◆ libevdev_event_value_from_name()
int libevdev_event_value_from_name | ( | unsigned int | type, |
unsigned int | code, | ||
const char * | name | ||
) |
Look up an event value by its type, code and name.
Event values start with a fixed prefix followed by their name (eg., "MT_TOOL_PALM"). The prefix must be included in the name. It returns the constant assigned to the event code or -1 if not found.
You have to pass the event type and code where to look for the name. For instance, to resolve "MT_TOOL_PALM" you need to pass EV_ABS as type, ABS_MT_TOOL_TYPE as code and "MT_TOOL_PALM" as string.
As of kernel 4.17, only EV_ABS/ABS_MT_TOOL_TYPE support name resolution.
- Parameters
-
type The event type (EV_* constant) where to look for the name. code The event code (ABS_* constant) where to look for the name. name A non-NULL string describing an input-event value ("MT_TOOL_TYPE", ...)
- Returns
- The given value constant for the name or -1 if not found.
◆ libevdev_event_value_from_name_n()
int libevdev_event_value_from_name_n | ( | unsigned int | type, |
unsigned int | code, | ||
const char * | name, | ||
size_t | len | ||
) |
Look up an event value by its type, code and name.
Event values start with a fixed prefix followed by their name (eg., "MT_TOOL_PALM"). The prefix must be included in the name. It returns the constant assigned to the event code or -1 if not found.
You have to pass the event type and code where to look for the name. For instance, to resolve "MT_TOOL_PALM" you need to pass EV_ABS as type, ABS_MT_TOOL_TYPE as code and "MT_TOOL_PALM" as string.
As of kernel 4.17, only EV_ABS/ABS_MT_TOOL_TYPE support name resolution.
- Parameters
-
type The event type (EV_* constant) where to look for the name. code The event code (ABS_* constant) where to look for the name. name A non-NULL string describing an input-event value ("MT_TOOL_TYPE", ...) len The length of the string in name
excluding any terminating 0 character.
- Returns
- The given value constant for the name or -1 if not found.
◆ libevdev_event_value_get_name()
const char * libevdev_event_value_get_name | ( | unsigned int | type, |
unsigned int | code, | ||
int | value | ||
) |
This function resolves the event value for a code.
For almost all event codes this will return NULL as the value is just a numerical value. As of kernel 4.17, the only event code that will return a non-NULL value is EV_ABS/ABS_MT_TOOL_TYPE.
- Parameters
-
type The event type for the value to query (EV_ABS, etc.) code The event code for the value to query (e.g. ABS_MT_TOOL_TYPE) value The event value to return the name for (e.g. MT_TOOL_PALM)
- Returns
- The name of the given event value (e.g. MT_TOOL_PALM) or NULL for an invalid type or code or NULL for an axis that has numerical values only.
- Note
- The list of names is compiled into libevdev. If the kernel adds new defines for new event values, libevdev will not automatically pick these up.
◆ libevdev_property_from_name()
int libevdev_property_from_name | ( | const char * | name | ) |
Look up an input property by its name.
Properties start with the fixed prefix "INPUT_PROP_" followed by their name (eg., "INPUT_PROP_POINTER"). The prefix must be included in the name. It returns the constant assigned to the property or -1 if not found.
- Parameters
-
name A non-NULL string describing an input property
- Returns
- The given code constant for the name or -1 if not found.
◆ libevdev_property_from_name_n()
int libevdev_property_from_name_n | ( | const char * | name, |
size_t | len | ||
) |
Look up an input property by its name.
Properties start with the fixed prefix "INPUT_PROP_" followed by their name (eg., "INPUT_PROP_POINTER"). The prefix must be included in the name. It returns the constant assigned to the property or -1 if not found.
- Parameters
-
name A non-NULL string describing an input property len The length of the string in name
excluding any terminating 0 character.
- Returns
- The given code constant for the name or -1 if not found.
◆ libevdev_property_get_name()
const char * libevdev_property_get_name | ( | unsigned int | prop | ) |
- Parameters
-
prop The input prop to return the name for (e.g. INPUT_PROP_BUTTONPAD)
- Returns
- The name of the given input prop (e.g. INPUT_PROP_BUTTONPAD) or NULL for an invalid property
- Note
- The list of names is compiled into libevdev. If the kernel adds new defines for new properties libevdev will not automatically pick these up.
- On older kernels input properties may not be defined and libevdev_property_get_name() will always return NULL