Exemplo n.º 1
0
void clearallkeys()
{
    int i;
    for(i = 0; i <AK_CTRL + 1; i++)
	my_kbd_handler (0, i, 0);
    for(i = 0; i < AK_CTRL + 1; i++)
	my_kbd_handler (i, 0, 0);
    buttonstate[0] = 0;
    buttonstate[1] = 0;
    buttonstate[2] = 0;
}
Exemplo n.º 2
0
/* Returns 0 if the queue is full, the event cannot be parsed, or the event
 * was not handled. */
int32_t push_event(PP_Resource event) {
    if (!ppb_input_event_interface || !ppb_mouse_event_interface ||
        !ppb_keyboard_event_interface) {
        DEBUG_LOG("Refusing to process pre-initialization input event.\n");
        return 0;
    }
    PP_InputEvent_Type type = ppb_input_event_interface->GetType(event);
    switch (type) {
    case PP_INPUTEVENT_TYPE_MOUSEDOWN:
    case PP_INPUTEVENT_TYPE_MOUSEUP: {
        int32_t buttonno = -1;
        switch (ppb_mouse_event_interface->GetButton(event)) {
        case PP_INPUTEVENT_MOUSEBUTTON_NONE:   return 0;
        case PP_INPUTEVENT_MOUSEBUTTON_LEFT:   buttonno = 0; break;
        case PP_INPUTEVENT_MOUSEBUTTON_MIDDLE: buttonno = 2; break;
        case PP_INPUTEVENT_MOUSEBUTTON_RIGHT:  buttonno = 1; break;
        }
        setmousebuttonstate(0, buttonno, type == PP_INPUTEVENT_TYPE_MOUSEDOWN ?
                            1 : 0);
        break;
    }
    case PP_INPUTEVENT_TYPE_MOUSEMOVE: {
        struct PP_Point delta = ppb_mouse_event_interface->GetMovement(event);
        setmousestate (0, 0, delta.x, 0);
        setmousestate (0, 1, delta.y, 0);
        break;
    }
    case PP_INPUTEVENT_TYPE_KEYDOWN:
    case PP_INPUTEVENT_TYPE_KEYUP: {
        int32_t keycode = ppb_keyboard_event_interface->GetKeyCode(event);
        my_kbd_handler(0, ppapi_keycode_to_dik(keycode),
                type == PP_INPUTEVENT_TYPE_KEYDOWN ? 1 : 0);
        break;
    }
    default:
        return 0;
    }
    return 1;
}