From 63527ec8067002115b23da4fa63506e477604445 Mon Sep 17 00:00:00 2001 From: Sanjay Govind Date: Fri, 24 Jan 2025 09:18:12 +1300 Subject: [PATCH] gui_application: fix handling of hotplug events --- rpcs3/rpcs3qt/gui_application.cpp | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/rpcs3/rpcs3qt/gui_application.cpp b/rpcs3/rpcs3qt/gui_application.cpp index b1a39dfb2f..a305f992f8 100644 --- a/rpcs3/rpcs3qt/gui_application.cpp +++ b/rpcs3/rpcs3qt/gui_application.cpp @@ -1201,27 +1201,32 @@ void gui_application::OnAppStateChanged(Qt::ApplicationState state) bool gui_application::native_event_filter::nativeEventFilter([[maybe_unused]] const QByteArray& eventType, [[maybe_unused]] void* message, [[maybe_unused]] qintptr* result) { #ifdef _WIN32 - if (!Emu.IsRunning() && !Emu.IsStarting()) + if (!Emu.IsRunning() && !Emu.IsStarting() && !g_raw_mouse_handler) { return false; } if (eventType == "windows_generic_MSG") { - if (MSG* msg = static_cast(message); msg) + if (MSG* msg = static_cast(message); msg && (msg->message == WM_INPUT || msg->message == WM_KEYDOWN || msg->message == WM_KEYUP || msg->message == WM_DEVICECHANGE)) { - if (g_raw_mouse_handler && (msg->message == WM_INPUT || msg->message == WM_KEYDOWN || msg->message == WM_KEYUP)) { - if (auto* handler = g_fxo->try_get(); handler && handler->type == mouse_handler::raw) - { - static_cast(handler)->handle_native_event(*msg); - } - g_raw_mouse_handler->handle_native_event(*msg); - } if (msg->message == WM_DEVICECHANGE) { - handle_hotplug_event(msg->wParam == DBT_DEVICEARRIVAL); + if (Emu.IsRunning() || Emu.IsStarting()) + { + handle_hotplug_event(msg->wParam == DBT_DEVICEARRIVAL); + } return false; } + if (auto* handler = g_fxo->try_get(); handler && handler->type == mouse_handler::raw) + { + static_cast(handler)->handle_native_event(*msg); + } + + if (g_raw_mouse_handler) + { + g_raw_mouse_handler->handle_native_event(*msg); + } } } #endif