diff --git a/sources/engine/Stride.Input/Windows/GameControllerDirectInput.cs b/sources/engine/Stride.Input/Windows/GameControllerDirectInput.cs index 807d08375e..8e2d8adb8a 100644 --- a/sources/engine/Stride.Input/Windows/GameControllerDirectInput.cs +++ b/sources/engine/Stride.Input/Windows/GameControllerDirectInput.cs @@ -37,7 +37,8 @@ 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(); + joystick.SetCooperativeLevel(descriptor, CooperativeLevel.NonExclusive | CooperativeLevel.Background); var objects = joystick.GetObjects(); int sliderCount = 0; 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