libei  0.2
A library for Emulated Input
libei.h File Reference
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>

Go to the source code of this file.

Typedefs

typedef void(* ei_log_handler) (struct ei *ei, enum ei_log_priority priority, const char *file, int lineno, const char *func, const char *message, bool is_continuation)
 The log handler for library logging. More...
 

Enumerations

enum  ei_device_type { EI_DEVICE_TYPE_VIRTUAL , EI_DEVICE_TYPE_PHYSICAL }
 The device type determines what the device represents. More...
 
enum  ei_device_capability { EI_DEVICE_CAP_POINTER , EI_DEVICE_CAP_POINTER_ABSOLUTE , EI_DEVICE_CAP_KEYBOARD , EI_DEVICE_CAP_TOUCH }
 The set of supported capabilities. More...
 
enum  ei_property_permission {
  EI_PROPERTY_PERM_NONE , EI_PROPERTY_PERM_READ , EI_PROPERTY_PERM_WRITE , EI_PROPERTY_PERM_DELETE ,
  EI_PROPERTY_PERM_ALL
}
 A set of masks for operations permitted on properties. More...
 
enum  ei_keymap_type { EI_KEYMAP_TYPE_XKB }
 The set of supported keymap types for a struct ei_keymap. More...
 
enum  ei_event_type {
  EI_EVENT_CONNECT , EI_EVENT_DISCONNECT , EI_EVENT_PROPERTY , EI_EVENT_SEAT_ADDED ,
  EI_EVENT_SEAT_REMOVED , EI_EVENT_DEVICE_ADDED , EI_EVENT_DEVICE_REMOVED , EI_EVENT_DEVICE_PAUSED ,
  EI_EVENT_DEVICE_RESUMED , EI_EVENT_KEYBOARD_MODIFIERS , EI_EVENT_FRAME , EI_EVENT_DEVICE_START_EMULATING ,
  EI_EVENT_DEVICE_STOP_EMULATING , EI_EVENT_POINTER_MOTION , EI_EVENT_POINTER_MOTION_ABSOLUTE , EI_EVENT_POINTER_BUTTON ,
  EI_EVENT_POINTER_SCROLL , EI_EVENT_POINTER_SCROLL_STOP , EI_EVENT_POINTER_SCROLL_CANCEL , EI_EVENT_POINTER_SCROLL_DISCRETE ,
  EI_EVENT_KEYBOARD_KEY , EI_EVENT_TOUCH_DOWN , EI_EVENT_TOUCH_UP , EI_EVENT_TOUCH_MOTION
}
 
enum  ei_log_priority { EI_LOG_PRIORITY_DEBUG , EI_LOG_PRIORITY_INFO , EI_LOG_PRIORITY_WARNING , EI_LOG_PRIORITY_ERROR }
 

Functions

struct eiei_new (void *user_data)
 This is an alias for ei_new_sender. More...
 
struct eiei_new_sender (void *user_data)
 Create a new sender ei context. More...
 
struct eiei_new_receiver (void *user_data)
 Create a new receiver ei context. More...
 
bool ei_is_sender (struct ei *ei)
 
void ei_log_set_handler (struct ei *ei, ei_log_handler log_handler)
 Change the log handler for this context. More...
 
void ei_log_set_priority (struct ei *ei, enum ei_log_priority priority)
 
enum ei_log_priority ei_log_get_priority (const struct ei *ei)
 
void ei_configure_name (struct ei *ei, const char *name)
 Set the name for this client. More...
 
int ei_property_set (struct ei *ei, const char *property, const char *value)
 See ei_property_set_with_permissions(), but the permissions are left as-is. More...
 
int ei_property_set_with_permissions (struct ei *ei, const char *property, const char *value, uint32_t permission)
 Change, create or delete a property. More...
 
uint32_t ei_property_get_permissions (struct ei *ei, const char *property)
 Return the permissions mask for the given property. More...
 
const char * ei_property_get (struct ei *ei, const char *property)
 Return the value of the given property or NULL if the property is not set or does not have the EI_PROPERTY_PERM_READ permission. More...
 
int ei_setup_backend_socket (struct ei *ei, const char *socketpath)
 Set this ei context to use the socket backend. More...
 
int ei_setup_backend_fd (struct ei *ei, int fd)
 Initialize the ei context on the given socket. More...
 
int ei_setup_backend_portal (struct ei *ei)
 Connect to the org.freedesktop.portal.Desktop portal. More...
 
int ei_setup_backend_portal_busname (struct ei *ei, const char *busname)
 Connect to an org.freedesktop.portal.Desktop implementation on the given busname. More...
 
struct eiei_ref (struct ei *ei)
 Increase the refcount of this struct by one. More...
 
struct eiei_unref (struct ei *ei)
 Decrease the refcount of this struct by one. More...
 
