CTR、SPRより後のモデルではXボタンで無線ON/OFFを切り替えられるように。ビルドにはnwm_ExtAPI.cppを差し替える必要がある

git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@731 385bec56-5757-e545-9c3a-d8741f4650f1
This commit is contained in:
N2614 2013-03-28 06:29:41 +00:00
parent a86972ad91
commit 46af748d2f
8 changed files with 324 additions and 6 deletions

View File

@ -1,6 +1,6 @@
【ビルド環境】
・SDK
CTR_SDK-3_3 branch r45925
CTR_SDK-3_3 branch r45925 + r51434
・コンパイラ
ARM C/C++ Compiler, 4.1 [Build 1049] for Nintendo
@ -21,6 +21,10 @@ QR
でビルドすること。
無線ON/OFF切り替えのため、sources/common/nwm_ExtAPI.cpp を
$HORIZON_ROOT/sources/libraries/nwm/CTR
にコピーしてからnwmをリビルドする必要がある。
【リリース時の注意】
ConsoleRestoreのReleaseビルドは、ショップ接続時などにで無限ループする不具合があるためDevelopmentビルドを使用する。

View File

@ -187,6 +187,12 @@ extern "C" void nnMain(void)
flip = !flip;
}
// XボタンでWiFi On/Off
if(padStatus.trigger & nn::hid::BUTTON_X)
{
s_HwUtility.ToggleWifiStatus();
}
// コンソールスクロール
if(padStatus.hold & nn::hid::BUTTON_UP)
{
@ -244,7 +250,8 @@ extern "C" void nnMain(void)
operationMessage,
s_HwUtility.GetRegion(),
s_HwUtility.GetSerialNumber(),
s_HwUtility.HasReadFriendCode()
s_HwUtility.HasReadFriendCode(),
s_HwUtility.IsWifiOn()
);
if (GetBackupMode() == BACKUP_MODE_DELETE_IF_FAILED)

View File

@ -212,6 +212,13 @@ extern "C" void nnMain(void)
flip = !flip;
}
// XボタンでWiFi On/Off
if(padStatus.trigger & nn::hid::BUTTON_X)
{
s_HwUtility.ToggleWifiStatus();
}
// 左ボタンでQR切替
if(padStatus.trigger & nn::hid::BUTTON_RIGHT)
{
@ -296,7 +303,7 @@ extern "C" void nnMain(void)
s_HwUtility.GetCupMicroVersion(), s_HwUtility.GetNupVersion(), s_HwUtility.GetBatteryRemain(),
s_HwUtility.GetInfraDeviceId(), s_HwUtility.GetFriendcode(), GetProgress(), IsRestoreFailed(),
IsRestoreSucceeded(), false, s_HwUtility.GetMacAddress(), operationMessage, s_HwUtility.GetRegion(),
s_HwUtility.GetSerialNumber(), s_HwUtility.HasReadFriendCode());
s_HwUtility.GetSerialNumber(), s_HwUtility.HasReadFriendCode(), s_HwUtility.IsWifiOn());
if (GetRestoreMode() != RESTORE_MODE_RESTORE)
{

View File

@ -41,6 +41,7 @@ std::string s_AdapterState;
u8 s_Progress;
OperationMessage* s_OperationMessage;
bool s_ReadFriendCode;
bool s_IsWifiOn;
}
@ -49,7 +50,21 @@ void SetTextWriterCore()
GetTextWriter()->SetTextColor(nn::util::Color8(255, 255, 255, 255));
GetTextWriter()->Print("\n");
f32 cursorX = GetTextWriter()->GetCursorX();
f32 cursorY = GetTextWriter()->GetCursorY();
GetTextWriter()->Printf("System Ver. %d.%d.%d-%d\n", s_CupMajor, s_CupMinor, s_CupMicro, s_NupMajor);
GetTextWriter()->SetCursorX(cursorX);
GetTextWriter()->SetCursorY(cursorY);
if(s_IsWifiOn)
{
GetTextWriter()->Printf(" WiFi ON\n");
}
else
{
GetTextWriter()->SetTextColor(nn::util::Color8(80, 80, 80, 255));
GetTextWriter()->Printf(" WiFi OFF\n");
GetTextWriter()->SetTextColor(nn::util::Color8(255, 255, 255, 255));
}
GetTextWriter()->Printf("System Region %s\n", nn::cfg::CTR::GetRegionCodeA3(s_Region));
GetTextWriter()->Printf("Serial No. %s\n", s_SerialNo);
GetTextWriter()->Printf("Device ID %s\n", s_DeviceIdStr);
@ -97,7 +112,8 @@ void DrawSystemState
OperationMessage& operationMessage,
nn::cfg::CTR::CfgRegionCode region,
u8* serialNo,
bool readFriendCode
bool readFriendCode,
bool isWifiOn
)
{
@ -120,6 +136,7 @@ void DrawSystemState
s_SerialNo[nn::cfg::CTR::CFG_SECURE_INFO_SERIAL_NO_LEN] = '\0';
s_OperationMessage = &operationMessage;
s_ReadFriendCode = readFriendCode;
s_IsWifiOn = isWifiOn;
// デフォルトで上画面に描画するもの

View File

@ -69,7 +69,8 @@ void DrawSystemState
OperationMessage& operationMessage,
nn::cfg::CTR::CfgRegionCode region,
u8* s_SerialNo,
bool readFriendCode
bool readFriendCode,
bool isWifiOn
);
}

