diff options
author | german77 <juangerman-13@hotmail.com> | 2024-01-07 16:05:12 +0100 |
---|---|---|
committer | Narr the Reg <juangerman-13@hotmail.com> | 2024-01-12 02:35:04 +0100 |
commit | b5dac5f525e8d5884506ebd98a530e237b518480 (patch) | |
tree | 6ceee925ba897dc3450bdad209982f0be4bc3f7a /src/hid_core/resources/abstracted_pad/abstract_mcu_handler.h | |
parent | Merge pull request #12653 from liamwhite/once-more (diff) | |
download | yuzu-b5dac5f525e8d5884506ebd98a530e237b518480.tar yuzu-b5dac5f525e8d5884506ebd98a530e237b518480.tar.gz yuzu-b5dac5f525e8d5884506ebd98a530e237b518480.tar.bz2 yuzu-b5dac5f525e8d5884506ebd98a530e237b518480.tar.lz yuzu-b5dac5f525e8d5884506ebd98a530e237b518480.tar.xz yuzu-b5dac5f525e8d5884506ebd98a530e237b518480.tar.zst yuzu-b5dac5f525e8d5884506ebd98a530e237b518480.zip |
Diffstat (limited to '')
-rw-r--r-- | src/hid_core/resources/abstracted_pad/abstract_mcu_handler.h | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/hid_core/resources/abstracted_pad/abstract_mcu_handler.h b/src/hid_core/resources/abstracted_pad/abstract_mcu_handler.h new file mode 100644 index 000000000..9902dd03a --- /dev/null +++ b/src/hid_core/resources/abstracted_pad/abstract_mcu_handler.h @@ -0,0 +1,52 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + +#pragma once + +#include "common/common_types.h" +#include "core/hle/result.h" +#include "hid_core/hid_types.h" + +namespace Service::HID { +struct IAbstractedPad; +class NpadAbstractedPadHolder; +class NpadAbstractPropertiesHandler; + +enum class NpadMcuState : u32 { + None, + Available, + Active, +}; + +struct NpadMcuHolder { + NpadMcuState state; + INSERT_PADDING_BYTES(0x4); + IAbstractedPad* abstracted_pad; +}; +static_assert(sizeof(NpadMcuHolder) == 0x10, "NpadMcuHolder is an invalid size"); + +/// Handles Npad request from HID interfaces +class NpadAbstractMcuHandler final { +public: + explicit NpadAbstractMcuHandler(); + ~NpadAbstractMcuHandler(); + + void SetAbstractPadHolder(NpadAbstractedPadHolder* holder); + void SetPropertiesHandler(NpadAbstractPropertiesHandler* handler); + + Result IncrementRefCounter(); + Result DecrementRefCounter(); + + void UpdateMcuState(); + Result GetAbstractedPad(IAbstractedPad** data, u32 mcu_index); + NpadMcuState GetMcuState(u32 mcu_index); + Result SetMcuState(bool is_enabled, u32 mcu_index); + +private: + NpadAbstractedPadHolder* abstract_pad_holder{nullptr}; + NpadAbstractPropertiesHandler* properties_handler{nullptr}; + + s32 ref_counter{}; + std::array<NpadMcuHolder, 2> mcu_holder{}; +}; +} // namespace Service::HID |