libevdev  1.5.0
A wrapper library for evdev devices
Functions
Miscellaneous helper functions

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. More...
 
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. More...
 
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_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. More...
 
int libevdev_event_type_from_name_n (const char *name, size_t len)
 Look up an event-type by its name. More...
 
int libevdev_event_code_from_name (unsigned int type, const char *name)
 Look up an event code by its type and name. More...
 
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. More...
 
int libevdev_property_from_name (const char *name)
 Look up an input property by its name. More...
 
int libevdev_property_from_name_n (const char *name, size_t len)
 Look up an input property by its name. More...
 

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

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
typeThe event type (EV_* constant) where to look for the name.
nameA 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.
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
typeThe event type (EV_* constant) where to look for the name.
nameA non-NULL string describing an input-event code ("KEY_A", "ABS_X", "BTN_Y", ...).
lenThe length of the string in name excluding any terminating 0 character.
Returns
The given code constant for the name or -1 if not found.
const char* libevdev_event_code_get_name ( unsigned int  type,
unsigned int  code 
)
Parameters
typeThe event type for the code to query (EV_SYN, EV_REL, etc.)
codeThe 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.
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
evThe input event to check
typeInput event type to compare the event against (EV_REL, EV_ABS, etc.)
codeInput 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)
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
evThe input event to check
typeInput 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)
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
nameA 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.
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
nameA non-NULL string describing an input-event type ("EV_KEY", "EV_ABS", ...).
lenThe 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.
int libevdev_event_type_get_max ( unsigned int  type)
Parameters
typeThe 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.
const char* libevdev_event_type_get_name ( unsigned int  type)
Parameters
typeThe 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.
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
nameA non-NULL string describing an input property
Returns
The given code constant for the name or -1 if not found.
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
nameA non-NULL string describing an input property
lenThe length of the string in name excluding any terminating 0 character.
Returns
The given code constant for the name or -1 if not found.
const char* libevdev_property_get_name ( unsigned int  prop)
Parameters
propThe 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