fatal: Finish CheckRepairStatus

This commit is contained in:
Michael Scire 2018-11-10 13:38:17 -08:00
parent f7a7ce1847
commit caf9d11c8c

View file

@ -32,24 +32,26 @@ static bool InRepairWithoutVolHeld() {
{ {
GpioPadSession vol_btn; GpioPadSession vol_btn;
if (R_SUCCEEDED(gpioOpenSession(&vol_btn, GpioPadName_ButtonVolUp))) { if (R_FAILED(gpioOpenSession(&vol_btn, GpioPadName_ButtonVolUp))) {
/* Ensure we close even on early return. */ return true;
ON_SCOPE_EXIT { gpioPadClose(&vol_btn); }; }
/* Set direction input. */ /* Ensure we close even on early return. */
gpioPadSetDirection(&vol_btn, GpioDirection_Input); ON_SCOPE_EXIT { gpioPadClose(&vol_btn); };
/* Ensure that we're holding the volume button for a full second. */ /* Set direction input. */
TimeoutHelper timeout_helper(1000000000UL); gpioPadSetDirection(&vol_btn, GpioDirection_Input);
while (!timeout_helper.TimedOut()) {
GpioValue val;
if (R_FAILED(gpioPadGetValue(&vol_btn, &val)) || val != GpioValue_Low) {
return true;
}
/* Sleep for 100 ms. */ /* Ensure that we're holding the volume button for a full second. */
svcSleepThread(100000000UL); TimeoutHelper timeout_helper(1000000000UL);
while (!timeout_helper.TimedOut()) {
GpioValue val;
if (R_FAILED(gpioPadGetValue(&vol_btn, &val)) || val != GpioValue_Low) {
return true;
} }
/* Sleep for 100 ms. */
svcSleepThread(100000000UL);
} }
} }
@ -66,11 +68,31 @@ static bool InRepairWithoutTimeReviserCartridge() {
return false; return false;
} }
/* TODO: if (!IsGamecardInserted()) { return true; } */ FsGameCardHandle gc_hnd;
u8 gc_attr;
{
FsDeviceOperator devop;
if (R_FAILED(fsOpenDeviceOperator(&devop))) {
return true;
}
/* TODO: return GetGameCardAttribute(GetGameCardHandle()) & GameCardAttribute_Repair == GameCardAttribute_Repair; */ /* Ensure we close even on early return. */
ON_SCOPE_EXIT { fsDeviceOperatorClose(&devop); };
return false; /* Check that a gamecard is inserted. */
bool inserted;
if (R_FAILED(fsDeviceOperatorIsGameCardInserted(&devop, &inserted)) || !inserted) {
return true;
}
/* Check that we can retrieve the gamecard's attributes. */
if (R_FAILED(fsDeviceOperatorGetGameCardHandle(&devop, &gc_hnd)) || R_FAILED(fsDeviceOperatorGetGameCardAttribute(&devop, &gc_hnd, &gc_attr))) {
return true;
}
}
/* Check that the gamecard is a repair tool. */
return (gc_attr & FsGameCardAttribute_Repair) == FsGameCardAttribute_Repair;
} }
void CheckRepairStatus() { void CheckRepairStatus() {