I am trying to use DirectInput to capture XBOX One controller input signals. I am tying it to a C# WinForms application. The issue I am having is: When the form has focus, it captures inputs just fine. When the window loses focus, I don't get any feedback. On Windows 7, this isn't an issue.
I have tried other controllers on Windows 10: PS4, Logitech, Steering Wheels, etc... Everything works as expected: When the window loses focus, I still get feedback. It's just the XBOX One controller on Windows 10.
I thought maybe it had something to do with this line:
dev.SetCooperativeLevel(_ctlParent, CooperativeLevel.Background | CooperativeLevel.Nonexclusive);
But, even if I take that line out, everything still acts the same.
It seems like the XBOX One controller ignores the CooperativeLevel.Background
flag and adds the CooperativeLevel.Foreground
flag. Here is some more info about the flags.
Is there anyone else familiar with this issue that has figured out a work around?
The drivers for the Xbox 360 Common Controller and the Xbox One Controller both emulate "HID" for use with the legacy DirectInput API for older games, but the emulation tends to have some quirks like this one.
Probably the best solution is to use XINPUT for these controllers and only fall back to DirectInput for legacy HID controllers. For Windows 10 DirectX 12 / UWP apps you can use Windows.Gaming.Input
directly as well.
See XINPUT and Windows 8 and DirectX Tool Kit: Now with GamePads.