libsdl-org / SDL

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

Can `WINDOWS_JoystickInit` use `SDL_CreateJoystickName` ? #10207

Open AntTheAlchemist opened 1 month ago

AntTheAlchemist commented 1 month ago

I'm testing a new mini gamepad and I noticed the HIDAPI driver init uses SDL_CreateJoystickName to insert a manufacturer name to the device name, but the Windows driver doesn't. Because the gamepad is unmapped, I just get "Keyboard" back from SDL_GetJoystickInstanceName, because even though HIDAPI has "BEKEN Keyboard" as the device name for this gamepad, it doesn't ++SDL_HIDAPI_numdrivers; for this gamepad (because there's no HIDAPI driver for it).

Is this expected behaviour? Can't we somehow get back a nicer joystick name in this situation?

slouken commented 1 month ago

You're welcome to dig in and see what the Windows APIs show for this device. We're not intentionally omitting the manufacturer that I know of.

AntTheAlchemist commented 1 month ago

After spending a few hours digging and going cross-eyed, I realised I don't know my way around this area well enough to add anything useful. What I did notice is that useful driver information is getting lost in some situations. It's a shame we can't have a global SDL list of devices (using global IDs). Info seems to be lost due to drivers discarding devices, such as the HIDAPI skipping over unmapped joysticks, but still holding on a device with more information that the Windows driver provides - which is a bit selfish of it.

slouken commented 1 month ago

Interesting idea...