From b0a5d01a1fa7f52ce2cb3236ca1d5bfba41001e9 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 21 Feb 2024 20:32:38 -0800 Subject: [PATCH] Separate code into M_ClearCurrentControl function --- src/menus/options-profiles-edit-controls.c | 28 ++++++++++++++-------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/menus/options-profiles-edit-controls.c b/src/menus/options-profiles-edit-controls.c index 5075852ab..60761768b 100644 --- a/src/menus/options-profiles-edit-controls.c +++ b/src/menus/options-profiles-edit-controls.c @@ -136,6 +136,23 @@ static void SetDeviceOnPress(void) } */ +static boolean M_ClearCurrentControl(void) +{ + // check if we're on a valid menu option... + if (currentMenu->menuitems[itemOn].mvar1) + { + // clear controls for that key + INT32 i; + + for (i = 0; i < MAXINPUTMAPPING; i++) + optionsmenu.tempcontrols[currentMenu->menuitems[itemOn].mvar1][i] = KEY_NULL; + + return true; + } + + return false; +} + void M_HandleProfileControls(void) { UINT8 maxscroll = currentMenu->numitems - 5; @@ -268,17 +285,8 @@ boolean M_ProfileControlsInputs(INT32 ch) if (M_MenuExtraPressed(pid)) { - // check if we're on a valid menu option... - if (currentMenu->menuitems[itemOn].mvar1) - { - // clear controls for that key - INT32 i; - - for (i = 0; i < MAXINPUTMAPPING; i++) - optionsmenu.tempcontrols[currentMenu->menuitems[itemOn].mvar1][i] = KEY_NULL; - + if (M_ClearCurrentControl()) S_StartSound(NULL, sfx_s3k66); - } M_SetMenuDelay(pid); return true; }