From 0ce39e61becfa7942a33c5856f4570c4fb166481 Mon Sep 17 00:00:00 2001 From: Maschell Date: Sat, 29 Jun 2024 19:25:17 +0200 Subject: [PATCH] Another attempt to make quick starting (aborting) more reliable --- source/QuickStartUtils.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/source/QuickStartUtils.cpp b/source/QuickStartUtils.cpp index 485b08b..50f15cf 100644 --- a/source/QuickStartUtils.cpp +++ b/source/QuickStartUtils.cpp @@ -1,13 +1,10 @@ -#include - +#include "QuickStartUtils.h" #include "BootUtils.h" #include "MenuUtils.h" -#include "QuickStartUtils.h" #include "logger.h" #include #include -#include #include #include #include @@ -118,11 +115,12 @@ private: class QuickStartAutoAbort { public: QuickStartAutoAbort() { - OSCreateAlarm(&mAlarm); + OSCreateAlarm(&mDRCConnectedAlarm); OSSetPeriodicAlarm(&mDRCConnectedAlarm, - OSSecondsToTicks(10), + OSGetTime() + OSSecondsToTicks(10), OSSecondsToTicks(1), &AbortOnDRCDisconnect); + OSCreateAlarm(&mAlarm); OSSetAlarm(&mAlarm, OSSecondsToTicks(120), AbortQuickStartTitle); mDRCConnected = IsDRCConnected(); } @@ -130,6 +128,9 @@ public: OSCancelAlarm(&mDRCConnectedAlarm); OSCancelAlarm(&mAlarm); + OSWaitAlarm(&mDRCConnectedAlarm); + OSWaitAlarm(&mAlarm); + // Reconnect the DRC if it was connected at launch but then disconnected; if (mDRCConnected && !IsDRCConnected()) { DEBUG_FUNCTION_LINE("Wake up GamePad"); @@ -140,12 +141,14 @@ public: static bool IsDRCConnected() { CCRCDCDrcState state = {}; - CCRCDCSysGetDrcState(CCR_CDC_DESTINATION_DRC0, &state); - return state.state != 0; + if (CCRCDCSysGetDrcState(CCR_CDC_DESTINATION_DRC0, &state) != 0) { + return false; + } + return true; } static void AbortQuickStartTitle(OSAlarm *alarm, OSContext *) { - DEBUG_FUNCTION_LINE("Selecting a title takes too long, lets abort the quick start menu"); + DEBUG_FUNCTION_LINE_INFO("GamePad was disconnected, lets abort the quick start menu"); CCRSysCaffeineBootCheckAbort(); }