mirror of
https://github.com/rvtr/ctr_Repair.git
synced 2025-10-31 13:51:08 -04:00
ACアダプタ状態はAPI互換性がないためmcuからリードする
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
This commit is contained in:
parent
da6c928c54
commit
2660725f42
@ -26,6 +26,7 @@
|
||||
#include <nn/friends.h>
|
||||
#include <nn/friends/CTR/friends_ApiPrivate.h>
|
||||
#include <nn/ps.h>
|
||||
#include <nn/drivers/mcu/CTR/driverMcuRegisterMap.h>
|
||||
|
||||
#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()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user