diff options
| author | 2022-09-24 22:52:33 -0500 | |
|---|---|---|
| committer | 2022-10-02 12:32:26 -0500 | |
| commit | 3ce0ef04ddcb2420b61f8c6d22f8039fb7359856 (patch) | |
| tree | f2e843da46429df8ae6c1f8f415bc507d3458f28 /src/core/hle | |
| parent | service: nfp: Rewrite and implement applet calls (diff) | |
| download | yuzu-3ce0ef04ddcb2420b61f8c6d22f8039fb7359856.tar.gz yuzu-3ce0ef04ddcb2420b61f8c6d22f8039fb7359856.tar.xz yuzu-3ce0ef04ddcb2420b61f8c6d22f8039fb7359856.zip | |
service: nfp: address comments
Diffstat (limited to 'src/core/hle')
| -rw-r--r-- | src/core/hle/service/nfp/nfp_device.cpp | 11 | ||||
| -rw-r--r-- | src/core/hle/service/nfp/nfp_device.h | 4 | ||||
| -rw-r--r-- | src/core/hle/service/nfp/nfp_types.h | 25 |
3 files changed, 21 insertions, 19 deletions
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_, | |||
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | NfpDevice::~NfpDevice() { | 44 | NfpDevice::~NfpDevice() { |
| 45 | if (is_controller_set) { | 45 | if (!is_controller_set) { |
| 46 | npad_device->DeleteCallback(callback_key); | 46 | return; |
| 47 | is_controller_set = false; | ||
| 48 | } | 47 | } |
| 48 | npad_device->DeleteCallback(callback_key); | ||
| 49 | is_controller_set = false; | ||
| 49 | }; | 50 | }; |
| 50 | 51 | ||
| 51 | void NfpDevice::NpadUpdate(Core::HID::ControllerTriggerType type) { | 52 | void NfpDevice::NpadUpdate(Core::HID::ControllerTriggerType type) { |
| @@ -453,7 +454,7 @@ Result NfpDevice::SetApplicationArea(const std::vector<u8>& data) { | |||
| 453 | return ResultSuccess; | 454 | return ResultSuccess; |
| 454 | } | 455 | } |
| 455 | 456 | ||
| 456 | Result NfpDevice::CreateApplicationArea(u32 access_id, const std::vector<u8>& data) { | 457 | Result NfpDevice::CreateApplicationArea(u32 access_id, std::span<const u8> data) { |
| 457 | if (device_state != DeviceState::TagMounted) { | 458 | if (device_state != DeviceState::TagMounted) { |
| 458 | LOG_ERROR(Service_NFP, "Wrong device state {}", device_state); | 459 | LOG_ERROR(Service_NFP, "Wrong device state {}", device_state); |
| 459 | if (device_state == DeviceState::TagRemoved) { | 460 | if (device_state == DeviceState::TagRemoved) { |
| @@ -470,7 +471,7 @@ Result NfpDevice::CreateApplicationArea(u32 access_id, const std::vector<u8>& da | |||
| 470 | return RecreateApplicationArea(access_id, data); | 471 | return RecreateApplicationArea(access_id, data); |
| 471 | } | 472 | } |
| 472 | 473 | ||
| 473 | Result NfpDevice::RecreateApplicationArea(u32 access_id, const std::vector<u8>& data) { | 474 | Result NfpDevice::RecreateApplicationArea(u32 access_id, std::span<const u8> data) { |
| 474 | if (device_state != DeviceState::TagMounted) { | 475 | if (device_state != DeviceState::TagMounted) { |
| 475 | LOG_ERROR(Service_NFP, "Wrong device state {}", device_state); | 476 | LOG_ERROR(Service_NFP, "Wrong device state {}", device_state); |
| 476 | if (device_state == DeviceState::TagRemoved) { | 477 | 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: | |||
| 56 | Result OpenApplicationArea(u32 access_id); | 56 | Result OpenApplicationArea(u32 access_id); |
| 57 | Result GetApplicationArea(std::vector<u8>& data) const; | 57 | Result GetApplicationArea(std::vector<u8>& data) const; |
| 58 | Result SetApplicationArea(const std::vector<u8>& data); | 58 | Result SetApplicationArea(const std::vector<u8>& data); |
| 59 | Result CreateApplicationArea(u32 access_id, const std::vector<u8>& data); | 59 | Result CreateApplicationArea(u32 access_id, std::span<const u8> data); |
| 60 | Result RecreateApplicationArea(u32 access_id, const std::vector<u8>& data); | 60 | Result RecreateApplicationArea(u32 access_id, std::span<const u8> data); |
| 61 | Result DeleteApplicationArea(); | 61 | Result DeleteApplicationArea(); |
| 62 | 62 | ||
| 63 | u64 GetHandle() const; | 63 | 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 @@ | |||
| 5 | 5 | ||
| 6 | #include <array> | 6 | #include <array> |
| 7 | 7 | ||
| 8 | #include "common/swap.h" | ||
| 8 | #include "core/hle/service/mii/types.h" | 9 | #include "core/hle/service/mii/types.h" |
| 9 | 10 | ||
| 10 | namespace Service::NFP { | 11 | namespace Service::NFP { |
| @@ -80,33 +81,33 @@ using ApplicationArea = std::array<u8, 0xD8>; | |||
| 80 | using AmiiboName = std::array<char, (amiibo_name_length * 4) + 1>; | 81 | using AmiiboName = std::array<char, (amiibo_name_length * 4) + 1>; |
| 81 | 82 | ||
| 82 | struct AmiiboDate { | 83 | struct AmiiboDate { |
| 83 | u16_be raw_date{}; | 84 | u16 raw_date{}; |
| 84 | 85 | ||
| 85 | u16 DateRaw() const { | 86 | u16 GetValue() const { |
| 86 | return static_cast<u16>(raw_date); | 87 | return Common::swap16(raw_date); |
| 87 | } | 88 | } |
| 88 | 89 | ||
| 89 | u16 GetYear() const { | 90 | u16 GetYear() const { |
| 90 | return static_cast<u16>(((DateRaw() & 0xFE00) >> 9) + 2000); | 91 | return static_cast<u16>(((GetValue() & 0xFE00) >> 9) + 2000); |
| 91 | } | 92 | } |
| 92 | u8 GetMonth() const { | 93 | u8 GetMonth() const { |
| 93 | return static_cast<u8>(((DateRaw() & 0x01E0) >> 5) - 1); | 94 | return static_cast<u8>(((GetValue() & 0x01E0) >> 5) - 1); |
| 94 | } | 95 | } |
| 95 | u8 GetDay() const { | 96 | u8 GetDay() const { |
| 96 | return static_cast<u8>(DateRaw() & 0x001F); | 97 | return static_cast<u8>(GetValue() & 0x001F); |
| 97 | } | 98 | } |
| 98 | 99 | ||
| 99 | void SetYear(u16 year) { | 100 | void SetYear(u16 year) { |
| 100 | raw_date = DateRaw() & ~0xFE00; | 101 | const u16 year_converted = static_cast<u16>((year - 2000) << 9); |
| 101 | raw_date |= static_cast<u16_be>((year - 2000) << 9); | 102 | raw_date = Common::swap16((GetValue() & ~0xFE00) | year_converted); |
| 102 | } | 103 | } |
| 103 | void SetMonth(u8 month) { | 104 | void SetMonth(u8 month) { |
| 104 | raw_date = DateRaw() & ~0x01E0; | 105 | const u16 month_converted = static_cast<u16>((month + 1) << 5); |
| 105 | raw_date |= static_cast<u16_be>((month + 1) << 5); | 106 | raw_date = Common::swap16((GetValue() & ~0x01E0) | month_converted); |
| 106 | } | 107 | } |
| 107 | void SetDay(u8 day) { | 108 | void SetDay(u8 day) { |
| 108 | raw_date = DateRaw() & ~0x001F; | 109 | const u16 day_converted = static_cast<u16>(day); |
| 109 | raw_date |= static_cast<u16_be>(day); | 110 | raw_date = Common::swap16((GetValue() & ~0x001F) | day_converted); |
| 110 | } | 111 | } |
| 111 | }; | 112 | }; |
| 112 | static_assert(sizeof(AmiiboDate) == 2, "AmiiboDate is an invalid size"); | 113 | static_assert(sizeof(AmiiboDate) == 2, "AmiiboDate is an invalid size"); |