diff --git a/sysmodules/rosalina/include/menu.h b/sysmodules/rosalina/include/menu.h index 9cf5a26..6fcc48b 100644 --- a/sysmodules/rosalina/include/menu.h +++ b/sysmodules/rosalina/include/menu.h @@ -78,6 +78,9 @@ extern u32 menuCombo; u32 waitInputWithTimeout(u32 msec); u32 waitInput(void); +u32 waitComboWithTimeout(u32 msec); +u32 waitCombo(void); + MyThread *menuCreateThread(void); void menuEnter(void); void menuLeave(void); diff --git a/sysmodules/rosalina/source/menu.c b/sysmodules/rosalina/source/menu.c index 087a56c..5c242eb 100644 --- a/sysmodules/rosalina/source/menu.c +++ b/sysmodules/rosalina/source/menu.c @@ -81,6 +81,47 @@ u32 waitInput(void) return waitInputWithTimeout(0); } +u32 waitComboWithTimeout(u32 msec) +{ + u32 key = 0; + u32 n = 0; + + //Wait for no keys to be pressed + while(HID_PAD && !terminationRequest && (msec == 0 || n < msec)) + { + svcSleepThread(1 * 1000 * 1000LL); + n++; + } + + if(terminationRequest || (msec != 0 && n >= msec)) + return 0; + + do + { + svcSleepThread(1 * 1000 * 1000LL); + n++; + + u32 tempKey = HID_PAD; + + for(u32 i = 0x26000; i > 0; i--) + { + if(tempKey != HID_PAD) break; + if(i == 1) key = tempKey; + } + } + while((!key || HID_PAD) && !terminationRequest && (msec == 0 || n < msec)); + + if(terminationRequest || (msec != 0 && n >= msec)) + return 0; + + return key; +} + +u32 waitCombo(void) +{ + return waitComboWithTimeout(0); +} + static Result _MCUHWC_GetBatteryLevel(u8 *out) { #define TRY(expr) if(R_FAILED(res = (expr))) { svcCloseHandle(mcuhwcHandle); return res; } diff --git a/sysmodules/rosalina/source/menus/miscellaneous.c b/sysmodules/rosalina/source/menus/miscellaneous.c index 06f3c5e..840ada2 100644 --- a/sysmodules/rosalina/source/menus/miscellaneous.c +++ b/sysmodules/rosalina/source/menus/miscellaneous.c @@ -146,7 +146,7 @@ void MiscellaneousMenu_ChangeMenuCombo(void) Draw_FlushFramebuffer(); Draw_Unlock(); - menuCombo = waitInput(); + menuCombo = waitCombo(); MiscellaneousMenu_ConvertComboToString(comboStr, menuCombo); do