void ei_set_user_data (struct ei *ei, void *user_data)
 Set a custom data pointer for this context. More...
 
void * ei_get_user_data (struct ei *ei)
 Return the custom data pointer for this context. More...
 
int ei_get_fd (struct ei *ei)
 libei keeps a single file descriptor for all events. More...
 
void ei_dispatch (struct ei *ei)
 Main event dispatching function. More...
 
struct ei_eventei_get_event (struct ei *ei)
 Return the next event from the event queue, removing it from the queue. More...
 
struct ei_eventei_peek_event (struct ei *ei)
 Returns the next event in the internal event queue (or NULL) without removing that event from the queue; the next call to ei_get_event() will return that same event. More...
 
struct ei_eventei_event_unref (struct ei_event *event)
 Release resources associated with this event. More...
 
const char * ei_seat_get_name (struct ei_seat *seat)
 
bool ei_seat_has_capability (struct ei_seat *seat, enum ei_device_capability cap)
 Return true if the capabilitiy is available on this seat or false otherwise. More...
 
void ei_seat_bind_capability (struct ei_seat *seat, enum ei_device_capability cap)
 Bind this client to the given seat capability. More...
 
 __attribute__ ((sentinel)) void ei_seat_bind_capabilities(struct ei_seat *seat
 Same as ei_seat_bind_capability() but takes multiple capabilities, terminated by NULL. More...
 
void ei_seat_unbind_capability (struct ei_seat *seat, enum ei_device_capability cap)
 Unbind a seat's capability. More...
 
struct ei_seatei_seat_ref (struct ei_seat *seat)
 
struct ei_seatei_seat_unref (struct ei_seat *seat)
 
struct eiei_seat_get_context (struct ei_seat *seat)
 Return the struct EI - the client implementation context this seat is associated with. More...
 
enum ei_event_type ei_event_get_type (struct ei_event *event)
 
struct ei_deviceei_event_get_device (struct ei_event *event)
 Return the device from this event. More...
 
uint64_t ei_event_get_time (struct ei_event *event)
 
uint32_t ei_event_keyboard_get_xkb_mods_depressed (struct ei_event *event)
 For an event of type EI_EVENT_KEYBOARD_MODIFIERS, get the mask of currently logically pressed-down modifiers. More...
 
uint32_t ei_event_keyboard_get_xkb_mods_latched (struct ei_event *event)
 For an event of type EI_EVENT_KEYBOARD_MODIFIERS, get the mask of currently logically latched modifiers. More...
 
uint32_t ei_event_keyboard_get_xkb_mods_locked (struct ei_event *event)
 For an event of type EI_EVENT_KEYBOARD_MODIFIERS, get the mask of currently logically locked modifiers. More...
 
uint32_t ei_event_keyboard_get_xkb_group (struct ei_event *event)
 For an event of type EI_EVENT_KEYBOARD_MODIFIERS, get the logical group state. More...
 
struct ei_deviceei_device_ref (struct ei_device *device)
 Increase the refcount of this struct by one. More...
 
struct ei_deviceei_device_unref (struct ei_device *device)
 Decrease the refcount of this struct by one. More...
 
struct ei_seatei_device_get_seat (struct ei_device *device)
 
void ei_seat_set_user_data (struct ei_seat *seat, void *user_data)
 Set a custom data pointer for this context. More...
 
void * ei_seat_get_user_data (struct ei_seat *seat)
 Return the custom data pointer for this context. More...
 
void ei_device_set_user_data (struct ei_device *device, void *user_data)
 Set a custom data pointer for this context. More...
 
void * ei_device_get_user_data (struct ei_device *device)
 Return the custom data pointer for this context. More...
 
struct ei_keymapei_device_get_keymap (struct ei_device *device)
 
size_t ei_keymap_get_size (struct ei_keymap *keymap)
 
enum ei_keymap_type ei_keymap_get_type (struct ei_keymap *keymap)
 Returns the type for this keymap. More...
 
int ei_keymap_get_fd (struct ei_keymap *keymap)
 Return a memmap-able file descriptor pointing to the keymap used by the device. More...
 
struct ei_deviceei_keymap_get_device (struct ei_keymap *keymap)
 Return the device this keymap belongs to, or NULL if it has not yet been assigned to a device. More...
 
struct ei_keymapei_keymap_ref (struct ei_keymap *keymap)
 Increase the refcount of this struct by one. More...
 
struct ei_keymapei_keymap_unref (struct ei_keymap *keymap)
 Decrease the refcount of this struct by one. More...
 
void ei_keymap_set_user_data (struct ei_keymap *keymap, void *user_data)
 
void * ei_keymap_get_user_data (struct ei_keymap *keymap)
 
void ei_device_close (struct ei_device *device)
 Notify the server that the client is no longer interested in this device. More...
 
const char * ei_device_get_name (struct ei_device *device)
 
enum ei_device_type ei_device_get_type (struct ei_device *device)
 The device type of the device is determined by the type of the ei context. More...
 
bool ei_device_has_capability (struct ei_device *device, enum ei_device_capability cap)
 Return true if the device has the requested capability. More...
 
struct ei_regionei_device_get_region (struct ei_device *device, size_t index)
 Obtain a region from a device of type EI_DEVICE_TYPE_VIRTUAL. More...
 
struct ei_regionei_region_ref (struct ei_region *region)
 
struct ei_regionei_region_unref (struct ei_region *region)
 
void ei_region_set_user_data (struct ei_region *region, void *user_data)
 
void * ei_region_get_user_data (struct ei_region *region)
 
uint32_t ei_region_get_x (struct ei_region *region)
 
uint32_t ei_region_get_y (struct ei_region *region)
 
uint32_t ei_region_get_width (struct ei_region *region)
 
uint32_t ei_region_get_height (struct ei_region *region)
 
bool ei_region_contains (struct ei_region *region, double x, double y)
 Return true if the point x/y (in desktop-wide coordinates) is within region. More...
 
bool ei_region_convert_point (struct ei_region *region, double *x, double *y)
 Convert the point x/y in a desktop-wide coordinate system into the corresponding point relative to the offset of the given region. More...
 
double ei_region_get_physical_scale (struct ei_region *region)
 Return the physical scale for this region. More...
 
struct ei_keymapei_device_keyboard_get_keymap (struct ei_device *device)
 Return the keymap for this device or NULL. More...
 
struct ei_deviceei_keymap_get_context (struct ei_keymap *keymap)
 Return the struct ei_device this keymap is associated with. More...
 
struct eiei_device_get_context (struct ei_device *device)
 Return the struct EI - the client implementation context this device is associated with. More...
 
void ei_device_start_emulating (struct ei_device *device)
 Notify the EIS implementation that the given device is about to start sending events. More...
 
void ei_device_stop_emulating (struct ei_device *device)
 Notify the EIS implementation that the given device is no longer sending events. More...
 
void ei_device_frame (struct ei_device *device)
 Generate a frame event to group the current set of events into a logical hardware event. More...
 
void ei_device_pointer_motion (struct ei_device *device, double x, double y)
 Generate a relative motion event on a device with the EI_DEVICE_CAP_POINTER capability. More...
 
void ei_device_pointer_motion_absolute (struct ei_device *device, double x, double y)
 Generate an absolute motion event on a device with the EI_DEVICE_CAP_POINTER_ABSOLUTE capability. More...
 
void ei_device_pointer_button (struct ei_device *device, uint32_t button, bool is_press)
 Generate a button event on a device with the EI_DEVICE_CAP_POINTER_ABSOLUTE or EI_DEVICE_CAP_POINTER capability. More...
 
void ei_device_pointer_scroll (struct ei_device *device, double x, double y)
 Generate a smooth (pixel-precise) scroll event on a device with the EI_DEVICE_CAP_POINTER_ABSOLUTE or EI_DEVICE_CAP_POINTER capability. More...
 
void ei_device_pointer_scroll_discrete (struct ei_device *device, int32_t x, int32_t y)
 Generate a discrete scroll event on a device with the EI_DEVICE_CAP_POINTER_ABSOLUTE or EI_DEVICE_CAP_POINTER capability. More...
 
void ei_device_pointer_scroll_stop (struct ei_device *device, bool stop_x, bool stop_y)
 Generate a scroll stop event on a device with the EI_DEVICE_CAP_POINTER_ABSOLUTE or EI_DEVICE_CAP_POINTER capability. More...
 
void ei_device_pointer_scroll_cancel (struct ei_device *device, bool cancel_x, bool cancel_y)
 Generate a scroll cancel event on a device with the EI_DEVICE_CAP_POINTER_ABSOLUTE or EI_DEVICE_CAP_POINTER capability. More...
 
void ei_device_keyboard_key (struct ei_device *device, uint32_t keycode, bool is_press)
 Generate a key event on a device with the EI_DEVICE_CAP_KEYBOARD capability. More...
 
struct ei_touch * ei_device_touch_new (struct ei_device *device)
 Initiate a new touch on a device with the EI_DEVICE_CAP_TOUCH capability. More...
 
void ei_touch_down (struct ei_touch *touch, double x, double y)
 This function can only be called once on an ei_touch object. More...
 
void ei_touch_motion (struct ei_touch *touch, double x, double y)
 Move this touch to the new coordinates. More...
 
void ei_touch_up (struct ei_touch *touch)
 Release this touch. More...
 
struct ei_touch * ei_touch_ref (struct ei_touch *touch)
 Increase the refcount of this struct by one. More...
 
struct ei_touch * ei_touch_unref (struct ei_touch *touch)
 Decrease the refcount of this struct by one. More...
 
void ei_touch_set_user_data (struct ei_touch *touch, void *user_data)
 Return the custom data pointer for this context. More...
 
void * ei_touch_get_user_data (struct ei_touch *touch)
 Set a custom data pointer for this context. More...
 
struct ei_deviceei_touch_get_device (struct ei_touch *touch)
 
struct ei_seatei_event_get_seat (struct ei_event *event)
 Return the seat from this event. More...
 
const char * ei_event_property_get_name (struct ei_event *event)
 For an event of type EI_EVENT_PROPERTY, get the property name that has changed. More...
 
const char * ei_event_property_get_value (struct ei_event *event)
 For an event of type EI_EVENT_PROPERTY, get the new property value (at the time of the event). More...
 
uint32_t ei_event_property_get_permissions (struct ei_event *event)
 For an event of type EI_EVENT_PROPERTY, get the permissions of the property (at the time of the event). More...
 
double ei_event_pointer_get_dx (struct ei_event *event)
 For an event of type EI_EVENT_POINTER_MOTION return the relative x movement in logical pixels or mm, depending on the device type. More...
 
double ei_event_pointer_get_dy (struct ei_event *event)
 For an event of type EI_EVENT_POINTER_MOTION return the relative y movement in logical pixels or mm, depending on the device type. More...
 
double ei_event_pointer_get_absolute_x (struct ei_event *event)
 For an event of type EI_EVENT_POINTER_MOTION_ABSOLUTE return the x position in logical pixels or mm, depending on the device type. More...
 
double ei_event_pointer_get_absolute_y (struct ei_event *event)
 For an event of type EI_EVENT_POINTER_MOTION_ABSOLUTE return the y position in logical pixels or mm, depending on the device type. More...
 
uint32_t ei_event_pointer_get_button (struct ei_event *event)
 For an event of type EI_EVENT_POINTER_BUTTON return the button code as defined in linux/input-event-codes.h. More...
 
bool ei_event_pointer_get_button_is_press (struct ei_event *event)
 For an event of type EI_EVENT_POINTER_BUTTON return true if the event is a button press, false for a release. More...
 
double ei_event_pointer_get_scroll_x (struct ei_event *event)
 For an event of type EI_EVENT_POINTER_SCROLL return the x scroll distance in logical pixels or mm, depending on the device type. More...
 
double ei_event_pointer_get_scroll_y (struct ei_event *event)
 For an event of type EI_EVENT_POINTER_SCROLL return the y scroll distance in logical pixels or mm, depending on the device type. More...
 
bool ei_event_pointer_get_scroll_stop_x (struct ei_event *event)
 For an event of type EI_EVENT_POINTER_SCROLL_CANCEL return whether the x axis has cancelled scrolling. More...
 
bool ei_event_pointer_get_scroll_stop_y (struct ei_event *event)
 For an event of type EI_EVENT_POINTER_SCROLL_STOP return whether the y axis has stopped scrolling. More...
 
int32_t ei_event_pointer_get_scroll_discrete_x (struct ei_event *event)
 For an event of type EI_EVENT_POINTER_SCROLL_DISCRETE return the x scroll distance in fractions or multiples of 120. More...
 
int32_t ei_event_pointer_get_scroll_discrete_y (struct ei_event *event)
 For an event of type EI_EVENT_POINTER_SCROLL_DISCRETE return the y scroll distance in fractions or multiples of 120. More...
 
uint32_t ei_event_keyboard_get_key (struct ei_event *event)
 For an event of type EI_EVENT_KEYBOARD_KEY return the key code (as defined in include/linux/input-event-codes.h). More...
 
bool ei_event_keyboard_get_key_is_press (struct ei_event *event)
 For an event of type EI_EVENT_KEYBOARD_KEY return true if the event is a key down, false for a release. More...
 
uint32_t ei_event_touch_get_id (struct ei_event *event)
 For an event of type EI_EVENT_TOUCH_DOWN, EI_EVENT_TOUCH_MOTION, or EI_EVENT_TOUCH_UP, return the tracking ID of the touch. More...
 
double ei_event_touch_get_x (struct ei_event *event)
 For an event of type EI_EVENT_TOUCH_DOWN, or EI_EVENT_TOUCH_MOTION, return the x coordinate of the touch in logical pixels or mm, depending on the device type. More...
 
double ei_event_touch_get_y (struct ei_event *event)
 For an event of type EI_EVENT_TOUCH_DOWN, or EI_EVENT_TOUCH_MOTION, return the y coordinate of the touch in logical pixels or mm, depending on the device type. More...