You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reported in version: 2.0.15 Reported for operating system, platform: Windows 10, x86_64
Comments on the original bug report:
On 2021-01-18 12:29:13 +0000, wrote:
Created attachment 4678
Partially-complete patch for Joy-Con analog/sensor support
This is a mostly functional patch that adds the hint SDL_JOYSTICK_HIDAPI_JOY_CONS to recognize Joy-Cons as Switch Pro Controllers (mostly) when SDL_JOYSTICK_HIDAPI_SWITCH is also enabled. But I'm not seeking to have it merged in yet -- I'm seeking help to get it working properly, but I think I've gotten it most of the way there with this patch.
When SDL_JOYSTICK_HIDAPI_JOY_CONS is enabled, this works exactly as I'd hoped -- Joy-Con home button lights up, sensor axes are changed to match other controllers, analog inputs are detected, buttons are mapped correctly, etc. In order to detect Joy-Cons as HIDAPI controllers, I've uncommented these lines in controller_type.h and then treating them as Switch Pro Controllers if this hint is enabled (with some device-specifics handled in SDL_hidapi_switch.c), but it seems Joy-Cons are just not working at all with this patch if the hint is not enabled, so I'm looking for some input/direction.
In SDL_GetJoystickGameControllerType I check SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS. If it is enabled and the controller is a Joy-Con, I have it return SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO and everything works fine and dandy from there.
If the hint is not enabled, I return SDL_CONTROLLER_TYPE_UNKNOWN instead. This was in the hopes that the default behaviour of a Joy-Con would be restored in this case. However, in my tests, no input is detected from the Joy-Cons anymore when the hint is disabled.
I suspect including Joy-Cons in the list in controller_type.h at all is flagging it as a HIDAPI controller and default behaviour is being skipped. As far as I can tell, including them in that array in controller_type.h at all is the only difference visible to anything else when that hint is disabled, so that's my best guess. If that's the case, I can't think of a way to only include the Joy-Cons in this list of controller types on the condition of this hint being enabled.
Is there a better way to do this? And is this generally a good way to go about doing this (adding a hint so we can take advantage of Joy-Cons without changing the default behaviour for whomever is used to the more limited live behaviour)?
If we can support the Joy-Cons properly with sensor support like I have working in this patch, SDL covers all the device-specific behaviour of my library and I can encourage my users to use SDL for wider controller support.
This bug report was migrated from our old Bugzilla tracker.
These attachments are available in the static archive:
Reported in version: 2.0.15
Reported for operating system, platform: Windows 10, x86_64
Comments on the original bug report:
On 2021-01-18 12:29:13 +0000, wrote:
On 2021-01-23 17:41:58 +0000, Sam Lantinga wrote:
The text was updated successfully, but these errors were encountered: