Skip to content

Omit mappings handled by SDL's HIDAPI or XInput driversΒ #478

@cgutman

Description

@cgutman

This is a continuation of the discussion from 9219d19, moonlight-stream/moonlight-qt#620, and #477. I took a look at the SDL code to figure out what's going on.

Some of the mapping GUIDs have special suffixes that mean they are associated with a particular API:
https://github.com/libsdl-org/SDL/blob/c59d4dcd38c382a1e9b69b053756f1139a861574/src/joystick/windows/SDL_xinputjoystick.c#L279-L280
https://github.com/libsdl-org/SDL/blob/b63cb822bf02ffa53e7a25755ff4606af0417389/src/joystick/hidapi/SDL_hidapijoystick.c#L918-L920

The trouble is that these special APIs almost always have an existing mapping built into SDL like this one for HIDAPI. Allowing mappings for these special APIs here creates the possibility for error like we've seen here.

For HIDAPI joysticks, this suffix is 6800 (0x68 = 'h') which is exactly what the suffix of the broken mapping is from 9219d19. The mistake there seems to be that they assumed it would be equivalent to the non-HIDAPI mapping for a PS4 Controller. This is not the case, since HIDAPI does not necessarily expose all axes and buttons in the same order that DirectInput does.

There is a similar case for XInput joysticks, where 78XX(0x78 = 'x', XX is the XInput subtype) is the magic suffix. Due to the unnecessary mapping in here, an ordinary Xbox 360 controller shows up as a ShanWan PS3/PC Wired GamePad when using the XInput API. We should definitely remove this mapping, because it's unnecessary and causes the much more common official Microsoft Xbox 360 controller to be mistaken for some knock-off PS3 controller (though at least the mapping is correct).

Due to these issues, I propose we remove all existing mappings where the last 2 bytes are 6800 or 78XX and closely scrutinize any attempts to add more. Mappings for these special controllers should only be necessary in the extremely rare case of a third-party Xbox/PlayStation/Nintendo gamepad that doesn't behave like the standard ones or very specialized hardware like a dance pad, guitar, or something that isn't used like a "normal" controller.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions