From a3f235f8a23303796a3727978806f2dcb13894eb Mon Sep 17 00:00:00 2001 From: german77 Date: Sat, 16 Sep 2023 08:38:10 -0600 Subject: service: hid: Implement ApplyNpadSystemCommonPolicy --- src/core/hle/service/hid/hid.cpp | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'src/core/hle/service/hid/hid.cpp') diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index fd466db7b..6f711c0da 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp @@ -231,8 +231,10 @@ std::shared_ptr Hid::GetAppletResource() { return applet_resource; } -Hid::Hid(Core::System& system_) - : ServiceFramework{system_, "hid"}, service_context{system_, service_name} { +Hid::Hid(Core::System& system_, std::shared_ptr applet_resource_) + : ServiceFramework{system_, "hid"}, applet_resource{applet_resource_}, service_context{ + system_, + service_name} { // clang-format off static const FunctionInfo functions[] = { {0, &Hid::CreateAppletResource, "CreateAppletResource"}, @@ -2543,8 +2545,9 @@ public: class HidSys final : public ServiceFramework { public: - explicit HidSys(Core::System& system_) - : ServiceFramework{system_, "hid:sys"}, service_context{system_, "hid:sys"} { + explicit HidSys(Core::System& system_, std::shared_ptr applet_resource_) + : ServiceFramework{system_, "hid:sys"}, service_context{system_, "hid:sys"}, + applet_resource{applet_resource_} { // clang-format off static const FunctionInfo functions[] = { {31, nullptr, "SendKeyboardLockKeyEvent"}, @@ -2756,9 +2759,12 @@ public: private: void ApplyNpadSystemCommonPolicy(HLERequestContext& ctx) { - // We already do this for homebrew so we can just stub it out LOG_WARNING(Service_HID, "called"); + GetAppletResource() + ->GetController(HidController::NPad) + .ApplyNpadSystemCommonPolicy(); + IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } @@ -2821,17 +2827,28 @@ private: rb.PushRaw(touchscreen_config); } + std::shared_ptr GetAppletResource() { + if (applet_resource == nullptr) { + applet_resource = std::make_shared(system, service_context); + } + + return applet_resource; + } + Kernel::KEvent* joy_detach_event; KernelHelpers::ServiceContext service_context; + std::shared_ptr applet_resource; }; void LoopProcess(Core::System& system) { auto server_manager = std::make_unique(system); + std::shared_ptr applet_resource; - server_manager->RegisterNamedService("hid", std::make_shared(system)); + server_manager->RegisterNamedService("hid", std::make_shared(system, applet_resource)); server_manager->RegisterNamedService("hidbus", std::make_shared(system)); server_manager->RegisterNamedService("hid:dbg", std::make_shared(system)); - server_manager->RegisterNamedService("hid:sys", std::make_shared(system)); + server_manager->RegisterNamedService("hid:sys", + std::make_shared(system, applet_resource)); server_manager->RegisterNamedService("irs", std::make_shared(system)); server_manager->RegisterNamedService("irs:sys", -- cgit v1.2.3