View File

@ -32,6 +32,8 @@
#include <nn/ac/private/ac.h>
#include <nn/ac/CTR/private/ac_InternalApi.h>
#include <nn/ac/CTR/private/ac_NetworkSetting.h>
#include <nn/nwm/CTR/nwm_ExtAPI.h>
#include <nn/nwm/CTR/nwm_ExtHwAPI.h>
#include "Util.h"
#include "FileName.h"
@ -109,6 +111,12 @@ void Util::Initialize()
// IVSの取得
ReadIvs(m_VerData.cup.majorVersion);
// モデルの取得
GetModel();
// nwmの初期化
nn::nwm::InitializeExtControl();
// MACアドレスの取得
nn::nwm::Mac mac;
@ -130,9 +138,38 @@ void Util::FinalizeForRestore()
void Util::Finalize()
{
nn::nwm::FinalizeExtControl();
nn::mcu::CTR::FinalizeHwCheck(&m_McuSession);
}
void Util::ToggleWifiStatus()
{
if(!CanChangeWifi())
{
return;
}
if(nn::nwm::IsWifiOn())
{
COMMON_LOGGER_RESULT_IF_FAILED(
nn::nwm::Ext::SetWifiOff()
);
}
else
{
COMMON_LOGGER_RESULT_IF_FAILED(
nn::nwm::Ext::SetWifiOn()
);
}
}
// 無線状態を取得する
bool Util::IsWifiOn()
{
return nn::nwm::IsWifiOn();
}
void Util::ReadIvs(u8 cupMajorVersion)
{
if (cupMajorVersion < common::CUP_MAJOR_VER_2ND_NUP)
@ -187,6 +224,36 @@ void Util::ReadIvs(u8 cupMajorVersion)
}
}
void Util::GetModel()
{
nn::mcu::CTR::HwCheck mcu(m_McuSession);
u8 buf[10];
const u8 RETRY = 10;
for(u8 i = 0; i < RETRY; i++)
{
nn::Result result = mcu.GetInfoRegisters(buf, sizeof(buf));
if(result.IsSuccess())
{
break;
}
nn::os::Thread::Sleep(nn::fnd::TimeSpan::FromMilliSeconds(16));
}
// 機種情報を cfg に反映
m_Model= buf[9];
}
bool Util::CanChangeWifi()
{
if(m_Model == TARGET_MODEL_CTR || m_Model == TARGET_MODEL_SPR)
{
return false;
}
return true;
}
// NULL終端されたシリアルナンバーを受け取る
// NULL終端された場所にチェックデジットを付加して新たにNULL終端する
void Util::AddCheckDigit(char* serial)

View File

@ -30,6 +30,18 @@ namespace common
class Util
{
public:
enum TargetModel
{
TARGET_MODEL_CTR, //!< CTR を表します。
TARGET_MODEL_SPR, //!< SPR を表します。
TARGET_MODEL_RESERVE_2, //!< 予約
TARGET_MODEL_RESERVE_3, //!< 予約
TARGET_MODEL_RESERVE_4, //!< 予約
TARGET_MODEL_RESERVE_5, //!< 予約
TARGET_MODEL_RESERVE_6, //!< 予約
TARGET_MODEL_RESERVE_7 //!< 予約
};
Util();
virtual ~Util();
@ -39,6 +51,12 @@ public:
void FinalizeForBackup();
void FinalizeForRestore();
// 無線状態を変更する
void ToggleWifiStatus();
// 無線状態を取得する
bool IsWifiOn();
// シリアルナンバーにモジュラス10 ウェイト3・1M10W31でチェックデジットを付加する
void AddCheckDigit(char* serial);
@ -123,6 +141,8 @@ private:
void Initialize();
void Finalize();
void ReadIvs(u8 cupMajorVersion);
void GetModel();
bool CanChangeWifi();
NN_PADDING4;
// フレンドコード
@ -169,7 +189,9 @@ private:
// FriendCodeを読んだかどうか
bool m_HasReadFriendCode;
NN_PADDING3;
// 機種情報
u8 m_Model;
NN_PADDING2;
NN_PADDING4;
};

