diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/ecore/src/lib/ecore_input/ecore_input.c | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/libraries/ecore/src/lib/ecore_input/ecore_input.c b/libraries/ecore/src/lib/ecore_input/ecore_input.c new file mode 100644 index 0000000..ce4c275 --- /dev/null +++ b/libraries/ecore/src/lib/ecore_input/ecore_input.c | |||
@@ -0,0 +1,120 @@ | |||
1 | #ifdef HAVE_CONFIG_H | ||
2 | # include <config.h> | ||
3 | #endif | ||
4 | |||
5 | #include <stdio.h> | ||
6 | #include <string.h> | ||
7 | |||
8 | #include "Ecore.h" | ||
9 | #include "ecore_private.h" | ||
10 | |||
11 | #include "Ecore_Input.h" | ||
12 | #include "ecore_input_private.h" | ||
13 | |||
14 | |||
15 | int _ecore_input_log_dom = -1; | ||
16 | |||
17 | EAPI int ECORE_EVENT_KEY_DOWN = 0; | ||
18 | EAPI int ECORE_EVENT_KEY_UP = 0; | ||
19 | EAPI int ECORE_EVENT_MOUSE_BUTTON_DOWN = 0; | ||
20 | EAPI int ECORE_EVENT_MOUSE_BUTTON_UP = 0; | ||
21 | EAPI int ECORE_EVENT_MOUSE_MOVE = 0; | ||
22 | EAPI int ECORE_EVENT_MOUSE_WHEEL = 0; | ||
23 | EAPI int ECORE_EVENT_MOUSE_IN = 0; | ||
24 | EAPI int ECORE_EVENT_MOUSE_OUT = 0; | ||
25 | |||
26 | static int _ecore_event_init_count = 0; | ||
27 | |||
28 | EAPI int | ||
29 | ecore_event_init(void) | ||
30 | { | ||
31 | if (++_ecore_event_init_count != 1) | ||
32 | return _ecore_event_init_count; | ||
33 | |||
34 | _ecore_input_log_dom = eina_log_domain_register | ||
35 | ("ecore_input", ECORE_INPUT_DEFAULT_LOG_COLOR); | ||
36 | if(_ecore_input_log_dom < 0) | ||
37 | { | ||
38 | EINA_LOG_ERR("Impossible to create a log domain for the ecore input module."); | ||
39 | return --_ecore_event_init_count; | ||
40 | } | ||
41 | |||
42 | ECORE_EVENT_KEY_DOWN = ecore_event_type_new(); | ||
43 | ECORE_EVENT_KEY_UP = ecore_event_type_new(); | ||
44 | ECORE_EVENT_MOUSE_BUTTON_DOWN = ecore_event_type_new(); | ||
45 | ECORE_EVENT_MOUSE_BUTTON_UP = ecore_event_type_new(); | ||
46 | ECORE_EVENT_MOUSE_MOVE = ecore_event_type_new(); | ||
47 | ECORE_EVENT_MOUSE_WHEEL = ecore_event_type_new(); | ||
48 | ECORE_EVENT_MOUSE_IN = ecore_event_type_new(); | ||
49 | ECORE_EVENT_MOUSE_OUT = ecore_event_type_new(); | ||
50 | |||
51 | return _ecore_event_init_count; | ||
52 | } | ||
53 | |||
54 | EAPI int | ||
55 | ecore_event_shutdown(void) | ||
56 | { | ||
57 | if (--_ecore_event_init_count != 0) | ||
58 | return _ecore_event_init_count; | ||
59 | |||
60 | ECORE_EVENT_KEY_DOWN = 0; | ||
61 | ECORE_EVENT_KEY_UP = 0; | ||
62 | ECORE_EVENT_MOUSE_BUTTON_DOWN = 0; | ||
63 | ECORE_EVENT_MOUSE_BUTTON_UP = 0; | ||
64 | ECORE_EVENT_MOUSE_MOVE = 0; | ||
65 | ECORE_EVENT_MOUSE_WHEEL = 0; | ||
66 | ECORE_EVENT_MOUSE_IN = 0; | ||
67 | ECORE_EVENT_MOUSE_OUT = 0; | ||
68 | eina_log_domain_unregister(_ecore_input_log_dom); | ||
69 | _ecore_input_log_dom = -1; | ||
70 | return _ecore_event_init_count; | ||
71 | } | ||
72 | |||
73 | typedef struct _Ecore_Event_Modifier_Match Ecore_Event_Modifier_Match; | ||
74 | struct _Ecore_Event_Modifier_Match | ||
75 | { | ||
76 | const char *key; | ||
77 | Ecore_Event_Modifier modifier; | ||
78 | unsigned int event_modifier; | ||
79 | }; | ||
80 | |||
81 | static const Ecore_Event_Modifier_Match matchs[] = { | ||
82 | { "Shift_L", ECORE_SHIFT, ECORE_EVENT_MODIFIER_SHIFT }, | ||
83 | { "Shift_R", ECORE_SHIFT, ECORE_EVENT_MODIFIER_SHIFT }, | ||
84 | { "Alt_L", ECORE_ALT, ECORE_EVENT_MODIFIER_ALT }, | ||
85 | { "Alt_R", ECORE_ALT, ECORE_EVENT_MODIFIER_ALT }, | ||
86 | { "Control_L", ECORE_CTRL, ECORE_EVENT_MODIFIER_CTRL }, | ||
87 | { "Control_R", ECORE_CTRL, ECORE_EVENT_MODIFIER_CTRL }, | ||
88 | { "Caps_Lock", ECORE_CAPS, ECORE_EVENT_MODIFIER_CAPS }, | ||
89 | { "Super_L", ECORE_WIN, ECORE_EVENT_MODIFIER_WIN }, | ||
90 | { "Super_R", ECORE_WIN, ECORE_EVENT_MODIFIER_WIN }, | ||
91 | { "Scroll_Lock", ECORE_SCROLL, ECORE_EVENT_MODIFIER_SCROLL } | ||
92 | }; | ||
93 | |||
94 | EAPI unsigned int | ||
95 | ecore_event_modifier_mask(Ecore_Event_Modifier modifier) | ||
96 | { | ||
97 | size_t i; | ||
98 | |||
99 | for (i = 0; i < sizeof (matchs) / sizeof (Ecore_Event_Modifier_Match); i++) | ||
100 | if (matchs[i].modifier == modifier) | ||
101 | return matchs[i].event_modifier; | ||
102 | |||
103 | return 0; | ||
104 | } | ||
105 | |||
106 | EAPI Ecore_Event_Modifier | ||
107 | ecore_event_update_modifier(const char *key, Ecore_Event_Modifiers *modifiers, int inc) | ||
108 | { | ||
109 | size_t i; | ||
110 | |||
111 | for (i = 0; i < sizeof (matchs) / sizeof (Ecore_Event_Modifier_Match); i++) | ||
112 | if (strcmp(matchs[i].key, key) == 0) | ||
113 | { | ||
114 | if (modifiers && matchs[i].modifier < modifiers->size) | ||
115 | modifiers->array[matchs[i].modifier] += inc; | ||
116 | return matchs[i].modifier; | ||
117 | } | ||
118 | |||
119 | return ECORE_NONE; | ||
120 | } | ||