fddbf432a42aa8ce34aa619dc82116ed4f54c4d4
[platform/core/uifw/e-mod-tizen-gesture.git] / src / e_mod_main.h
1 #ifndef E_MOD_MAIN_H
2 #define E_MOD_MAIN_H
3
4 #include <tizen-extension-server-protocol.h>
5 #include <e.h>
6 #include <Ecore_Drm.h>
7
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)
12
13 #define E_GESTURE_FINGER_MAX 3
14 #define E_GESTURE_TYPE_MAX TIZEN_GESTURE_TYPE_SWIPE+1
15 #define E_GESTURE_TYPE_ALL TIZEN_GESTURE_TYPE_SWIPE
16
17 /* FIX ME: Set values in contiguration file, do not use definition */
18 #define E_GESTURE_SWIPE_DONE_TIME 0.5
19 #define E_GESTURE_SWIPE_START_TIME 0.01
20 #define E_GESTURE_SWIPE_START_AREA 50
21 #define E_GESTURE_SWIPE_DIFF_FAIL 100
22 #define E_GESTURE_SWIPE_DIFF_SUCCESS 300
23 #define E_GESTURE_SWIPE_COMBINE_KEY 124
24
25 #define ABS(x) ((x)>0)?(x):-(x)
26
27 typedef struct _E_Gesture E_Gesture;
28 typedef struct _E_Gesture* E_GesturePtr;
29 typedef struct _E_Gesture_Event E_Gesture_Event;
30 typedef struct _E_Gesture_Event_Swipe E_Gesture_Event_Swipe;
31 typedef struct _E_Gesture_Event_Swipe_Finger E_Gesture_Event_Swipe_Finger;
32 typedef struct _E_Gesture_Event_Swipe_Finger_Direction E_Gesture_Event_Swipe_Finger_Direction;
33 typedef struct _E_Gesture_Grabbed_Client E_Gesture_Grabbed_Client;
34
35 typedef struct _Coords Coords;
36
37 typedef enum _E_Gesture_Direction E_Gesture_Direction;
38
39 extern E_GesturePtr gesture;
40
41 #define E_GESTURE_DIRECTION_MAX 4
42 enum _E_Gesture_Direction
43 {
44    E_GESTURE_DIRECTION_NONE,
45    E_GESTURE_DIRECTION_DOWN, //Start point is North
46    E_GESTURE_DIRECTION_LEFT, // Start point is East
47    E_GESTURE_DIRECTION_UP, // Start point is South
48    E_GESTURE_DIRECTION_RIGHT // Start point is West
49 };
50
51 struct _Coords
52 {
53    int x, y;
54 };
55
56 struct _E_Gesture_Event_Swipe_Finger_Direction
57 {
58    struct wl_client *client;
59    struct wl_resource *res;
60 };
61
62 struct _E_Gesture_Event_Swipe_Finger
63 {
64    Coords start;
65    Eina_Bool enabled;
66    E_Gesture_Event_Swipe_Finger_Direction direction[E_GESTURE_DIRECTION_MAX+1];
67 };
68
69 struct _E_Gesture_Grabbed_Client
70 {
71    struct wl_client *client;
72    struct wl_listener *destroy_listener;
73
74    E_Gesture_Event_Swipe_Finger swipe_fingers[E_GESTURE_FINGER_MAX+1];
75 };
76
77
78 struct _E_Gesture_Event_Swipe
79 {
80    E_Gesture_Event_Swipe_Finger fingers[E_GESTURE_FINGER_MAX+1];
81
82    E_Gesture_Direction direction;
83
84    unsigned int combined_keycode;
85
86    unsigned int enabled_finger;
87    Ecore_Timer *start_timer;
88    Ecore_Timer *done_timer;
89 };
90
91 struct _E_Gesture_Event
92 {
93    E_Gesture_Event_Swipe swipes;
94
95    int num_pressed;
96    Eina_Bool recognized_gesture;
97 };
98
99 struct _E_Gesture
100 {
101    struct wl_global *global;
102
103    Ecore_Event_Filter *ef_handler;
104    Eina_List *handlers;
105    Eina_List *grab_client_list;
106
107    Eina_List *touch_devices;
108
109    unsigned int grabbed_gesture;
110    E_Gesture_Event gesture_events;
111
112    unsigned int gesture_filter;
113    unsigned int gesture_recognized;
114 };
115
116 /* E Module */
117 E_API extern E_Module_Api e_modapi;
118 E_API void *e_modapi_init(E_Module *m);
119 E_API int   e_modapi_shutdown(E_Module *m);
120 E_API int   e_modapi_save(E_Module *m);
121
122 Eina_Bool e_gesture_process_events(void *event, int type);
123 int e_gesture_type_convert(uint32_t type);
124 #endif