示例#1
0
/* FIXME
   Mir still needs to implement its IM API, for now we assume
   a single key press produces a character.
*/
static void
HandleKeyEvent(MirKeyboardEvent const* key_event, SDL_Window* window)
{
    xkb_keysym_t key_code;
    Uint8 key_state;
    int event_scancode;
    uint32_t sdl_scancode = SDL_SCANCODE_UNKNOWN;

    MirKeyboardAction action = MIR_mir_keyboard_event_action(key_event);

    key_state      = SDL_PRESSED;
    key_code       = MIR_mir_keyboard_event_key_code(key_event);
    event_scancode = MIR_mir_keyboard_event_scan_code(key_event);

    if (action == mir_keyboard_action_up)
        key_state = SDL_RELEASED;

    if (event_scancode < SDL_arraysize(xfree86_scancode_table2))
        sdl_scancode = xfree86_scancode_table2[event_scancode];

    if (sdl_scancode != SDL_SCANCODE_UNKNOWN)
        SDL_SendKeyboardKey(key_state, sdl_scancode);

    if (key_state == SDL_PRESSED)
        HandleKeyText(key_code);
}
示例#2
0
/* FIXME
   Mir still needs to implement its IM API, for now we assume
   a single key press produces a character.
*/
static void
HandleKeyEvent(MirKeyEvent const ev, SDL_Window* window)
{
    uint32_t scancode = SDL_SCANCODE_UNKNOWN;
    Uint8 key_state = ev.action == mir_key_action_up ? SDL_RELEASED : SDL_PRESSED;

    CheckKeyboardFocus(window);

    if (ev.scan_code < SDL_arraysize(xfree86_scancode_table2))
        scancode = xfree86_scancode_table2[ev.scan_code];

    if (scancode != SDL_SCANCODE_UNKNOWN)
        SDL_SendKeyboardKey(key_state, scancode);

    if (key_state == SDL_PRESSED)
        HandleKeyText(ev.key_code);
}