e_input: fix not to do unnecessary udev-lookups and loops
[platform/upstream/enlightenment.git] / src / bin / e_input.h
1 #ifdef E_TYPEDEFS
2
3 typedef struct _E_Input E_Input;
4
5 E_API extern int E_INPUT_EVENT_INPUT_DEVICE_ADD;
6 E_API extern int E_INPUT_EVENT_INPUT_DEVICE_DEL;
7 E_API extern int E_INPUT_EVENT_SEAT_ADD;
8 E_API extern int E_EVENT_INPUT_ENABLED;
9 E_API extern int E_EVENT_INPUT_DISABLED;
10
11 #else
12
13 #ifndef E_INPUT_H
14 #define E_INPUT_H
15
16 #define E_INPUT_TYPE (int)0xE0b0beaf
17
18 #include <xkbcommon/xkbcommon.h>
19
20 typedef enum _E_Input_Seat_Capabilities
21 {
22    E_INPUT_SEAT_POINTER = (1 << 0),
23    E_INPUT_SEAT_KEYBOARD = (1 << 1),
24    E_INPUT_SEAT_TOUCH = (1 << 2),
25 } E_Input_Seat_Capabilities;
26
27 typedef enum _E_Input_Libinput_Backend
28 {
29    E_INPUT_LIBINPUT_BACKEND_UDEV = 1,
30    E_INPUT_LIBINPUT_BACKEND_PATH
31 } E_Input_Libinput_Backend;
32
33 struct _E_Input_Event_Input_Device_Add
34 {
35    const char *name; /* descriptive device name */
36    const char *sysname; /* system name of the input device */
37    const char *seatname; /* logical name of the seat */
38    E_Input_Seat_Capabilities caps; /* capabilities on a device */
39 };
40
41 struct _E_Input_Event_Input_Device_Del
42 {
43    const char *name; /* descriptive device name */
44    const char *sysname; /* system name of the input device */
45    const char *seatname; /* logical name of the seat */
46    E_Input_Seat_Capabilities caps; /* capabilities on a device */
47 };
48
49 typedef struct _E_Input_Device E_Input_Device;
50 typedef struct _E_Input_Backend E_Input_Backend;
51 typedef struct _E_Input_Evdev E_Input_Evdev;
52 typedef struct _E_Input_Seat E_Input_Seat;
53
54 typedef struct _E_Input_Event_Input_Device_Add E_Input_Event_Input_Device_Add;
55 typedef struct _E_Input_Event_Input_Device_Del E_Input_Event_Input_Device_Del;
56
57 struct _E_Input
58 {
59    Ecore_Window window;
60    E_Input_Device *dev;
61    const char *input_base_dir;
62 };
63
64 struct _E_Input_Device
65 {
66    const char *seat;
67
68    Eina_List *seats;
69    Eina_List *inputs;
70    Eina_Hash *fd_hash;
71
72    struct xkb_context *xkb_ctx;
73    int window;
74    Eina_Bool left_handed : 1;
75 };
76
77 EINTERN int e_input_init(Ecore_Evas *ee);
78 EINTERN int e_input_shutdown(void);
79 EINTERN const char *e_input_base_dir_get(void);
80
81 EINTERN E_Input_Device *e_input_device_open(void);
82 EINTERN Eina_Bool e_input_device_close(E_Input_Device *dev);
83 EINTERN void e_input_device_keyboard_cached_context_set(struct xkb_context *ctx);
84 EINTERN void e_input_device_keyboard_cached_keymap_set(struct xkb_keymap *map);
85 EINTERN Eina_Bool e_input_device_input_backend_create(E_Input_Device *dev, E_Input_Libinput_Backend backend);
86 EINTERN Eina_Bool e_input_device_input_create_libinput_udev(E_Input_Device *dev);
87 EINTERN Eina_Bool e_input_device_input_create_libinput_path(E_Input_Device *dev);
88 EINTERN void e_input_device_window_set(E_Input_Device *dev, unsigned int window);
89 EINTERN void e_input_device_pointer_xy_get(E_Input_Device *dev, int *x, int *y);
90 EINTERN Eina_Bool e_input_device_pointer_left_handed_set(E_Input_Device *dev, Eina_Bool left_handed);
91 EINTERN Eina_Bool e_input_device_pointer_rotation_set(E_Input_Device *dev, int rotation);
92 EINTERN Eina_Bool e_input_device_touch_rotation_set(E_Input_Device *dev, unsigned int rotation);
93 EINTERN void e_input_device_rotation_set(E_Input_Device *dev, unsigned int rotation);
94 EINTERN Eina_Bool e_input_device_touch_transformation_set(E_Input_Device *dev, int offset_x, int offset_y, int w, int h);
95
96 EINTERN Eina_Bool e_input_enable_input(E_Input_Backend *input);
97 EINTERN void e_input_disable_input(E_Input_Backend *input);
98
99 EINTERN void e_input_evdev_axis_size_set(E_Input_Evdev *edev, int w, int h);
100 EINTERN const char *e_input_evdev_sysname_get(E_Input_Evdev *evdev);
101 EINTERN Eina_Bool e_input_evdev_key_remap_enable(E_Input_Evdev *edev, Eina_Bool enable);
102 EINTERN Eina_Bool e_input_evdev_key_remap_set(E_Input_Evdev *edev, int *from_keys, int *to_keys, int num);
103 EINTERN Eina_Bool e_input_evdev_touch_calibration_set(E_Input_Evdev *edev, float matrix[6]);
104
105 E_API const Eina_List *e_input_devices_get(void);
106 E_API void e_input_device_pointer_warp(E_Input_Device *dev, int x, int y);
107
108 E_API const char *e_input_evdev_name_get(E_Input_Evdev *evdev);
109 E_API Eina_List *e_input_seat_evdev_list_get(E_Input_Seat *seat);
110 E_API int e_input_evdev_wheel_click_angle_get(E_Input_Evdev *dev);
111 E_API Ecore_Device *e_input_evdev_get_ecore_device(const char *path, Ecore_Device_Class clas);
112
113 #endif
114 #endif