diff --git a/trunk/ConsoleDataMigration/ConsoleRestore/ConsoleRestore.cpp b/trunk/ConsoleDataMigration/ConsoleRestore/ConsoleRestore.cpp index d585fc4..079df23 100644 --- a/trunk/ConsoleDataMigration/ConsoleRestore/ConsoleRestore.cpp +++ b/trunk/ConsoleDataMigration/ConsoleRestore/ConsoleRestore.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include "demo.h" #include @@ -155,7 +156,7 @@ extern "C" void nnMain(void) // hid の初期化 result = nn::hid::Initialize(); - NN_UTIL_PANIC_IF_FAILED(result); + NN_ERR_THROW_FATAL_IF_FATAL_ONLY(result); // cfg の初期化 nn::cfg::CTR::init::Initialize(); @@ -174,6 +175,18 @@ extern "C" void nnMain(void) nn::mcu::CTR::InitializeHwCheck(&s_McuSession); nn::mcu::CTR::HwCheck mcu(s_McuSession); + // ndmの初期化 + result = nn::ndm::Initialize(); + NN_ERR_THROW_FATAL_IF_FATAL_ONLY(result); + + // NIM以外のデーモンの自律動作を停止 + result = nn::ndm::Suspend(nn::ndm::DN_CEC); + NN_ERR_THROW_FATAL_IF_FATAL_ONLY(result); + result = nn::ndm::Suspend(nn::ndm::DN_BOSS); + NN_ERR_THROW_FATAL_IF_FATAL_ONLY(result); + result = nn::ndm::Suspend(nn::ndm::DN_FRIENDS); + NN_ERR_THROW_FATAL_IF_FATAL_ONLY(result); + // amの初期化 nn::am::InitializeForSystemMenu(); diff --git a/trunk/ConsoleDataMigration/ConsoleRestore/Controller.cpp b/trunk/ConsoleDataMigration/ConsoleRestore/Controller.cpp index 86016a0..06c9ddf 100644 --- a/trunk/ConsoleDataMigration/ConsoleRestore/Controller.cpp +++ b/trunk/ConsoleDataMigration/ConsoleRestore/Controller.cpp @@ -510,10 +510,20 @@ void ControlState(::std::vector& operationMessage, bool& nextStep, } break; - // プレイ履歴復元 + // 削除処理 case HISTORY_RECOVER: { - nn::ptm::CTR::InvalidateSystemTime(); + static bool init = true; + if (init) + { + // ptmのセーブデータ移行後に時計を無効化する + nn::ptm::CTR::InvalidateSystemTime(); + + // cfgのハードウェア固有情報をcal値で初期化する + InitializeHardwareDependentSetting(); + + init = false; + } s_RestoreState = TIME_ADJUST; } diff --git a/trunk/ConsoleDataMigration/ConsoleRestore/Importer.cpp b/trunk/ConsoleDataMigration/ConsoleRestore/Importer.cpp index 19fc1a8..5a8728a 100644 --- a/trunk/ConsoleDataMigration/ConsoleRestore/Importer.cpp +++ b/trunk/ConsoleDataMigration/ConsoleRestore/Importer.cpp @@ -1186,6 +1186,82 @@ void ImportPlayHistory() s_ImportThread.Start(ImportPlayHistoryThreadFunc, s_ImportThreadStack); } +void ExportTouchPanelCfgData() +{ + using namespace nn::cfg::CTR::detail; + + nn::Result result; + nn::cfg::CTR::detail::TouchPanelCfgData touchPanelCfgData; + common::SdReaderWriter sdWriter; + + COMMON_LOGGER("Export TouchPanelData\n"); + + common::SdMountManager::Mount(); + + result = nn::cfg::CTR::init::GetConfig(&touchPanelCfgData, sizeof(TouchPanelCfgData), + GET_CFG_KEY(NN_CFG_HID, NN_CFG_HID_CAL_TOUCHPANEL)); + COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); + if (result.IsSuccess()) + { + result = sdWriter.WriteBuf(common::TOUCH_PANEL_CALIBRATION_PATHNAME, &touchPanelCfgData, sizeof(touchPanelCfgData)); + COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); + } + + common::SdMountManager::Unmount(); +} + +void ImportTouchPanelCfgData(nn::cfg::CTR::detail::TouchPanelCfgData* data) +{ + using namespace nn::cfg::CTR::detail; + + nn::Result result; + + COMMON_LOGGER("Import TouchPanelData\n"); + + common::SdMountManager::Mount(); + + size_t bufSize = common::HeapManager::GetHeap()->GetAllocatableSize(); + void* buf = common::HeapManager::GetHeap()->Allocate(bufSize); + if (buf != NULL) + { + common::SdReaderWriter sdReader; + + size_t readSize; + result = sdReader.ReadBuf(common::TOUCH_PANEL_CALIBRATION_PATHNAME, buf, bufSize, &readSize); + if(result.IsSuccess()) + { + // SDから読み出し成功 + std::memcpy(data, buf, readSize); + } + else + { + COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); + } + common::HeapManager::GetHeap()->Free(buf); + } + + common::SdMountManager::Unmount(); +} + +void InitializeHardwareDependentSetting() +{ + using namespace nn::cfg::CTR::detail; + nn::Result result; + + nn::cfg::CTR::detail::TouchPanelCfgData touchPanelCfgData; + ImportTouchPanelCfgData(&touchPanelCfgData); + result = nn::cfg::CTR::init::SetConfig(GET_CFG_KEY(NN_CFG_HID, NN_CFG_HID_CAL_TOUCHPANEL), &touchPanelCfgData, + sizeof(TouchPanelCfgData)); + + COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); + + nn::cfg::CTR::init::ResetCameraCalibration(); + COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); + + nn::cfg::CTR::init::ResetAnalogStickCalibration(); + COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); +} + void ImportData() { static bool init = true; @@ -1206,6 +1282,10 @@ void ImportData() // TWLサウンド領域のデータをNANDに書き込む ImportTwlSoundData(); + // タッチパネルキャリブレーションデータをSDカードに出力する + // 本体初期化後はcal値が設定されている + ExportTouchPanelCfgData(); + // SDカードのセーブデータをNANDに書き込む ImportSaveData(); diff --git a/trunk/ConsoleDataMigration/ConsoleRestore/Importer.h b/trunk/ConsoleDataMigration/ConsoleRestore/Importer.h index 0dc1bf0..1f1c279 100644 --- a/trunk/ConsoleDataMigration/ConsoleRestore/Importer.h +++ b/trunk/ConsoleDataMigration/ConsoleRestore/Importer.h @@ -69,6 +69,9 @@ void ClearFileReadResult(); // プレイ履歴を読み込みます。ptmのセーブデータ移行後に呼び出す必要があります void ImportPlayHistory(); + +// cfgのハードウェア固有領域をcal値で初期化します +void InitializeHardwareDependentSetting(); } #endif /* IMPORTER_H_ */ diff --git a/trunk/ConsoleDataMigration/common/FileName.h b/trunk/ConsoleDataMigration/common/FileName.h index 712ebfe..86ab783 100644 --- a/trunk/ConsoleDataMigration/common/FileName.h +++ b/trunk/ConsoleDataMigration/common/FileName.h @@ -49,6 +49,7 @@ const wchar_t* const INITIALIZED_CHECK_PATHNAME = L"sdmc:/CTR_Console_Repair/Con const wchar_t* const RTC_SYNC_CHECK_PATHNAME = L"sdmc:/CTR_Console_Repair/RtcSyncFinished"; const wchar_t* const PLAYHISTORY_PATHNAME = L"sdmc:/CTR_Console_Repair/playhistory.bin"; const wchar_t* const PLAYHISTORY_COUNT_PATHNAME = L"sdmc:/CTR_Console_Repair/playhistoryCount.bin"; +const wchar_t* const TOUCH_PANEL_CALIBRATION_PATHNAME = L"sdmc:/CTR_Console_Repair/tpCalibration.bin"; enum TWL_PATHNAME {