citra-emu
/
citra
Archived
1
0
Fork 0

Move writing to shared page to the nwm init

This commit is contained in:
James Rowe 2018-02-17 22:14:21 -07:00
parent ffe94421b2
commit 752cfcaaae
4 changed files with 26 additions and 16 deletions

View File

@ -2,6 +2,7 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include <random>
#include "core/hle/service/nwm/nwm.h"
#include "core/hle/service/nwm/nwm_cec.h"
#include "core/hle/service/nwm/nwm_ext.h"
@ -10,6 +11,8 @@
#include "core/hle/service/nwm/nwm_soc.h"
#include "core/hle/service/nwm/nwm_tst.h"
#include "core/hle/service/nwm/nwm_uds.h"
#include "core/hle/shared_page.h"
#include "network/network.h"
namespace Service {
namespace NWM {
@ -21,6 +24,21 @@ void Init() {
AddService(new NWM_SAP);
AddService(new NWM_SOC);
AddService(new NWM_TST);
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<> dis(0, std::numeric_limits<u8>::max());
auto mac = SharedPage::DefaultMac;
for (int i = 3; i < sizeof(SharedPage::MacAddress); ++i) {
mac[i] = static_cast<u8>(dis(gen));
}
if (auto room_member = Network::GetRoomMember().lock()) {
if (room_member->IsConnected()) {
mac = static_cast<SharedPage::MacAddress>(room_member->GetMacAddress());
}
}
SharedPage::SetMacAddress(mac);
SharedPage::SetWifiLinkLevel(SharedPage::WifiLinkLevel::BEST);
}
void InstallInterfaces(SM::ServiceManager& service_manager) {

View File

@ -593,12 +593,6 @@ void NWM_UDS::InitializeWithVersion(Kernel::HLERequestContext& ctx) {
node_info.push_back(current_node);
}
if (auto room_member = Network::GetRoomMember().lock()) {
if (room_member->IsConnected()) {
SharedPage::SetMacAddress(static_cast<SharedPage::MacAddress>(room_member->GetMacAddress()));
}
}
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.PushCopyObjects(connection_status_event);

View File

@ -83,9 +83,6 @@ void Init() {
update_time_event =
CoreTiming::RegisterEvent("SharedPage::UpdateTimeCallback", UpdateTimeCallback);
CoreTiming::ScheduleEvent(0, update_time_event);
SetWifiLinkLevel(WifiLinkLevel::POOR);
SetMacAddress(DefaultMac);
}
void SetMacAddress(const MacAddress& addr) {
@ -96,4 +93,4 @@ void SetWifiLinkLevel(WifiLinkLevel level) {
shared_page.wifi_link_level = static_cast<u8>(level);
}
} // namespace
} // namespace SharedPage

View File

@ -39,13 +39,14 @@ union BatteryState {
using MacAddress = std::array<u8, 6>;
// Default MAC address in the nintendo 3ds range
constexpr MacAddress DefaultMac = { 0x40, 0xF4, 0x07, 0x00, 0x00, 0x00 };
// Default MAC address in the Nintendo 3DS range
constexpr MacAddress DefaultMac = {0x40, 0xF4, 0x07, 0x00, 0x00, 0x00};
enum class WifiLinkLevel : u8 {
POOR = 0,
GOOD = 1,
BEST = 2,
OFF = 0,
POOR = 1,
GOOD = 2,
BEST = 3,
};
struct SharedPageDef {
@ -81,4 +82,4 @@ void SetMacAddress(const MacAddress&);
void SetWifiLinkLevel(WifiLinkLevel);
} // namespace
} // namespace SharedPage