void error(const char *message) { initScreens(); clearScreens(); drawString("An error has occurred:", 10, 10, COLOR_RED); int posY = drawString(message, 10, 30, COLOR_WHITE); drawString("Press any button to shutdown", 10, posY + 2 * SPACING_Y, COLOR_WHITE); waitInput(); mcuPowerOff(); }
void error(const char *message) { if(isFirmlaunch) mcuReboot(); initScreens(); drawString("An error has occurred:", true, 10, 10, COLOR_RED); u32 posY = drawString(message, true, 10, 30, COLOR_WHITE); drawString("Press any button to shutdown", true, 10, posY + 2 * SPACING_Y, COLOR_WHITE); waitInput(); mcuPowerOff(); }
void error(const char *fmt, ...) { char buf[DRAW_MAX_FORMATTED_STRING_SIZE + 1]; va_list args; va_start(args, fmt); vsprintf(buf, fmt, args); va_end(args); if(!isFirmlaunch) { initScreens(); drawString(true, 10, 10, COLOR_RED, "An error has occurred:"); u32 posY = drawString(true, 10, 30, COLOR_WHITE, buf); drawString(true, 10, posY + 2 * SPACING_Y, COLOR_WHITE, "Press any button to shutdown"); waitInput(false); } else fileWrite(buf, "firmlauncherror.txt", strlen(buf)); mcuPowerOff(); }
u32 waitInput(bool isMenu) { static u64 dPadDelay = 0ULL; u64 initialValue = 0ULL; u32 key, oldKey = HID_PAD; if(isMenu) { dPadDelay = dPadDelay > 0ULL ? 87ULL : 143ULL; startChrono(); initialValue = chrono(); } while(true) { key = HID_PAD; if(!key) { if((i2cReadRegister(I2C_DEV_MCU, 0x10) & 1)== 1) mcuPowerOff(); oldKey = 0; dPadDelay = 0; continue; } if(key == oldKey && (!isMenu || (!(key & DPAD_BUTTONS) || chrono() - initialValue < dPadDelay))) continue; //Make sure the key is pressed u32 i; for(i = 0; i < 0x13000 && key == HID_PAD; i++); if(i == 0x13000) break; } return key; }