From 64587477cd558f378fea64071ca0c82cbd2d0f3c Mon Sep 17 00:00:00 2001 From: Lockl00p <97256723+Lockl00p@users.noreply.github.com> Date: Thu, 23 May 2024 22:20:38 -0500 Subject: [PATCH] Fix issue with A button being automatically selected when changing keybinds --- README.md | 1 + console.c | 4 +++- sys_switch.c | 9 +++++++++ vid_sdl.c | 9 +++++++-- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e4de8552..50385096 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,7 @@ Note: This requires a modded switch. 3. Build using `DP_MAKE_TARGET=switch make sdl-release`. 4. Copy `darkplaces-sdl.nro` to your switch's SD Card (under `/switch`) 5. Make the `/switch/darkplaces` directory. +(Press Minus to save any config changes) (Basedir is `/switch/darkplaces/(switch username)`) ## Contributing diff --git a/console.c b/console.c index a33264c1..e21f66a3 100644 --- a/console.c +++ b/console.c @@ -929,7 +929,9 @@ void Con_Init (void) Cmd_AddCommand(CF_SHARED, "clear", Con_Clear_f, "clear console history"); Cmd_AddCommand(CF_SHARED, "maps", Con_Maps_f, "list information about available maps"); Cmd_AddCommand(CF_SHARED, "condump", Con_ConDump_f, "output console history to a file (see also log_file)"); - + #ifdef __SWITCH__ + Sys_Register_Commands(); + #endif con_initialized = true; } diff --git a/sys_switch.c b/sys_switch.c index 119d4fa2..61c8a3a1 100644 --- a/sys_switch.c +++ b/sys_switch.c @@ -76,6 +76,15 @@ int StartupError(char message[]){ } } +void menu_enter_f(cmd_state_t *cmd) +{ + Key_Event(K_ENTER,0,true); + Key_Event(K_ENTER,0,false); +} + +void Sys_Register_Commands(){ + Cmd_AddCommand(CF_SHARED, "emulate_enter", menu_enter_f, "Emulate pressing Enter"); +} int main(int argc, char *argv[]) { diff --git a/vid_sdl.c b/vid_sdl.c index fc580002..0bf349eb 100644 --- a/vid_sdl.c +++ b/vid_sdl.c @@ -1125,8 +1125,10 @@ void Sys_SDL_HandleEvents(void) case SDL_JOYBUTTONDOWN: #ifdef __SWITCH__ if(event.jbutton.button == 0){ - Key_Event( K_ENTER, 0, true ); - Key_Event( K_ENTER, 0, false ); + SDL_FlushEvent(SDL_JOYBUTTONDOWN); + SDL_FlushEvent(SDL_JOYBUTTONUP); + Cbuf_AddText(cmd_local, "\nwait\nwait\nwait\n\nemulate_enter\n"); + } else if(event.jbutton.button == 13){ Key_Event( K_UPARROW, 0, true ); @@ -1152,6 +1154,9 @@ void Sys_SDL_HandleEvents(void) Key_Event( K_BACKSPACE, 0, true ); Key_Event( K_BACKSPACE, 0, false ); } + else if(event.jbutton.button == 11){ + Cbuf_AddText(cmd_local, "\nsaveconfig\n"); + } break; #endif -- 2.39.2