From da33f5c0cce7fc1ab05038d2a9e0ca01c9d22026 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sun, 23 Oct 2022 05:31:39 +0200 Subject: [PATCH] Allow mouse capture on internal mice even if mouse_type is not actually set to MOUSE_TYPE_INTERNAL, fixes #2682. --- src/include/86box/machine.h | 1 + src/machine/machine_table.c | 6 ++++++ src/qt/qt_ui.cpp | 2 +- src/win/win_ui.c | 2 +- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/include/86box/machine.h b/src/include/86box/machine.h index 0ba9e38f3..4c59fd719 100644 --- a/src/include/86box/machine.h +++ b/src/include/86box/machine.h @@ -335,6 +335,7 @@ extern int machine_get_max_ram(int m); extern int machine_get_ram_granularity(int m); extern int machine_get_type(int m); extern void machine_close(void); +extern int machine_has_mouse(void); extern uint8_t machine_get_p1(void); extern void machine_load_p1(int m); diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index cbfdccab9..6bd052c38 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -11990,3 +11990,9 @@ machine_get_machine_from_internal_name(char *s) return(0); } + +int +machine_has_mouse(void) +{ + return(machines[machine].flags & MACHINE_MOUSE); +} diff --git a/src/qt/qt_ui.cpp b/src/qt/qt_ui.cpp index febf4cba7..09199bdac 100644 --- a/src/qt/qt_ui.cpp +++ b/src/qt/qt_ui.cpp @@ -104,7 +104,7 @@ void plat_setfullscreen(int on) { } void plat_mouse_capture(int on) { - if (!kbd_req_capture && (mouse_type == MOUSE_TYPE_NONE)) + if (!kbd_req_capture && (mouse_type == MOUSE_TYPE_NONE) && !machine_has_mouse()) return; main_window->setMouseCapture(on > 0 ? true : false); diff --git a/src/win/win_ui.c b/src/win/win_ui.c index b8902cf77..803ed2a80 100644 --- a/src/win/win_ui.c +++ b/src/win/win_ui.c @@ -1549,7 +1549,7 @@ plat_mouse_capture(int on) { RECT rect; - if (!kbd_req_capture && (mouse_type == MOUSE_TYPE_NONE)) + if (!kbd_req_capture && (mouse_type == MOUSE_TYPE_NONE) && !machine_has_mouse()) return; if (on && !mouse_capture) {