discomfitor pushed a commit to branch master. http://git.enlightenment.org/core/enlightenment.git/commit/?id=b228c95dce950f795ea04e2681189c61f2fc6888
commit b228c95dce950f795ea04e2681189c61f2fc6888 Author: Mike Blumenkrantz <[email protected]> Date: Fri Feb 24 14:15:42 2017 -0500 make wl key input generator take keynames instead of keycodes --- src/bin/e_comp_wl_input.c | 127 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 123 insertions(+), 4 deletions(-) diff --git a/src/bin/e_comp_wl_input.c b/src/bin/e_comp_wl_input.c index 8110d6c..33a0822 100644 --- a/src/bin/e_comp_wl_input.c +++ b/src/bin/e_comp_wl_input.c @@ -14,6 +14,7 @@ E_API int E_EVENT_TEXT_INPUT_PANEL_VISIBILITY_CHANGE = -1; static xkb_keycode_t (*_xkb_keymap_key_by_name)(void *, const char *); static void _e_comp_wl_input_context_keymap_set(struct xkb_keymap *keymap, struct xkb_context *context); +static Eina_Hash *input_gen_modifiers; //the following two fields are just set by e_comp_wl_input_keymap_set if it is called before e_comp_wl is valid. //when then later init is called those two fields are used in the keymap of the e_comp_wl struct @@ -502,6 +503,8 @@ e_comp_wl_input_shutdown(void) { struct wl_resource *res; + E_FREE_FUNC(input_gen_modifiers, eina_hash_free); + /* destroy pointer resources */ EINA_LIST_FREE(e_comp_wl->ptr.resources, res) wl_resource_destroy(res); @@ -787,9 +790,6 @@ _event_generate(const char *key, const char *keyname, int mods, Eina_Bool up) Ecore_Event_Key *ev; int keycode; - /* "key" here is the platform-specific key name; - * /usr/share/X11/xkb/keycodes/evdev is probably what your system is using - */ keycode = _xkb_keymap_key_by_name(e_comp_wl->xkb.keymap, keyname ?: key); if (keycode == -1) { @@ -831,15 +831,134 @@ _event_generate_mods(int mods, Eina_Bool up) E_API void e_comp_wl_input_keyboard_event_generate(const char *key, int mods, Eina_Bool up) { + const char *keyname = NULL; + /* assumes qwerty layout */ + /* /usr/share/X11/xkb/keycodes/evdev */ + static const char *keycodes[] = + { + ['`'] = "TLDE", + ['1'] = "AE01", + ['2'] = "AE02", + ['3'] = "AE03", + ['4'] = "AE04", + ['5'] = "AE05", + ['6'] = "AE06", + ['7'] = "AE07", + ['8'] = "AE08", + ['9'] = "AE09", + ['0'] = "AE10", + ['-'] = "AE11", + ['='] = "AE12", + //''] = "BKSP", + ['\t'] = "TAB", + ['q'] = "AD01", + ['w'] = "AD02", + ['e'] = "AD03", + ['r'] = "AD04", + ['t'] = "AD05", + ['y'] = "AD06", + ['u'] = "AD07", + ['i'] = "AD08", + ['o'] = "AD09", + ['p'] = "AD10", + ['['] = "AD11", + [']'] = "AD12", + ['\\'] = "BKSL", + ['\r'] = "RTRN", + //''] = "CAPS", + ['a'] = "AC01", + ['s'] = "AC02", + ['d'] = "AC03", + ['f'] = "AC04", + ['g'] = "AC05", + ['h'] = "AC06", + ['j'] = "AC07", + ['k'] = "AC08", + ['l'] = "AC09", + [';'] = "AC10", + ['\''] = "AC11", + //''] = "LFSH", + ['z'] = "AB01", + ['x'] = "AB02", + ['c'] = "AB03", + ['v'] = "AB04", + ['b'] = "AB05", + ['n'] = "AB06", + ['m'] = "AB07", + [','] = "AB08", + ['.'] = "AB09", + ['/'] = "AB10", + //''] = "RTSH", + [' '] = "SPCE", + }; + if (!_xkb_keymap_key_by_name) { ERR("xkbcommon >= 0.6.0 required for keyboard event generation!"); return; } + EINA_SAFETY_ON_NULL_RETURN(key); + EINA_SAFETY_ON_TRUE_RETURN(!key[0]); + if (!input_gen_modifiers) + { +//<RTSH> = 62; +//<LALT> = 64; +//<LCTL> = 37; +//<RCTL> = 105; +//<RALT> = 108; +//<LWIN> = 133; +//<RWIN> = 134; +//<COMP> = 135; +//alias <MENU> = <COMP>; +//<ESC> = 9; + static const char *modcodes[] = + { + "Shift_L", + "LFSH", + + "Control_L", + "LCTL", + + "Super_L", + "LWIN", + + "Alt_L", + "LALT", + + "Escape", + "ESC", + + "Alt_R", + "RALT", + + "Super_R", + "RWIN", + + "Menu", + "MENU", + + "Control_R", + "RCTRL", + + "Mode_switch", + "ALGR", + }; + unsigned int i; + + input_gen_modifiers = eina_hash_string_superfast_new(NULL); + for (i = 0; i < EINA_C_ARRAY_LENGTH(modcodes); i += 2) + eina_hash_add(input_gen_modifiers, modcodes[i], modcodes[i + 1]); + } if (!up) _event_generate_mods(mods, up); - _event_generate(key, NULL, mods, up); + keyname = eina_hash_find(input_gen_modifiers, key); + if ((!keyname) && (!key[1])) + { + if (key[0] < (int)EINA_C_ARRAY_LENGTH(keycodes)) + keyname = keycodes[(unsigned char)key[0]]; + } + _event_generate(key, keyname, mods, up); if (up) _event_generate_mods(mods, up); } --
