bool win32_keyboard_device::handle_wnd_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { UNUSED_PARAMETER(hwnd); bool handled = false; switch (message) { case WM_KEYDOWN: case WM_SYSKEYDOWN: { handled = on_key_down(wparam, lparam); break; } case WM_KEYUP: case WM_SYSKEYUP: { handled = on_key_up(wparam, lparam); break; } case WM_CHAR: case WM_SYSCHAR: { handled = on_char_received(wparam, lparam); break; } } return handled; }
bool GuiWindow::keydown(int keycode, bool repeat) { if (on_key_down) { return on_key_down(this, on_key_down_data, keycode, repeat); } return false; }
void poll_input_devices( struct input_t* inp ) { static int update_ts = No; /* Clear input structure */ // ZeroMemory( inp, sizeof( struct input_t ) ); /* Poll input devices */ while( SDL_PollEvent( &event ) ) { switch( event.type ) { case SDL_KEYDOWN: on_key_down( &event.key.keysym, inp ); update_ts = Yes; break; case SDL_KEYUP: on_key_up( &event.key.keysym, inp ); update_ts = No; inp->timestamp = 0; break; case SDL_MOUSEBUTTONDOWN: on_touch_down( &event.button, inp ); update_ts = Yes; break; case SDL_MOUSEBUTTONUP: on_touch_up( &event.button, inp ); update_ts = No; inp->timestamp = 0; break; case SDL_JOYBUTTONDOWN: on_joy_button_down( &event.jbutton, inp ); update_ts = Yes; break; case SDL_JOYBUTTONUP: on_joy_button_up( &event.jbutton, inp ); update_ts = No; inp->timestamp = 0; break; case SDL_JOYAXISMOTION: on_joy_axis_move( &event.jaxis, inp ); break; case SDL_QUIT: inp->escape = Yes; break; } } /* Update timestamp */ if( update_ts ) inp->timestamp++; else inp->timestamp = 0; }
void UIWidget::key_down_func() { if (disabled) return; // call this function on the children first for (auto &child : ElementID::recast_collection<UIWidget>(get_children())) child->key_down_func(); // then call on self on_key_down(); }
void Dialog::run_step(bool block) { ALLEGRO_EVENT event; if (block) { al_wait_for_event(event_queue, NULL); } while (al_get_next_event(event_queue, &event)) { switch (event.type) { case ALLEGRO_EVENT_DISPLAY_CLOSE: this->request_quit(); break; case ALLEGRO_EVENT_KEY_DOWN: case ALLEGRO_EVENT_KEY_REPEAT: on_key_down(event.keyboard); break; case ALLEGRO_EVENT_MOUSE_AXES: on_mouse_axes(event.mouse); break; case ALLEGRO_EVENT_MOUSE_BUTTON_DOWN: on_mouse_button_down(event.mouse); break; case ALLEGRO_EVENT_MOUSE_BUTTON_UP: on_mouse_button_up(event.mouse); break; case ALLEGRO_EVENT_DISPLAY_EXPOSE: this->request_draw(); break; default: if (event_handler) { event_handler->handle_event(event); } break; } } }
void handle_events(bool &running, SDL_Window *window) { SDL_Event event; while (SDL_PollEvent(&event)) { gui::poll_events(event); switch (event.type) { case SDL_KEYUP: if (event.key.keysym.sym == SDLK_ESCAPE) running = false; if (event.key.keysym.sym == SDLK_PRINTSCREEN) save_screenshot(window); on_key_up(event.key.keysym.mod, event.key.keysym.sym); break; case SDL_KEYDOWN: on_key_down(event.key.keysym.mod, event.key.keysym.sym); break; case SDL_MOUSEMOTION: if (event.motion.state & SDL_BUTTON_LMASK) on_mouse_dragged(SDL_BUTTON_LEFT, event.motion.x, event.motion.y, event.motion.xrel, event.motion.yrel); else if (event.motion.state & SDL_BUTTON_MMASK) on_mouse_dragged(SDL_BUTTON_MIDDLE, event.motion.x, event.motion.y, event.motion.xrel, event.motion.yrel); else if (event.motion.state & SDL_BUTTON_RMASK) on_mouse_dragged(SDL_BUTTON_RIGHT, event.motion.x, event.motion.y, event.motion.xrel, event.motion.yrel); else on_mouse_moved(event.motion.x, event.motion.y, event.motion.xrel, event.motion.yrel); break; case SDL_MOUSEBUTTONDOWN: on_mouse_pressed(event.button.button, event.button.x, event.button.y); break; case SDL_MOUSEBUTTONUP: on_mouse_released(event.button.button, event.button.x, event.button.y); break; case SDL_QUIT: running = false; break; } } }
LRESULT Window::on_message(HWND _hWnd, UINT message, WPARAM wParam, LPARAM lParam) { if (IsEmbedded() && !IsAltair()) { /* some older iPaqs such as the H3900 send only WM_KEYUP for VK_APP*, but never VK_KEYDOWN; the hx4700 has an additional set of undocumented key codes (0xca..0xcd) for the APP keys, but sends WM_KEYUP/VK_APP* additionally; the following rules hopefully catch all of these obscurities */ if (message == WM_KEYUP && wParam >= 0x80) /* convert to WM_KEYDOWN to make all handlers catch it */ message = WM_KEYDOWN; else if (message == WM_KEYDOWN && wParam >= 0x80) /* ignore the real WM_KEYDOWN, just in case it really happens */ return 0; } switch (message) { case WM_CREATE: on_create(); return 0; case WM_DESTROY: on_destroy(); return 0; case WM_CLOSE: if (on_close()) /* true returned: message was handled */ return 0; break; case WM_SIZE: on_resize(LOWORD(lParam), HIWORD(lParam)); return 0; case WM_MOUSEMOVE: if (on_mouse_move(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), wParam)) return 0; break; case WM_LBUTTONDOWN: if (on_mouse_down(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) { /* true returned: message was handled */ ResetDisplayTimeOut(); return 0; } break; case WM_LBUTTONUP: if (on_mouse_up(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) { /* true returned: message was handled */ ResetDisplayTimeOut(); return 0; } break; case WM_LBUTTONDBLCLK: if (!double_clicks) /* instead of disabling CS_DBLCLKS (which would affect all instances of a window class), we just translate WM_LBUTTONDBLCLK to WM_LBUTTONDOWN here; this even works for built-in window class such as BUTTON */ return on_message(_hWnd, WM_LBUTTONDOWN, wParam, lParam); if (on_mouse_double(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) { /* true returned: message was handled */ ResetDisplayTimeOut(); return 0; } break; #ifdef WM_MOUSEWHEEL case WM_MOUSEWHEEL: if (on_mouse_wheel(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), GET_WHEEL_DELTA_WPARAM(wParam))) { /* true returned: message was handled */ ResetDisplayTimeOut(); return 0; } break; #endif case WM_KEYDOWN: if (on_key_down(::TranscodeKey(wParam))) { /* true returned: message was handled */ ResetDisplayTimeOut(); return 0; } break; case WM_KEYUP: if (on_key_up(::TranscodeKey(wParam))) { /* true returned: message was handled */ ResetDisplayTimeOut(); return 0; } break; case WM_COMMAND: if (on_command(LOWORD(wParam), HIWORD(wParam))) { /* true returned: message was handled */ ResetDisplayTimeOut(); return 0; } break; case WM_CANCELMODE: if (on_cancel_mode()) return 0; break; case WM_SETFOCUS: on_setfocus(); return 0; case WM_KILLFOCUS: on_killfocus(); return 0; case WM_TIMER: if (on_timer(*(WindowTimer *)wParam)) return 0; break; case WM_PAINT: if (custom_painting) { PaintCanvas canvas(*this); on_paint(canvas, canvas.get_dirty()); return 0; } break; case WM_GETDLGCODE: if (on_key_check(wParam)) return DLGC_WANTMESSAGE; break; } if (message >= WM_USER && message <= 0x7FFF && on_user(message - WM_USER)) return 0; return on_unhandled_message(_hWnd, message, wParam, lParam); }
LRESULT Window::on_message(HWND _hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_CREATE: return on_create() ? 0 : -1; break; case WM_DESTROY: if (on_destroy()) return 0; break; case WM_CLOSE: if (on_close()) /* true returned: message was handled */ return 0; break; case WM_SIZE: if (on_resize(LOWORD(lParam), HIWORD(lParam))) return 0; break; case WM_MOUSEMOVE: if (on_mouse_move(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), wParam)) return 0; break; case WM_LBUTTONDOWN: XCSoarInterface::InterfaceTimeoutReset(); if (on_mouse_down(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) { /* true returned: message was handled */ ResetDisplayTimeOut(); return 0; } break; case WM_LBUTTONUP: XCSoarInterface::InterfaceTimeoutReset(); if (on_mouse_up(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) { /* true returned: message was handled */ ResetDisplayTimeOut(); return 0; } break; case WM_LBUTTONDBLCLK: XCSoarInterface::InterfaceTimeoutReset(); if (on_mouse_double(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) { /* true returned: message was handled */ ResetDisplayTimeOut(); return 0; } break; #ifdef WM_MOUSEWHEEL case WM_MOUSEWHEEL: XCSoarInterface::InterfaceTimeoutReset(); if (on_mouse_wheel(GET_WHEEL_DELTA_WPARAM(wParam))) { /* true returned: message was handled */ ResetDisplayTimeOut(); return 0; } break; #endif case WM_KEYDOWN: XCSoarInterface::InterfaceTimeoutReset(); if (on_key_down(wParam)) { /* true returned: message was handled */ ResetDisplayTimeOut(); return 0; } break; case WM_KEYUP: XCSoarInterface::InterfaceTimeoutReset(); if (on_key_up(wParam)) { /* true returned: message was handled */ ResetDisplayTimeOut(); return 0; } break; case WM_COMMAND: XCSoarInterface::InterfaceTimeoutReset(); if (on_command(LOWORD(wParam), HIWORD(wParam))) { /* true returned: message was handled */ ResetDisplayTimeOut(); return 0; } break; case WM_SETFOCUS: if (on_setfocus()) return 0; break; case WM_KILLFOCUS: if (on_killfocus()) return 0; break; case WM_TIMER: if (on_timer(wParam)) return 0; break; } if (message >= WM_USER && message <= 0x7FFF && on_user(message - WM_USER)) return 0; return on_unhandled_message(_hWnd, message, wParam, lParam); }
void kWindow::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { on_key_down(nChar,nRepCnt,nFlags); CWnd::OnKeyDown(nChar,nRepCnt,nFlags); }