Qt: Fix up SDL3 button binding.

This commit is contained in:
BearOso 2024-12-13 19:04:56 -06:00
parent fa94c74b84
commit 03ec60cfda
2 changed files with 6 additions and 4 deletions

View File

@ -6,6 +6,7 @@
#include "s9x_sound_driver_sdl3.hpp" #include "s9x_sound_driver_sdl3.hpp"
#include "SDL3/SDL_audio.h" #include "SDL3/SDL_audio.h"
#include <cstdio>
#include <vector> #include <vector>
bool S9xSDL3SoundDriver::write_samples(int16_t *data, int samples) bool S9xSDL3SoundDriver::write_samples(int16_t *data, int samples)

View File

@ -110,10 +110,10 @@ void ControllerPanel::autoPopulateWithJoystick(int joystick_id, int slot)
SDL_GAMEPAD_BUTTON_DPAD_LEFT, SDL_GAMEPAD_BUTTON_DPAD_LEFT,
SDL_GAMEPAD_BUTTON_DPAD_RIGHT, SDL_GAMEPAD_BUTTON_DPAD_RIGHT,
// B, A and X, Y are inverted on XInput vs SNES // B, A and X, Y are inverted on XInput vs SNES
SDL_GAMEPAD_BUTTON_SOUTH,
SDL_GAMEPAD_BUTTON_EAST, SDL_GAMEPAD_BUTTON_EAST,
SDL_GAMEPAD_BUTTON_WEST, SDL_GAMEPAD_BUTTON_SOUTH,
SDL_GAMEPAD_BUTTON_NORTH, SDL_GAMEPAD_BUTTON_NORTH,
SDL_GAMEPAD_BUTTON_WEST,
SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER,
SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER,
SDL_GAMEPAD_BUTTON_START, SDL_GAMEPAD_BUTTON_START,
@ -125,7 +125,8 @@ void ControllerPanel::autoPopulateWithJoystick(int joystick_id, int slot)
auto get_binding_for_button = [&](SDL_GamepadButton button) -> SDL_GamepadBinding auto get_binding_for_button = [&](SDL_GamepadButton button) -> SDL_GamepadBinding
{ {
for (int i = 0; i < num_bindings; i++) for (int i = 0; i < num_bindings; i++)
if (bindings[i]->output.button == button) if (bindings[i]->output_type == SDL_GAMEPAD_BINDTYPE_BUTTON &&
bindings[i]->output.button == button)
return *bindings[i]; return *bindings[i];
return SDL_GamepadBinding{}; return SDL_GamepadBinding{};
}; };