libei: doc/api/libei.h Source File

libei 1.6.0 A library for Emulated Input

libei.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: MIT */
2/*
3 * Copyright © 2020 Red Hat, Inc.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24
25#pragma once
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31#include <stdbool.h>
32#include <stddef.h>
33#include <stdint.h>
34
120
125
135struct ei;
136
148struct ei_device;
149
163struct ei_seat;
164
173struct ei_event;
174
182struct ei_keymap;
183
204struct ei_region;
205
216struct ei_touch;
217
226struct ei_ping;
227
250 enum ei_device_type { EI_DEVICE_TYPE_VIRTUAL = 1, EI_DEVICE_TYPE_PHYSICAL };
251
275 enum ei_device_capability {
279 EI_DEVICE_CAP_POINTER = (1 << 0),
283 EI_DEVICE_CAP_POINTER_ABSOLUTE = (1 << 1),
287 EI_DEVICE_CAP_KEYBOARD = (1 << 2),
291 EI_DEVICE_CAP_TOUCH = (1 << 3),
295 EI_DEVICE_CAP_SCROLL = (1 << 4),
299 EI_DEVICE_CAP_BUTTON = (1 << 5),
305 EI_DEVICE_CAP_TEXT = (1 << 6),
306};
307
313 enum ei_keymap_type {
317 EI_KEYMAP_TYPE_XKB = 1,
318};
319
329 enum ei_event_type {
338 EI_EVENT_CONNECT = 1,
339
352 EI_EVENT_DISCONNECT,
353
363 EI_EVENT_SEAT_ADDED,
364
375 EI_EVENT_SEAT_REMOVED,
376
386 EI_EVENT_DEVICE_ADDED,
387
398 EI_EVENT_DEVICE_REMOVED,
399
413 EI_EVENT_DEVICE_PAUSED,
414
421 EI_EVENT_DEVICE_RESUMED,
422
461 EI_EVENT_KEYBOARD_MODIFIERS,
462
470 EI_EVENT_PONG = 90,
471
481 EI_EVENT_SYNC,
482
491 EI_EVENT_FRAME = 100,
492
507 EI_EVENT_DEVICE_START_EMULATING = 200,
515 EI_EVENT_DEVICE_STOP_EMULATING,
516
524 EI_EVENT_POINTER_MOTION = 300,
525
533 EI_EVENT_POINTER_MOTION_ABSOLUTE = 400,
534
541 EI_EVENT_BUTTON_BUTTON = 500,
542
550 EI_EVENT_SCROLL_DELTA = 600,
557 EI_EVENT_SCROLL_STOP,
564 EI_EVENT_SCROLL_CANCEL,
572 EI_EVENT_SCROLL_DISCRETE,
573
580 EI_EVENT_KEYBOARD_KEY = 700,
581
591 EI_EVENT_TOUCH_DOWN = 800,
599 EI_EVENT_TOUCH_UP,
607 EI_EVENT_TOUCH_MOTION,
608
619 EI_EVENT_TEXT_KEYSYM = 900,
620
629 EI_EVENT_TEXT_UTF8,
630};
631
637 const char *ei_event_type_to_string(enum ei_event_type);
638
642struct ei *
643ei_new(void *user_data);
644
662struct ei *
663ei_new_sender(void *user_data);
664
682struct ei *
683ei_new_receiver(void *user_data);
684
691struct ei *
692ei_ref(struct ei *ei);
693
701struct ei *
702ei_unref(struct ei *ei);
703
709void
710ei_set_user_data(struct ei *ei, void *user_data);
711
716void *
717ei_get_user_data(struct ei *ei);
718
722bool
723ei_is_sender(struct ei *ei);
724
728 enum ei_log_priority {
729 EI_LOG_PRIORITY_DEBUG = 10,
730 EI_LOG_PRIORITY_INFO = 20,
731 EI_LOG_PRIORITY_WARNING = 30,
732 EI_LOG_PRIORITY_ERROR = 40,
733};
734
735struct ei_log_context;
736
741unsigned int
742ei_log_context_get_line(struct ei_log_context *ctx);
743
748const char *
749ei_log_context_get_file(struct ei_log_context *ctx);
750
755const char *
756ei_log_context_get_func(struct ei_log_context *ctx);
757
775 typedef void (*ei_log_handler)(struct ei *ei,
776 enum ei_log_priority priority,
777 const char *message,
778 struct ei_log_context *context);
789void
790ei_log_set_handler(struct ei *ei, ei_log_handler log_handler);
791
795void
796ei_log_set_priority(struct ei *ei, enum ei_log_priority priority);
797
801enum ei_log_priority
802ei_log_get_priority(const struct ei *ei);
803
812 typedef uint64_t (*ei_clock_now_func)(struct ei *ei);
813
819void
820ei_clock_set_now_func(struct ei *, ei_clock_now_func func);
821
834void
835ei_configure_name(struct ei *ei, const char *name);
836
858int
859ei_setup_backend_fd(struct ei *ei, int fd);
860
887int
888ei_setup_backend_socket(struct ei *ei, const char *socketpath);
889
896int
897ei_get_fd(struct ei *ei);
898
908struct ei_ping *
909ei_new_ping(struct ei *ei);
910
923uint64_t
924ei_ping_get_id(struct ei_ping *ping);
925
934struct ei_ping *
935ei_ping_ref(struct ei_ping *ei_ping);
936
945struct ei_ping *
946ei_ping_unref(struct ei_ping *ei_ping);
947
955void
956ei_ping_set_user_data(struct ei_ping *ei_ping, void *user_data);
957
964void *
965ei_ping_get_user_data(struct ei_ping *ei_ping);
966
984void
985ei_ping(struct ei_ping *ping);
986
996void
997ei_dispatch(struct ei *ei);
998
1005struct ei_event *
1006ei_get_event(struct ei *ei);
1007
1024struct ei_event *
1025ei_peek_event(struct ei *ei);
1026
1034uint64_t
1035ei_now(struct ei *ei);
1036
1052void
1053ei_disconnect(struct ei *ei);
1054
1062void
1063ei_seat_set_user_data(struct ei_seat *seat, void *user_data);
1064
1071void *
1072ei_seat_get_user_data(struct ei_seat *seat);
1073
1077const char *
1078ei_seat_get_name(struct ei_seat *seat);
1079
1087bool
1088ei_seat_has_capability(struct ei_seat *seat, enum ei_device_capability cap);
1089
1107void
1108ei_seat_bind_capabilities(struct ei_seat *seat, ...) __attribute__((sentinel));
1109
1121void
1122ei_seat_unbind_capabilities(struct ei_seat *seat, ...) __attribute__((sentinel));
1123
1148void
1149ei_seat_request_device_with_capabilities(struct ei_seat *seat, ...) __attribute__((sentinel));
1150
1154struct ei_seat *
1155ei_seat_ref(struct ei_seat *seat);
1156
1160struct ei_seat *
1161ei_seat_unref(struct ei_seat *seat);
1162
1168struct ei *
1169ei_seat_get_context(struct ei_seat *seat);
1170
1179struct ei_event *
1180ei_event_ref(struct ei_event *event);
1181
1191struct ei_event *
1192ei_event_unref(struct ei_event *event);
1193
1197enum ei_event_type
1198ei_event_get_type(struct ei_event *event);
1199
1209struct ei_device *
1210ei_event_get_device(struct ei_event *event);
1211
1221uint64_t
1222ei_event_get_time(struct ei_event *event);
1223
1232struct ei_device *
1233ei_device_ref(struct ei_device *device);
1234
1243struct ei_device *
1244ei_device_unref(struct ei_device *device);
1245
1249struct ei_seat *
1250ei_device_get_seat(struct ei_device *device);
1251
1259void
1260ei_device_set_user_data(struct ei_device *device, void *user_data);
1261
1268void *
1269ei_device_get_user_data(struct ei_device *device);
1270
1277uint32_t
1278ei_device_get_width(struct ei_device *device);
1279
1286uint32_t
1287ei_device_get_height(struct ei_device *device);
1288
1294size_t
1295ei_keymap_get_size(struct ei_keymap *keymap);
1296
1303enum ei_keymap_type
1304ei_keymap_get_type(struct ei_keymap *keymap);
1305
1313int
1314ei_keymap_get_fd(struct ei_keymap *keymap);
1315
1326struct ei_device *
1327ei_keymap_get_device(struct ei_keymap *keymap);
1328
1337struct ei_keymap *
1338ei_keymap_ref(struct ei_keymap *keymap);
1339
1348struct ei_keymap *
1349ei_keymap_unref(struct ei_keymap *keymap);
1350
1354void
1355ei_keymap_set_user_data(struct ei_keymap *keymap, void *user_data);
1356
1360void *
1361ei_keymap_get_user_data(struct ei_keymap *keymap);
1362
1382void
1383ei_device_close(struct ei_device *device);
1384
1390const char *
1391ei_device_get_name(struct ei_device *device);
1392
1398enum ei_device_type
1399ei_device_get_type(struct ei_device *device);
1400
1408bool
1409ei_device_has_capability(struct ei_device *device, enum ei_device_capability cap);
1410
1432struct ei_region *
1433ei_device_get_region(struct ei_device *device, size_t index);
1434
1443struct ei_region *
1444ei_device_get_region_at(struct ei_device *device, double x, double y);
1445
1449struct ei_region *
1450ei_region_ref(struct ei_region *region);
1451
1455struct ei_region *
1456ei_region_unref(struct ei_region *region);
1457
1461void
1462ei_region_set_user_data(struct ei_region *region, void *user_data);
1463
1467void *
1468ei_region_get_user_data(struct ei_region *region);
1469
1473uint32_t
1474ei_region_get_x(struct ei_region *region);
1475
1479uint32_t
1480ei_region_get_y(struct ei_region *region);
1481
1485uint32_t
1486ei_region_get_width(struct ei_region *region);
1487
1491uint32_t
1492ei_region_get_height(struct ei_region *region);
1493
1521const char *
1522ei_region_get_mapping_id(struct ei_region *region);
1523
1530bool
1531ei_region_contains(struct ei_region *region, double x, double y);
1532
1543bool
1544ei_region_convert_point(struct ei_region *region, double *x, double *y);
1545
1615double
1616ei_region_get_physical_scale(struct ei_region *region);
1617
1632/* FIXME: the current API makes it impossible to know when the keymap has
1633 * been consumed so the file stays open forever.
1634 */
1635struct ei_keymap *
1636ei_device_keyboard_get_keymap(struct ei_device *device);
1637
1643struct ei_device *
1644ei_keymap_get_context(struct ei_keymap *keymap);
1645
1651struct ei *
1652ei_device_get_context(struct ei_device *device);
1653
1683void
1684ei_device_start_emulating(struct ei_device *device, uint32_t sequence);
1685
1698void
1699ei_device_stop_emulating(struct ei_device *device);
1700
1717void
1718ei_device_frame(struct ei_device *device, uint64_t time);
1719
1732void
1733ei_device_pointer_motion(struct ei_device *device, double x, double y);
1734
1750void
1751ei_device_pointer_motion_absolute(struct ei_device *device, double x, double y);
1752
1767void
1768ei_device_button_button(struct ei_device *device, uint32_t button, bool is_press);
1769
1788void
1789ei_device_scroll_delta(struct ei_device *device, double x, double y);
1790
1813void
1814ei_device_scroll_discrete(struct ei_device *device, int32_t x, int32_t y);
1815
1845void
1846ei_device_scroll_stop(struct ei_device *device, bool stop_x, bool stop_y);
1847
1876void
1877ei_device_scroll_cancel(struct ei_device *device, bool cancel_x, bool cancel_y);
1878
1899void
1900ei_device_keyboard_key(struct ei_device *device, uint32_t keycode, bool is_press);
1901
1925void
1926ei_device_text_keysym(struct ei_device *device, uint32_t keysym, bool is_press);
1927
1945void
1946ei_device_text_utf8(struct ei_device *device, const char *utf8);
1947
1967void
1968ei_device_text_utf8_with_length(struct ei_device *device, const char *text, size_t length);
1969
1982struct ei_touch *
1983ei_device_touch_new(struct ei_device *device);
1984
1998void
1999ei_touch_down(struct ei_touch *touch, double x, double y);
2000
2006void
2007ei_touch_motion(struct ei_touch *touch, double x, double y);
2008
2016void
2017ei_touch_up(struct ei_touch *touch);
2018
2030void
2031ei_touch_cancel(struct ei_touch *touch);
2032
2041struct ei_touch *
2042ei_touch_ref(struct ei_touch *touch);
2043
2052struct ei_touch *
2053ei_touch_unref(struct ei_touch *touch);
2054
2062void
2063ei_touch_set_user_data(struct ei_touch *touch, void *user_data);
2064
2071void *
2072ei_touch_get_user_data(struct ei_touch *touch);
2073
2079struct ei_device *
2080ei_touch_get_device(struct ei_touch *touch);
2081
2091struct ei_seat *
2092ei_event_get_seat(struct ei_event *event);
2093
2103struct ei_ping *
2104ei_event_pong_get_ping(struct ei_event *event);
2105
2114uint32_t
2115ei_event_emulating_get_sequence(struct ei_event *event);
2116
2124uint32_t
2125ei_event_keyboard_get_xkb_mods_depressed(struct ei_event *event);
2126
2134uint32_t
2135ei_event_keyboard_get_xkb_mods_latched(struct ei_event *event);
2136
2144uint32_t
2145ei_event_keyboard_get_xkb_mods_locked(struct ei_event *event);
2146
2167uint32_t
2168ei_event_keyboard_get_xkb_group(struct ei_event *event);
2169
2176double
2177ei_event_pointer_get_dx(struct ei_event *event);
2178
2185double
2186ei_event_pointer_get_dy(struct ei_event *event);
2187
2194double
2195ei_event_pointer_get_absolute_x(struct ei_event *event);
2196
2203double
2204ei_event_pointer_get_absolute_y(struct ei_event *event);
2205
2212uint32_t
2213ei_event_button_get_button(struct ei_event *event);
2214
2221bool
2222ei_event_button_get_is_press(struct ei_event *event);
2223
2230double
2231ei_event_scroll_get_dx(struct ei_event *event);
2232
2239double
2240ei_event_scroll_get_dy(struct ei_event *event);
2241
2248bool
2249ei_event_scroll_get_stop_x(struct ei_event *event);
2250
2257bool
2258ei_event_scroll_get_stop_y(struct ei_event *event);
2259
2266int32_t
2267ei_event_scroll_get_discrete_dx(struct ei_event *event);
2268
2275int32_t
2276ei_event_scroll_get_discrete_dy(struct ei_event *event);
2277
2284uint32_t
2285ei_event_keyboard_get_key(struct ei_event *event);
2286
2293bool
2294ei_event_keyboard_get_key_is_press(struct ei_event *event);
2295
2308uint32_t
2309ei_event_touch_get_id(struct ei_event *event);
2310
2318double
2319ei_event_touch_get_x(struct ei_event *event);
2320
2328double
2329ei_event_touch_get_y(struct ei_event *event);
2330
2341bool
2342ei_event_touch_get_is_cancel(struct ei_event *event);
2343
2352uint32_t
2353ei_event_text_get_keysym(struct ei_event *event);
2354
2364bool
2365ei_event_text_get_keysym_is_press(struct ei_event *event);
2366
2375const char *
2376ei_event_text_get_utf8(struct ei_event *event);
2377
2381
2382#ifdef __cplusplus
2383}
2384#endif
ei_device_keyboard_get_keymap
struct ei_keymap * ei_device_keyboard_get_keymap(struct ei_device *device)
Return the keymap for this device or NULL.
ei_device_get_width
uint32_t ei_device_get_width(struct ei_device *device)
Return the width of the device in mm if the device is of type EI_DEVICE_TYPE_PHYSICAL,...
ei_device_set_user_data
void ei_device_set_user_data(struct ei_device *device, void *user_data)
Set a custom data pointer for this context.
ei_device_get_type
enum ei_device_type ei_device_get_type(struct ei_device *device)
ei_device_get_region_at
struct ei_region * ei_device_get_region_at(struct ei_device *device, double x, double y)
Return the region that contains the given point x/y (in desktop-wide coordinates) or NULL if the coor...
ei_device_close
void ei_device_close(struct ei_device *device)
Notify the server that the client is no longer interested in this device.
ei_device_unref
struct ei_device * ei_device_unref(struct ei_device *device)
Decrease the refcount of this struct by one.
ei_device_get_context
struct ei * ei_device_get_context(struct ei_device *device)
Return the struct ei context this device is associated with.
ei_device_get_seat
struct ei_seat * ei_device_get_seat(struct ei_device *device)
ei_device_get_name
const char * ei_device_get_name(struct ei_device *device)
ei_device_has_capability
bool ei_device_has_capability(struct ei_device *device, enum ei_device_capability cap)
Return true if the device has the requested capability.
ei_device_get_height
uint32_t ei_device_get_height(struct ei_device *device)
Return the height of the device in mm if the device is of type EI_DEVICE_TYPE_PHYSICAL,...
ei_device_ref
struct ei_device * ei_device_ref(struct ei_device *device)
Increase the refcount of this struct by one.
ei_device_get_user_data
void * ei_device_get_user_data(struct ei_device *device)
Return the custom data pointer for this context.
ei_device_get_region
struct ei_region * ei_device_get_region(struct ei_device *device, size_t index)
Obtain a region from a device of type EI_DEVICE_TYPE_VIRTUAL.
ei_keymap_get_fd
int ei_keymap_get_fd(struct ei_keymap *keymap)
Return a memmap-able file descriptor pointing to the keymap used by the device.
ei_keymap_get_user_data
void * ei_keymap_get_user_data(struct ei_keymap *keymap)
ei_keymap_get_size
size_t ei_keymap_get_size(struct ei_keymap *keymap)
ei_keymap_get_type
enum ei_keymap_type ei_keymap_get_type(struct ei_keymap *keymap)
Returns the type for this keymap.
ei_keymap_ref
struct ei_keymap * ei_keymap_ref(struct ei_keymap *keymap)
Increase the refcount of this struct by one.
ei_keymap_unref
struct ei_keymap * ei_keymap_unref(struct ei_keymap *keymap)
Decrease the refcount of this struct by one.
ei_keymap_set_user_data
void ei_keymap_set_user_data(struct ei_keymap *keymap, void *user_data)
ei_keymap_get_device
struct ei_device * ei_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.
ei_keymap_get_context
struct ei_device * ei_keymap_get_context(struct ei_keymap *keymap)
Return the struct ei_device this keymap is associated with.
ei_log_context_get_func
const char * ei_log_context_get_func(struct ei_log_context *ctx)
ei_log_get_priority
enum ei_log_priority ei_log_get_priority(const struct ei *ei)
ei_log_context_get_line
unsigned int ei_log_context_get_line(struct ei_log_context *ctx)
ei_log_context_get_file
const char * ei_log_context_get_file(struct ei_log_context *ctx)
ei_log_priority
ei_log_priority
Definition libei.h:728
ei_log_handler
void(* ei_log_handler)(struct ei *ei, enum ei_log_priority priority, const char *message, struct ei_log_context *context)
The log handler for library logging.
Definition libei.h:775
ei_log_set_priority
void ei_log_set_priority(struct ei *ei, enum ei_log_priority priority)
ei_log_set_handler
void ei_log_set_handler(struct ei *ei, ei_log_handler log_handler)
Change the log handler for this context.
EI_LOG_PRIORITY_INFO
@ EI_LOG_PRIORITY_INFO
Definition libei.h:730
EI_LOG_PRIORITY_DEBUG
@ EI_LOG_PRIORITY_DEBUG
Definition libei.h:729
EI_LOG_PRIORITY_WARNING
@ EI_LOG_PRIORITY_WARNING
Definition libei.h:731
EI_LOG_PRIORITY_ERROR
@ EI_LOG_PRIORITY_ERROR
Definition libei.h:732
ei_event_touch_get_id
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,...
ei_event_emulating_get_sequence
uint32_t ei_event_emulating_get_sequence(struct ei_event *event)
For an event of type EI_EVENT_DEVICE_START_EMULATING, return the sequence number set by the EIS imple...
ei_event_scroll_get_dx
double ei_event_scroll_get_dx(struct ei_event *event)
For an event of type EI_EVENT_SCROLL_DELTA return the x scroll distance in logical pixels or mm,...
ei_event_scroll_get_dy
double ei_event_scroll_get_dy(struct ei_event *event)
For an event of type EI_EVENT_SCROLL_DELTA return the y scroll distance in logical pixels or mm,...
ei_event_text_get_keysym_is_press
bool ei_event_text_get_keysym_is_press(struct ei_event *event)
For an event of type EI_EVENT_TEXT_KEYSYM return true if the event is a logical key down for the keys...
ei_event_pointer_get_absolute_x
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,...
ei_event_text_get_keysym
uint32_t ei_event_text_get_keysym(struct ei_event *event)
For an event of type EI_EVENT_TEXT_KEYSYM return the XKB-compatible keysym.
ei_event_button_get_is_press
bool ei_event_button_get_is_press(struct ei_event *event)
For an event of type EI_EVENT_BUTTON_BUTTON return true if the event is a button press,...
ei_event_scroll_get_stop_y
bool ei_event_scroll_get_stop_y(struct ei_event *event)
For an event of type EI_EVENT_SCROLL_STOP return whether the y axis has stopped scrolling.
ei_event_keyboard_get_xkb_mods_locked
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 modifier...
ei_event_scroll_get_discrete_dy
int32_t ei_event_scroll_get_discrete_dy(struct ei_event *event)
For an event of type EI_EVENT_SCROLL_DISCRETE return the y scroll distance in fractions or multiples ...
ei_event_keyboard_get_key
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-eve...
ei_event_touch_get_x
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 to...
ei_event_keyboard_get_xkb_mods_depressed
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 mo...
ei_event_text_get_utf8
const char * ei_event_text_get_utf8(struct ei_event *event)
For an event of type EI_EVENT_TEXT_UTF8 return the zero-terminated UTF8 string.
ei_event_touch_get_y
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 to...
ei_event_pointer_get_dy
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,...
ei_event_touch_get_is_cancel
bool ei_event_touch_get_is_cancel(struct ei_event *event)
For an event of type EI_EVENT_TOUCH_UP return true if the event was cancelled instead of logically re...
ei_event_scroll_get_stop_x
bool ei_event_scroll_get_stop_x(struct ei_event *event)
For an event of type EI_EVENT_SCROLL_CANCEL return whether the x axis has cancelled scrolling.
ei_event_keyboard_get_xkb_mods_latched
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 modifie...
ei_event_scroll_get_discrete_dx
int32_t ei_event_scroll_get_discrete_dx(struct ei_event *event)
For an event of type EI_EVENT_SCROLL_DISCRETE return the x scroll distance in fractions or multiples ...
ei_event_button_get_button
uint32_t ei_event_button_get_button(struct ei_event *event)
For an event of type EI_EVENT_BUTTON_BUTTON return the button code as defined in linux/input-event-co...
ei_event_pointer_get_dx
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,...
ei_event_keyboard_get_xkb_group
uint32_t ei_event_keyboard_get_xkb_group(struct ei_event *event)
For an event of type EI_EVENT_KEYBOARD_MODIFIERS, get the current effective group.
ei_event_pointer_get_absolute_y
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,...
ei_event_keyboard_get_key_is_press
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,...
ei_region_set_user_data
void ei_region_set_user_data(struct ei_region *region, void *user_data)
ei_region_get_physical_scale
double ei_region_get_physical_scale(struct ei_region *region)
Return the physical scale for this region.
ei_region_get_width
uint32_t ei_region_get_width(struct ei_region *region)
ei_region_get_mapping_id
const char * ei_region_get_mapping_id(struct ei_region *region)
Get the unique identifier (representing an external resource) that is attached to this region,...
ei_region_unref
struct ei_region * ei_region_unref(struct ei_region *region)
ei_region_get_user_data
void * ei_region_get_user_data(struct ei_region *region)
ei_region_get_y
uint32_t ei_region_get_y(struct ei_region *region)
ei_region_contains
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.
ei_region_get_x
uint32_t ei_region_get_x(struct ei_region *region)
ei_region_convert_point
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 th...
ei_region_ref
struct ei_region * ei_region_ref(struct ei_region *region)
ei_region_get_height
uint32_t ei_region_get_height(struct ei_region *region)
ei_seat_set_user_data
void ei_seat_set_user_data(struct ei_seat *seat, void *user_data)
Set a custom data pointer for this context.
ei_seat_get_context
struct ei * ei_seat_get_context(struct ei_seat *seat)
Return the struct ei context this seat is associated with.
ei_seat_bind_capabilities
void ei_seat_bind_capabilities(struct ei_seat *seat,...) __attribute__((sentinel))
Bind this client to the given seat capabilities, terminated by NULL.
ei_seat_get_name
const char * ei_seat_get_name(struct ei_seat *seat)
ei_seat_get_user_data
void * ei_seat_get_user_data(struct ei_seat *seat)
Return the custom data pointer for this context.
ei_seat_ref
struct ei_seat * ei_seat_ref(struct ei_seat *seat)
ei_seat_request_device_with_capabilities
void ei_seat_request_device_with_capabilities(struct ei_seat *seat,...) __attribute__((sentinel))
Request a new device with (a subset of) the given capabilities from the EIS implementation.
ei_seat_has_capability
bool ei_seat_has_capability(struct ei_seat *seat, enum ei_device_capability cap)
Return true if the capability is available on this seat or false otherwise.
ei_seat_unref
struct ei_seat * ei_seat_unref(struct ei_seat *seat)
ei_seat_unbind_capabilities
void ei_seat_unbind_capabilities(struct ei_seat *seat,...) __attribute__((sentinel))
Unbind a seat's capabilities, terminated by NULL.
ei_device_stop_emulating
void ei_device_stop_emulating(struct ei_device *device)
Notify the EIS implementation that the given device is no longer sending events.
ei_device_start_emulating
void ei_device_start_emulating(struct ei_device *device, uint32_t sequence)
Notify the EIS implementation that the given device is about to start sending events.
ei_touch_get_device
struct ei_device * ei_touch_get_device(struct ei_touch *touch)
ei_touch_down
void ei_touch_down(struct ei_touch *touch, double x, double y)
This function can only be called once on an ei_touch object.
ei_device_scroll_cancel
void ei_device_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_SCROLL capability.
ei_device_pointer_motion_absolute
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.
ei_touch_up
void ei_touch_up(struct ei_touch *touch)
Release this touch.
ei_device_scroll_delta
void ei_device_scroll_delta(struct ei_device *device, double x, double y)
Generate a smooth (pixel-precise) scroll event on a device with the EI_DEVICE_CAP_SCROLL capability.
ei_touch_get_user_data
void * ei_touch_get_user_data(struct ei_touch *touch)
Return the custom data pointer for this context.
ei_device_text_keysym
void ei_device_text_keysym(struct ei_device *device, uint32_t keysym, bool is_press)
Generate a key event on a device with the EI_DEVICE_CAP_TEXT capability.
ei_device_scroll_stop
void ei_device_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_SCROLL capability.
ei_device_button_button
void ei_device_button_button(struct ei_device *device, uint32_t button, bool is_press)
Generate a button event on a device with the EI_DEVICE_CAP_BUTTON capability.
ei_device_text_utf8_with_length
void ei_device_text_utf8_with_length(struct ei_device *device, const char *text, size_t length)
Generate a UTF-8 text event on a device with the EI_DEVICE_CAP_TEXT capability.
ei_device_text_utf8
void ei_device_text_utf8(struct ei_device *device, const char *utf8)
Generate a UTF-8 text event on a device with the EI_DEVICE_CAP_TEXT capability.
ei_touch_ref
struct ei_touch * ei_touch_ref(struct ei_touch *touch)
Increase the refcount of this struct by one.
ei_touch_motion
void ei_touch_motion(struct ei_touch *touch, double x, double y)
Move this touch to the new coordinates.
ei_device_keyboard_key
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.
ei_device_frame
void ei_device_frame(struct ei_device *device, uint64_t time)
Generate a frame event to group the current set of events into a logical hardware event.
ei_device_scroll_discrete
void ei_device_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_SCROLL capability.
ei_touch_unref
struct ei_touch * ei_touch_unref(struct ei_touch *touch)
Decrease the refcount of this struct by one.
ei_device_touch_new
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.
ei_touch_cancel
void ei_touch_cancel(struct ei_touch *touch)
Cancel this touch.
ei_device_pointer_motion
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.
ei_touch_set_user_data
void ei_touch_set_user_data(struct ei_touch *touch, void *user_data)
Set a custom data pointer for this context.
ei_setup_backend_socket
int ei_setup_backend_socket(struct ei *ei, const char *socketpath)
Set this ei context to use the socket backend.
ei_is_sender
bool ei_is_sender(struct ei *ei)
Returns true if the context is was created with ei_new_sender() or false otherwise.
ei_ping_ref
struct ei_ping * ei_ping_ref(struct ei_ping *ei_ping)
Increase the refcount of this struct by one.
ei_clock_set_now_func
void ei_clock_set_now_func(struct ei *, ei_clock_now_func func)
Override the function that returns the current time ei_now().
ei_new_receiver
struct ei * ei_new_receiver(void *user_data)
Create a new receiver ei context.
ei_dispatch
void ei_dispatch(struct ei *ei)
Main event dispatching function.
ei_disconnect
void ei_disconnect(struct ei *ei)
Disconnect the current ei context from the EIS implementation.
ei_get_fd
int ei_get_fd(struct ei *ei)
libei keeps a single file descriptor for all events.
ei_set_user_data
void ei_set_user_data(struct ei *ei, void *user_data)
Set a custom data pointer for this context.
ei_ping_get_id
uint64_t ei_ping_get_id(struct ei_ping *ping)
Return a unique, increasing id for this struct.
ei_event_get_seat
struct ei_seat * ei_event_get_seat(struct ei_event *event)
Return the seat from this event.
ei_event_pong_get_ping
struct ei_ping * ei_event_pong_get_ping(struct ei_event *event)
Returns the associated ei_ping struct with this event.
ei_device_type
ei_device_type
The device type determines what the device represents.
Definition libei.h:250
ei_new_ping
struct ei_ping * ei_new_ping(struct ei *ei)
Create a new ei_ping object to trigger a round trip to the EIS implementation.
ei_unref
struct ei * ei_unref(struct ei *ei)
Decrease the refcount of this struct by one.
ei_new_sender
struct ei * ei_new_sender(void *user_data)
Create a new sender ei context.
ei_now
uint64_t ei_now(struct ei *ei)
ei_event_get_device
struct ei_device * ei_event_get_device(struct ei_event *event)
Return the device from this event.
ei_peek_event
struct ei_event * ei_peek_event(struct ei *ei)
Returns the next event in the internal event queue (or NULL) without removing that event from the que...
ei_setup_backend_fd
int ei_setup_backend_fd(struct ei *ei, int fd)
Initialize the ei context on the given socket file descriptor.
ei_keymap_type
ei_keymap_type
The set of supported keymap types for a struct ei_keymap.
Definition libei.h:313
ei_clock_now_func
uint64_t(* ei_clock_now_func)(struct ei *ei)
Optional override function for ei_now().
Definition libei.h:812
ei_ping_get_user_data
void * ei_ping_get_user_data(struct ei_ping *ei_ping)
Return the custom data pointer for this struct.
ei_event_get_time
uint64_t ei_event_get_time(struct ei_event *event)
Return the time for the event of type EI_EVENT_FRAME in microseconds.
ei_event_ref
struct ei_event * ei_event_ref(struct ei_event *event)
Increase the refcount of this struct by one.
ei_device_capability
ei_device_capability
The set of supported capabilities.
Definition libei.h:275
ei_ping
void ei_ping(struct ei_ping *ping)
Issue a roundtrip request to the EIS implementation, resulting in an EI_EVENT_PONG event when this ro...
ei_get_event
struct ei_event * ei_get_event(struct ei *ei)
Return the next event from the event queue, removing it from the queue.
ei_event_unref
struct ei_event * ei_event_unref(struct ei_event *event)
Decrease the refcount of this struct by one.
ei_event_get_type
enum ei_event_type ei_event_get_type(struct ei_event *event)
ei_event_type
ei_event_type
This enum is not exhaustive, future versions of this library may add new event types.
Definition libei.h:329
ei_ping_set_user_data
void ei_ping_set_user_data(struct ei_ping *ei_ping, void *user_data)
Set a custom data pointer for this struct.
ei_ping_unref
struct ei_ping * ei_ping_unref(struct ei_ping *ei_ping)
Decrease the refcount of this struct by one.
ei_configure_name
void ei_configure_name(struct ei *ei, const char *name)
Set the name for this client.
ei_event_type_to_string
const char * ei_event_type_to_string(enum ei_event_type)
This is a debugging helper to return a string of the name of the event type, or NULL if the event typ...
ei_ref
struct ei * ei_ref(struct ei *ei)
Increase the refcount of this struct by one.
ei_new
struct ei * ei_new(void *user_data)
This is an alias for ei_new_sender.
ei_get_user_data
void * ei_get_user_data(struct ei *ei)
Return the custom data pointer for this context.
EI_DEVICE_TYPE_PHYSICAL
@ EI_DEVICE_TYPE_PHYSICAL
Definition libei.h:250
EI_DEVICE_TYPE_VIRTUAL
@ EI_DEVICE_TYPE_VIRTUAL
Definition libei.h:250
EI_KEYMAP_TYPE_XKB
@ EI_KEYMAP_TYPE_XKB
A libxkbcommon-compatible XKB keymap.
Definition libei.h:317
EI_DEVICE_CAP_POINTER
@ EI_DEVICE_CAP_POINTER
The device can send relative motion events.
Definition libei.h:279
EI_DEVICE_CAP_SCROLL
@ EI_DEVICE_CAP_SCROLL
The device can send scroll events.
Definition libei.h:295
EI_DEVICE_CAP_POINTER_ABSOLUTE
@ EI_DEVICE_CAP_POINTER_ABSOLUTE
The device can send absolute motion events.
Definition libei.h:283
EI_DEVICE_CAP_TOUCH
@ EI_DEVICE_CAP_TOUCH
The device can send touch events.
Definition libei.h:291
EI_DEVICE_CAP_BUTTON
@ EI_DEVICE_CAP_BUTTON
The device can send button events.
Definition libei.h:299
EI_DEVICE_CAP_KEYBOARD
@ EI_DEVICE_CAP_KEYBOARD
The device can send keyboard events.
Definition libei.h:287
EI_DEVICE_CAP_TEXT
@ EI_DEVICE_CAP_TEXT
The device can send text-like data.
Definition libei.h:305
EI_EVENT_SEAT_REMOVED
@ EI_EVENT_SEAT_REMOVED
The server has removed a seat previously available to this client.
Definition libei.h:375
EI_EVENT_POINTER_MOTION_ABSOLUTE
@ EI_EVENT_POINTER_MOTION_ABSOLUTE
An absolute motion event with absolute position within the device's regions or size,...
Definition libei.h:533
EI_EVENT_POINTER_MOTION
@ EI_EVENT_POINTER_MOTION
A relative motion event with delta coordinates in logical pixels or mm, depending on the device type.
Definition libei.h:524
EI_EVENT_SCROLL_DELTA
@ EI_EVENT_SCROLL_DELTA
A vertical and/or horizontal scroll event with logical-pixels or mm precision, depending on the devic...
Definition libei.h:550
EI_EVENT_DEVICE_START_EMULATING
@ EI_EVENT_DEVICE_START_EMULATING
The server is about to send events for a device.
Definition libei.h:507
EI_EVENT_SCROLL_DISCRETE
@ EI_EVENT_SCROLL_DISCRETE
A vertical and/or horizontal scroll event with a discrete range in logical scroll steps,...
Definition libei.h:572
EI_EVENT_SCROLL_STOP
@ EI_EVENT_SCROLL_STOP
An ongoing scroll sequence stopped.
Definition libei.h:557
EI_EVENT_SEAT_ADDED
@ EI_EVENT_SEAT_ADDED
The server has added a seat available to this client.
Definition libei.h:363
EI_EVENT_FRAME
@ EI_EVENT_FRAME
"Hardware" frame event.
Definition libei.h:491
EI_EVENT_DEVICE_REMOVED
@ EI_EVENT_DEVICE_REMOVED
The server has removed a device belonging to this client.
Definition libei.h:398
EI_EVENT_DEVICE_RESUMED
@ EI_EVENT_DEVICE_RESUMED
The client may send events.
Definition libei.h:421
EI_EVENT_SYNC
@ EI_EVENT_SYNC
This event represents a synchronization request (ping) from the EIS implementation.
Definition libei.h:481
EI_EVENT_BUTTON_BUTTON
@ EI_EVENT_BUTTON_BUTTON
A button press or release event.
Definition libei.h:541
EI_EVENT_DEVICE_ADDED
@ EI_EVENT_DEVICE_ADDED
The server has added a device for this client.
Definition libei.h:386
EI_EVENT_TOUCH_DOWN
@ EI_EVENT_TOUCH_DOWN
Event for a single touch set down on the device's logical surface.
Definition libei.h:591
EI_EVENT_DEVICE_PAUSED
@ EI_EVENT_DEVICE_PAUSED
Any events sent from this device will be discarded until the next resume.
Definition libei.h:413
EI_EVENT_TEXT_KEYSYM
@ EI_EVENT_TEXT_KEYSYM
Event for a single keysym logically pressed/released on this device.
Definition libei.h:619
EI_EVENT_CONNECT
@ EI_EVENT_CONNECT
The server has approved the connection to this client.
Definition libei.h:338
EI_EVENT_PONG
@ EI_EVENT_PONG
Returned in response to ei_ping().
Definition libei.h:470
EI_EVENT_DEVICE_STOP_EMULATING
@ EI_EVENT_DEVICE_STOP_EMULATING
The server stopped emulating events on this device, see EIS_EVENT_DEVICE_START_EMULATING.
Definition libei.h:515
EI_EVENT_TOUCH_UP
@ EI_EVENT_TOUCH_UP
Event for a single touch released from the device's logical surface.
Definition libei.h:599
EI_EVENT_KEYBOARD_KEY
@ EI_EVENT_KEYBOARD_KEY
A key press or release event.
Definition libei.h:580
EI_EVENT_TOUCH_MOTION
@ EI_EVENT_TOUCH_MOTION
Event for a single currently-down touch changing position (or other properties).
Definition libei.h:607
EI_EVENT_DISCONNECT
@ EI_EVENT_DISCONNECT
The server has disconnected this client - all resources left to reference this server are now obsolet...
Definition libei.h:352
EI_EVENT_SCROLL_CANCEL
@ EI_EVENT_SCROLL_CANCEL
An ongoing scroll sequence was cancelled.
Definition libei.h:564
EI_EVENT_TEXT_UTF8
@ EI_EVENT_TEXT_UTF8
Event for a UTF-8 compatible text sequence sent by this device.
Definition libei.h:629
EI_EVENT_KEYBOARD_MODIFIERS
@ EI_EVENT_KEYBOARD_MODIFIERS
The server has changed the modifier state on the device's keymap.
Definition libei.h:461
ei_device
A single device to generate input events from.
ei_event
An event received from the EIS implementation.
ei_keymap
A keymap for a device with the EI_DEVICE_CAP_KEYBOARD capability.
ei_ping
A callback struct returned by ei_new_ping() to handle roundtrips to the EIS implementation.
ei_region
A rectangular region, defined by an x/y offset and a width and a height.
ei_seat
A logical seat for a group of devices.
ei_touch
A single touch initiated by a sender context.
ei
The main context to interact with libei.