1
0
Fork 0

fix ASAN error in sdl_impl.cpp (#7427)

This commit is contained in:
oltolm 2024-02-09 23:08:15 +01:00 committed by GitHub
parent 0c40c10022
commit 3c9157b1ec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 13 additions and 11 deletions

View File

@ -429,18 +429,20 @@ Common::ParamPackage SDLState::GetSDLControllerButtonBindByGUID(
#if SDL_VERSION_ATLEAST(2, 0, 6) #if SDL_VERSION_ATLEAST(2, 0, 6)
{ {
const SDL_ExtendedGameControllerBind extended_bind = if (mapped_button != SDL_CONTROLLER_BUTTON_INVALID) {
controller->bindings[mapped_button]; const SDL_ExtendedGameControllerBind extended_bind =
if (extended_bind.input.axis.axis_max < extended_bind.input.axis.axis_min) { controller->bindings[mapped_button];
params.Set("direction", "-"); if (extended_bind.input.axis.axis_max < extended_bind.input.axis.axis_min) {
} else { params.Set("direction", "-");
params.Set("direction", "+"); } else {
params.Set("direction", "+");
}
params.Set("threshold", (extended_bind.input.axis.axis_min +
(extended_bind.input.axis.axis_max -
extended_bind.input.axis.axis_min) /
2.0f) /
SDL_JOYSTICK_AXIS_MAX);
} }
params.Set(
"threshold",
(extended_bind.input.axis.axis_min +
(extended_bind.input.axis.axis_max - extended_bind.input.axis.axis_min) / 2.0f) /
SDL_JOYSTICK_AXIS_MAX);
} }
#else #else
params.Set("direction", "+"); // lacks extended_bind, so just a guess params.Set("direction", "+"); // lacks extended_bind, so just a guess