From 84aac6965280cc3eab075abec4eace08c02cd31b Mon Sep 17 00:00:00 2001 From: N2614 Date: Fri, 2 May 2014 02:11:11 +0000 Subject: [PATCH] =?UTF-8?q?=E3=83=90=E3=83=83=E3=83=86=E3=83=AA=E6=AE=8B?= =?UTF-8?q?=E9=87=8F=E3=82=92ptm=E3=81=8B=E3=82=89=E5=8F=96=E5=BE=97?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E5=A4=89=E6=9B=B4=E3=80=82?= =?UTF-8?q?cfg:s=E3=82=92=E4=BD=BF=E3=81=86=E3=82=88=E3=81=86=E5=A4=89?= =?UTF-8?q?=E6=9B=B4?= 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@797 385bec56-5757-e545-9c3a-d8741f4650f1 --- .../sources/NetworkUpdater/ConsoleRestore.cpp | 15 +++-- .../sources/NetworkUpdater/Importer.cpp | 8 +-- .../sources/NetworkUpdater/Updater.cpp | 15 ----- trunk/NetworkUpdater/sources/common/Util.cpp | 65 +++++++++++-------- 4 files changed, 49 insertions(+), 54 deletions(-) diff --git a/trunk/NetworkUpdater/sources/NetworkUpdater/ConsoleRestore.cpp b/trunk/NetworkUpdater/sources/NetworkUpdater/ConsoleRestore.cpp index 8767ab0..af5368f 100644 --- a/trunk/NetworkUpdater/sources/NetworkUpdater/ConsoleRestore.cpp +++ b/trunk/NetworkUpdater/sources/NetworkUpdater/ConsoleRestore.cpp @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include @@ -75,10 +74,9 @@ void FinalizeAll() s_RenderSystem.Finalize(); s_HwUtility.FinalizeForRestore(); - nn::ps::Finalize(); - nn::ptm::CTR::FinalizeForSystemMenu(); + nn::am::FinalizeForSystemMenu(); + nn::ptm::CTR::Finalize(); nn::cfg::CTR::system::Finalize(); - nn::cfg::CTR::init::Finalize(); nn::hid::Finalize(); nn::fs::Finalize(); @@ -115,11 +113,14 @@ extern "C" void nnMain(void) NN_ERR_THROW_FATAL_IF_FATAL_ONLY(result); // cfg の初期化 - nn::cfg::CTR::Initialize(); + nn::cfg::CTR::system::Initialize(); // amの初期化 nn::am::InitializeForSystemMenu(); + // ptmの初期化 + nn::ptm::CTR::Initialize(); + // ヒープの確保 common::InitializeHeap(); @@ -143,7 +144,7 @@ extern "C" void nnMain(void) common::Logger::SetEjectHandler(OnSdEjected); common::Logger::SetInsertHandler(OnSdInserted); COMMON_LOGGER("\n"); - COMMON_LOGGER("CTR Console Restore start\n"); + COMMON_LOGGER("CTR Network Updater start\n"); // ボタン入力 nn::hid::PadReader s_PadReader; @@ -157,7 +158,7 @@ extern "C" void nnMain(void) 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(), s_HwUtility.GetCupMinorVersion(), s_HwUtility.GetCupMicroVersion(), diff --git a/trunk/NetworkUpdater/sources/NetworkUpdater/Importer.cpp b/trunk/NetworkUpdater/sources/NetworkUpdater/Importer.cpp index af982ec..bbecb78 100644 --- a/trunk/NetworkUpdater/sources/NetworkUpdater/Importer.cpp +++ b/trunk/NetworkUpdater/sources/NetworkUpdater/Importer.cpp @@ -17,7 +17,6 @@ #include #include #include -#include #include // cfg:norの初期化に必要 #include #include @@ -82,15 +81,12 @@ void SetCountry(nn::cfg::CTR::CfgCountryCode countryCode) 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, nn::cfg::CTR::detail::NN_CFG_USER_INFO_LANGUAGE), &languageCode, sizeof(nn::cfg::CTR::detail::LanguageCfgData))); - NN_UTIL_PANIC_IF_FAILED(nn::cfg::CTR::init::FlushConfig()); - nn::cfg::nor::CTR::Initialize(); - NN_UTIL_PANIC_IF_FAILED(nn::cfg::nor::CTR::SetLanguage(static_cast(languageCode))); - nn::cfg::nor::CTR::Finalize(); + NN_UTIL_PANIC_IF_FAILED(nn::cfg::CTR::system::FlushConfig()); } nn::Result ImportCountryLanguageData() diff --git a/trunk/NetworkUpdater/sources/NetworkUpdater/Updater.cpp b/trunk/NetworkUpdater/sources/NetworkUpdater/Updater.cpp index 64b188b..7e8e911 100644 --- a/trunk/NetworkUpdater/sources/NetworkUpdater/Updater.cpp +++ b/trunk/NetworkUpdater/sources/NetworkUpdater/Updater.cpp @@ -68,21 +68,6 @@ void UpdateThreadFunc() nn::Result result; 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 diff --git a/trunk/NetworkUpdater/sources/common/Util.cpp b/trunk/NetworkUpdater/sources/common/Util.cpp index f56339c..6258359 100644 --- a/trunk/NetworkUpdater/sources/common/Util.cpp +++ b/trunk/NetworkUpdater/sources/common/Util.cpp @@ -69,10 +69,6 @@ void Util::Initialize() { 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(); @@ -96,7 +92,6 @@ void Util::FinalizeForRestore() void Util::Finalize() { nn::nwm::FinalizeExtControl(); - nn::mcu::CTR::FinalizeHwCheck(&m_McuSession); } void Util::SetWifiOn() @@ -119,29 +114,23 @@ bool Util::IsWifiOn() bool Util::IsAdapterConnected() { - 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; + return nn::ptm::CTR::GetAdapterState() == nn::ptm::CTR::ADAPTERSTATE_CONNECTED; } bool Util::IsBatteryLower() { - m_BatteryRemain = GetBatteryRemain(); - return m_BatteryRemain <= 10; + nn::ptm::CTR::BatteryLevel level = nn::ptm::CTR::GetBatteryLevel(); + 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() @@ -171,9 +160,33 @@ nn::Handle Util::GetMcuHandle() u32 Util::GetBatteryRemain() { - u8 remain; - mp_Mcu->GetBatteryRemain(&remain); - return remain; + nn::ptm::CTR::BatteryLevel level = nn::ptm::CTR::GetBatteryLevel(); + if(level == nn::ptm::CTR::BATTERYLEVEL_0) + { + 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()