diff options
author | Narr the Reg <juangerman-13@hotmail.com> | 2023-11-17 18:46:26 +0100 |
---|---|---|
committer | german77 <juangerman-13@hotmail.com> | 2023-11-21 00:19:17 +0100 |
commit | cff2d0e19e164d879b57bab9d06306fa70a1049e (patch) | |
tree | d3288aa0bc2b7988a492fe51bc04e2c822ceb275 /src/core/hle/service/hid/resource_manager.h | |
parent | Merge pull request #12011 from Macj0rdan/controller-applet (diff) | |
download | yuzu-cff2d0e19e164d879b57bab9d06306fa70a1049e.tar yuzu-cff2d0e19e164d879b57bab9d06306fa70a1049e.tar.gz yuzu-cff2d0e19e164d879b57bab9d06306fa70a1049e.tar.bz2 yuzu-cff2d0e19e164d879b57bab9d06306fa70a1049e.tar.lz yuzu-cff2d0e19e164d879b57bab9d06306fa70a1049e.tar.xz yuzu-cff2d0e19e164d879b57bab9d06306fa70a1049e.tar.zst yuzu-cff2d0e19e164d879b57bab9d06306fa70a1049e.zip |
Diffstat (limited to 'src/core/hle/service/hid/resource_manager.h')
-rw-r--r-- | src/core/hle/service/hid/resource_manager.h | 119 |
1 files changed, 63 insertions, 56 deletions
diff --git a/src/core/hle/service/hid/resource_manager.h b/src/core/hle/service/hid/resource_manager.h index 34dbf36bc..2b6a9b5e6 100644 --- a/src/core/hle/service/hid/resource_manager.h +++ b/src/core/hle/service/hid/resource_manager.h @@ -3,10 +3,6 @@ #pragma once -#include <chrono> - -#include "core/core.h" -#include "core/hle/service/hid/controllers/controller_base.h" #include "core/hle/service/kernel_helpers.h" #include "core/hle/service/service.h" @@ -14,74 +10,85 @@ namespace Core::Timing { struct EventType; } -namespace Core::HID { -class HIDCore; -} - namespace Service::HID { +class Controller_Stubbed; +class ConsoleSixAxis; +class DebugPad; +class Gesture; +class Keyboard; +class Mouse; +class NPad; +class Palma; +class SevenSixAxis; +class SixAxis; +class TouchScreen; +class XPad; + +using CaptureButton = Controller_Stubbed; +using DebugMouse = Controller_Stubbed; +using HomeButton = Controller_Stubbed; +using SleepButton = Controller_Stubbed; +using UniquePad = Controller_Stubbed; -enum class HidController : std::size_t { - DebugPad, - Touchscreen, - Mouse, - Keyboard, - XPad, - HomeButton, - SleepButton, - CaptureButton, - InputDetector, - UniquePad, - NPad, - Gesture, - ConsoleSixAxisSensor, - DebugMouse, - Palma, - - MaxControllers, -}; class ResourceManager { + public: explicit ResourceManager(Core::System& system_); ~ResourceManager(); - template <typename T> - T& GetController(HidController controller) { - return static_cast<T&>(*controllers[static_cast<size_t>(controller)]); - } - - template <typename T> - const T& GetController(HidController controller) const { - return static_cast<T&>(*controllers[static_cast<size_t>(controller)]); - } - void Initialize(); + std::shared_ptr<CaptureButton> GetCaptureButton() const; + std::shared_ptr<ConsoleSixAxis> GetConsoleSixAxis() const; + std::shared_ptr<DebugMouse> GetDebugMouse() const; + std::shared_ptr<DebugPad> GetDebugPad() const; + std::shared_ptr<Gesture> GetGesture() const; + std::shared_ptr<HomeButton> GetHomeButton() const; + std::shared_ptr<Keyboard> GetKeyboard() const; + std::shared_ptr<Mouse> GetMouse() const; + std::shared_ptr<NPad> GetNpad() const; + std::shared_ptr<Palma> GetPalma() const; + std::shared_ptr<SevenSixAxis> GetSevenSixAxis() const; + std::shared_ptr<SixAxis> GetSixAxis() const; + std::shared_ptr<SleepButton> GetSleepButton() const; + std::shared_ptr<TouchScreen> GetTouchScreen() const; + std::shared_ptr<UniquePad> GetUniquePad() const; + void UpdateControllers(std::uintptr_t user_data, std::chrono::nanoseconds ns_late); void UpdateNpad(std::uintptr_t user_data, std::chrono::nanoseconds ns_late); void UpdateMouseKeyboard(std::uintptr_t user_data, std::chrono::nanoseconds ns_late); void UpdateMotion(std::uintptr_t user_data, std::chrono::nanoseconds ns_late); private: - template <typename T> - void MakeController(HidController controller, u8* shared_memory) { - if constexpr (std::is_constructible_v<T, Core::System&, u8*>) { - controllers[static_cast<std::size_t>(controller)] = - std::make_unique<T>(system, shared_memory); - } else { - controllers[static_cast<std::size_t>(controller)] = - std::make_unique<T>(system.HIDCore(), shared_memory); - } - } - - template <typename T> - void MakeControllerWithServiceContext(HidController controller, u8* shared_memory) { - controllers[static_cast<std::size_t>(controller)] = - std::make_unique<T>(system.HIDCore(), shared_memory, service_context); - } - bool is_initialized{false}; - std::array<std::unique_ptr<ControllerBase>, static_cast<size_t>(HidController::MaxControllers)> - controllers{}; + + std::shared_ptr<CaptureButton> capture_button = nullptr; + std::shared_ptr<ConsoleSixAxis> console_six_axis = nullptr; + std::shared_ptr<DebugMouse> debug_mouse = nullptr; + std::shared_ptr<DebugPad> debug_pad = nullptr; + std::shared_ptr<Gesture> gesture = nullptr; + std::shared_ptr<HomeButton> home_button = nullptr; + std::shared_ptr<Keyboard> keyboard = nullptr; + std::shared_ptr<Mouse> mouse = nullptr; + std::shared_ptr<NPad> npad = nullptr; + std::shared_ptr<Palma> palma = nullptr; + std::shared_ptr<SevenSixAxis> seven_six_axis = nullptr; + std::shared_ptr<SixAxis> six_axis = nullptr; + std::shared_ptr<SleepButton> sleep_button = nullptr; + std::shared_ptr<TouchScreen> touch_screen = nullptr; + std::shared_ptr<UniquePad> unique_pad = nullptr; + std::shared_ptr<XPad> xpad = nullptr; + + // TODO: Create these resources + // std::shared_ptr<AudioControl> audio_control = nullptr; + // std::shared_ptr<ButtonConfig> button_config = nullptr; + // std::shared_ptr<Config> config = nullptr; + // std::shared_ptr<Connection> connection = nullptr; + // std::shared_ptr<CustomConfig> custom_config = nullptr; + // std::shared_ptr<Digitizer> digitizer = nullptr; + // std::shared_ptr<Hdls> hdls = nullptr; + // std::shared_ptr<PlayReport> play_report = nullptr; + // std::shared_ptr<Rail> rail = nullptr; Core::System& system; KernelHelpers::ServiceContext service_context; |