diff options
author | Narr the Reg <juangerman-13@hotmail.com> | 2023-12-06 01:39:18 +0100 |
---|---|---|
committer | Narr the Reg <juangerman-13@hotmail.com> | 2023-12-07 03:24:04 +0100 |
commit | e445ef9d607d04dab185be55b1395007a40c3b81 (patch) | |
tree | 663039ca69e79c19ad35cd188f31b3135a790963 /src/core/hle/service/hid/controllers/applet_resource.h | |
parent | Merge pull request #12271 from liamwhite/pretext-fix (diff) | |
download | yuzu-e445ef9d607d04dab185be55b1395007a40c3b81.tar yuzu-e445ef9d607d04dab185be55b1395007a40c3b81.tar.gz yuzu-e445ef9d607d04dab185be55b1395007a40c3b81.tar.bz2 yuzu-e445ef9d607d04dab185be55b1395007a40c3b81.tar.lz yuzu-e445ef9d607d04dab185be55b1395007a40c3b81.tar.xz yuzu-e445ef9d607d04dab185be55b1395007a40c3b81.tar.zst yuzu-e445ef9d607d04dab185be55b1395007a40c3b81.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/hle/service/hid/controllers/applet_resource.h | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/src/core/hle/service/hid/controllers/applet_resource.h b/src/core/hle/service/hid/controllers/applet_resource.h new file mode 100644 index 000000000..3dcec2898 --- /dev/null +++ b/src/core/hle/service/hid/controllers/applet_resource.h @@ -0,0 +1,87 @@ +// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + +#pragma once + +#include <array> + +#include "common/bit_field.h" +#include "common/common_types.h" +#include "core/hle/result.h" + +namespace Core { +class System; +} + +namespace Kernel { +class KSharedMemory; +} + +namespace Service::HID { +class AppletResource { +public: + explicit AppletResource(Core::System& system_); + ~AppletResource(); + + Result CreateAppletResource(u64 aruid); + + Result RegisterAppletResourceUserId(u64 aruid, bool enable_input); + void UnregisterAppletResourceUserId(u64 aruid); + + u64 GetActiveAruid(); + Result GetSharedMemoryHandle(Kernel::KSharedMemory** out_handle, u64 aruid); + + u64 GetIndexFromAruid(u64 aruid); + + Result DestroySevenSixAxisTransferMemory(); + + void EnableInput(u64 aruid, bool is_enabled); + void EnableSixAxisSensor(u64 aruid, bool is_enabled); + void EnablePadInput(u64 aruid, bool is_enabled); + void EnableTouchScreen(u64 aruid, bool is_enabled); + void SetIsPalmaConnectable(u64 aruid, bool is_connectable); + void EnablePalmaBoostMode(u64 aruid, bool is_enabled); + +private: + static constexpr std::size_t AruidIndexMax = 0x20; + + enum RegistrationStatus : u32 { + None, + Initialized, + PendingDelete, + }; + + struct DataStatusFlag { + union { + u32 raw{}; + + BitField<0, 1, u32> is_initialized; + BitField<1, 1, u32> is_assigned; + BitField<16, 1, u32> enable_pad_input; + BitField<17, 1, u32> enable_six_axis_sensor; + BitField<18, 1, u32> bit_18; + BitField<19, 1, u32> is_palma_connectable; + BitField<20, 1, u32> enable_palma_boost_mode; + BitField<21, 1, u32> enable_touchscreen; + }; + }; + + struct AruidRegisterList { + std::array<RegistrationStatus, AruidIndexMax> flag{}; + std::array<u64, AruidIndexMax> aruid{}; + }; + static_assert(sizeof(AruidRegisterList) == 0x180, "AruidRegisterList is an invalid size"); + + struct AruidData { + DataStatusFlag flag{}; + u64 aruid{}; + Kernel::KSharedMemory* shared_memory_handle{nullptr}; + }; + + u64 active_aruid{}; + AruidRegisterList registration_list{}; + std::array<AruidData, AruidIndexMax> data{}; + + Core::System& system; +}; +} // namespace Service::HID |