libsdl-org / SDL

Simple Directmedia Layer
https://libsdl.org
zlib License
9.79k stars 1.82k forks source link

Xbox One Controller issues #7896

Closed Arcnor closed 11 months ago

Arcnor commented 1 year ago

Hi,

I'm having the most strange issue, was hesitant about posting it but maybe somebody has an idea.

I'm using SDL from versions 2.0.12 up to 2.26.5 (tried all of them) on Windows 10. I'm using testgamecontroller.c. My Xbox One Controllers (using a Wireless Adaptor) are being detected by SDL:

INFO: XBox One Controller 0: Xbox One Controller (guid 030000005e040000dd02000000007200, VID 0x045e, PID 0x02dd, player index = 0)
INFO: There are 1 game controller(s) attached (1 joystick(s))
INFO: Attempting to open device 0, guid 030000005e040000dd02000000007200

However, no buttons or axis or anything are being shown. While I was changing versions, suddenly everything started working, but after I disconnected the Wireless Adaptor and connected it again, it failed again (but continued to show the controller connected, as above).

The controllers themselves (I tried multiple of them) are working fine with all other apps on my system, be it the Windows "Set up USB Game Controllers" app, Chrome, Unity, Steam, etc... I also tried another controller (8BitDo Ultimate) and it worked fine with every SDL version, as expected.

I also debugged a bit, and it seems SDL is detecting my controller using "RAWINPUT", which also calls XInput among other layers. I don't understand how all the different layers work, but the XInput button & axis data was there and it seemed to be changing. However, that seems to be ignored in favor of SDL_HidP_GetData at RAWINPUT_HandleStatePacket, and that always returns 0.

I understand this is probably something to do with my system (I've restarted and closed every single app before running mine as well, just in case, to no avail. But as mentioned, other apps seem to be fine with the controllers) but maybe somebody has some sort of idea on how to fix this.

Thanks in advance.

slouken commented 1 year ago

Do you use Remote Desktop into this machine? If so, this is being tracked at https://github.com/libsdl-org/SDL/issues/7759 and is being investigated by Microsoft.

Arcnor commented 1 year ago

Hmm, I actually do! But I haven't done so since restarting and still doesn't work (except randomly and briefly, as mentioned). I agree it looks very similar, but also, I think I'm receiving WM_INPUT messages, although I don't think they change anything.

In any case, I'll just wait for the resolution of that bug for now, and it's good to see I'm not crazy :D.

Squall-Leonhart commented 1 year ago

This is a known issue with WGI having its device invalidated by the new user session, the original user session must be logged off and back in to require.

You'll also find that the xbox accessories app can send vibration controls but the test screen doesn't respond to any button presses.

https://github.com/microsoft/GDK/issues/28

Arcnor commented 1 year ago

Thanks, the only problem as I mention above is that this doesn't work even after restarting (unless logging off won't work the same way as restarting, I can also try that) but I agree this looks really similar, hopefully that's the real issue and we get a fix soon.

Arcnor commented 1 year ago

By the way, I've also found out that this tool https://generalarcade.com/gamepadtool/ works all the time for me, it seems to be using SDL 2.0.7, not sure if WGI was not being used there yet or what other difference could be there.

slouken commented 1 year ago

Yeah, the older version of SDL isn't using raw input. You can get that behavior in the new SDL by setting the environment variable SDL_JOYSTICK_RAWINPUT to 0