浏览代码

Add WM_DEVICECHANGE handling for the Native Windows Launcher to trigger input notification changes (#18181) (#18184)

Signed-off-by: Steve Pham <[email protected]>
Steve Pham 1 年之前
父节点
当前提交
4ef9f4ddf6

+ 3 - 1
Code/Editor/Platform/Windows/Editor/Core/QtEditorApplication_windows.cpp

@@ -27,6 +27,8 @@
 #include <AzFramework/Input/Buses/Requests/InputSystemCursorRequestBus.h>
 #include <AzFramework/Input/Devices/Mouse/InputDeviceMouse.h>
 
+#include <dbt.h>
+
 namespace Editor
 {
     EditorQtApplication* EditorQtApplication::newInstance(int& argc, char** argv)
@@ -111,7 +113,7 @@ namespace Editor
             }
             else if (msg->message == WM_DEVICECHANGE)
             {
-                if (msg->wParam == 0x0007) // DBT_DEVNODES_CHANGED
+                if (msg->wParam == DBT_DEVNODES_CHANGED) // DBT_DEVNODES_CHANGED
                 {
                     AzFramework::RawInputNotificationBusWindows::Broadcast(
                         &AzFramework::RawInputNotificationsWindows::OnRawInputDeviceChangeEvent);

+ 8 - 0
Code/Framework/AzFramework/Platform/Windows/AzFramework/Windowing/NativeWindow_Windows.cpp

@@ -16,6 +16,8 @@
 #include <AzCore/std/containers/array.h>
 #include <AzCore/std/string/conversions.h>
 
+#include <dbt.h>
+
 namespace AzFramework
 {
     const wchar_t* NativeWindowImpl_Win32::s_defaultClassName = L"O3DEWin32Class";
@@ -386,6 +388,12 @@ namespace AzFramework
             shouldBubbleEventUp = true;
             break;
         }
+        case WM_DEVICECHANGE:
+            if (wParam == DBT_DEVNODES_CHANGED)
+            {
+                // If any device changes were detected, broadcast to the input device notification
+                AzFramework::RawInputNotificationBusWindows::Broadcast(&AzFramework::RawInputNotificationsWindows::OnRawInputDeviceChangeEvent);
+            }
         default:
             shouldBubbleEventUp = true;
             break;