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.cpp | |
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 '')
-rw-r--r-- | src/core/hle/service/hid/resource_manager.cpp | 155 |
1 files changed, 106 insertions, 49 deletions
diff --git a/src/core/hle/service/hid/resource_manager.cpp b/src/core/hle/service/hid/resource_manager.cpp index d6f42c646..e76d4eea9 100644 --- a/src/core/hle/service/hid/resource_manager.cpp +++ b/src/core/hle/service/hid/resource_manager.cpp @@ -9,14 +9,15 @@ #include "core/hle/service/hid/resource_manager.h" #include "core/hle/service/ipc_helpers.h" -#include "core/hle/service/hid/controllers/console_sixaxis.h" -#include "core/hle/service/hid/controllers/controller_base.h" +#include "core/hle/service/hid/controllers/console_six_axis.h" #include "core/hle/service/hid/controllers/debug_pad.h" #include "core/hle/service/hid/controllers/gesture.h" #include "core/hle/service/hid/controllers/keyboard.h" #include "core/hle/service/hid/controllers/mouse.h" #include "core/hle/service/hid/controllers/npad.h" #include "core/hle/service/hid/controllers/palma.h" +#include "core/hle/service/hid/controllers/seven_six_axis.h" +#include "core/hle/service/hid/controllers/six_axis.h" #include "core/hle/service/hid/controllers/stubbed.h" #include "core/hle/service/hid/controllers/touchscreen.h" #include "core/hle/service/hid/controllers/xpad.h" @@ -42,76 +43,132 @@ void ResourceManager::Initialize() { } u8* shared_memory = system.Kernel().GetHidSharedMem().GetPointer(); - MakeController<Controller_DebugPad>(HidController::DebugPad, shared_memory); - MakeController<Controller_Touchscreen>(HidController::Touchscreen, shared_memory); - MakeController<Controller_Mouse>(HidController::Mouse, shared_memory); - MakeController<Controller_Keyboard>(HidController::Keyboard, shared_memory); - MakeController<Controller_XPad>(HidController::XPad, shared_memory); - MakeController<Controller_Stubbed>(HidController::HomeButton, shared_memory); - MakeController<Controller_Stubbed>(HidController::SleepButton, shared_memory); - MakeController<Controller_Stubbed>(HidController::CaptureButton, shared_memory); - MakeController<Controller_Stubbed>(HidController::InputDetector, shared_memory); - MakeController<Controller_Stubbed>(HidController::UniquePad, shared_memory); - MakeControllerWithServiceContext<Controller_NPad>(HidController::NPad, shared_memory); - MakeController<Controller_Gesture>(HidController::Gesture, shared_memory); - MakeController<Controller_ConsoleSixAxis>(HidController::ConsoleSixAxisSensor, shared_memory); - MakeController<Controller_Stubbed>(HidController::DebugMouse, shared_memory); - MakeControllerWithServiceContext<Controller_Palma>(HidController::Palma, shared_memory); + debug_pad = std::make_shared<DebugPad>(system.HIDCore(), shared_memory); + mouse = std::make_shared<Mouse>(system.HIDCore(), shared_memory); + debug_mouse = std::make_shared<DebugMouse>(system.HIDCore(), shared_memory); + keyboard = std::make_shared<Keyboard>(system.HIDCore(), shared_memory); + unique_pad = std::make_shared<UniquePad>(system.HIDCore(), shared_memory); + npad = std::make_shared<NPad>(system.HIDCore(), shared_memory, service_context); + gesture = std::make_shared<Gesture>(system.HIDCore(), shared_memory); + touch_screen = std::make_shared<TouchScreen>(system.HIDCore(), shared_memory); + xpad = std::make_shared<XPad>(system.HIDCore(), shared_memory); + + palma = std::make_shared<Palma>(system.HIDCore(), shared_memory, service_context); + + home_button = std::make_shared<HomeButton>(system.HIDCore(), shared_memory); + sleep_button = std::make_shared<SleepButton>(system.HIDCore(), shared_memory); + capture_button = std::make_shared<CaptureButton>(system.HIDCore(), shared_memory); + + six_axis = std::make_shared<SixAxis>(system.HIDCore(), npad); + console_six_axis = std::make_shared<ConsoleSixAxis>(system.HIDCore(), shared_memory); + seven_six_axis = std::make_shared<SevenSixAxis>(system); + + home_button->SetCommonHeaderOffset(0x4C00); + sleep_button->SetCommonHeaderOffset(0x4E00); + capture_button->SetCommonHeaderOffset(0x5000); + unique_pad->SetCommonHeaderOffset(0x5A00); + debug_mouse->SetCommonHeaderOffset(0x3DC00); // Homebrew doesn't try to activate some controllers, so we activate them by default - GetController<Controller_NPad>(HidController::NPad).Activate(); - GetController<Controller_Touchscreen>(HidController::Touchscreen).Activate(); - - GetController<Controller_Stubbed>(HidController::HomeButton).SetCommonHeaderOffset(0x4C00); - GetController<Controller_Stubbed>(HidController::SleepButton).SetCommonHeaderOffset(0x4E00); - GetController<Controller_Stubbed>(HidController::CaptureButton).SetCommonHeaderOffset(0x5000); - GetController<Controller_Stubbed>(HidController::InputDetector).SetCommonHeaderOffset(0x5200); - GetController<Controller_Stubbed>(HidController::UniquePad).SetCommonHeaderOffset(0x5A00); - GetController<Controller_Stubbed>(HidController::DebugMouse).SetCommonHeaderOffset(0x3DC00); + npad->Activate(); + six_axis->Activate(); + touch_screen->Activate(); system.HIDCore().ReloadInputDevices(); is_initialized = true; } +std::shared_ptr<CaptureButton> ResourceManager::GetCaptureButton() const { + return capture_button; +} + +std::shared_ptr<ConsoleSixAxis> ResourceManager::GetConsoleSixAxis() const { + return console_six_axis; +} + +std::shared_ptr<DebugMouse> ResourceManager::GetDebugMouse() const { + return debug_mouse; +} + +std::shared_ptr<DebugPad> ResourceManager::GetDebugPad() const { + return debug_pad; +} + +std::shared_ptr<Gesture> ResourceManager::GetGesture() const { + return gesture; +} + +std::shared_ptr<HomeButton> ResourceManager::GetHomeButton() const { + return home_button; +} + +std::shared_ptr<Keyboard> ResourceManager::GetKeyboard() const { + return keyboard; +} + +std::shared_ptr<Mouse> ResourceManager::GetMouse() const { + return mouse; +} + +std::shared_ptr<NPad> ResourceManager::GetNpad() const { + return npad; +} + +std::shared_ptr<Palma> ResourceManager::GetPalma() const { + return palma; +} + +std::shared_ptr<SevenSixAxis> ResourceManager::GetSevenSixAxis() const { + return seven_six_axis; +} + +std::shared_ptr<SixAxis> ResourceManager::GetSixAxis() const { + return six_axis; +} + +std::shared_ptr<SleepButton> ResourceManager::GetSleepButton() const { + return sleep_button; +} + +std::shared_ptr<TouchScreen> ResourceManager::GetTouchScreen() const { + return touch_screen; +} + +std::shared_ptr<UniquePad> ResourceManager::GetUniquePad() const { + return unique_pad; +} void ResourceManager::UpdateControllers(std::uintptr_t user_data, std::chrono::nanoseconds ns_late) { auto& core_timing = system.CoreTiming(); - - for (const auto& controller : controllers) { - // Keyboard has it's own update event - if (controller == controllers[static_cast<size_t>(HidController::Keyboard)]) { - continue; - } - // Mouse has it's own update event - if (controller == controllers[static_cast<size_t>(HidController::Mouse)]) { - continue; - } - // Npad has it's own update event - if (controller == controllers[static_cast<size_t>(HidController::NPad)]) { - continue; - } - controller->OnUpdate(core_timing); - } + debug_pad->OnUpdate(core_timing); + unique_pad->OnUpdate(core_timing); + gesture->OnUpdate(core_timing); + touch_screen->OnUpdate(core_timing); + palma->OnUpdate(core_timing); + home_button->OnUpdate(core_timing); + sleep_button->OnUpdate(core_timing); + capture_button->OnUpdate(core_timing); + xpad->OnUpdate(core_timing); } void ResourceManager::UpdateNpad(std::uintptr_t user_data, std::chrono::nanoseconds ns_late) { auto& core_timing = system.CoreTiming(); - - controllers[static_cast<size_t>(HidController::NPad)]->OnUpdate(core_timing); + npad->OnUpdate(core_timing); } void ResourceManager::UpdateMouseKeyboard(std::uintptr_t user_data, std::chrono::nanoseconds ns_late) { auto& core_timing = system.CoreTiming(); - - controllers[static_cast<size_t>(HidController::Mouse)]->OnUpdate(core_timing); - controllers[static_cast<size_t>(HidController::Keyboard)]->OnUpdate(core_timing); + mouse->OnUpdate(core_timing); + debug_mouse->OnUpdate(core_timing); + keyboard->OnUpdate(core_timing); } void ResourceManager::UpdateMotion(std::uintptr_t user_data, std::chrono::nanoseconds ns_late) { auto& core_timing = system.CoreTiming(); - - controllers[static_cast<size_t>(HidController::NPad)]->OnMotionUpdate(core_timing); + six_axis->OnUpdate(core_timing); + seven_six_axis->OnUpdate(core_timing); + console_six_axis->OnUpdate(core_timing); } IAppletResource::IAppletResource(Core::System& system_, std::shared_ptr<ResourceManager> resource) |