SDL: Revert "More than one binding might trigger a gamepad button"

From 538292c1dab1705194dfb2d531c0b712a28d89c3 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sun, 16 Jul 2023 03:18:51 -0700
Subject: [PATCH] Revert "More than one binding might trigger a gamepad button"

This reverts commit 6251504ac8aeb632cba5c9bb3502ad3628bc1bb3.

This is added CPU cost for a use case that was never supported. testcontroller will explicitly clear any previous binding, so I'm backing this out until there is a good use case.
---
 src/joystick/SDL_gamepad.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/src/joystick/SDL_gamepad.c b/src/joystick/SDL_gamepad.c
index 509d54050c54..5e81037d07de 100644
--- a/src/joystick/SDL_gamepad.c
+++ b/src/joystick/SDL_gamepad.c
@@ -269,6 +269,7 @@ static void HandleJoystickButton(Uint64 timestamp, SDL_Gamepad *gamepad, int but
             } else {
                 SDL_SendGamepadButton(timestamp, gamepad, binding->output.button, state);
             }
+            break;
         }
     }
 }
@@ -2423,28 +2424,24 @@ Uint8 SDL_GetGamepadButton(SDL_Gamepad *gamepad, SDL_GamepadButton button)
                     int threshold = binding->input.axis.axis_min + (binding->input.axis.axis_max - binding->input.axis.axis_min) / 2;
                     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 && value >= threshold) {
-                            retval = SDL_PRESSED;
+                        if (valid_input_range) {
+                            retval = (value >= threshold) ? SDL_PRESSED : SDL_RELEASED;
                             break;
                         }
                     } else {
                         valid_input_range = (value >= binding->input.axis.axis_max && value <= binding->input.axis.axis_min);
-                        if (valid_input_range && value <= threshold) {
-                            retval = SDL_PRESSED;
+                        if (valid_input_range) {
+                            retval = (value <= threshold) ? SDL_PRESSED : SDL_RELEASED;
                             break;
                         }
                     }
                 } else if (binding->inputType == SDL_GAMEPAD_BINDTYPE_BUTTON) {
-                    if (SDL_GetJoystickButton(gamepad->joystick, binding->input.button)) {
-                        retval = SDL_TRUE;
-                        break;
-                    }
+                    retval = SDL_GetJoystickButton(gamepad->joystick, binding->input.button);
+                    break;
                 } else if (binding->inputType == SDL_GAMEPAD_BINDTYPE_HAT) {
                     int hat_mask = SDL_GetJoystickHat(gamepad->joystick, binding->input.hat.hat);
-                    if (hat_mask & binding->input.hat.hat_mask) {
-                        retval = SDL_TRUE;
-                        break;
-                    }
+                    retval = (hat_mask & binding->input.hat.hat_mask) ? SDL_PRESSED : SDL_RELEASED;
+                    break;
                 }
             }
         }