mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-12-26 05:30:05 +00:00
nfc: Initialize device when controller is connected
This commit is contained in:
parent
0e7e98e24e
commit
6ff4bf9b1c
@ -42,8 +42,18 @@ NfcDevice::~NfcDevice() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void NfcDevice::NpadUpdate(Core::HID::ControllerTriggerType type) {
|
void NfcDevice::NpadUpdate(Core::HID::ControllerTriggerType type) {
|
||||||
if (type == Core::HID::ControllerTriggerType::Connected ||
|
if (!is_initalized) {
|
||||||
type == Core::HID::ControllerTriggerType::Disconnected) {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type == Core::HID::ControllerTriggerType::Connected) {
|
||||||
|
Initialize();
|
||||||
|
availability_change_event->Signal();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type == Core::HID::ControllerTriggerType::Disconnected) {
|
||||||
|
device_state = NFP::DeviceState::Unavailable;
|
||||||
availability_change_event->Signal();
|
availability_change_event->Signal();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -113,6 +123,7 @@ void NfcDevice::Initialize() {
|
|||||||
device_state =
|
device_state =
|
||||||
npad_device->HasNfc() ? NFP::DeviceState::Initialized : NFP::DeviceState::Unavailable;
|
npad_device->HasNfc() ? NFP::DeviceState::Initialized : NFP::DeviceState::Unavailable;
|
||||||
encrypted_tag_data = {};
|
encrypted_tag_data = {};
|
||||||
|
is_initalized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NfcDevice::Finalize() {
|
void NfcDevice::Finalize() {
|
||||||
@ -121,6 +132,7 @@ void NfcDevice::Finalize() {
|
|||||||
StopDetection();
|
StopDetection();
|
||||||
}
|
}
|
||||||
device_state = NFP::DeviceState::Unavailable;
|
device_state = NFP::DeviceState::Unavailable;
|
||||||
|
is_initalized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result NfcDevice::StartDetection(NFP::TagProtocol allowed_protocol) {
|
Result NfcDevice::StartDetection(NFP::TagProtocol allowed_protocol) {
|
||||||
|
@ -67,6 +67,7 @@ private:
|
|||||||
Kernel::KEvent* deactivate_event = nullptr;
|
Kernel::KEvent* deactivate_event = nullptr;
|
||||||
Kernel::KEvent* availability_change_event = nullptr;
|
Kernel::KEvent* availability_change_event = nullptr;
|
||||||
|
|
||||||
|
bool is_initalized{};
|
||||||
NFP::TagProtocol allowed_protocols{};
|
NFP::TagProtocol allowed_protocols{};
|
||||||
NFP::DeviceState device_state{NFP::DeviceState::Unavailable};
|
NFP::DeviceState device_state{NFP::DeviceState::Unavailable};
|
||||||
|
|
||||||
|
@ -66,8 +66,18 @@ NfpDevice::~NfpDevice() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void NfpDevice::NpadUpdate(Core::HID::ControllerTriggerType type) {
|
void NfpDevice::NpadUpdate(Core::HID::ControllerTriggerType type) {
|
||||||
if (type == Core::HID::ControllerTriggerType::Connected ||
|
if (!is_initalized) {
|
||||||
type == Core::HID::ControllerTriggerType::Disconnected) {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type == Core::HID::ControllerTriggerType::Connected) {
|
||||||
|
Initialize();
|
||||||
|
availability_change_event->Signal();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type == Core::HID::ControllerTriggerType::Disconnected) {
|
||||||
|
device_state = DeviceState::Unavailable;
|
||||||
availability_change_event->Signal();
|
availability_change_event->Signal();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -145,6 +155,7 @@ void NfpDevice::Initialize() {
|
|||||||
device_state = npad_device->HasNfc() ? DeviceState::Initialized : DeviceState::Unavailable;
|
device_state = npad_device->HasNfc() ? DeviceState::Initialized : DeviceState::Unavailable;
|
||||||
encrypted_tag_data = {};
|
encrypted_tag_data = {};
|
||||||
tag_data = {};
|
tag_data = {};
|
||||||
|
is_initalized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NfpDevice::Finalize() {
|
void NfpDevice::Finalize() {
|
||||||
@ -155,6 +166,7 @@ void NfpDevice::Finalize() {
|
|||||||
StopDetection();
|
StopDetection();
|
||||||
}
|
}
|
||||||
device_state = DeviceState::Unavailable;
|
device_state = DeviceState::Unavailable;
|
||||||
|
is_initalized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result NfpDevice::StartDetection(TagProtocol allowed_protocol) {
|
Result NfpDevice::StartDetection(TagProtocol allowed_protocol) {
|
||||||
|
@ -92,6 +92,7 @@ private:
|
|||||||
Kernel::KEvent* deactivate_event = nullptr;
|
Kernel::KEvent* deactivate_event = nullptr;
|
||||||
Kernel::KEvent* availability_change_event = nullptr;
|
Kernel::KEvent* availability_change_event = nullptr;
|
||||||
|
|
||||||
|
bool is_initalized{};
|
||||||
bool is_data_moddified{};
|
bool is_data_moddified{};
|
||||||
bool is_app_area_open{};
|
bool is_app_area_open{};
|
||||||
TagProtocol allowed_protocols{};
|
TagProtocol allowed_protocols{};
|
||||||
|
Loading…
Reference in New Issue
Block a user