mirror of
https://github.com/rvtr/ctr_Repair.git
synced 2025-10-31 13:51:08 -04:00
バッテリ残量をptmから取得するよう変更。cfg:sを使うよう変更
git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@797 385bec56-5757-e545-9c3a-d8741f4650f1
This commit is contained in:
parent
d242effc01
commit
84aac69652
@ -18,7 +18,6 @@
|
|||||||
#include <nn/ptm/CTR/ptm_ApiSysmenu.h>
|
#include <nn/ptm/CTR/ptm_ApiSysmenu.h>
|
||||||
#include <nn/mcu.h>
|
#include <nn/mcu.h>
|
||||||
#include <nn/cfg/CTR/cfg_Api.h>
|
#include <nn/cfg/CTR/cfg_Api.h>
|
||||||
#include <nn/cfg/CTR/cfg_ApiInit.h>
|
|
||||||
#include <nn/cfg/CTR/cfg_ApiSys.h>
|
#include <nn/cfg/CTR/cfg_ApiSys.h>
|
||||||
#include <nn/ps.h>
|
#include <nn/ps.h>
|
||||||
#include <nn/nwm.h>
|
#include <nn/nwm.h>
|
||||||
@ -75,10 +74,9 @@ void FinalizeAll()
|
|||||||
s_RenderSystem.Finalize();
|
s_RenderSystem.Finalize();
|
||||||
|
|
||||||
s_HwUtility.FinalizeForRestore();
|
s_HwUtility.FinalizeForRestore();
|
||||||
nn::ps::Finalize();
|
nn::am::FinalizeForSystemMenu();
|
||||||
nn::ptm::CTR::FinalizeForSystemMenu();
|
nn::ptm::CTR::Finalize();
|
||||||
nn::cfg::CTR::system::Finalize();
|
nn::cfg::CTR::system::Finalize();
|
||||||
nn::cfg::CTR::init::Finalize();
|
|
||||||
nn::hid::Finalize();
|
nn::hid::Finalize();
|
||||||
nn::fs::Finalize();
|
nn::fs::Finalize();
|
||||||
|
|
||||||
@ -115,11 +113,14 @@ extern "C" void nnMain(void)
|
|||||||
NN_ERR_THROW_FATAL_IF_FATAL_ONLY(result);
|
NN_ERR_THROW_FATAL_IF_FATAL_ONLY(result);
|
||||||
|
|
||||||
// cfg の初期化
|
// cfg の初期化
|
||||||
nn::cfg::CTR::Initialize();
|
nn::cfg::CTR::system::Initialize();
|
||||||
|
|
||||||
// amの初期化
|
// amの初期化
|
||||||
nn::am::InitializeForSystemMenu();
|
nn::am::InitializeForSystemMenu();
|
||||||
|
|
||||||
|
// ptmの初期化
|
||||||
|
nn::ptm::CTR::Initialize();
|
||||||
|
|
||||||
// ヒープの確保
|
// ヒープの確保
|
||||||
common::InitializeHeap();
|
common::InitializeHeap();
|
||||||
|
|
||||||
@ -143,7 +144,7 @@ extern "C" void nnMain(void)
|
|||||||
common::Logger::SetEjectHandler(OnSdEjected);
|
common::Logger::SetEjectHandler(OnSdEjected);
|
||||||
common::Logger::SetInsertHandler(OnSdInserted);
|
common::Logger::SetInsertHandler(OnSdInserted);
|
||||||
COMMON_LOGGER("\n");
|
COMMON_LOGGER("\n");
|
||||||
COMMON_LOGGER("CTR Console Restore start\n");
|
COMMON_LOGGER("CTR Network Updater start\n");
|
||||||
|
|
||||||
// ボタン入力
|
// ボタン入力
|
||||||
nn::hid::PadReader s_PadReader;
|
nn::hid::PadReader s_PadReader;
|
||||||
@ -157,7 +158,7 @@ extern "C" void nnMain(void)
|
|||||||
s_HwUtility.SetWifiOn();
|
s_HwUtility.SetWifiOn();
|
||||||
|
|
||||||
// 情報出力
|
// 情報出力
|
||||||
COMMON_LOGGER("CTR Console Restore %s-%s-%s\n", CONSOLE_REPAIR_VERSION_MAJOR, CONSOLE_REPAIR_VERSION_MINOR, CONSOLE_REPAIR_VERSION_MICRO);
|
COMMON_LOGGER("CTR Network Updater %s-%s-%s\n", CONSOLE_REPAIR_VERSION_MAJOR, CONSOLE_REPAIR_VERSION_MINOR, CONSOLE_REPAIR_VERSION_MICRO);
|
||||||
COMMON_LOGGER("System Ver. %d.%d.%d-%d\n", s_HwUtility.GetCupMajorVersion(),
|
COMMON_LOGGER("System Ver. %d.%d.%d-%d\n", s_HwUtility.GetCupMajorVersion(),
|
||||||
s_HwUtility.GetCupMinorVersion(),
|
s_HwUtility.GetCupMinorVersion(),
|
||||||
s_HwUtility.GetCupMicroVersion(),
|
s_HwUtility.GetCupMicroVersion(),
|
||||||
|
|||||||
@ -17,7 +17,6 @@
|
|||||||
#include <nn/fs/CTR/fs_ArchiveTypesForSystem.h>
|
#include <nn/fs/CTR/fs_ArchiveTypesForSystem.h>
|
||||||
#include <nn/fs/CTR/MPCore/fs_FileSystemBasePrivate.h>
|
#include <nn/fs/CTR/MPCore/fs_FileSystemBasePrivate.h>
|
||||||
#include <nn/fs/CTR/MPCore/fs_ApiIntegrityVerificationSeed.h>
|
#include <nn/fs/CTR/MPCore/fs_ApiIntegrityVerificationSeed.h>
|
||||||
#include <nn/cfg/CTR/cfg_ApiInit.h>
|
|
||||||
#include <nn/cfg/CTR/cfg_ApiNor.h> // cfg:norの初期化に必要
|
#include <nn/cfg/CTR/cfg_ApiNor.h> // cfg:norの初期化に必要
|
||||||
#include <nn/cfg/CTR/cfg_Api.h>
|
#include <nn/cfg/CTR/cfg_Api.h>
|
||||||
#include <nn/am/am_ApiSystemMenu.h>
|
#include <nn/am/am_ApiSystemMenu.h>
|
||||||
@ -82,15 +81,12 @@ void SetCountry(nn::cfg::CTR::CfgCountryCode countryCode)
|
|||||||
|
|
||||||
void SetLanguage(nn::cfg::CTR::CfgLanguageCode languageCode)
|
void SetLanguage(nn::cfg::CTR::CfgLanguageCode languageCode)
|
||||||
{
|
{
|
||||||
NN_UTIL_PANIC_IF_FAILED(nn::cfg::CTR::init::SetConfig(
|
NN_UTIL_PANIC_IF_FAILED(nn::cfg::CTR::system::SetConfig(
|
||||||
GET_CFG_KEY(nn::cfg::CTR::detail::NN_CFG_USER_INFO,
|
GET_CFG_KEY(nn::cfg::CTR::detail::NN_CFG_USER_INFO,
|
||||||
nn::cfg::CTR::detail::NN_CFG_USER_INFO_LANGUAGE),
|
nn::cfg::CTR::detail::NN_CFG_USER_INFO_LANGUAGE),
|
||||||
&languageCode,
|
&languageCode,
|
||||||
sizeof(nn::cfg::CTR::detail::LanguageCfgData)));
|
sizeof(nn::cfg::CTR::detail::LanguageCfgData)));
|
||||||
NN_UTIL_PANIC_IF_FAILED(nn::cfg::CTR::init::FlushConfig());
|
NN_UTIL_PANIC_IF_FAILED(nn::cfg::CTR::system::FlushConfig());
|
||||||
nn::cfg::nor::CTR::Initialize();
|
|
||||||
NN_UTIL_PANIC_IF_FAILED(nn::cfg::nor::CTR::SetLanguage(static_cast<nn::cfg::CTR::CfgLanguageCode>(languageCode)));
|
|
||||||
nn::cfg::nor::CTR::Finalize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nn::Result ImportCountryLanguageData()
|
nn::Result ImportCountryLanguageData()
|
||||||
|
|||||||
@ -68,21 +68,6 @@ void UpdateThreadFunc()
|
|||||||
nn::Result result;
|
nn::Result result;
|
||||||
|
|
||||||
COMMON_LOGGER_DETAIL("********************UpdateThreadFunc Start********************\n");
|
COMMON_LOGGER_DETAIL("********************UpdateThreadFunc Start********************\n");
|
||||||
nn::cfg::CTR::init::Initialize();
|
|
||||||
nn::cfg::CfgCountryCode country;
|
|
||||||
nn::cfg::CfgRegionCode region;
|
|
||||||
const char *regionStr;
|
|
||||||
const char *countryStr;
|
|
||||||
NN_UNUSED_VAR(regionStr);
|
|
||||||
NN_UNUSED_VAR(countryStr);
|
|
||||||
|
|
||||||
country = nn::cfg::GetCountry();
|
|
||||||
region = nn::cfg::GetRegion();
|
|
||||||
countryStr = nn::cfg::GetCountryCodeA2(country);
|
|
||||||
regionStr = nn::cfg::GetRegionCodeA3(region);
|
|
||||||
|
|
||||||
COMMON_LOGGER("[Updater] country:%2d:%s\n", country, countryStr);
|
|
||||||
COMMON_LOGGER("[Updater] region :%2d:%s\n", region, regionStr);
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------------
|
/* -------------------------------------------------------------------
|
||||||
Initialize
|
Initialize
|
||||||
|
|||||||
@ -69,10 +69,6 @@ void Util::Initialize()
|
|||||||
{
|
{
|
||||||
nn::Result result;
|
nn::Result result;
|
||||||
|
|
||||||
// mcuの初期化
|
|
||||||
nn::mcu::CTR::InitializeHwCheck(&m_McuSession);
|
|
||||||
mp_Mcu = new nn::mcu::CTR::HwCheck(m_McuSession);
|
|
||||||
|
|
||||||
// リージョンの取得
|
// リージョンの取得
|
||||||
m_Region = nn::cfg::CTR::GetRegion();
|
m_Region = nn::cfg::CTR::GetRegion();
|
||||||
|
|
||||||
@ -96,7 +92,6 @@ void Util::FinalizeForRestore()
|
|||||||
void Util::Finalize()
|
void Util::Finalize()
|
||||||
{
|
{
|
||||||
nn::nwm::FinalizeExtControl();
|
nn::nwm::FinalizeExtControl();
|
||||||
nn::mcu::CTR::FinalizeHwCheck(&m_McuSession);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Util::SetWifiOn()
|
void Util::SetWifiOn()
|
||||||
@ -119,29 +114,23 @@ bool Util::IsWifiOn()
|
|||||||
|
|
||||||
bool Util::IsAdapterConnected()
|
bool Util::IsAdapterConnected()
|
||||||
{
|
{
|
||||||
static nn::os::Tick last(0);
|
return nn::ptm::CTR::GetAdapterState() == nn::ptm::CTR::ADAPTERSTATE_CONNECTED;
|
||||||
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()
|
bool Util::IsBatteryLower()
|
||||||
{
|
{
|
||||||
m_BatteryRemain = GetBatteryRemain();
|
nn::ptm::CTR::BatteryLevel level = nn::ptm::CTR::GetBatteryLevel();
|
||||||
return m_BatteryRemain <= 10;
|
if(level == nn::ptm::CTR::BATTERYLEVEL_0 ||
|
||||||
|
level == nn::ptm::CTR::BATTERYLEVEL_1 ||
|
||||||
|
level == nn::ptm::CTR::BATTERYLEVEL_2)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 Util::GetCupMajorVersion()
|
u8 Util::GetCupMajorVersion()
|
||||||
@ -171,9 +160,33 @@ nn::Handle Util::GetMcuHandle()
|
|||||||
|
|
||||||
u32 Util::GetBatteryRemain()
|
u32 Util::GetBatteryRemain()
|
||||||
{
|
{
|
||||||
u8 remain;
|
nn::ptm::CTR::BatteryLevel level = nn::ptm::CTR::GetBatteryLevel();
|
||||||
mp_Mcu->GetBatteryRemain(&remain);
|
if(level == nn::ptm::CTR::BATTERYLEVEL_0)
|
||||||
return remain;
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if(level == nn::ptm::CTR::BATTERYLEVEL_1)
|
||||||
|
{
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
else if(level == nn::ptm::CTR::BATTERYLEVEL_2)
|
||||||
|
{
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
else if(level == nn::ptm::CTR::BATTERYLEVEL_3)
|
||||||
|
{
|
||||||
|
return 30;
|
||||||
|
}
|
||||||
|
else if(level == nn::ptm::CTR::BATTERYLEVEL_4)
|
||||||
|
{
|
||||||
|
return 60;
|
||||||
|
}
|
||||||
|
else if(level == nn::ptm::CTR::BATTERYLEVEL_5)
|
||||||
|
{
|
||||||
|
return 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
nn::cfg::CTR::CfgRegionCode Util::GetRegion()
|
nn::cfg::CTR::CfgRegionCode Util::GetRegion()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user