From 6a0f332e3cf98ef633ed941f4cbceec8794d5c5f Mon Sep 17 00:00:00 2001 From: Aurora Wright Date: Mon, 18 Dec 2017 20:56:32 +0100 Subject: [PATCH] Shutdown when waiting for button presses if the shell is closed, except when coming from a NTRboothax boot --- source/utils.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/source/utils.c b/source/utils.c index 9dff18f..7158d2d 100644 --- a/source/utils.c +++ b/source/utils.c @@ -68,9 +68,11 @@ static u64 chrono(void) u32 waitInput(bool isMenu) { static u64 dPadDelay = 0ULL; + static u32 shouldShellShutdown = 2; u64 initialValue = 0ULL; u32 key, oldKey = HID_PAD; + if(shouldShellShutdown == 2) shouldShellShutdown = (bootType == B9SNTR || bootType == NTR) ? 0 : 1; if(isMenu) { @@ -85,7 +87,13 @@ u32 waitInput(bool isMenu) if(!key) { - if((i2cReadRegister(I2C_DEV_MCU, 0x10) & 1)== 1) mcuPowerOff(); + if((i2cReadRegister(I2C_DEV_MCU, 0x10) & 1) == 1) mcuPowerOff(); + if(!(i2cReadRegister(I2C_DEV_MCU, 0xF) & 2)) + { + if(shouldShellShutdown) mcuPowerOff(); + } + else shouldShellShutdown = 1; + oldKey = 0; dPadDelay = 0; continue;