Fixed VID/PID list parsing of SDL_HINT_GAMECONTROLLER_SENSOR_FUSION
Fixes https://github.com/libsdl-org/SDL/issues/11118
This commit is contained in:
parent
5db64300b8
commit
81b48de3f5
1 changed files with 19 additions and 26 deletions
|
@ -888,9 +888,6 @@ static bool IsROGAlly(SDL_Joystick *joystick)
|
||||||
|
|
||||||
static bool ShouldAttemptSensorFusion(SDL_Joystick *joystick, bool *invert_sensors)
|
static bool ShouldAttemptSensorFusion(SDL_Joystick *joystick, bool *invert_sensors)
|
||||||
{
|
{
|
||||||
const char *hint;
|
|
||||||
int hint_value;
|
|
||||||
|
|
||||||
SDL_AssertJoysticksLocked();
|
SDL_AssertJoysticksLocked();
|
||||||
|
|
||||||
*invert_sensors = false;
|
*invert_sensors = false;
|
||||||
|
@ -905,30 +902,26 @@ static bool ShouldAttemptSensorFusion(SDL_Joystick *joystick, bool *invert_senso
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
hint = SDL_GetHint(SDL_HINT_GAMECONTROLLER_SENSOR_FUSION);
|
const char *hint = SDL_GetHint(SDL_HINT_GAMECONTROLLER_SENSOR_FUSION);
|
||||||
hint_value = SDL_GetStringInteger(hint, -1);
|
if (hint && *hint) {
|
||||||
if (hint_value > 0) {
|
if (*hint == '@' || SDL_strncmp(hint, "0x", 2) == 0) {
|
||||||
return true;
|
SDL_vidpid_list gamepads;
|
||||||
}
|
SDL_GUID guid;
|
||||||
if (hint_value == 0) {
|
Uint16 vendor, product;
|
||||||
return false;
|
bool enabled;
|
||||||
}
|
SDL_zero(gamepads);
|
||||||
|
|
||||||
if (hint) {
|
// See if the gamepad is in our list of devices to enable
|
||||||
SDL_vidpid_list gamepads;
|
guid = SDL_GetJoystickGUID(joystick);
|
||||||
SDL_GUID guid;
|
SDL_GetJoystickGUIDInfo(guid, &vendor, &product, NULL, NULL);
|
||||||
Uint16 vendor, product;
|
SDL_LoadVIDPIDListFromHints(&gamepads, hint, NULL);
|
||||||
bool enabled;
|
enabled = SDL_VIDPIDInList(vendor, product, &gamepads);
|
||||||
SDL_zero(gamepads);
|
SDL_FreeVIDPIDList(&gamepads);
|
||||||
|
if (enabled) {
|
||||||
// See if the gamepad is in our list of devices to enable
|
return true;
|
||||||
guid = SDL_GetJoystickGUID(joystick);
|
}
|
||||||
SDL_GetJoystickGUIDInfo(guid, &vendor, &product, NULL, NULL);
|
} else {
|
||||||
SDL_LoadVIDPIDListFromHints(&gamepads, hint, NULL);
|
return SDL_GetStringBoolean(hint, false);
|
||||||
enabled = SDL_VIDPIDInList(vendor, product, &gamepads);
|
|
||||||
SDL_FreeVIDPIDList(&gamepads);
|
|
||||||
if (enabled) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue