diff options
author | german77 <juangerman-13@hotmail.com> | 2022-09-25 04:28:06 +0200 |
---|---|---|
committer | german77 <juangerman-13@hotmail.com> | 2022-10-02 19:32:26 +0200 |
commit | afea5c163fd2bd4b99753f6780c256c7280052a8 (patch) | |
tree | 7ae025424a60b9559f51101d7548e1dde4d1399e /src/core/hle/service/nfp/nfp_device.h | |
parent | core: hid: Add nfc support to emulated controller (diff) | |
download | yuzu-afea5c163fd2bd4b99753f6780c256c7280052a8.tar yuzu-afea5c163fd2bd4b99753f6780c256c7280052a8.tar.gz yuzu-afea5c163fd2bd4b99753f6780c256c7280052a8.tar.bz2 yuzu-afea5c163fd2bd4b99753f6780c256c7280052a8.tar.lz yuzu-afea5c163fd2bd4b99753f6780c256c7280052a8.tar.xz yuzu-afea5c163fd2bd4b99753f6780c256c7280052a8.tar.zst yuzu-afea5c163fd2bd4b99753f6780c256c7280052a8.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/hle/service/nfp/nfp_device.h | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/src/core/hle/service/nfp/nfp_device.h b/src/core/hle/service/nfp/nfp_device.h new file mode 100644 index 000000000..53cc0833f --- /dev/null +++ b/src/core/hle/service/nfp/nfp_device.h @@ -0,0 +1,97 @@ +// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include <array> +#include <vector> + +#include "common/common_funcs.h" +#include "core/hle/service/kernel_helpers.h" +#include "core/hle/service/mii/types.h" +#include "core/hle/service/nfp/nfp_types.h" +#include "core/hle/service/service.h" + +namespace Kernel { +class KEvent; +class KReadableEvent; +} // namespace Kernel + +namespace Core { +class System; +} // namespace Core + +namespace Core::HID { +class EmulatedController; +enum class ControllerTriggerType; +enum class NpadIdType : u32; +} // namespace Core::HID + +namespace Service::NFP { +class NfpDevice { +public: + NfpDevice(Core::HID::NpadIdType npad_id_, Core::System& system_, + KernelHelpers::ServiceContext& service_context_, + Kernel::KEvent* availability_change_event_); + ~NfpDevice(); + + void Initialize(); + void Finalize(); + + Result StartDetection(s32 protocol_); + Result StopDetection(); + Result Mount(); + Result Unmount(); + Result Flush(); + + Result GetTagInfo(TagInfo& tag_info) const; + Result GetCommonInfo(CommonInfo& common_info) const; + Result GetModelInfo(ModelInfo& model_info) const; + Result GetRegisterInfo(RegisterInfo& register_info) const; + + Result SetNicknameAndOwner(const AmiiboName& amiibo_name); + Result RestoreAmiibo(); + Result DeleteAllData(); + + 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 DeleteApplicationArea(); + + u64 GetHandle() const; + u32 GetApplicationAreaSize() const; + DeviceState GetCurrentState() const; + Core::HID::NpadIdType GetNpadId() const; + + Kernel::KReadableEvent& GetActivateEvent() const; + Kernel::KReadableEvent& GetDeactivateEvent() const; + +private: + void NpadUpdate(Core::HID::ControllerTriggerType type); + bool LoadAmiibo(const std::vector<u8>& data); + void CloseAmiibo(); + + AmiiboName GetAmiiboName(const AmiiboSettings& settings) const; + void SetAmiiboName(AmiiboSettings& settings, const AmiiboName& amiibo_name); + + bool is_controller_set{}; + int callback_key; + const Core::HID::NpadIdType npad_id; + Core::System& system; + Core::HID::EmulatedController* npad_device = nullptr; + KernelHelpers::ServiceContext& service_context; + Kernel::KEvent* activate_event = nullptr; + Kernel::KEvent* deactivate_event = nullptr; + Kernel::KEvent* availability_change_event = nullptr; + + bool is_data_moddified{}; + s32 protocol{}; + DeviceState device_state{DeviceState::Unavailable}; + + NTAG215File tag_data{}; + EncryptedNTAG215File encrypted_tag_data{}; +}; + +} // namespace Service::NFP |