5 #include <tizen-extension-server-protocol.h>
6 #include <Ecore_Input_Evas.h>
8 #define GTERR(msg, ARG...) ERR("[tizen_gesture][%s:%d] "msg, __FUNCTION__, __LINE__, ##ARG)
9 #define GTWRN(msg, ARG...) WRN("[tizen_gesture][%s:%d] "msg, __FUNCTION__, __LINE__, ##ARG)
10 #define GTINF(msg, ARG...) INF("[tizen_gesture][%s:%d] "msg, __FUNCTION__, __LINE__, ##ARG)
11 #define GTDBG(msg, ARG...) DBG("[tizen_gesture][%s:%d] "msg, __FUNCTION__, __LINE__, ##ARG)
13 #define E_GESTURE_SERVER_CLIENT (void *)0x1
15 #define E_GESTURE_TYPE_EDGE_SWIPE TIZEN_GESTURE_TYPE_EDGE_SWIPE
16 #define E_GESTURE_TYPE_EDGE_DRAG TIZEN_GESTURE_TYPE_EDGE_DRAG
17 #define E_GESTURE_TYPE_TAP TIZEN_GESTURE_TYPE_TAP
18 #define E_GESTURE_TYPE_PALM_COVER TIZEN_GESTURE_TYPE_PALM_COVER
19 #define E_GESTURE_TYPE_PAN TIZEN_GESTURE_TYPE_PAN
20 #define E_GESTURE_TYPE_PINCH TIZEN_GESTURE_TYPE_PINCH
21 #define E_GESTURE_TYPE_PALM_SWIPE TIZEN_GESTURE_TYPE_PALM_SWIPE
23 #define E_GESTURE_FINGER_MAX 3
24 #define E_GESTURE_TYPE_MAX (E_GESTURE_TYPE_PALM_SWIPE + 1)
25 #define E_GESTURE_TYPE_ALL (E_GESTURE_TYPE_EDGE_SWIPE | E_GESTURE_TYPE_EDGE_DRAG | E_GESTURE_TYPE_TAP | E_GESTURE_TYPE_PAN | E_GESTURE_TYPE_PINCH | E_GESTURE_TYPE_PALM_COVER | E_GESTURE_TYPE_PALM_SWIPE)
26 #define E_GESTURE_KEYBOARD_NAME "Gesture Keyboard"
27 #define E_GESTURE_AUX_HINT_GESTURE_DISABLE "wm.policy.win.gesture.disable"
29 /* FIX ME: Set values in contiguration file, do not use definition */
30 #define E_GESTURE_KEYBOARD_DEVICE "Any"
32 #define E_GESTURE_EDGE_SWIPE_DONE_TIME 0.5
33 #define E_GESTURE_EDGE_SWIPE_START_TIME 0.01
34 #define E_GESTURE_EDGE_SWIPE_START_AREA 50
35 #define E_GESTURE_EDGE_SWIPE_DIFF_FAIL 100
36 #define E_GESTURE_EDGE_SWIPE_DIFF_SUCCESS 300
37 /* FIX ME: Key code will be get from keymap */
38 #define E_GESTURE_EDGE_SWIPE_COMBINE_KEY 124
39 #define E_GESTURE_EDGE_SWIPE_BACK_KEY 166
40 #define E_GESTURE_EDGE_SWIPE_BACK_DEFAULT_ENABLE EINA_TRUE
42 #define E_GESTURE_EDGE_DRAG_START_TIME 0.01
43 #define E_GESTURE_EDGE_DRAG_START_AREA 50
44 #define E_GESTURE_EDGE_DRAG_DIFF 10
46 #define E_GESTURE_TAP_REPEATS_MAX 3
47 #define E_GESTURE_TAP_START_TIME 0.05
48 #define E_GESTURE_TAP_DONE_TIME 1.0
49 #define E_GESTURE_TAP_INTERVAL_TIME 1.0
50 #define E_GESTURE_TAP_MOVING_RANGE 25
52 #define E_GESTURE_PAN_START_TIME 0.05
53 #define E_GESTURE_PAN_MOVING_RANGE 15
55 #define E_GESTURE_PINCH_MOVING_DISTANCE_RANGE 15.0
57 #define ABS(x) (((x)>0)?(x):-(x))
58 #define RAD2DEG(x) ((x) * 57.295779513)
60 typedef struct _E_Gesture E_Gesture;
61 typedef struct _E_Gesture* E_GesturePtr;
62 typedef struct _E_Gesture_Event E_Gesture_Event;
63 typedef struct _E_Gesture_Event_Edge E_Gesture_Event_Edge;
64 typedef struct _E_Gesture_Event_Edge_Swipe E_Gesture_Event_Edge_Swipe;
65 typedef struct _E_Gesture_Event_Edge_Drag E_Gesture_Event_Edge_Drag;
66 typedef struct _E_Gesture_Event_Edge_Finger E_Gesture_Event_Edge_Finger;
67 typedef struct _E_Gesture_Event_Edge_Finger_Edge E_Gesture_Event_Edge_Finger_Edge;
68 typedef struct _E_Gesture_Grabbed_Client E_Gesture_Grabbed_Client;
69 typedef struct _E_Gesture_Conf_Edd E_Gesture_Conf_Edd;
70 typedef struct _E_Gesture_Config_Data E_Gesture_Config_Data;
72 typedef struct _E_Gesture_Event_Tap_Finger_Repeats E_Gesture_Event_Tap_Finger_Repeats;
73 typedef struct _E_Gesture_Event_Tap_Finger E_Gesture_Event_Tap_Finger;
74 typedef struct _E_Gesture_Event_Tap E_Gesture_Event_Tap;
76 typedef struct _E_Gesture_Event_Pan E_Gesture_Event_Pan;
78 typedef struct _E_Gesture_Event_Pinch E_Gesture_Event_Pinch;
80 typedef struct _E_Gesture_Event_Palm_Cover E_Gesture_Event_Palm_Cover;
82 typedef struct _Coords Coords;
83 typedef struct _Rect Rect;
84 typedef struct _E_Gesture_Finger E_Gesture_Finger;
85 typedef struct _E_Gesture_Event_Info E_Gesture_Event_Info;
86 typedef struct _E_Gesture_Event_Client E_Gesture_Event_Client;
87 typedef struct _E_Gesture_Select_Surface E_Gesture_Select_Surface;
88 typedef struct _E_Gesture_Activate_Info E_Gesture_Activate_Info;
90 typedef enum _E_Gesture_Edge E_Gesture_Edge;
91 typedef enum _E_Gesture_Event_State E_Gesture_Event_State;
92 typedef enum _E_Gesture_Tap_State E_Gesture_Tap_State;
93 typedef enum _E_Gesture_PanPinch_State E_Gesture_PanPinch_State;
95 extern E_GesturePtr gesture;
97 #define E_GESTURE_EDGE_MAX 4
99 #define E_GESTURE_EDGE_ALL ((1 << E_GESTURE_EDGE_TOP) | (1 << E_GESTURE_EDGE_RIGHT) | (1 << E_GESTURE_EDGE_BOTTOM) | (1 << E_GESTURE_EDGE_LEFT))
101 enum _E_Gesture_Event_State
103 E_GESTURE_EVENT_STATE_PROPAGATE,
104 E_GESTURE_EVENT_STATE_KEEP,
105 E_GESTURE_EVENT_STATE_IGNORE
108 enum _E_Gesture_Tap_State
110 E_GESTURE_TAP_STATE_NONE,
111 E_GESTURE_TAP_STATE_READY, // tap is required, idle
112 E_GESTURE_TAP_STATE_START, // first finger is pressed
113 E_GESTURE_TAP_STATE_PROCESS, // all fingers are pressed or first release
114 E_GESTURE_TAP_STATE_WAIT, // all fingers are released and wait next tap
115 E_GESTURE_TAP_STATE_DONE
118 enum _E_Gesture_PanPinch_State
120 E_GESTURE_PANPINCH_STATE_NONE,
121 E_GESTURE_PANPINCH_STATE_READY,
122 E_GESTURE_PANPINCH_STATE_START,
123 E_GESTURE_PANPINCH_STATE_MOVING,
124 E_GESTURE_PANPINCH_STATE_DONE
138 struct _E_Gesture_Finger
144 struct _E_Gesture_Event_Info
150 struct _E_Gesture_Activate_Info
153 struct wl_resource *surface;
158 struct _E_Gesture_Conf_Edd
160 char *key_device_name; // The name of keyboard device to generate key events
161 Eina_Bool event_keep; // 1: Do not propagate events to client immediatly until recognizing gestures
162 // 0: Propagate events immediatly but send a cancel event after recognizing gestures (default)
165 double time_done; // The duration to recognize a edge swipe
166 double time_begin; // The minimun of time to distinguish if it is a gesture or normal touch
167 int area_offset; // Edge region to start to calculate
168 int min_length; // Limit size to move cross direction
169 int max_length; // Moving length to recognize edge swipe
170 int compose_key; // Keycode of composed with gesture
171 int back_key; // Keycode of back key
172 Eina_Bool default_enable_back; // Convert a top edge swipe to back key
176 double time_begin; // The minimun of time to distinguish if it is a gesture or normal touch
177 int area_offset; // Edge region to start to calculate
178 int diff_length; // Moved length to generate edge drag events
182 int repeats_max; // Maximum number of repeats
183 double time_start; // Minimun of time to distinguish if it is a gesture or normal touch
184 double time_done; // Duration to release all fingers
185 double time_interval; // Interval duration between taps
186 int moving_range; // Limit region duriong taps
190 double time_start; // The minimun of time to distinguish if it is a gesture or normal touch
191 int moving_range; // Moved length to generate pan events
195 double moving_distance_range; // Moved length to generate pinch events
199 struct _E_Gesture_Config_Data
202 E_Config_DD *conf_edd;
203 E_Gesture_Conf_Edd *conf;
206 struct _E_Gesture_Event_Client
208 struct wl_client *client;
209 struct wl_resource *res;
212 struct _E_Gesture_Select_Surface
214 struct wl_resource *surface;
215 struct wl_resource *res;
218 struct _E_Gesture_Event_Edge_Finger_Edge
220 struct wl_client *client;
221 struct wl_resource *res;
226 struct _E_Gesture_Event_Edge_Finger
230 Eina_List *edge[E_GESTURE_EDGE_MAX + 1];
233 struct _E_Gesture_Event_Edge
235 E_Gesture_Activate_Info activation;
236 E_Gesture_Event_Edge_Finger fingers[E_GESTURE_FINGER_MAX + 2];
240 unsigned int enabled_finger;
241 unsigned int enabled_edge;
244 struct _E_Gesture_Event_Edge_Swipe
246 E_Gesture_Event_Edge base;
248 unsigned int combined_keycode;
249 unsigned int back_keycode;
251 Ecore_Timer *start_timer;
252 Ecore_Timer *done_timer;
255 struct _E_Gesture_Event_Edge_Drag
257 E_Gesture_Event_Edge base;
259 Ecore_Timer *start_timer;
267 struct _E_Gesture_Event_Tap_Finger_Repeats
269 struct wl_client *client;
270 struct wl_resource *res;
273 struct _E_Gesture_Event_Tap_Finger
276 unsigned int max_repeats;
277 E_Gesture_Event_Tap_Finger_Repeats repeats[E_GESTURE_TAP_REPEATS_MAX + 1];
280 struct _E_Gesture_Event_Tap
282 E_Gesture_Activate_Info activation;
283 E_Gesture_Event_Tap_Finger fingers[E_GESTURE_FINGER_MAX + 2];
284 E_Gesture_Tap_State state;
285 unsigned int enabled_finger;
286 unsigned int current_finger;
287 unsigned int repeats;
288 unsigned int max_fingers;
291 Ecore_Timer *start_timer;
293 Ecore_Timer *done_timer;
295 Ecore_Timer *interval_timer;
300 struct _E_Gesture_Event_Pan
302 E_Gesture_Activate_Info activation;
303 E_Gesture_Event_Client fingers[E_GESTURE_FINGER_MAX + 2];
304 E_Gesture_PanPinch_State state;
310 Ecore_Timer *start_timer;
311 Ecore_Timer *move_timer;
314 struct _E_Gesture_Event_Pinch
316 E_Gesture_Activate_Info activation;
317 E_Gesture_Event_Client fingers[E_GESTURE_FINGER_MAX + 2];
318 E_Gesture_PanPinch_State state;
320 int num_pinch_fingers;
322 Ecore_Timer *start_timer;
323 Ecore_Timer *move_timer;
326 struct _E_Gesture_Event_Palm_Cover
328 E_Gesture_Activate_Info activation;
329 E_Gesture_Event_Client client_info;
330 Eina_List *select_surface_list;
331 unsigned int start_time;
334 struct _E_Gesture_Grabbed_Client
336 struct wl_client *client;
337 struct wl_listener *destroy_listener;
338 unsigned int grabbed_gesture;
340 E_Gesture_Event_Edge_Finger edge_swipe_fingers[E_GESTURE_FINGER_MAX + 2];
341 E_Gesture_Event_Edge_Finger edge_drag_fingers[E_GESTURE_FINGER_MAX + 2];
342 E_Gesture_Event_Tap_Finger tap_fingers[E_GESTURE_FINGER_MAX + 2];
343 E_Gesture_Event_Client pan_fingers[E_GESTURE_FINGER_MAX + 2];
344 E_Gesture_Event_Client pinch_fingers[E_GESTURE_FINGER_MAX + 2];
345 E_Gesture_Event_Client palm_cover;
348 struct _E_Gesture_Event
350 E_Gesture_Event_Edge_Swipe edge_swipes;
351 E_Gesture_Event_Edge_Drag edge_drags;
352 E_Gesture_Event_Tap taps;
353 E_Gesture_Event_Pan pans;
354 E_Gesture_Event_Pinch pinchs;
355 E_Gesture_Event_Palm_Cover palm_covers;
357 E_Gesture_Finger base_point[E_GESTURE_FINGER_MAX + 2];
360 Eina_Bool recognized_gesture;
361 Eina_Bool event_keep;
366 struct wl_global *global;
367 E_Gesture_Config_Data *config;
369 Eina_Bool enabled_window;
371 Ecore_Event_Filter *ef_handler;
373 Eina_List *grab_client_list;
374 Eina_List *select_surface_list;
379 Eina_List *touch_devices;
381 char *kbd_identifier;
383 Ecore_Device *kbd_device;
386 unsigned int grabbed_gesture;
387 E_Gesture_Event gesture_events;
388 E_Gesture_Event_State event_state;
389 E_Gesture_Event_State prev_event_state;
391 Eina_List *event_queue;
393 unsigned int gesture_filter;
394 unsigned int gesture_recognized;
398 E_API extern E_Module_Api e_modapi;
399 E_API void *e_modapi_init(E_Module *m);
400 E_API int e_modapi_shutdown(E_Module *m);
401 E_API int e_modapi_save(E_Module *m);
403 Eina_Bool e_gesture_process_events(void *event, int type);
404 int e_gesture_type_convert(uint32_t type);
407 void e_gesture_conf_init(E_Gesture_Config_Data *gconfig);
408 void e_gesture_conf_deinit(E_Gesture_Config_Data *gconfig);
411 void e_gesture_device_shutdown(void);
412 E_Gesture_Event_State e_gesture_device_add(Ecore_Event_Device_Info *ev);
413 E_Gesture_Event_State e_gesture_device_del(Ecore_Event_Device_Info *ev);
414 Eina_Bool e_gesture_is_touch_device(const Ecore_Device *dev);
415 void e_gesture_device_keydev_set(char *option);
417 void e_gesture_event_filter_enable(Eina_Bool enabled);
420 unsigned int e_gesture_util_tap_max_fingers_get(void);
421 unsigned int e_gesture_util_tap_max_repeats_get(unsigned int);