View File

@ -0,0 +1,193 @@
/*---------------------------------------------------------------------------*
Project: Horizon
File: nwm_ExtAPI.cpp
Copyright (C)2009-2011 Nintendo Co., Ltd. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Rev$
*---------------------------------------------------------------------------*/
#include <nn/srv.h>
#include <nn/nwm/CTR/nwm_ExtAPI.h>
#include <nn/nwm/CTR/nwm_ExtMpAPI.h>
#include <nn/nwm/CTR/nwm_ExtLgyAPI.h>
#include <nn/nwm/CTR/nwm_ExtHwAPI.h>
#include <nn/nwm/nwm_Result.h>
#include "nwm_Ext.h"
#include <nn/os/os_HandleManager.h>
#include <nn/cfg.h>
#include <nn/cfg/CTR/cfg_DebugParam.h>
using namespace nn;
using namespace nn::nwm::CTR;
namespace nn {
namespace nwm {
namespace CTR {
Result InitializeExtControl()
{
return detail::InitializeBase(&detail::Ext::s_Session, PORT_NAME_EXT);
}
Result FinalizeExtControl()
{
return detail::FinalizeBase(&detail::Ext::s_Session);
}
namespace Ext {
Result GetMacAddress( Mac& mac )
{
return nn::nwm::CTR::GetMacAddress( mac );
}
Result GetState( u16* pState )
{
return detail::Ext::GetState( pState );
}
bool IsWifiOn()
{
return nn::nwm::CTR::IsWifiOn();
}
Result GetLinkLevel( LinkLevel* pLinkLevel )
{
if ( pLinkLevel )
{
*pLinkLevel = nn::nwm::CTR::GetLinkLevel();
return ResultSuccess();
}
else
{
return ResultInvalidPointer();
}
}
Result GetCommunicationMode( Mode* pMode )
{
if ( pMode )
{
*pMode = nn::nwm::CTR::GetCommunicationMode();
return ResultSuccess();
}
else
{
return ResultInvalidPointer();
}
}
// 以下、MP用API
Result OpenMpMode()
{
return detail::Ext::OpenMpMode();
}
Result CloseMpMode()
{
return detail::Ext::CloseMpMode();
}
Result UpdateMpLinkLevel( LinkLevel linkLevel )
{
return detail::Ext::UpdateMpLinkLevel( linkLevel );
}
Result NotifyWifiOffPreparationComplete()
{
return detail::Ext::NotifyWifiOffPreparationComplete();
}
Result PrepareLegacyMode(u8 pParameters[32])
{
return detail::Ext::PrepareLegacyMode(pParameters);
}
Result GetHardwareInfo(HardwareInfo &info)
{
return detail::Ext::GetHardwareInfo(&info);
}
Result SetWifiOn()
{
Result result;
nn::cfg::Initialize();
#if 0
// デバッグモードフラグが有効な場合のみ、操作を行う。
if( nn::cfg::IsDebugMode() == true )
{
#endif
result = detail::Ext::PseudoToggleWifiButton(false);
#if 0
}
else
{
result = ResultNotAuthorized();
}
#endif
nn::cfg::Finalize();
return result;
}
Result SetWifiOff()
{
Result result;
nn::cfg::Initialize();
#if 0
// デバッグモードフラグが有効な場合のみ、操作を行う。
if( nn::cfg::IsDebugMode() == true )
{
#endif
result = detail::Ext::PseudoToggleWifiButton(true);
#if 0
}
else
{
result = ResultNotAuthorized();
}
#endif
nn::cfg::Finalize();
return result;
}
Result SimulateFirmwareError()
{
Result result;
nn::cfg::Initialize();
// デバッグモードフラグが有効な場合のみ、操作を行う。
if( nn::cfg::IsDebugMode() == true )
{
result = detail::Ext::SimulateFirmwareError();
}
else
{
result = ResultNotAuthorized();
}
nn::cfg::Finalize();
return result;
}
} // namespace Ext
} // namespace CTR
} // namespace nwm
} // namespace nn