bool skin_ui_process_events(SkinUI* ui) { SkinEvent ev; #ifdef _WIN32 if (ui->ui_params.win32_ignore_events) { // In QT, Windows messages are received by the QT thread, which is // the thread that creates all of its windows, so that should be // okay. However, in GPU accelerated images, there's a native window // that's created that represents the actual OpenGL output pane, and // that window is created from this thread and not the QT thread. We // need to keep its message queue from getting jammed up with // messages, so we need to grab any messages we see and drop // unnecessary ones on the floor. MSG message; PeekMessage(&message, NULL, 0, 0, PM_REMOVE); } #endif // _WIN32 while(skin_event_poll(&ev)) { switch(ev.type) { case kEventVideoExpose: DE("EVENT: kEventVideoExpose\n"); skin_window_redraw(ui->window, NULL); break; case kEventKeyDown: DE("EVENT: kEventKeyDown scancode=%d mod=0x%x\n", ev.u.key.keycode, ev.u.key.mod); skin_keyboard_process_event(ui->keyboard, &ev, 1); break; case kEventKeyUp: DE("EVENT: kEventKeyUp scancode=%d mod=0x%x\n", ev.u.key.keycode, ev.u.key.mod); skin_keyboard_process_event(ui->keyboard, &ev, 0); break; case kEventTextInput: DE("EVENT: kEventTextInput text=[%s] down=%s\n", ev.u.text.text, ev.u.text.down ? "true" : "false"); skin_keyboard_process_event(ui->keyboard, &ev, ev.u.text.down); break; case kEventMouseMotion: DE("EVENT: kEventMouseMotion x=%d y=%d xrel=%d yrel=%d button=%d\n", ev.u.mouse.x, ev.u.mouse.y, ev.u.mouse.xrel, ev.u.mouse.yrel, ev.u.mouse.button); skin_window_process_event(ui->window, &ev); break; case kEventMouseButtonDown: case kEventMouseButtonUp: DE("EVENT: kEventMouseButton x=%d y=%d xrel=%d yrel=%d button=%d\n", ev.u.mouse.x, ev.u.mouse.y, ev.u.mouse.xrel, ev.u.mouse.yrel, ev.u.mouse.button); { int down = (ev.type == kEventMouseButtonDown); if (ev.u.mouse.button == kMouseButtonScrollUp) { /* scroll-wheel simulates DPad up */ SkinKeyCode kcode; kcode = skin_keycode_rotate(kKeyCodeDpadUp, skin_layout_get_dpad_rotation( ui->layout)); ui->ui_funcs->keyboard_event(NULL, kcode, down); } else if (ev.u.mouse.button == kMouseButtonScrollDown) { /* scroll-wheel simulates DPad down */ SkinKeyCode kcode; kcode = skin_keycode_rotate(kKeyCodeDpadDown, skin_layout_get_dpad_rotation( ui->layout)); ui->ui_funcs->keyboard_event(NULL, kcode, down); } else if (ev.u.mouse.button == kMouseButtonLeft) { skin_window_process_event(ui->window, &ev); } } break; case kEventQuit: DE("EVENT: kEventQuit\n"); /* only save emulator config through clean exit */ return true; } } skin_keyboard_flush(ui->keyboard); return false; }
bool skin_ui_process_events(SkinUI* ui) { SkinEvent ev; while(skin_event_poll(&ev)) { switch(ev.type) { case kEventVideoExpose: DE("EVENT: kEventVideoExpose\n"); skin_window_redraw(ui->window, NULL); break; case kEventKeyDown: DE("EVENT: kEventKeyDown scancode=%d mod=0x%x\n", ev.u.key.keycode, ev.u.key.mod); skin_keyboard_process_event(ui->keyboard, &ev, 1); break; case kEventKeyUp: DE("EVENT: kEventKeyUp scancode=%d mod=0x%x\n", ev.u.key.keycode, ev.u.key.mod); skin_keyboard_process_event(ui->keyboard, &ev, 0); break; case kEventTextInput: DE("EVENT: kEventTextInput text=[%s] down=%s\n", ev.u.text.text, ev.u.text.down ? "true" : "false"); skin_keyboard_process_event(ui->keyboard, &ev, ev.u.text.down); break; case kEventMouseMotion: DE("EVENT: kEventMouseMotion x=%d y=%d xrel=%d yrel=%d button=%d\n", ev.u.mouse.x, ev.u.mouse.y, ev.u.mouse.xrel, ev.u.mouse.yrel, ev.u.mouse.button); skin_window_process_event(ui->window, &ev); break; case kEventMouseButtonDown: case kEventMouseButtonUp: DE("EVENT: kEventMouseButton x=%d y=%d xrel=%d yrel=%d button=%d\n", ev.u.mouse.x, ev.u.mouse.y, ev.u.mouse.xrel, ev.u.mouse.yrel, ev.u.mouse.button); { int down = (ev.type == kEventMouseButtonDown); if (ev.u.mouse.button == kMouseButtonScrollUp) { /* scroll-wheel simulates DPad up */ SkinKeyCode kcode; kcode = skin_keycode_rotate(kKeyCodeDpadUp, skin_layout_get_dpad_rotation( ui->layout)); ui->ui_funcs->keyboard_event(NULL, kcode, down); } else if (ev.u.mouse.button == kMouseButtonScrollDown) { /* scroll-wheel simulates DPad down */ SkinKeyCode kcode; kcode = skin_keycode_rotate(kKeyCodeDpadDown, skin_layout_get_dpad_rotation( ui->layout)); ui->ui_funcs->keyboard_event(NULL, kcode, down); } else if (ev.u.mouse.button == kMouseButtonLeft) { skin_window_process_event(ui->window, &ev); } } break; case kEventQuit: DE("EVENT: kEventQuit\n"); /* only save emulator config through clean exit */ return true; } } skin_keyboard_flush(ui->keyboard); return false; }