Skip to content

Commit ad60292

Browse files
committed
Support multiple joystick buttons bound to the same gamepad button
(cherry picked from commit ed94331) (cherry picked from commit 74ff82f)
1 parent 9eca707 commit ad60292

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/joystick/SDL_gamecontroller.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2364,23 +2364,19 @@ Uint8 SDL_GameControllerGetButton(SDL_GameController *gamecontroller, SDL_GameCo
23642364
if (binding->input.axis.axis_min < binding->input.axis.axis_max) {
23652365
valid_input_range = (value >= binding->input.axis.axis_min && value <= binding->input.axis.axis_max);
23662366
if (valid_input_range) {
2367-
retval = (value >= threshold) ? SDL_PRESSED : SDL_RELEASED;
2368-
break;
2367+
retval |= (value >= threshold) ? SDL_PRESSED : SDL_RELEASED;
23692368
}
23702369
} else {
23712370
valid_input_range = (value >= binding->input.axis.axis_max && value <= binding->input.axis.axis_min);
23722371
if (valid_input_range) {
2373-
retval = (value <= threshold) ? SDL_PRESSED : SDL_RELEASED;
2374-
break;
2372+
retval |= (value <= threshold) ? SDL_PRESSED : SDL_RELEASED;
23752373
}
23762374
}
23772375
} else if (binding->inputType == SDL_CONTROLLER_BINDTYPE_BUTTON) {
2378-
retval = SDL_JoystickGetButton(gamecontroller->joystick, binding->input.button);
2379-
break;
2376+
retval |= SDL_JoystickGetButton(gamecontroller->joystick, binding->input.button);
23802377
} else if (binding->inputType == SDL_CONTROLLER_BINDTYPE_HAT) {
23812378
int hat_mask = SDL_JoystickGetHat(gamecontroller->joystick, binding->input.hat.hat);
2382-
retval = (hat_mask & binding->input.hat.hat_mask) ? SDL_PRESSED : SDL_RELEASED;
2383-
break;
2379+
retval |= (hat_mask & binding->input.hat.hat_mask) ? SDL_PRESSED : SDL_RELEASED;
23842380
}
23852381
}
23862382
}

0 commit comments

Comments
 (0)