static GLFWbool inputChar(_GLFWwindow* window, uint32_t key) { uint32_t code, numSyms; long cp; const xkb_keysym_t *syms; xkb_keysym_t sym; code = key + 8; numSyms = xkb_state_key_get_syms(_glfw.wl.xkb.state, code, &syms); if (numSyms == 1) { #ifdef HAVE_XKBCOMMON_COMPOSE_H sym = composeSymbol(syms[0]); #else sym = syms[0]; #endif cp = _glfwKeySym2Unicode(sym); if (cp != -1) { const int mods = _glfw.wl.xkb.modifiers; const int plain = !(mods & (GLFW_MOD_CONTROL | GLFW_MOD_ALT)); _glfwInputChar(window, cp, mods, plain); } } return xkb_keymap_key_repeats(_glfw.wl.xkb.keymap, syms[0]); }
static int translateChar(XKeyEvent* event) { KeySym keysym; // Get X11 keysym XLookupString(event, NULL, 0, &keysym, NULL); // Convert to Unicode (see x11_keysym2unicode.c) return (int) _glfwKeySym2Unicode(keysym); }
static void handleKeyEvent(const MirKeyEvent key, _GLFWwindow* window) { const int pressed = key.action == mir_key_action_up ? GLFW_RELEASE : GLFW_PRESS; const int mods = mirModToGLFWMod(key.modifiers); const long text = _glfwKeySym2Unicode(key.key_code); const int plain = !(mods & (GLFW_MOD_CONTROL | GLFW_MOD_ALT)); _glfwInputKey(window, toGLFWKeyCode(key.scan_code), key.scan_code, pressed, mods); if (text != -1) _glfwInputChar(window, text, mods, plain); }
static void inputChar(_GLFWwindow* window, uint32_t key) { uint32_t code, numSyms; long cp; const xkb_keysym_t *syms; code = key + 8; numSyms = xkb_state_key_get_syms(_glfw.wl.xkb.state, code, &syms); if (numSyms == 1) { cp = _glfwKeySym2Unicode(syms[0]); if (cp != -1) { const int mods = _glfw.wl.xkb.modifiers; const int plain = !(mods & (GLFW_MOD_CONTROL | GLFW_MOD_ALT)); _glfwInputChar(window, cp, mods, plain); } } }
static void keyboardHandleKey(void* data, struct wl_keyboard* keyboard, uint32_t serial, uint32_t time, uint32_t key, uint32_t state) { uint32_t code, num_syms; long cp; int keyCode; int action; const xkb_keysym_t *syms; _GLFWwindow* window = _glfw.wl.keyboardFocus; if (!window) return; keyCode = toGLFWKeyCode(key); action = state == WL_KEYBOARD_KEY_STATE_PRESSED ? GLFW_PRESS : GLFW_RELEASE; _glfwInputKey(window, keyCode, key, action, _glfw.wl.xkb.modifiers); code = key + 8; num_syms = xkb_key_get_syms(_glfw.wl.xkb.state, code, &syms); if (num_syms == 1) { cp = _glfwKeySym2Unicode(syms[0]); if (cp != -1) { const int mods = _glfw.wl.xkb.modifiers; const int plain = !(mods & (GLFW_MOD_CONTROL | GLFW_MOD_ALT)); _glfwInputChar(window, cp, mods, plain); } } }