From 2660725f423e6557e5f8002f68c8114f3fc22756 Mon Sep 17 00:00:00 2001 From: N2614 Date: Tue, 7 Jun 2011 08:11:08 +0000 Subject: [PATCH] =?UTF-8?q?AC=E3=82=A2=E3=83=80=E3=83=97=E3=82=BF=E7=8A=B6?= =?UTF-8?q?=E6=85=8B=E3=81=AFAPI=E4=BA=92=E6=8F=9B=E6=80=A7=E3=81=8C?= =?UTF-8?q?=E3=81=AA=E3=81=84=E3=81=9F=E3=82=81mcu=E3=81=8B=E3=82=89?= =?UTF-8?q?=E3=83=AA=E3=83=BC=E3=83=89=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@328 385bec56-5757-e545-9c3a-d8741f4650f1 --- .../sources/common/Util.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/trunk/ConsoleDataMigration/sources/common/Util.cpp b/trunk/ConsoleDataMigration/sources/common/Util.cpp index 177d7d4..45082ec 100644 --- a/trunk/ConsoleDataMigration/sources/common/Util.cpp +++ b/trunk/ConsoleDataMigration/sources/common/Util.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include "Util.h" #include "FileName.h" @@ -207,7 +208,23 @@ void Util::GetSaveDataDirectoryRoot(::std::string& sysSaveRoot, void* ivs, size_ bool Util::IsAdapterConnected() { - return nn::ptm::CTR::GetAdapterState() == nn::ptm::CTR::ADAPTERSTATE_CONNECTED; + static nn::os::Tick last(0); + static bool lastResult = false; + const u8 UPDATE_INTERVAL = 100; + + nn::os::Tick now = nn::os::Tick::GetSystemCurrent(); + if(last == 0 || (now - last).ToTimeSpan().GetMilliSeconds() > UPDATE_INTERVAL) + { + u8 buf; + nn::Result result = mp_Mcu->ReadByReceive(nn::drivers::mcu::CTR::MCU_PERIPHERAL_STATUS_ADDR, &buf, sizeof(buf)); + if(result.IsSuccess()) + { + last = now; + lastResult = buf & nn::drivers::mcu::CTR::MCU_STATUS_ADAPTER_MASK; + } + } + return lastResult; + } bool Util::IsBatteryLower()