|
|
|
@ -25,8 +25,8 @@ constexpr ResultCode ERR_TAG_FAILED(ErrorModule::NFP,
|
|
|
|
|
Module::Interface::Interface(std::shared_ptr<Module> module, const char* name)
|
|
|
|
|
: ServiceFramework(name), module(std::move(module)) {
|
|
|
|
|
auto& kernel = Core::System::GetInstance().Kernel();
|
|
|
|
|
nfc_tag_load = Kernel::WritableEvent::CreateRegisteredEventPair(
|
|
|
|
|
kernel, Kernel::ResetType::OneShot, "IUser:NFCTagDetected");
|
|
|
|
|
nfc_tag_load = Kernel::WritableEvent::CreateEventPair(kernel, Kernel::ResetType::OneShot,
|
|
|
|
|
"IUser:NFCTagDetected");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Module::Interface::~Interface() = default;
|
|
|
|
@ -65,9 +65,9 @@ public:
|
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
|
|
|
|
|
|
auto& kernel = Core::System::GetInstance().Kernel();
|
|
|
|
|
deactivate_event = Kernel::WritableEvent::CreateRegisteredEventPair(
|
|
|
|
|
deactivate_event = Kernel::WritableEvent::CreateEventPair(
|
|
|
|
|
kernel, Kernel::ResetType::OneShot, "IUser:DeactivateEvent");
|
|
|
|
|
availability_change_event = Kernel::WritableEvent::CreateRegisteredEventPair(
|
|
|
|
|
availability_change_event = Kernel::WritableEvent::CreateEventPair(
|
|
|
|
|
kernel, Kernel::ResetType::OneShot, "IUser:AvailabilityChangeEvent");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -166,10 +166,7 @@ private:
|
|
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 1};
|
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
|
|
|
|
|
|
const auto& event{
|
|
|
|
|
Core::System::GetInstance().Kernel().FindNamedEvent("IUser:DeactivateEvent")};
|
|
|
|
|
rb.PushCopyObjects(event->second);
|
|
|
|
|
rb.PushCopyObjects(deactivate_event.readable);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void StopDetection(Kernel::HLERequestContext& ctx) {
|
|
|
|
@ -178,7 +175,7 @@ private:
|
|
|
|
|
switch (device_state) {
|
|
|
|
|
case DeviceState::TagFound:
|
|
|
|
|
case DeviceState::TagNearby:
|
|
|
|
|
deactivate_event->Signal();
|
|
|
|
|
deactivate_event.writable->Signal();
|
|
|
|
|
device_state = DeviceState::Initialized;
|
|
|
|
|
break;
|
|
|
|
|
case DeviceState::SearchingForTag:
|
|
|
|
@ -269,9 +266,7 @@ private:
|
|
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 1};
|
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
|
const auto& event{
|
|
|
|
|
Core::System::GetInstance().Kernel().FindNamedEvent("IUser:AvailabilityChangeEvent")};
|
|
|
|
|
rb.PushCopyObjects(event->second);
|
|
|
|
|
rb.PushCopyObjects(availability_change_event.readable);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GetRegisterInfo(Kernel::HLERequestContext& ctx) {
|
|
|
|
@ -326,8 +321,8 @@ private:
|
|
|
|
|
const u32 npad_id{0}; // Player 1 controller
|
|
|
|
|
State state{State::NonInitialized};
|
|
|
|
|
DeviceState device_state{DeviceState::Initialized};
|
|
|
|
|
Kernel::SharedPtr<Kernel::WritableEvent> deactivate_event;
|
|
|
|
|
Kernel::SharedPtr<Kernel::WritableEvent> availability_change_event;
|
|
|
|
|
Kernel::EventPair deactivate_event;
|
|
|
|
|
Kernel::EventPair availability_change_event;
|
|
|
|
|
const Module::Interface& nfp_interface;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -346,14 +341,14 @@ bool Module::Interface::LoadAmiibo(const std::vector<u8>& buffer) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::memcpy(&amiibo, buffer.data(), sizeof(amiibo));
|
|
|
|
|
nfc_tag_load->Signal();
|
|
|
|
|
nfc_tag_load.writable->Signal();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const Kernel::SharedPtr<Kernel::ReadableEvent>& Module::Interface::GetNFCEvent() const {
|
|
|
|
|
const auto& event{Core::System::GetInstance().Kernel().FindNamedEvent("IUser:NFCTagDetected")};
|
|
|
|
|
return event->second;
|
|
|
|
|
return nfc_tag_load.readable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const Module::Interface::AmiiboFile& Module::Interface::GetAmiiboBuffer() const {
|
|
|
|
|
return amiibo;
|
|
|
|
|
}
|
|
|
|
|