9b1f8ac674979fdd4b34597e303e7ce5f3a433ef
[framework/uifw/ecore.git] / src / lib / ecore_input / Ecore_Input.h
1 #ifndef _ECORE_INPUT_H
2 #define _ECORE_INPUT_H
3
4 #ifdef _WIN32
5 # include <stddef.h>
6 #else
7 # include <inttypes.h>
8 #endif
9
10 #ifdef EAPI
11 # undef EAPI
12 #endif
13
14 #ifdef _WIN32
15 # ifdef EFL_ECORE_INPUT_BUILD
16 #  ifdef DLL_EXPORT
17 #   define EAPI __declspec(dllexport)
18 #  else
19 #   define EAPI
20 #  endif /* ! DLL_EXPORT */
21 # else
22 #  define EAPI __declspec(dllimport)
23 # endif /* ! EFL_ECORE_INPUT_BUILD */
24 #else
25 # ifdef __GNUC__
26 #  if __GNUC__ >= 4
27 #   define EAPI __attribute__ ((visibility("default")))
28 #  else
29 #   define EAPI
30 #  endif
31 # else
32 #  define EAPI
33 # endif
34 #endif
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39
40    EAPI extern int ECORE_EVENT_KEY_DOWN;
41    EAPI extern int ECORE_EVENT_KEY_UP;
42    EAPI extern int ECORE_EVENT_MOUSE_BUTTON_DOWN;
43    EAPI extern int ECORE_EVENT_MOUSE_BUTTON_UP;
44    EAPI extern int ECORE_EVENT_MOUSE_MOVE;
45    EAPI extern int ECORE_EVENT_MOUSE_WHEEL;
46    EAPI extern int ECORE_EVENT_MOUSE_IN;
47    EAPI extern int ECORE_EVENT_MOUSE_OUT;
48
49 #define ECORE_EVENT_MODIFIER_SHIFT      0x0001
50 #define ECORE_EVENT_MODIFIER_CTRL       0x0002
51 #define ECORE_EVENT_MODIFIER_ALT        0x0004
52 #define ECORE_EVENT_MODIFIER_WIN        0x0008
53 #define ECORE_EVENT_MODIFIER_SCROLL     0x0010
54 #define ECORE_EVENT_MODIFIER_NUM        0x0020
55 #define ECORE_EVENT_MODIFIER_CAPS       0x0040
56 #define ECORE_EVENT_LOCK_SCROLL         0x0080
57 #define ECORE_EVENT_LOCK_NUM            0x0100
58 #define ECORE_EVENT_LOCK_CAPS           0x0200
59 #define ECORE_EVENT_LOCK_SHIFT          0x0300
60 #define ECORE_EVENT_MODIFIER_ALTGR      0x0400 /**< @since 1.3 */
61
62    typedef uintptr_t                        Ecore_Window;
63    typedef struct _Ecore_Event_Key          Ecore_Event_Key;
64    typedef struct _Ecore_Event_Mouse_Button Ecore_Event_Mouse_Button;
65    typedef struct _Ecore_Event_Mouse_Wheel  Ecore_Event_Mouse_Wheel;
66    typedef struct _Ecore_Event_Mouse_Move   Ecore_Event_Mouse_Move;
67    typedef struct _Ecore_Event_Mouse_IO     Ecore_Event_Mouse_IO;
68    typedef struct _Ecore_Event_Modifiers    Ecore_Event_Modifiers;
69    
70    typedef enum _Ecore_Event_Modifier
71      {
72         ECORE_NONE,
73         ECORE_SHIFT,
74         ECORE_CTRL,
75         ECORE_ALT,
76         ECORE_WIN,
77         ECORE_SCROLL,
78         ECORE_CAPS,
79         ECORE_MODE, /**< @since 1.3 */
80         ECORE_LAST
81      } Ecore_Event_Modifier;
82
83    typedef enum _Ecore_Event_Press
84      {
85         ECORE_DOWN,
86         ECORE_UP
87      } Ecore_Event_Press;
88
89    typedef enum _Ecore_Event_IO
90      {
91         ECORE_IN,
92         ECORE_OUT
93      } Ecore_Event_IO;
94
95    typedef enum _Ecore_Compose_State
96      {   
97         ECORE_COMPOSE_NONE,
98         ECORE_COMPOSE_MIDDLE,
99         ECORE_COMPOSE_DONE
100      } Ecore_Compose_State;
101
102    struct _Ecore_Event_Key
103      {
104         const char      *keyname;
105         const char      *key;
106         const char      *string;
107         const char      *compose;
108         Ecore_Window     window;
109         Ecore_Window     root_window;
110         Ecore_Window     event_window;
111         
112         unsigned int     timestamp;
113         unsigned int     modifiers;
114         
115         int              same_screen;
116      };
117
118    struct _Ecore_Event_Mouse_Button
119      {
120         Ecore_Window     window;
121         Ecore_Window     root_window;
122         Ecore_Window     event_window;
123         
124         unsigned int     timestamp;
125         unsigned int     modifiers;
126         unsigned int     buttons;
127         unsigned int     double_click;
128         unsigned int     triple_click;
129         int              same_screen;
130         
131         int              x;
132         int              y;
133         struct {
134            int           x;
135            int           y;
136         } root;
137         
138         struct {
139            int           device; /* 0 if normal mouse, 1+ for other mouse-devices (eg multi-touch - other fingers) */
140            double        radius, radius_x, radius_y; /* radius of press point - radius_x and y if its an ellipse (radius is the average of the 2) */
141            double        pressure; /* pressure - 1.0 == normal, > 1.0 == more, 0.0 == none */
142            double        angle; /* angle relative to perpendicular (0.0 == perpendicular), in degrees */
143            double        x, y; /* same as x, y root.x, root.y, but with sub-pixel precision, if available */
144            struct {
145               double     x, y;
146            } root;
147         } multi;
148      };
149    
150    struct _Ecore_Event_Mouse_Wheel
151      {
152         Ecore_Window     window;
153         Ecore_Window     root_window;
154         Ecore_Window     event_window;
155         
156         unsigned int     timestamp;
157         unsigned int     modifiers;
158         
159         int              same_screen;
160         int              direction;
161         int              z;
162         
163         int              x;
164         int              y;
165         struct {
166            int           x;
167            int           y;
168         } root;
169      };
170    
171    struct _Ecore_Event_Mouse_Move
172      {
173         Ecore_Window     window;
174         Ecore_Window     root_window;
175         Ecore_Window     event_window;
176         
177         unsigned int     timestamp;
178         unsigned int     modifiers;
179         
180         int              same_screen;
181         
182         int              x;
183         int              y;
184         struct {
185            int           x;
186            int           y;
187         } root;
188         
189         struct {
190            int           device; /* 0 if normal mouse, 1+ for other mouse-devices (eg multi-touch - other fingers) */
191            double        radius, radius_x, radius_y; /* radius of press point - radius_x and y if its an ellipse (radius is the average of the 2) */
192            double        pressure; /* pressure - 1.0 == normal, > 1.0 == more, 0.0 == none */
193            double        angle; /* angle relative to perpendicular (0.0 == perpendicular), in degrees */
194            double        x, y; /* same as x, y root.x, root.y, but with sub-pixel precision, if available */
195            struct {
196               double     x, y;
197            } root;
198         } multi;
199      };
200    
201    struct _Ecore_Event_Mouse_IO
202      {
203         Ecore_Window     window;
204         Ecore_Window     event_window;
205         
206         unsigned int     timestamp;
207         unsigned int     modifiers;
208         
209         int              x;
210         int              y;
211      };
212
213    struct _Ecore_Event_Modifiers
214      {
215         unsigned int size;
216         unsigned int array[ECORE_LAST];
217      };
218    
219    EAPI int                  ecore_event_init(void);
220    EAPI int                  ecore_event_shutdown(void);
221    
222    EAPI unsigned int         ecore_event_modifier_mask(Ecore_Event_Modifier modifier);
223    EAPI Ecore_Event_Modifier ecore_event_update_modifier(const char *key, Ecore_Event_Modifiers *modifiers, int inc);
224
225    /**
226     * @since 1.3
227     */
228    EAPI Ecore_Compose_State  ecore_compose_get(const Eina_List *seq, char **seqstr_ret);
229    
230 #ifdef __cplusplus
231 }
232 #endif
233
234 #endif