From b838f8b41df071d5222a4cfeaa71d3199bf1b68b Mon Sep 17 00:00:00 2001 From: Nathaniel Walizer Date: Tue, 14 Jan 2025 02:28:21 -0800 Subject: [PATCH] Add save/load bindings to shoulder buttons --- src/sdl_input.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/sdl_input.c b/src/sdl_input.c index 7a235bd..d3b79d2 100644 --- a/src/sdl_input.c +++ b/src/sdl_input.c @@ -68,6 +68,9 @@ static const int sdl_keycodes[nes_controller_num_buttons] = { SDLK_RIGHT, }; +static const int sdl_save_button = SDL_CONTROLLER_BUTTON_LEFTSHOULDER; +static const int sdl_load_button = SDL_CONTROLLER_BUTTON_RIGHTSHOULDER; + static const int sdl_buttons[nes_controller_num_buttons] = { SDL_CONTROLLER_BUTTON_A, SDL_CONTROLLER_BUTTON_B, @@ -138,6 +141,20 @@ static int sdl_input_update(nes_Input_Reader* reader, } else { input->controllers[0].buttons &= ~mask; } + + } else if (sdl_save_button == event.cbutton.button) { + if (SDL_CONTROLLERBUTTONDOWN == event.type) { + status = input_Result_Save; + } else { + status = input_Result_Cancel; + } + + } else if (sdl_load_button == event.cbutton.button) { + if (SDL_CONTROLLERBUTTONDOWN == event.type) { + status = input_Result_Load; + } else { + status = input_Result_Cancel; + } } } else if (SDL_CONTROLLERAXISMOTION == event.type) {