9 #include "ecore_private.h"
11 #include "Ecore_Input.h"
12 #include "ecore_input_private.h"
15 int _ecore_input_log_dom = -1;
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;
26 static int _ecore_event_init_count = 0;
29 ecore_event_init(void)
31 if (++_ecore_event_init_count != 1)
32 return _ecore_event_init_count;
35 _ecore_event_init_count--;
39 _ecore_input_log_dom = eina_log_domain_register
40 ("ecore_input", ECORE_INPUT_DEFAULT_LOG_COLOR);
41 if(_ecore_input_log_dom < 0)
43 EINA_LOG_ERR("Impossible to create a log domain for the ecore input module.");
44 return --_ecore_event_init_count;
47 ECORE_EVENT_KEY_DOWN = ecore_event_type_new();
48 ECORE_EVENT_KEY_UP = ecore_event_type_new();
49 ECORE_EVENT_MOUSE_BUTTON_DOWN = ecore_event_type_new();
50 ECORE_EVENT_MOUSE_BUTTON_UP = ecore_event_type_new();
51 ECORE_EVENT_MOUSE_MOVE = ecore_event_type_new();
52 ECORE_EVENT_MOUSE_WHEEL = ecore_event_type_new();
53 ECORE_EVENT_MOUSE_IN = ecore_event_type_new();
54 ECORE_EVENT_MOUSE_OUT = ecore_event_type_new();
56 return _ecore_event_init_count;
60 ecore_event_shutdown(void)
62 if (--_ecore_event_init_count != 0)
63 return _ecore_event_init_count;
65 ECORE_EVENT_KEY_DOWN = 0;
66 ECORE_EVENT_KEY_UP = 0;
67 ECORE_EVENT_MOUSE_BUTTON_DOWN = 0;
68 ECORE_EVENT_MOUSE_BUTTON_UP = 0;
69 ECORE_EVENT_MOUSE_MOVE = 0;
70 ECORE_EVENT_MOUSE_WHEEL = 0;
71 ECORE_EVENT_MOUSE_IN = 0;
72 ECORE_EVENT_MOUSE_OUT = 0;
73 eina_log_domain_unregister(_ecore_input_log_dom);
74 _ecore_input_log_dom = -1;
76 return _ecore_event_init_count;
79 typedef struct _Ecore_Event_Modifier_Match Ecore_Event_Modifier_Match;
80 struct _Ecore_Event_Modifier_Match
83 Ecore_Event_Modifier modifier;
84 unsigned int event_modifier;
87 static const Ecore_Event_Modifier_Match matchs[] = {
88 { "Shift_L", ECORE_SHIFT, ECORE_EVENT_MODIFIER_SHIFT },
89 { "Shift_R", ECORE_SHIFT, ECORE_EVENT_MODIFIER_SHIFT },
90 { "Alt_L", ECORE_ALT, ECORE_EVENT_MODIFIER_ALT },
91 { "Alt_R", ECORE_ALT, ECORE_EVENT_MODIFIER_ALT },
92 { "Control_L", ECORE_CTRL, ECORE_EVENT_MODIFIER_CTRL },
93 { "Control_R", ECORE_CTRL, ECORE_EVENT_MODIFIER_CTRL },
94 { "Caps_Lock", ECORE_CAPS, ECORE_EVENT_MODIFIER_CAPS },
95 { "Super_L", ECORE_WIN, ECORE_EVENT_MODIFIER_WIN },
96 { "Super_R", ECORE_WIN, ECORE_EVENT_MODIFIER_WIN },
97 { "ISO_Level3_Shift", ECORE_MODE, ECORE_EVENT_MODIFIER_ALTGR },
98 { "Scroll_Lock", ECORE_SCROLL, ECORE_EVENT_MODIFIER_SCROLL }
102 ecore_event_modifier_mask(Ecore_Event_Modifier modifier)
106 for (i = 0; i < sizeof (matchs) / sizeof (Ecore_Event_Modifier_Match); i++)
107 if (matchs[i].modifier == modifier)
108 return matchs[i].event_modifier;
113 EAPI Ecore_Event_Modifier
114 ecore_event_update_modifier(const char *key, Ecore_Event_Modifiers *modifiers, int inc)
118 for (i = 0; i < sizeof (matchs) / sizeof (Ecore_Event_Modifier_Match); i++)
119 if (strcmp(matchs[i].key, key) == 0)
121 if (modifiers && matchs[i].modifier < modifiers->size)
122 modifiers->array[matchs[i].modifier] += inc;
123 return matchs[i].modifier;