8249884da1a667f8156c6d9ca6c3a743191856f0
[platform/upstream/enlightenment.git] / src / bin / e_input.h
1 #ifdef E_TYPEDEFS
2
3 typedef struct _E_Input E_Input;
4
5 #else
6
7 #ifndef E_INPUT_H
8 #define E_INPUT_H
9
10 #define E_INPUT_TYPE (int)0xE0b0beaf
11
12 #define E_INPUT_REQUEST_SERVER ((void *)0x1)
13
14 #include <xkbcommon/xkbcommon.h>
15 #include "e_device.h"
16 #include "e_input_event.h"
17
18 EINTERN extern int E_INPUT_EVENT_SEAT_ADD;
19 EINTERN extern int E_EVENT_INPUT_ENABLED;
20 EINTERN extern int E_EVENT_INPUT_DISABLED;
21
22 typedef enum _E_Input_Hook_Point
23 {
24    E_INPUT_HOOK_POINTER_WARP,
25    E_INPUT_HOOK_LAST
26 } E_Input_Hook_Point;
27
28 typedef void (*E_Input_Hook_Cb) (void *data, const char *device_name);
29 typedef struct _E_Input_Hook E_Input_Hook;
30
31 struct _E_Input_Hook
32 {
33    EINA_INLIST;
34    E_Input_Hook_Point hookpoint;
35    E_Input_Hook_Cb func;
36    void *data;
37    unsigned char delete_me : 1;
38 };
39
40 typedef enum _E_Input_Seat_Capabilities
41 {
42    E_INPUT_SEAT_POINTER = (1 << 0),
43    E_INPUT_SEAT_KEYBOARD = (1 << 1),
44    E_INPUT_SEAT_TOUCH = (1 << 2),
45 } E_Input_Seat_Capabilities;
46
47 typedef enum _E_Input_Libinput_Backend
48 {
49    E_INPUT_LIBINPUT_BACKEND_UDEV = 1,
50    E_INPUT_LIBINPUT_BACKEND_PATH
51 } E_Input_Libinput_Backend;
52
53 typedef struct _E_Input_Device E_Input_Device;
54 typedef struct _E_Input_Backend E_Input_Backend;
55 typedef struct _E_Input_Evdev E_Input_Evdev;
56 typedef struct _E_Input_Seat E_Input_Seat;
57 typedef struct _E_Input_Coord E_Input_Coord;
58
59 typedef void (*e_input_relative_motion_cb)(double dx[2], double dy[2], uint64_t time_us);
60 typedef void (*e_input_keyboard_grab_key_cb)(uint32_t keycode, uint32_t state, uint32_t timestamp);
61
62 struct _E_Input
63 {
64    Ecore_Window window;
65    Ecore_Evas *ee;
66    E_Input_Device *dev;
67    const char *input_base_dir;
68    Eina_List *handlers;
69
70    Eina_Bool use_thread : 1;
71    unsigned int touch_max_count;
72    unsigned int touch_device_count;
73
74    e_input_relative_motion_cb relative_motion_handler;
75    e_input_keyboard_grab_key_cb keyboard_grab_key_handler;
76 };
77
78 struct _E_Input_Device
79 {
80    const char *seat;
81
82    Eina_List *seats;
83    Eina_List *inputs;
84    Eina_Hash *fd_hash;
85
86    struct xkb_context *xkb_ctx;
87    Ecore_Window window;
88    Eina_Bool left_handed : 1;
89
90    unsigned int blocked;
91    void *blocked_client;
92    unsigned int server_blocked;
93 };
94
95 EINTERN int e_input_init(Ecore_Evas *ee);
96 EINTERN int e_input_shutdown(void);
97 EINTERN const char *e_input_base_dir_get(void);
98 EINTERN Eina_Bool e_input_thread_enabled_get(void);
99 EINTERN E_Input *e_input_get(void);
100 EINTERN Ecore_Evas *e_input_ecore_evas_get(E_Input *ei);
101
102 EINTERN E_Input_Device *e_input_device_open(void);
103 EINTERN Eina_Bool e_input_device_close(E_Input_Device *dev);
104 EINTERN void e_input_device_keyboard_cached_context_set(struct xkb_context *ctx);
105 EINTERN void e_input_device_keyboard_cached_keymap_set(struct xkb_keymap *map);
106 EINTERN Eina_Bool e_input_device_input_backend_create(E_Input_Device *dev, E_Input_Libinput_Backend backend);
107 EINTERN Eina_Bool e_input_device_input_create_libinput_udev(E_Input_Device *dev);
108 EINTERN Eina_Bool e_input_device_input_create_libinput_path(E_Input_Device *dev);
109 EINTERN void e_input_device_window_set(E_Input_Device *dev, Ecore_Window window);
110 EINTERN void e_input_device_pointer_xy_get(E_Input_Device *dev, int *x, int *y);
111 EINTERN Eina_Bool e_input_device_pointer_left_handed_set(E_Input_Device *dev, Eina_Bool left_handed);
112 EINTERN Eina_Bool e_input_device_pointer_rotation_set(E_Input_Device *dev, int rotation);
113 EINTERN Eina_Bool e_input_device_touch_rotation_set(E_Input_Device *dev, unsigned int rotation);
114 EINTERN void e_input_device_rotation_set(E_Input_Device *dev, unsigned int rotation);
115 EINTERN Eina_Bool e_input_device_touch_transformation_set(E_Input_Device *dev, int offset_x, int offset_y, int w, int h);
116
117 EINTERN Eina_Bool e_input_enable_input(E_Input_Backend *input);
118 EINTERN void e_input_disable_input(E_Input_Backend *input);
119
120 EINTERN void e_input_evdev_axis_size_set(E_Input_Evdev *edev, int w, int h);
121 EINTERN const char *e_input_evdev_sysname_get(E_Input_Evdev *evdev);
122 EINTERN Eina_Bool e_input_evdev_key_remap_enable(E_Input_Evdev *edev, Eina_Bool enable);
123 EINTERN Eina_Bool e_input_evdev_key_remap_set(E_Input_Evdev *edev, int *from_keys, int *to_keys, int num);
124 EINTERN Eina_Bool e_input_evdev_touch_calibration_set(E_Input_Evdev *edev, float matrix[6]);
125 EINTERN Eina_Bool e_input_evdev_mouse_accel_speed_set(E_Input_Evdev *edev, double speed);
126 EINTERN Eina_Bool e_input_evdev_mouse_accel_enable(E_Input_Evdev *edev, Eina_Bool enable);
127 EINTERN unsigned int e_input_evdev_touch_pressed_get(E_Input_Evdev *edev);
128
129 E_API const Eina_List *e_input_devices_get(void);
130 E_API Eina_Bool e_input_device_pointer_warp(E_Input_Device *dev, int x, int y);
131 E_API Eina_Bool e_input_device_mouse_accel_speed_set(E_Input_Device *dev, double speed);
132
133 EINTERN const char *e_input_evdev_name_get(E_Input_Evdev *evdev);
134 EINTERN Eina_List *e_input_seat_evdev_list_get(E_Input_Seat *seat);
135 EINTERN int e_input_evdev_wheel_click_angle_get(E_Input_Evdev *dev);
136 EINTERN Ecore_Device *e_input_evdev_get_ecore_device(const char *path, Ecore_Device_Class clas);
137 EINTERN E_Device *e_input_evdev_get_e_device(const char *path, Ecore_Device_Class clas);
138
139 EINTERN unsigned int e_input_device_touch_pressed_get(E_Input_Device *dev);
140 EINTERN Eina_Bool e_input_device_keyboard_remap_set(E_Input_Device *dev, int *from_keys, int *to_keys, int num);
141
142 E_API unsigned int e_input_touch_max_count_get();
143 EINTERN void e_input_touch_max_count_set(unsigned int max_count);
144
145 EINTERN Eina_Bool e_input_device_block(E_Input_Device *dev, unsigned int type, void *client);
146 EINTERN Eina_Bool e_input_device_unblock(E_Input_Device *dev, void *client);
147 EINTERN Eina_Bool e_input_device_output_name_set(E_Input_Device *dev, const char *input, const char *output);
148 EINTERN const char *e_input_device_output_name_get(E_Input_Device *dev, const char *input);
149
150 EINTERN Eina_Bool e_input_device_seat_name_set(E_Input_Device *dev, const char *input, const char *seat_name);
151
152 E_API E_Input_Hook *e_input_hook_add(E_Input_Hook_Point hookpoint, E_Input_Hook_Cb func, const void *data);
153 E_API void e_input_hook_del(E_Input_Hook *ch);
154
155 E_API Eina_Bool e_input_thread_mode_get();
156 E_API E_Input_Event_Source *e_input_event_source_get();
157 EINTERN void e_input_create_event_source(E_Input_Backend *input);
158
159 EINTERN Eina_Bool e_input_relative_motion_handler_set(e_input_relative_motion_cb handler);
160 EINTERN e_input_relative_motion_cb e_input_relative_motion_handler_get(void);
161
162 EINTERN Eina_Bool e_input_keyboard_grab_key_handler_set(e_input_keyboard_grab_key_cb handler);
163 EINTERN e_input_keyboard_grab_key_cb e_input_keyboard_grab_key_handler_get(void);
164
165 EINTERN Eina_Bool e_input_device_subtype_set(E_Input_Device *dev, const char *input, const char *subtype);
166
167 #endif
168 #endif