Add a B/1 button press to cancel the button remapping prompt (#1037)

* Add B/1 button press to cancel button remapping

* Add another nunchuck case and omit a couple unused cases
This commit is contained in:
InfiniteBlueGX 2022-10-27 10:56:46 -05:00 committed by GitHub
parent c1bbda273b
commit 9b3eccf8a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -95,6 +95,7 @@ static char progressTitle[101];
static char progressMsg[201];
static int progressDone = 0;
static int progressTotal = 0;
static bool buttonMappingCancelled = false;
u8 * bg_music;
u32 bg_music_size;
@ -2919,7 +2920,8 @@ ButtonMappingWindow()
u32 pressed = 0;
while(pressed == 0)
buttonMappingCancelled = false;
while(pressed == 0 && !buttonMappingCancelled)
{
usleep(THREAD_SLEEP);
@ -2935,10 +2937,22 @@ ButtonMappingWindow()
if(userInput[0].wpad->btns_d == WPAD_BUTTON_HOME)
pressed = WPAD_BUTTON_HOME;
if(userInput[0].wpad->btns_d & WPAD_CLASSIC_BUTTON_B ||
userInput[0].wpad->btns_d & WPAD_BUTTON_B ||
userInput[0].wpad->btns_d & WPAD_BUTTON_1 ||
userInput[0].wiidrcdata.btns_d & WIIDRC_BUTTON_B)
buttonMappingCancelled = true;
}
else if(mapMenuCtrl == CTRLR_WIIDRC)
{
pressed = userInput[0].wiidrcdata.btns_d;
if(userInput[0].wpad->btns_d & WPAD_CLASSIC_BUTTON_B ||
userInput[0].wpad->btns_d & WPAD_BUTTON_B ||
userInput[0].wpad->btns_d & WPAD_BUTTON_1 ||
userInput[0].pad.btns_d & PAD_BUTTON_B)
buttonMappingCancelled = true;
}
else
{
@ -2952,24 +2966,47 @@ ButtonMappingWindow()
case CTRLR_WIIMOTE:
if(pressed > 0x1000)
pressed = 0; // not a valid input
if(userInput[0].pad.btns_d & PAD_BUTTON_B ||
userInput[0].wiidrcdata.btns_d & WIIDRC_BUTTON_B ||
userInput[0].wpad->btns_d & WPAD_CLASSIC_BUTTON_B)
buttonMappingCancelled = true;
break;
case CTRLR_CLASSIC:
if(userInput[0].wpad->exp.type != WPAD_EXP_CLASSIC && userInput[0].wpad->exp.classic.type < 2)
pressed = 0; // not a valid input
else if(userInput[0].wpad->exp.type == WPAD_EXP_NUNCHUK)
pressed = 0; // not a valid input (Nunchuk Z/C is assigned as Classic Controller Up/Left for some reason)
else if(pressed <= 0x1000)
pressed = 0;
if(userInput[0].pad.btns_d & PAD_BUTTON_B ||
userInput[0].wiidrcdata.btns_d & WIIDRC_BUTTON_B ||
userInput[0].wpad->btns_d & WPAD_BUTTON_B ||
userInput[0].wpad->btns_d & WPAD_BUTTON_1)
buttonMappingCancelled = true;
break;
case CTRLR_WUPC:
if(userInput[0].wpad->exp.type != WPAD_EXP_CLASSIC && userInput[0].wpad->exp.classic.type == 2)
pressed = 0; // not a valid input
else if(pressed <= 0x1000)
pressed = 0;
if(userInput[0].pad.btns_d & PAD_BUTTON_B ||
userInput[0].wiidrcdata.btns_d & WIIDRC_BUTTON_B ||
userInput[0].wpad->btns_d & WPAD_BUTTON_B ||
userInput[0].wpad->btns_d & WPAD_BUTTON_1)
buttonMappingCancelled = true;
break;
case CTRLR_NUNCHUK:
if(userInput[0].wpad->exp.type != WPAD_EXP_NUNCHUK)
pressed = 0; // not a valid input
if((userInput[0].wpad->exp.type != WPAD_EXP_NUNCHUK && userInput[0].wpad->btns_d & WPAD_BUTTON_B) ||
(userInput[0].wpad->exp.type != WPAD_EXP_NUNCHUK && userInput[0].wpad->btns_d & WPAD_BUTTON_1) ||
userInput[0].pad.btns_d & PAD_BUTTON_B ||
userInput[0].wiidrcdata.btns_d & WIIDRC_BUTTON_B ||
userInput[0].wpad->btns_d & WPAD_CLASSIC_BUTTON_B)
buttonMappingCancelled = true;
break;
}
}
@ -3138,8 +3175,13 @@ static int MenuSettingsMappingsMap()
if(ret >= 0)
{
// get a button selection from user
btnmap[mapMenuCtrlSNES][mapMenuCtrl][ret] = ButtonMappingWindow();
int buttonPressed = ButtonMappingWindow();
if (!buttonMappingCancelled)
{
// get a button selection from user if the remap wasn't cancelled
btnmap[mapMenuCtrlSNES][mapMenuCtrl][ret] = buttonPressed;
}
}
if(ret >= 0 || firstRun)