From b400661bfa40b34e4453ee697f4e38d475f2e704 Mon Sep 17 00:00:00 2001 From: w0wca7a <154334645+w0wca7a@users.noreply.github.com> Date: Wed, 25 Jun 2025 23:30:26 +0300 Subject: [PATCH 1/3] Update Win32.cs Add window handler --- sources/engine/Stride.Input/Windows/RawInput/Win32.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sources/engine/Stride.Input/Windows/RawInput/Win32.cs b/sources/engine/Stride.Input/Windows/RawInput/Win32.cs index b8fb3386f7..2067c1dc88 100644 --- a/sources/engine/Stride.Input/Windows/RawInput/Win32.cs +++ b/sources/engine/Stride.Input/Windows/RawInput/Win32.cs @@ -16,6 +16,9 @@ internal static class Win32 [DllImport("user32.dll")] public static extern void ClipCursor(IntPtr rect); + + [DllImport("user32.dll")] + public static extern IntPtr GetForegroundWindow(); } } #endif From f8150d4441008649236ddfceeff2675f0e6fe95c Mon Sep 17 00:00:00 2001 From: w0wca7a <154334645+w0wca7a@users.noreply.github.com> Date: Wed, 25 Jun 2025 23:35:05 +0300 Subject: [PATCH 2/3] Update GameControllerDirectInput.cs fixes SharpDX error --- .../engine/Stride.Input/Windows/GameControllerDirectInput.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sources/engine/Stride.Input/Windows/GameControllerDirectInput.cs b/sources/engine/Stride.Input/Windows/GameControllerDirectInput.cs index 807d08375e..d631e91fa9 100644 --- a/sources/engine/Stride.Input/Windows/GameControllerDirectInput.cs +++ b/sources/engine/Stride.Input/Windows/GameControllerDirectInput.cs @@ -37,7 +37,10 @@ public GameControllerDirectInput(InputSourceWindowsDirectInput source, DirectInp Id = instance.InstanceGuid; ProductId = instance.ProductGuid; joystick = new DirectInputJoystick(directInput, instance.InstanceGuid); - joystick.SetCooperativeLevel(IntPtr.Zero, CooperativeLevel.NonExclusive | CooperativeLevel.Foreground); + var descriptor = RawInput.Win32.GetForegroundWindow(); + + if (descriptor != IntPtr.Zero) + joystick.SetCooperativeLevel(descriptor, CooperativeLevel.NonExclusive | CooperativeLevel.Background); var objects = joystick.GetObjects(); int sliderCount = 0; From ba948890ae3c2b91238a6d6ff566b166e7f2ae04 Mon Sep 17 00:00:00 2001 From: w0wca7a <154334645+w0wca7a@users.noreply.github.com> Date: Wed, 25 Jun 2025 23:56:03 +0300 Subject: [PATCH 3/3] Update GameControllerDirectInput.cs fix window descriptor --- .../engine/Stride.Input/Windows/GameControllerDirectInput.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sources/engine/Stride.Input/Windows/GameControllerDirectInput.cs b/sources/engine/Stride.Input/Windows/GameControllerDirectInput.cs index d631e91fa9..8e2d8adb8a 100644 --- a/sources/engine/Stride.Input/Windows/GameControllerDirectInput.cs +++ b/sources/engine/Stride.Input/Windows/GameControllerDirectInput.cs @@ -38,9 +38,7 @@ public GameControllerDirectInput(InputSourceWindowsDirectInput source, DirectInp ProductId = instance.ProductGuid; joystick = new DirectInputJoystick(directInput, instance.InstanceGuid); var descriptor = RawInput.Win32.GetForegroundWindow(); - - if (descriptor != IntPtr.Zero) - joystick.SetCooperativeLevel(descriptor, CooperativeLevel.NonExclusive | CooperativeLevel.Background); + joystick.SetCooperativeLevel(descriptor, CooperativeLevel.NonExclusive | CooperativeLevel.Background); var objects = joystick.GetObjects(); int sliderCount = 0;