From d2f48eda297f86daff8f6b1f1198d9739ab02113 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 18 Feb 2024 00:38:16 -0800 Subject: [PATCH] Menus/Controls: RESET TO DEFAULT and CLEAR ALL buttons --- src/k_menu.h | 2 + src/menus/options-profiles-edit-controls.c | 51 ++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/src/k_menu.h b/src/k_menu.h index a623aedb3..5218f2cd9 100644 --- a/src/k_menu.h +++ b/src/k_menu.h @@ -1068,6 +1068,8 @@ boolean M_ProfileEditInputs(INT32 ch); void M_HandleProfileControls(void); boolean M_ProfileControlsInputs(INT32 ch); void M_ProfileSetControl(INT32 ch); +void M_ProfileDefaultControls(INT32 ch); +void M_ProfileClearControls(INT32 ch); void M_MapProfileControl(event_t *ev); void M_ProfileTryController(INT32 choice); diff --git a/src/menus/options-profiles-edit-controls.c b/src/menus/options-profiles-edit-controls.c index 47750759b..1968c5d96 100644 --- a/src/menus/options-profiles-edit-controls.c +++ b/src/menus/options-profiles-edit-controls.c @@ -1,6 +1,7 @@ /// \file menus/options-profiles-edit-controls.c /// \brief Profile Controls Editor +#include "../g_input.h" #include "../k_menu.h" #include "../s_sound.h" #include "../i_joy.h" // for joystick menu controls @@ -88,6 +89,12 @@ menuitem_t OPTIONS_ProfileControls[] = { {IT_STRING | IT_CALL, "TRY MAPPINGS", "Test your controls.", NULL, {.routine = M_ProfileTryController}, 0, 0}, + {IT_STRING | IT_CALL, "RESET TO DEFAULT", "Reset all controls back to default.", + NULL, {.routine = M_ProfileDefaultControls}, 0, 0}, + + {IT_STRING | IT_CALL, "CLEAR ALL", "Unbind all controls.", + NULL, {.routine = M_ProfileClearControls}, 0, 0}, + {IT_STRING | IT_CALL, "CONFIRM", "Go back to profile setup.", NULL, {.routine = M_ProfileControlsConfirm}, 0, 0}, }; @@ -290,6 +297,50 @@ void M_ProfileSetControl(INT32 ch) optionsmenu.bindtimer = TICRATE*5; } +static void M_ProfileDefaultControlsResponse(INT32 ch) +{ + if (ch == MA_YES) + { + memcpy(&optionsmenu.tempcontrols, gamecontroldefault, sizeof optionsmenu.tempcontrols); + S_StartSound(NULL, sfx_s24f); + } +} + +void M_ProfileDefaultControls(INT32 ch) +{ + (void)ch; + M_StartMessage( + "Profiles", + "Reset all controls to the default mappings?", + &M_ProfileDefaultControlsResponse, + MM_YESNO, + NULL, + NULL + ); +} + +static void M_ProfileClearControlsResponse(INT32 ch) +{ + if (ch == MA_YES) + { + memset(&optionsmenu.tempcontrols, 0, sizeof optionsmenu.tempcontrols); + S_StartSound(NULL, sfx_s3k66); + } +} + +void M_ProfileClearControls(INT32 ch) +{ + (void)ch; + M_StartMessage( + "Profiles", + "Clear all control bindings?", + &M_ProfileClearControlsResponse, + MM_YESNO, + NULL, + NULL + ); +} + // Map the event to the profile. #define KEYHOLDFOR 1