diff options
| author | 2023-09-16 11:40:42 -0400 | |
|---|---|---|
| committer | 2023-09-16 11:40:42 -0400 | |
| commit | 9912704234fe1aae367ef6c93d6ffaa7ce819f42 (patch) | |
| tree | a80e4779953422cb3392bc3ee791f3b25bd7575b /src | |
| parent | Merge pull request #11518 from german77/bad-npad (diff) | |
| parent | service: hid: Implement ApplyNpadSystemCommonPolicy (diff) | |
| download | yuzu-9912704234fe1aae367ef6c93d6ffaa7ce819f42.tar.gz yuzu-9912704234fe1aae367ef6c93d6ffaa7ce819f42.tar.xz yuzu-9912704234fe1aae367ef6c93d6ffaa7ce819f42.zip | |
Merge pull request #11519 from german77/system-policy
service: hid: Implement ApplyNpadSystemCommonPolicy
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/service/hid/controllers/npad.cpp | 25 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/npad.h | 2 | ||||
| -rw-r--r-- | src/core/hle/service/hid/hid.cpp | 31 | ||||
| -rw-r--r-- | src/core/hle/service/hid/hid.h | 2 |
4 files changed, 52 insertions, 8 deletions
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index e7d25e86e..146bb486d 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp | |||
| @@ -1511,6 +1511,31 @@ Core::HID::NpadButton Controller_NPad::GetAndResetPressState() { | |||
| 1511 | return static_cast<Core::HID::NpadButton>(press_state.exchange(0)); | 1511 | return static_cast<Core::HID::NpadButton>(press_state.exchange(0)); |
| 1512 | } | 1512 | } |
| 1513 | 1513 | ||
| 1514 | void Controller_NPad::ApplyNpadSystemCommonPolicy() { | ||
| 1515 | Core::HID::NpadStyleTag styletag{}; | ||
| 1516 | styletag.fullkey.Assign(1); | ||
| 1517 | styletag.handheld.Assign(1); | ||
| 1518 | styletag.joycon_dual.Assign(1); | ||
| 1519 | styletag.system_ext.Assign(1); | ||
| 1520 | styletag.system.Assign(1); | ||
| 1521 | SetSupportedStyleSet(styletag); | ||
| 1522 | |||
| 1523 | SetNpadHandheldActivationMode(NpadHandheldActivationMode::Dual); | ||
| 1524 | |||
| 1525 | supported_npad_id_types.clear(); | ||
| 1526 | supported_npad_id_types.resize(10); | ||
| 1527 | supported_npad_id_types[0] = Core::HID::NpadIdType::Player1; | ||
| 1528 | supported_npad_id_types[1] = Core::HID::NpadIdType::Player2; | ||
| 1529 | supported_npad_id_types[2] = Core::HID::NpadIdType::Player3; | ||
| 1530 | supported_npad_id_types[3] = Core::HID::NpadIdType::Player4; | ||
| 1531 | supported_npad_id_types[4] = Core::HID::NpadIdType::Player5; | ||
| 1532 | supported_npad_id_types[5] = Core::HID::NpadIdType::Player6; | ||
| 1533 | supported_npad_id_types[6] = Core::HID::NpadIdType::Player7; | ||
| 1534 | supported_npad_id_types[7] = Core::HID::NpadIdType::Player8; | ||
| 1535 | supported_npad_id_types[8] = Core::HID::NpadIdType::Other; | ||
| 1536 | supported_npad_id_types[9] = Core::HID::NpadIdType::Handheld; | ||
| 1537 | } | ||
| 1538 | |||
| 1514 | bool Controller_NPad::IsControllerSupported(Core::HID::NpadStyleIndex controller) const { | 1539 | bool Controller_NPad::IsControllerSupported(Core::HID::NpadStyleIndex controller) const { |
| 1515 | if (controller == Core::HID::NpadStyleIndex::Handheld) { | 1540 | if (controller == Core::HID::NpadStyleIndex::Handheld) { |
| 1516 | const bool support_handheld = | 1541 | const bool support_handheld = |
diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h index 09707d2f8..949e58a4c 100644 --- a/src/core/hle/service/hid/controllers/npad.h +++ b/src/core/hle/service/hid/controllers/npad.h | |||
| @@ -190,6 +190,8 @@ public: | |||
| 190 | // Specifically for cheat engine and other features. | 190 | // Specifically for cheat engine and other features. |
| 191 | Core::HID::NpadButton GetAndResetPressState(); | 191 | Core::HID::NpadButton GetAndResetPressState(); |
| 192 | 192 | ||
| 193 | void ApplyNpadSystemCommonPolicy(); | ||
| 194 | |||
| 193 | static bool IsNpadIdValid(Core::HID::NpadIdType npad_id); | 195 | static bool IsNpadIdValid(Core::HID::NpadIdType npad_id); |
| 194 | static Result IsDeviceHandleValid(const Core::HID::VibrationDeviceHandle& device_handle); | 196 | static Result IsDeviceHandleValid(const Core::HID::VibrationDeviceHandle& device_handle); |
| 195 | static Result VerifyValidSixAxisSensorHandle( | 197 | static Result VerifyValidSixAxisSensorHandle( |
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index 3657e61d3..4d70006c1 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp | |||
| @@ -231,8 +231,10 @@ std::shared_ptr<IAppletResource> Hid::GetAppletResource() { | |||
| 231 | return applet_resource; | 231 | return applet_resource; |
| 232 | } | 232 | } |
| 233 | 233 | ||
| 234 | Hid::Hid(Core::System& system_) | 234 | Hid::Hid(Core::System& system_, std::shared_ptr<IAppletResource> applet_resource_) |
| 235 | : ServiceFramework{system_, "hid"}, service_context{system_, service_name} { | 235 | : ServiceFramework{system_, "hid"}, applet_resource{applet_resource_}, service_context{ |
| 236 | system_, | ||
| 237 | service_name} { | ||
| 236 | // clang-format off | 238 | // clang-format off |
| 237 | static const FunctionInfo functions[] = { | 239 | static const FunctionInfo functions[] = { |
| 238 | {0, &Hid::CreateAppletResource, "CreateAppletResource"}, | 240 | {0, &Hid::CreateAppletResource, "CreateAppletResource"}, |
| @@ -2543,8 +2545,9 @@ public: | |||
| 2543 | 2545 | ||
| 2544 | class HidSys final : public ServiceFramework<HidSys> { | 2546 | class HidSys final : public ServiceFramework<HidSys> { |
| 2545 | public: | 2547 | public: |
| 2546 | explicit HidSys(Core::System& system_) | 2548 | explicit HidSys(Core::System& system_, std::shared_ptr<IAppletResource> applet_resource_) |
| 2547 | : ServiceFramework{system_, "hid:sys"}, service_context{system_, "hid:sys"} { | 2549 | : ServiceFramework{system_, "hid:sys"}, service_context{system_, "hid:sys"}, |
| 2550 | applet_resource{applet_resource_} { | ||
| 2548 | // clang-format off | 2551 | // clang-format off |
| 2549 | static const FunctionInfo functions[] = { | 2552 | static const FunctionInfo functions[] = { |
| 2550 | {31, nullptr, "SendKeyboardLockKeyEvent"}, | 2553 | {31, nullptr, "SendKeyboardLockKeyEvent"}, |
| @@ -2756,9 +2759,12 @@ public: | |||
| 2756 | 2759 | ||
| 2757 | private: | 2760 | private: |
| 2758 | void ApplyNpadSystemCommonPolicy(HLERequestContext& ctx) { | 2761 | void ApplyNpadSystemCommonPolicy(HLERequestContext& ctx) { |
| 2759 | // We already do this for homebrew so we can just stub it out | ||
| 2760 | LOG_WARNING(Service_HID, "called"); | 2762 | LOG_WARNING(Service_HID, "called"); |
| 2761 | 2763 | ||
| 2764 | GetAppletResource() | ||
| 2765 | ->GetController<Controller_NPad>(HidController::NPad) | ||
| 2766 | .ApplyNpadSystemCommonPolicy(); | ||
| 2767 | |||
| 2762 | IPC::ResponseBuilder rb{ctx, 2}; | 2768 | IPC::ResponseBuilder rb{ctx, 2}; |
| 2763 | rb.Push(ResultSuccess); | 2769 | rb.Push(ResultSuccess); |
| 2764 | } | 2770 | } |
| @@ -2821,17 +2827,28 @@ private: | |||
| 2821 | rb.PushRaw(touchscreen_config); | 2827 | rb.PushRaw(touchscreen_config); |
| 2822 | } | 2828 | } |
| 2823 | 2829 | ||
| 2830 | std::shared_ptr<IAppletResource> GetAppletResource() { | ||
| 2831 | if (applet_resource == nullptr) { | ||
| 2832 | applet_resource = std::make_shared<IAppletResource>(system, service_context); | ||
| 2833 | } | ||
| 2834 | |||
| 2835 | return applet_resource; | ||
| 2836 | } | ||
| 2837 | |||
| 2824 | Kernel::KEvent* joy_detach_event; | 2838 | Kernel::KEvent* joy_detach_event; |
| 2825 | KernelHelpers::ServiceContext service_context; | 2839 | KernelHelpers::ServiceContext service_context; |
| 2840 | std::shared_ptr<IAppletResource> applet_resource; | ||
| 2826 | }; | 2841 | }; |
| 2827 | 2842 | ||
| 2828 | void LoopProcess(Core::System& system) { | 2843 | void LoopProcess(Core::System& system) { |
| 2829 | auto server_manager = std::make_unique<ServerManager>(system); | 2844 | auto server_manager = std::make_unique<ServerManager>(system); |
| 2845 | std::shared_ptr<IAppletResource> applet_resource; | ||
| 2830 | 2846 | ||
| 2831 | server_manager->RegisterNamedService("hid", std::make_shared<Hid>(system)); | 2847 | server_manager->RegisterNamedService("hid", std::make_shared<Hid>(system, applet_resource)); |
| 2832 | server_manager->RegisterNamedService("hidbus", std::make_shared<HidBus>(system)); | 2848 | server_manager->RegisterNamedService("hidbus", std::make_shared<HidBus>(system)); |
| 2833 | server_manager->RegisterNamedService("hid:dbg", std::make_shared<HidDbg>(system)); | 2849 | server_manager->RegisterNamedService("hid:dbg", std::make_shared<HidDbg>(system)); |
| 2834 | server_manager->RegisterNamedService("hid:sys", std::make_shared<HidSys>(system)); | 2850 | server_manager->RegisterNamedService("hid:sys", |
| 2851 | std::make_shared<HidSys>(system, applet_resource)); | ||
| 2835 | 2852 | ||
| 2836 | server_manager->RegisterNamedService("irs", std::make_shared<Service::IRS::IRS>(system)); | 2853 | server_manager->RegisterNamedService("irs", std::make_shared<Service::IRS::IRS>(system)); |
| 2837 | server_manager->RegisterNamedService("irs:sys", | 2854 | server_manager->RegisterNamedService("irs:sys", |
diff --git a/src/core/hle/service/hid/hid.h b/src/core/hle/service/hid/hid.h index f247b83c2..0ca43de93 100644 --- a/src/core/hle/service/hid/hid.h +++ b/src/core/hle/service/hid/hid.h | |||
| @@ -95,7 +95,7 @@ private: | |||
| 95 | 95 | ||
| 96 | class Hid final : public ServiceFramework<Hid> { | 96 | class Hid final : public ServiceFramework<Hid> { |
| 97 | public: | 97 | public: |
| 98 | explicit Hid(Core::System& system_); | 98 | explicit Hid(Core::System& system_, std::shared_ptr<IAppletResource> applet_resource_); |
| 99 | ~Hid() override; | 99 | ~Hid() override; |
| 100 | 100 | ||
| 101 | std::shared_ptr<IAppletResource> GetAppletResource(); | 101 | std::shared_ptr<IAppletResource> GetAppletResource(); |