mirror of https://github.com/libsdl-org/SDL.git
Support multiple joystick buttons bound to the same gamepad button
(cherry picked from commit ed943318e2)
This commit is contained in:
parent
67b537cef4
commit
74ff82f4a2
|
|
@ -2364,23 +2364,19 @@ Uint8 SDL_GameControllerGetButton(SDL_GameController *gamecontroller, SDL_GameCo
|
|||
if (binding->input.axis.axis_min < binding->input.axis.axis_max) {
|
||||
valid_input_range = (value >= binding->input.axis.axis_min && value <= binding->input.axis.axis_max);
|
||||
if (valid_input_range) {
|
||||
retval = (value >= threshold) ? SDL_PRESSED : SDL_RELEASED;
|
||||
break;
|
||||
retval |= (value >= threshold) ? SDL_PRESSED : SDL_RELEASED;
|
||||
}
|
||||
} else {
|
||||
valid_input_range = (value >= binding->input.axis.axis_max && value <= binding->input.axis.axis_min);
|
||||
if (valid_input_range) {
|
||||
retval = (value <= threshold) ? SDL_PRESSED : SDL_RELEASED;
|
||||
break;
|
||||
retval |= (value <= threshold) ? SDL_PRESSED : SDL_RELEASED;
|
||||
}
|
||||
}
|
||||
} else if (binding->inputType == SDL_CONTROLLER_BINDTYPE_BUTTON) {
|
||||
retval = SDL_JoystickGetButton(gamecontroller->joystick, binding->input.button);
|
||||
break;
|
||||
retval |= SDL_JoystickGetButton(gamecontroller->joystick, binding->input.button);
|
||||
} else if (binding->inputType == SDL_CONTROLLER_BINDTYPE_HAT) {
|
||||
int hat_mask = SDL_JoystickGetHat(gamecontroller->joystick, binding->input.hat.hat);
|
||||
retval = (hat_mask & binding->input.hat.hat_mask) ? SDL_PRESSED : SDL_RELEASED;
|
||||
break;
|
||||
retval |= (hat_mask & binding->input.hat.hat_mask) ? SDL_PRESSED : SDL_RELEASED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue