//----------------------------------------------------------------------------- LRESULT pump_events(HWND hwnd, UINT id, WPARAM wparam, LPARAM lparam) { switch (id) { case WM_DESTROY: { break; } case WM_QUIT: case WM_CLOSE: { m_queue.push_exit_event(0); break; } case WM_SIZE: { uint32_t width = GET_X_LPARAM(lparam); uint32_t height = GET_Y_LPARAM(lparam); m_queue.push_metrics_event(0, 0, width, height); break; } case WM_SYSCOMMAND: { switch (wparam) { case SC_MINIMIZE: case SC_RESTORE: { HWND parent = GetWindow(hwnd, GW_OWNER); if (NULL != parent) { PostMessage(parent, id, wparam, lparam); } } } break; } case WM_MOUSEMOVE: { int32_t mx = GET_X_LPARAM(lparam); int32_t my = GET_Y_LPARAM(lparam); m_queue.push_mouse_event(mx, my); break; } case WM_LBUTTONDOWN: case WM_LBUTTONUP: { int32_t mx = GET_X_LPARAM(lparam); int32_t my = GET_Y_LPARAM(lparam); m_queue.push_mouse_event(mx, my, MouseButton::LEFT, id == WM_LBUTTONDOWN); break; } case WM_RBUTTONUP: case WM_RBUTTONDOWN: { int32_t mx = GET_X_LPARAM(lparam); int32_t my = GET_Y_LPARAM(lparam); m_queue.push_mouse_event(mx, my, MouseButton::RIGHT, id == WM_RBUTTONDOWN); break; } case WM_MBUTTONDOWN: case WM_MBUTTONUP: { int32_t mx = GET_X_LPARAM(lparam); int32_t my = GET_Y_LPARAM(lparam); m_queue.push_mouse_event(mx, my, MouseButton::MIDDLE, id == WM_MBUTTONDOWN); break; } case WM_KEYDOWN: case WM_SYSKEYDOWN: case WM_KEYUP: case WM_SYSKEYUP: { KeyboardButton::Enum kb = win_translate_key(wparam & 0xff); int32_t modifier_mask = 0; if (kb == KeyboardButton::LSHIFT || kb == KeyboardButton::RSHIFT) { (id == WM_KEYDOWN || id == WM_SYSKEYDOWN) ? modifier_mask |= ModifierButton::SHIFT : modifier_mask &= ~ModifierButton::SHIFT; } else if (kb == KeyboardButton::LCONTROL || kb == KeyboardButton::RCONTROL) { (id == WM_KEYDOWN || id == WM_SYSKEYDOWN) ? modifier_mask |= ModifierButton::CTRL : modifier_mask &= ~ModifierButton::CTRL; } else if (kb == KeyboardButton::LALT || kb == KeyboardButton::RALT) { (id == WM_KEYDOWN || id == WM_SYSKEYDOWN) ? modifier_mask |= ModifierButton::ALT : modifier_mask &= ~ModifierButton::ALT; } m_queue.push_keyboard_event(modifier_mask, kb, (id == WM_KEYDOWN || id == WM_SYSKEYDOWN)); break; } default: break; } return DefWindowProc(hwnd, id, wparam, lparam); }
LRESULT pump_events(HWND hwnd, UINT id, WPARAM wparam, LPARAM lparam) { switch (id) { case WM_DESTROY: { break; } case WM_QUIT: case WM_CLOSE: { s_exit = true; _queue.push_exit_event(0); return 0; } case WM_SIZE: { uint32_t width = GET_X_LPARAM(lparam); uint32_t height = GET_Y_LPARAM(lparam); _queue.push_metrics_event(0, 0, width, height); break; } case WM_SYSCOMMAND: { switch (wparam) { case SC_MINIMIZE: case SC_RESTORE: { HWND parent = GetWindow(hwnd, GW_OWNER); if (NULL != parent) { PostMessage(parent, id, wparam, lparam); } } } break; } case WM_MOUSEWHEEL: { int32_t mx = GET_X_LPARAM(lparam); int32_t my = GET_Y_LPARAM(lparam); short delta = GET_WHEEL_DELTA_WPARAM(wparam); _queue.push_mouse_event(mx, my, (float)(delta/WHEEL_DELTA)); break; } case WM_MOUSEMOVE: { int32_t mx = GET_X_LPARAM(lparam); int32_t my = GET_Y_LPARAM(lparam); _queue.push_mouse_event(mx, my); break; } case WM_LBUTTONDOWN: case WM_LBUTTONUP: { int32_t mx = GET_X_LPARAM(lparam); int32_t my = GET_Y_LPARAM(lparam); _queue.push_mouse_event(mx, my, MouseButton::LEFT, id == WM_LBUTTONDOWN); break; } case WM_RBUTTONUP: case WM_RBUTTONDOWN: { int32_t mx = GET_X_LPARAM(lparam); int32_t my = GET_Y_LPARAM(lparam); _queue.push_mouse_event(mx, my, MouseButton::RIGHT, id == WM_RBUTTONDOWN); break; } case WM_MBUTTONDOWN: case WM_MBUTTONUP: { int32_t mx = GET_X_LPARAM(lparam); int32_t my = GET_Y_LPARAM(lparam); _queue.push_mouse_event(mx, my, MouseButton::MIDDLE, id == WM_MBUTTONDOWN); break; } case WM_KEYDOWN: case WM_SYSKEYDOWN: case WM_KEYUP: case WM_SYSKEYUP: { KeyboardButton::Enum kb = win_translate_key(wparam & 0xff); _queue.push_keyboard_event(kb, (id == WM_KEYDOWN || id == WM_SYSKEYDOWN)); break; } default: break; } return DefWindowProc(hwnd, id, wparam, lparam); }