コード例 #1
0
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);
}
コード例 #2
0
ファイル: wl_init.c プロジェクト: alkama/Bonzomatic
static void keyboardHandleKey(void* data,
                              struct wl_keyboard* keyboard,
                              uint32_t serial,
                              uint32_t time,
                              uint32_t key,
                              uint32_t state)
{
    int keyCode;
    int action;
    _GLFWwindow* window = _glfw.wl.keyboardFocus;
    GLFWbool shouldRepeat;
    struct itimerspec timer = {};

    if (!window)
        return;

    keyCode = toGLFWKeyCode(key);
    action = state == WL_KEYBOARD_KEY_STATE_PRESSED
            ? GLFW_PRESS : GLFW_RELEASE;

    _glfw.wl.serial = serial;
    _glfwInputKey(window, keyCode, key, action,
                  _glfw.wl.xkb.modifiers);

    if (action == GLFW_PRESS)
    {
        shouldRepeat = inputChar(window, key);

        if (shouldRepeat && _glfw.wl.keyboardRepeatRate > 0)
        {
            _glfw.wl.keyboardLastKey = keyCode;
            _glfw.wl.keyboardLastScancode = key;
            if (_glfw.wl.keyboardRepeatRate > 1)
                timer.it_interval.tv_nsec = 1000000000 / _glfw.wl.keyboardRepeatRate;
            else
                timer.it_interval.tv_sec = 1;
            timer.it_value.tv_sec = _glfw.wl.keyboardRepeatDelay / 1000;
            timer.it_value.tv_nsec = (_glfw.wl.keyboardRepeatDelay % 1000) * 1000000;
        }
    }
    timerfd_settime(_glfw.wl.timerfd, 0, &timer, NULL);
}
コード例 #3
0
ファイル: wl_init.c プロジェクト: Piotrek1910/Painter
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);
        }
    }
}
コード例 #4
0
ファイル: wl_init.c プロジェクト: ebbnflow/glfw
static void keyboardHandleKey(void* data,
                              struct wl_keyboard* keyboard,
                              uint32_t serial,
                              uint32_t time,
                              uint32_t key,
                              uint32_t state)
{
    int keyCode;
    int action;
    _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);

    if (action == GLFW_PRESS)
        inputChar(window, key);
}