summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgerman77 <juangerman-13@hotmail.com>2022-09-25 05:52:33 +0200
committergerman77 <juangerman-13@hotmail.com>2022-10-02 19:32:26 +0200
commit3ce0ef04ddcb2420b61f8c6d22f8039fb7359856 (patch)
treef2e843da46429df8ae6c1f8f415bc507d3458f28
parentservice: nfp: Rewrite and implement applet calls (diff)
downloadyuzu-3ce0ef04ddcb2420b61f8c6d22f8039fb7359856.tar
yuzu-3ce0ef04ddcb2420b61f8c6d22f8039fb7359856.tar.gz
yuzu-3ce0ef04ddcb2420b61f8c6d22f8039fb7359856.tar.bz2
yuzu-3ce0ef04ddcb2420b61f8c6d22f8039fb7359856.tar.lz
yuzu-3ce0ef04ddcb2420b61f8c6d22f8039fb7359856.tar.xz
yuzu-3ce0ef04ddcb2420b61f8c6d22f8039fb7359856.tar.zst
yuzu-3ce0ef04ddcb2420b61f8c6d22f8039fb7359856.zip
-rw-r--r--src/common/input.h2
-rw-r--r--src/core/hid/input_converter.cpp2
-rw-r--r--src/core/hle/service/nfp/nfp_device.cpp11
-rw-r--r--src/core/hle/service/nfp/nfp_device.h4
-rw-r--r--src/core/hle/service/nfp/nfp_types.h25
-rw-r--r--src/input_common/drivers/virtual_amiibo.cpp4
-rw-r--r--src/input_common/drivers/virtual_amiibo.h2
-rw-r--r--src/input_common/input_engine.h3
-rw-r--r--src/input_common/input_poller.cpp2
9 files changed, 29 insertions, 26 deletions
diff --git a/src/common/input.h b/src/common/input.h
index 8365cc36e..bfa0639f5 100644
--- a/src/common/input.h
+++ b/src/common/input.h
@@ -332,7 +332,7 @@ public:
return CameraError::NotSupported;
}
- virtual NfcState SupportsNfc() {
+ virtual NfcState SupportsNfc() const {
return NfcState::NotSupported;
}
diff --git a/src/core/hid/input_converter.cpp b/src/core/hid/input_converter.cpp
index e7b871acc..fe9915abe 100644
--- a/src/core/hid/input_converter.cpp
+++ b/src/core/hid/input_converter.cpp
@@ -291,7 +291,7 @@ Common::Input::NfcStatus TransformToNfc(const Common::Input::CallbackStatus& cal
Common::Input::NfcStatus nfc{};
switch (callback.type) {
case Common::Input::InputType::Nfc:
- nfc = callback.nfc_status;
+ return callback.nfc_status;
break;
default:
LOG_ERROR(Input, "Conversion from type {} to NFC not implemented", callback.type);
diff --git a/src/core/hle/service/nfp/nfp_device.cpp b/src/core/hle/service/nfp/nfp_device.cpp
index da7daae88..ce3bcccf4 100644
--- a/src/core/hle/service/nfp/nfp_device.cpp
+++ b/src/core/hle/service/nfp/nfp_device.cpp
@@ -42,10 +42,11 @@ NfpDevice::NfpDevice(Core::HID::NpadIdType npad_id_, Core::System& system_,
}
NfpDevice::~NfpDevice() {
- if (is_controller_set) {
- npad_device->DeleteCallback(callback_key);
- is_controller_set = false;
+ if (!is_controller_set) {
+ return;
}
+ npad_device->DeleteCallback(callback_key);
+ is_controller_set = false;
};
void NfpDevice::NpadUpdate(Core::HID::ControllerTriggerType type) {
@@ -453,7 +454,7 @@ Result NfpDevice::SetApplicationArea(const std::vector<u8>& data) {
return ResultSuccess;
}
-Result NfpDevice::CreateApplicationArea(u32 access_id, const std::vector<u8>& data) {
+Result NfpDevice::CreateApplicationArea(u32 access_id, std::span<const u8> data) {
if (device_state != DeviceState::TagMounted) {
LOG_ERROR(Service_NFP, "Wrong device state {}", device_state);
if (device_state == DeviceState::TagRemoved) {
@@ -470,7 +471,7 @@ Result NfpDevice::CreateApplicationArea(u32 access_id, const std::vector<u8>& da
return RecreateApplicationArea(access_id, data);
}
-Result NfpDevice::RecreateApplicationArea(u32 access_id, const std::vector<u8>& data) {
+Result NfpDevice::RecreateApplicationArea(u32 access_id, std::span<const u8> data) {
if (device_state != DeviceState::TagMounted) {
LOG_ERROR(Service_NFP, "Wrong device state {}", device_state);
if (device_state == DeviceState::TagRemoved) {
diff --git a/src/core/hle/service/nfp/nfp_device.h b/src/core/hle/service/nfp/nfp_device.h
index 53cc0833f..9ceb7b8fd 100644
--- a/src/core/hle/service/nfp/nfp_device.h
+++ b/src/core/hle/service/nfp/nfp_device.h
@@ -56,8 +56,8 @@ public:
Result OpenApplicationArea(u32 access_id);
Result GetApplicationArea(std::vector<u8>& data) const;
Result SetApplicationArea(const std::vector<u8>& data);
- Result CreateApplicationArea(u32 access_id, const std::vector<u8>& data);
- Result RecreateApplicationArea(u32 access_id, const std::vector<u8>& data);
+ Result CreateApplicationArea(u32 access_id, std::span<const u8> data);
+ Result RecreateApplicationArea(u32 access_id, std::span<const u8> data);
Result DeleteApplicationArea();
u64 GetHandle() const;
diff --git a/src/core/hle/service/nfp/nfp_types.h b/src/core/hle/service/nfp/nfp_types.h
index d58657a21..2685ae8fe 100644
--- a/src/core/hle/service/nfp/nfp_types.h
+++ b/src/core/hle/service/nfp/nfp_types.h
@@ -5,6 +5,7 @@
#include <array>
+#include "common/swap.h"
#include "core/hle/service/mii/types.h"
namespace Service::NFP {
@@ -80,33 +81,33 @@ using ApplicationArea = std::array<u8, 0xD8>;
using AmiiboName = std::array<char, (amiibo_name_length * 4) + 1>;
struct AmiiboDate {
- u16_be raw_date{};
+ u16 raw_date{};
- u16 DateRaw() const {
- return static_cast<u16>(raw_date);
+ u16 GetValue() const {
+ return Common::swap16(raw_date);
}
u16 GetYear() const {
- return static_cast<u16>(((DateRaw() & 0xFE00) >> 9) + 2000);
+ return static_cast<u16>(((GetValue() & 0xFE00) >> 9) + 2000);
}
u8 GetMonth() const {
- return static_cast<u8>(((DateRaw() & 0x01E0) >> 5) - 1);
+ return static_cast<u8>(((GetValue() & 0x01E0) >> 5) - 1);
}
u8 GetDay() const {
- return static_cast<u8>(DateRaw() & 0x001F);
+ return static_cast<u8>(GetValue() & 0x001F);
}
void SetYear(u16 year) {
- raw_date = DateRaw() & ~0xFE00;
- raw_date |= static_cast<u16_be>((year - 2000) << 9);
+ const u16 year_converted = static_cast<u16>((year - 2000) << 9);
+ raw_date = Common::swap16((GetValue() & ~0xFE00) | year_converted);
}
void SetMonth(u8 month) {
- raw_date = DateRaw() & ~0x01E0;
- raw_date |= static_cast<u16_be>((month + 1) << 5);
+ const u16 month_converted = static_cast<u16>((month + 1) << 5);
+ raw_date = Common::swap16((GetValue() & ~0x01E0) | month_converted);
}
void SetDay(u8 day) {
- raw_date = DateRaw() & ~0x001F;
- raw_date |= static_cast<u16_be>(day);
+ const u16 day_converted = static_cast<u16>(day);
+ raw_date = Common::swap16((GetValue() & ~0x001F) | day_converted);
}
};
static_assert(sizeof(AmiiboDate) == 2, "AmiiboDate is an invalid size");
diff --git a/src/input_common/drivers/virtual_amiibo.cpp b/src/input_common/drivers/virtual_amiibo.cpp
index 8fadb1322..0cd5129da 100644
--- a/src/input_common/drivers/virtual_amiibo.cpp
+++ b/src/input_common/drivers/virtual_amiibo.cpp
@@ -20,7 +20,7 @@ constexpr PadIdentifier identifier = {
VirtualAmiibo::VirtualAmiibo(std::string input_engine_) : InputEngine(std::move(input_engine_)) {}
-VirtualAmiibo::~VirtualAmiibo() {}
+VirtualAmiibo::~VirtualAmiibo() = default;
Common::Input::PollingError VirtualAmiibo::SetPollingMode(
[[maybe_unused]] const PadIdentifier& identifier_,
@@ -41,7 +41,7 @@ Common::Input::PollingError VirtualAmiibo::SetPollingMode(
}
Common::Input::NfcState VirtualAmiibo::SupportsNfc(
- [[maybe_unused]] const PadIdentifier& identifier_) {
+ [[maybe_unused]] const PadIdentifier& identifier_) const {
return Common::Input::NfcState::Success;
}
diff --git a/src/input_common/drivers/virtual_amiibo.h b/src/input_common/drivers/virtual_amiibo.h
index 5790e4a1f..9eac07544 100644
--- a/src/input_common/drivers/virtual_amiibo.h
+++ b/src/input_common/drivers/virtual_amiibo.h
@@ -39,7 +39,7 @@ public:
Common::Input::PollingError SetPollingMode(
const PadIdentifier& identifier_, const Common::Input::PollingMode polling_mode_) override;
- Common::Input::NfcState SupportsNfc(const PadIdentifier& identifier_) override;
+ Common::Input::NfcState SupportsNfc(const PadIdentifier& identifier_) const override;
Common::Input::NfcState WriteNfcData(const PadIdentifier& identifier_,
const std::vector<u8>& data) override;
diff --git a/src/input_common/input_engine.h b/src/input_common/input_engine.h
index 9b8470c6f..cfbdb26bd 100644
--- a/src/input_common/input_engine.h
+++ b/src/input_common/input_engine.h
@@ -129,7 +129,8 @@ public:
}
// Request nfc data from a controller
- virtual Common::Input::NfcState SupportsNfc([[maybe_unused]] const PadIdentifier& identifier) {
+ virtual Common::Input::NfcState SupportsNfc(
+ [[maybe_unused]] const PadIdentifier& identifier) const {
return Common::Input::NfcState::NotSupported;
}
diff --git a/src/input_common/input_poller.cpp b/src/input_common/input_poller.cpp
index a8eb1442b..75705b67e 100644
--- a/src/input_common/input_poller.cpp
+++ b/src/input_common/input_poller.cpp
@@ -768,7 +768,7 @@ public:
return input_engine->SetCameraFormat(identifier, camera_format);
}
- Common::Input::NfcState SupportsNfc() override {
+ Common::Input::NfcState SupportsNfc() const override {
return input_engine->SupportsNfc(identifier);
}