In the win32 version of my game SDL_NumJoysticks() correctly returns the number of joysticks/gamepads currently connected, but in the UWP version it always returns 0. The code is identical in both versions. Do I have to enable something extra for joysticks to work under UWP?
Do you have the ability to step into SDL2 itself, on UWP? If so, I have a few suggestions for looking into this.
Also, before getting a count of joysticks, do you:
- call SDL_Init, and if so, with what flags?
- create an SDL_Window
Also, what specific device(s) are you seeing this on? Windows 10 on a desktop or laptop? Xbox One? Other?
Update: I am able to reproduce this on my end.
I’ll look into this further, tonight.
Thanks for the quick reply…
- i’m using SDL_INIT_EVERYTHING to initialize.
- yes I’m callingSDL_NumJoysticks() after the window has been created and all other subsystems ( IMG, TTF, Audio) have been initialized as well.
- I’m using Windows 10 on a desktop.
I traced SDL_NumJoysticks and SYS_Joystick is NULL…
Are you running Windows 10 in any sort of virtual machine, or is Windows 10 your desktop’s native OS?
Windows 10 is the native OS.
Ok, this is really odd: XInput doesn’t appear to be working at all. Even when I create a new, UWP, Direct3D application, it doesn’t detect anything.
On Win32, SDL appears to be using DirectInput to find the controllers.
I’ll make a post on MSDN’s public forums, and see if Microsoft can provide any answers.
Well at least it’s not just me… I spent the afternoon going in circles.
Update: XInput does appear to work for me on Xbox One, just not in desktop Windows 10.
I’ve posted a question on MSDN about this. It’s up at https://social.msdn.microsoft.com/Forums/en-US/9064838b-e8c3-4c18-8a83-19bf0dfe150d/xinput-fails-to-detect-game-controllers?forum=wpdevelop
My fingers are crossed regarding this, that that’ll help!
Thanks, hopefully they will come up with a workaround.
It looks like only some controllers are supported. According to a Microsoft representative, via a reply to that MSDN post, only “Xbox compatible controllers” are supported in UWP apps, for the time being.
I have a Xbox One adapter that I’m trying to get working, but am running into a bit of system trouble. In the meantime, if you have an Xbox compatible controller that you can try, it may work, and I’d be interested to hear if it does!
I was using a cheap xbox 360 knockoff controller… let me know if you get yours working.
Ok, I was able to get a Microsoft-made, Xbox 360 controller+adapter, working with Xinput in UWP. My non-Microsoft made controller does not work in UWP, and only works from Win32 apps.
This seems to confirm what was said in that MSDN post, whereby UWP apps have limitations on which devices are supported.
Thanks David… I guess I’ll need to get an official xbox one controller.