diff options
Diffstat (limited to 'src/osd/windows/window.cpp')
-rw-r--r-- | src/osd/windows/window.cpp | 65 |
1 files changed, 38 insertions, 27 deletions
diff --git a/src/osd/windows/window.cpp b/src/osd/windows/window.cpp index 690cc90658c..30afd7bc9d3 100644 --- a/src/osd/windows/window.cpp +++ b/src/osd/windows/window.cpp @@ -297,7 +297,7 @@ void win_window_info::show_pointer() s_saved_cursor_pos.x = s_saved_cursor_pos.y = -1; } - while (ShowCursor(TRUE) < 1) {}; + while (ShowCursor(TRUE) < 1) { } ShowCursor(FALSE); } @@ -342,7 +342,7 @@ static LRESULT CALLBACK winwindow_video_window_proc_ui(HWND wnd, UINT message, W // is_mame_window //============================================================ -static bool is_mame_window(HWND hwnd) +inline bool is_mame_window(HWND hwnd) { for (const auto &window : osd_common_t::window_list()) if (dynamic_cast<win_window_info &>(*window).platform_window() == hwnd) @@ -351,50 +351,50 @@ static bool is_mame_window(HWND hwnd) return false; } -inline static BOOL handle_mouse_button(windows_osd_interface *osd, int button, int down, int x, int y) +inline BOOL handle_mouse_button(windows_osd_interface &osd, int button, int down, LPARAM lparam) { MouseUpdateEventArgs args; args.pressed = (down ? 1 : 0) << button; args.released = (down ? 0 : 1) << button; args.vdelta = 0; args.hdelta = 0; - args.xpos = x; - args.ypos = y; + args.xpos = GET_X_LPARAM(lparam); + args.ypos = GET_Y_LPARAM(lparam); - bool handled = osd->handle_input_event(INPUT_EVENT_MOUSE_BUTTON, &args); + bool const handled = osd.handle_input_event(INPUT_EVENT_MOUSE_BUTTON, &args); // When in lightgun mode or mouse mode, the mouse click may be routed to the input system // because the mouse interactions in the UI are routed from the video_window_proc below // we need to make sure they aren't suppressed in these cases. - return handled && !osd->options().lightgun() && !osd->options().mouse(); + return handled && !osd.options().lightgun() && !osd.options().mouse(); } -inline static BOOL handle_mouse_wheel(windows_osd_interface *osd, int v, int h, int x, int y) +inline BOOL handle_mouse_wheel(windows_osd_interface &osd, int v, int h, LPARAM lparam) { MouseUpdateEventArgs args; args.pressed = 0; args.released = 0; args.vdelta = v; args.hdelta = h; - args.xpos = x; - args.ypos = y; + args.xpos = GET_X_LPARAM(lparam); + args.ypos = GET_Y_LPARAM(lparam); - bool handled = osd->handle_input_event(INPUT_EVENT_MOUSE_WHEEL, &args); + bool const handled = osd.handle_input_event(INPUT_EVENT_MOUSE_WHEEL, &args); // When in lightgun mode or mouse mode, the mouse wheel may be routed to the input system // because the mouse interactions in the UI are routed from the video_window_proc below // we need to make sure they aren't suppressed in these cases. - return handled && !osd->options().lightgun() && !osd->options().mouse(); + return handled && !osd.options().lightgun() && !osd.options().mouse(); } -inline static BOOL handle_keypress(windows_osd_interface *osd, int vkey, int down, int scancode, BOOL extended_key) +inline BOOL handle_keypress(windows_osd_interface &osd, int vkey, int down, LPARAM lparam) { KeyPressEventArgs args; args.event_id = down ? INPUT_EVENT_KEYDOWN : INPUT_EVENT_KEYUP; - args.scancode = MAKE_DI_SCAN(scancode, extended_key); + args.scancode = MAKE_DI_SCAN(SCAN_CODE(lparam), IS_EXTENDED(lparam)); args.vkey = vkey; - return osd->handle_input_event(args.event_id, &args); + return osd.handle_input_event(args.event_id, &args); } //============================================================ @@ -435,54 +435,55 @@ void windows_osd_interface::process_events(bool ingame, bool nodispatch) // forward mouse button downs to the input system case WM_LBUTTONDOWN: - dispatch = !handle_mouse_button(this, 0, TRUE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam)); + dispatch = !handle_mouse_button(*this, 0, TRUE, message.lParam); break; case WM_RBUTTONDOWN: - dispatch = !handle_mouse_button(this, 1, TRUE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam)); + dispatch = !handle_mouse_button(*this, 1, TRUE, message.lParam); break; case WM_MBUTTONDOWN: - dispatch = !handle_mouse_button(this, 2, TRUE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam)); + dispatch = !handle_mouse_button(*this, 2, TRUE, message.lParam); break; case WM_XBUTTONDOWN: - dispatch = !handle_mouse_button(this, 3, TRUE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam)); + dispatch = !handle_mouse_button(*this, (GET_XBUTTON_WPARAM(message.wParam) == XBUTTON1) ? 3 : 4, TRUE, message.lParam); break; // forward mouse button ups to the input system case WM_LBUTTONUP: - dispatch = !handle_mouse_button(this, 0, FALSE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam)); + dispatch = !handle_mouse_button(*this, 0, FALSE, message.lParam); break; case WM_RBUTTONUP: - dispatch = !handle_mouse_button(this, 1, FALSE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam)); + dispatch = !handle_mouse_button(*this, 1, FALSE, message.lParam); break; case WM_MBUTTONUP: - dispatch = !handle_mouse_button(this, 2, FALSE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam)); + dispatch = !handle_mouse_button(*this, 2, FALSE, message.lParam); break; case WM_XBUTTONUP: - dispatch = !handle_mouse_button(this, 3, FALSE, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam)); + dispatch = !handle_mouse_button(*this, (GET_XBUTTON_WPARAM(message.wParam) == XBUTTON1) ? 3 : 4, FALSE, message.lParam); break; // forward mouse wheel movement to the input system case WM_MOUSEWHEEL: - dispatch = !handle_mouse_wheel(this, GET_WHEEL_DELTA_WPARAM(message.wParam), 0, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam)); + dispatch = !handle_mouse_wheel(*this, GET_WHEEL_DELTA_WPARAM(message.wParam), 0, message.lParam); break; case WM_MOUSEHWHEEL: - dispatch = !handle_mouse_wheel(this, 0, GET_WHEEL_DELTA_WPARAM(message.wParam), GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam)); + dispatch = !handle_mouse_wheel(*this, 0, GET_WHEEL_DELTA_WPARAM(message.wParam), message.lParam); break; + // forward keystrokes to the input system case WM_KEYDOWN: if (NOT_ALREADY_DOWN(message.lParam)) - dispatch = !handle_keypress(this, message.wParam, TRUE, SCAN_CODE(message.lParam), IS_EXTENDED(message.lParam)); + dispatch = !handle_keypress(*this, message.wParam, TRUE, message.lParam); break; case WM_KEYUP: - dispatch = !handle_keypress(this, message.wParam, FALSE, SCAN_CODE(message.lParam), IS_EXTENDED(message.lParam)); + dispatch = !handle_keypress(*this, message.wParam, FALSE, message.lParam); break; } } @@ -1220,6 +1221,16 @@ LRESULT CALLBACK win_window_info::video_window_proc(HWND wnd, UINT message, WPAR case WM_POINTERCAPTURECHANGED: window->pointer_capture_changed(wparam, lparam); break; + // TODO: other pointer events? + //case WM_POINTERACTIVATE: + //case WM_POINTERDEVICECHANGE: + //case WM_POINTERDEVICECINRANGE: + //case WM_POINTERDEVICECOUTOFRANGE: + //case WM_POINTERROUTEDAWAY: + //case WM_POINTERROUTEDRELEASED: + //case WM_POINTERROUTEDTO: + //case WM_POINTERWHEEL: + //case WM_POINTERHWHEEL: // pause the system when we start a menu or resize case WM_ENTERSIZEMOVE: |