/* * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include "Ecore.h" #include "ecore_input_private.h" #include "ecore_private.h" #include "Ecore_Input.h" int _ecore_input_log_dom = -1; EAPI int ECORE_EVENT_KEY_DOWN = 0; EAPI int ECORE_EVENT_KEY_UP = 0; EAPI int ECORE_EVENT_MOUSE_BUTTON_DOWN = 0; EAPI int ECORE_EVENT_MOUSE_BUTTON_UP = 0; EAPI int ECORE_EVENT_MOUSE_MOVE = 0; EAPI int ECORE_EVENT_MOUSE_WHEEL = 0; EAPI int ECORE_EVENT_MOUSE_IN = 0; EAPI int ECORE_EVENT_MOUSE_OUT = 0; static int _ecore_event_init_count = 0; EAPI int ecore_event_init(void) { if (++_ecore_event_init_count != 1) return _ecore_event_init_count; _ecore_input_log_dom = eina_log_domain_register("EcoreInput", ECORE_INPUT_DEFAULT_LOG_COLOR); if(_ecore_input_log_dom < 0) { EINA_LOG_ERR("Impossible to create a log domain for the ecore input module."); return --_ecore_event_init_count; } ECORE_EVENT_KEY_DOWN = ecore_event_type_new(); ECORE_EVENT_KEY_UP = ecore_event_type_new(); ECORE_EVENT_MOUSE_BUTTON_DOWN = ecore_event_type_new(); ECORE_EVENT_MOUSE_BUTTON_UP = ecore_event_type_new(); ECORE_EVENT_MOUSE_MOVE = ecore_event_type_new(); ECORE_EVENT_MOUSE_WHEEL = ecore_event_type_new(); ECORE_EVENT_MOUSE_IN = ecore_event_type_new(); ECORE_EVENT_MOUSE_OUT = ecore_event_type_new(); return _ecore_event_init_count; } EAPI int ecore_event_shutdown(void) { if (--_ecore_event_init_count != 0) return _ecore_event_init_count; ECORE_EVENT_KEY_DOWN = 0; ECORE_EVENT_KEY_UP = 0; ECORE_EVENT_MOUSE_BUTTON_DOWN = 0; ECORE_EVENT_MOUSE_BUTTON_UP = 0; ECORE_EVENT_MOUSE_MOVE = 0; ECORE_EVENT_MOUSE_WHEEL = 0; ECORE_EVENT_MOUSE_IN = 0; ECORE_EVENT_MOUSE_OUT = 0; eina_log_domain_unregister(_ecore_input_log_dom); _ecore_input_log_dom = -1; return ++_ecore_event_init_count; } typedef struct _Ecore_Event_Modifier_Match Ecore_Event_Modifier_Match; struct _Ecore_Event_Modifier_Match { const char *key; Ecore_Event_Modifier modifier; unsigned int event_modifier; }; static const Ecore_Event_Modifier_Match matchs[] = { { "Shift_L", ECORE_SHIFT, ECORE_EVENT_MODIFIER_SHIFT }, { "Shift_R", ECORE_SHIFT, ECORE_EVENT_MODIFIER_SHIFT }, { "Alt_L", ECORE_ALT, ECORE_EVENT_MODIFIER_ALT }, { "Alt_R", ECORE_ALT, ECORE_EVENT_MODIFIER_ALT }, { "Control_L", ECORE_CTRL, ECORE_EVENT_MODIFIER_CTRL }, { "Control_R", ECORE_CTRL, ECORE_EVENT_MODIFIER_CTRL }, { "Caps_Lock", ECORE_CAPS, ECORE_EVENT_MODIFIER_CAPS }, { "Super_L", ECORE_WIN, ECORE_EVENT_MODIFIER_WIN }, { "Super_R", ECORE_WIN, ECORE_EVENT_MODIFIER_WIN }, { "Scroll_Lock", ECORE_SCROLL, ECORE_EVENT_MODIFIER_SCROLL } }; EAPI unsigned int ecore_event_modifier_mask(Ecore_Event_Modifier modifier) { int i; for (i = 0; i < sizeof (matchs) / sizeof (Ecore_Event_Modifier_Match); i++) if (matchs[i].modifier == modifier) return matchs[i].event_modifier; return 0; } EAPI Ecore_Event_Modifier ecore_event_update_modifier(const char *key, Ecore_Event_Modifiers *modifiers, int inc) { int i; for (i = 0; i < sizeof (matchs) / sizeof (Ecore_Event_Modifier_Match); i++) if (strcmp(matchs[i].key, key) == 0) { if (modifiers && matchs[i].modifier < modifiers->size) modifiers->array[matchs[i].modifier] += inc; return matchs[i].modifier; } return ECORE_NONE; }