diff options
| author | 2023-08-11 00:44:42 -0600 | |
|---|---|---|
| committer | 2023-08-11 10:13:21 -0600 | |
| commit | bdd96118d13d69c753b635e6adec475e3ea2bf6b (patch) | |
| tree | e97a07f318347b6ca1d8bb182498bb6e0b1c05a5 /src/core/hle | |
| parent | Merge pull request #11093 from liamwhite/result-ergonomics (diff) | |
| download | yuzu-bdd96118d13d69c753b635e6adec475e3ea2bf6b.tar.gz yuzu-bdd96118d13d69c753b635e6adec475e3ea2bf6b.tar.xz yuzu-bdd96118d13d69c753b635e6adec475e3ea2bf6b.zip | |
service: hid: Implement functions needed by QLaunch
Diffstat (limited to 'src/core/hle')
| -rw-r--r-- | src/core/hle/service/hid/controllers/touchscreen.h | 16 | ||||
| -rw-r--r-- | src/core/hle/service/hid/hid.cpp | 68 |
2 files changed, 60 insertions, 24 deletions
diff --git a/src/core/hle/service/hid/controllers/touchscreen.h b/src/core/hle/service/hid/controllers/touchscreen.h index e57a3a80e..dd00921fd 100644 --- a/src/core/hle/service/hid/controllers/touchscreen.h +++ b/src/core/hle/service/hid/controllers/touchscreen.h | |||
| @@ -16,22 +16,6 @@ class EmulatedConsole; | |||
| 16 | namespace Service::HID { | 16 | namespace Service::HID { |
| 17 | class Controller_Touchscreen final : public ControllerBase { | 17 | class Controller_Touchscreen final : public ControllerBase { |
| 18 | public: | 18 | public: |
| 19 | // This is nn::hid::TouchScreenModeForNx | ||
| 20 | enum class TouchScreenModeForNx : u8 { | ||
| 21 | UseSystemSetting, | ||
| 22 | Finger, | ||
| 23 | Heat2, | ||
| 24 | }; | ||
| 25 | |||
| 26 | // This is nn::hid::TouchScreenConfigurationForNx | ||
| 27 | struct TouchScreenConfigurationForNx { | ||
| 28 | TouchScreenModeForNx mode{TouchScreenModeForNx::UseSystemSetting}; | ||
| 29 | INSERT_PADDING_BYTES_NOINIT(0x7); | ||
| 30 | INSERT_PADDING_BYTES_NOINIT(0xF); // Reserved | ||
| 31 | }; | ||
| 32 | static_assert(sizeof(TouchScreenConfigurationForNx) == 0x17, | ||
| 33 | "TouchScreenConfigurationForNx is an invalid size"); | ||
| 34 | |||
| 35 | explicit Controller_Touchscreen(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_); | 19 | explicit Controller_Touchscreen(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_); |
| 36 | ~Controller_Touchscreen() override; | 20 | ~Controller_Touchscreen() override; |
| 37 | 21 | ||
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index 2bf1d8a27..fd466db7b 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp | |||
| @@ -2368,7 +2368,7 @@ void Hid::GetNpadCommunicationMode(HLERequestContext& ctx) { | |||
| 2368 | 2368 | ||
| 2369 | void Hid::SetTouchScreenConfiguration(HLERequestContext& ctx) { | 2369 | void Hid::SetTouchScreenConfiguration(HLERequestContext& ctx) { |
| 2370 | IPC::RequestParser rp{ctx}; | 2370 | IPC::RequestParser rp{ctx}; |
| 2371 | const auto touchscreen_mode{rp.PopRaw<Controller_Touchscreen::TouchScreenConfigurationForNx>()}; | 2371 | const auto touchscreen_mode{rp.PopRaw<Core::HID::TouchScreenConfigurationForNx>()}; |
| 2372 | const auto applet_resource_user_id{rp.Pop<u64>()}; | 2372 | const auto applet_resource_user_id{rp.Pop<u64>()}; |
| 2373 | 2373 | ||
| 2374 | LOG_WARNING(Service_HID, "(STUBBED) called, touchscreen_mode={}, applet_resource_user_id={}", | 2374 | LOG_WARNING(Service_HID, "(STUBBED) called, touchscreen_mode={}, applet_resource_user_id={}", |
| @@ -2543,7 +2543,8 @@ public: | |||
| 2543 | 2543 | ||
| 2544 | class HidSys final : public ServiceFramework<HidSys> { | 2544 | class HidSys final : public ServiceFramework<HidSys> { |
| 2545 | public: | 2545 | public: |
| 2546 | explicit HidSys(Core::System& system_) : ServiceFramework{system_, "hid:sys"} { | 2546 | explicit HidSys(Core::System& system_) |
| 2547 | : ServiceFramework{system_, "hid:sys"}, service_context{system_, "hid:sys"} { | ||
| 2547 | // clang-format off | 2548 | // clang-format off |
| 2548 | static const FunctionInfo functions[] = { | 2549 | static const FunctionInfo functions[] = { |
| 2549 | {31, nullptr, "SendKeyboardLockKeyEvent"}, | 2550 | {31, nullptr, "SendKeyboardLockKeyEvent"}, |
| @@ -2568,7 +2569,7 @@ public: | |||
| 2568 | {303, &HidSys::ApplyNpadSystemCommonPolicy, "ApplyNpadSystemCommonPolicy"}, | 2569 | {303, &HidSys::ApplyNpadSystemCommonPolicy, "ApplyNpadSystemCommonPolicy"}, |
| 2569 | {304, nullptr, "EnableAssigningSingleOnSlSrPress"}, | 2570 | {304, nullptr, "EnableAssigningSingleOnSlSrPress"}, |
| 2570 | {305, nullptr, "DisableAssigningSingleOnSlSrPress"}, | 2571 | {305, nullptr, "DisableAssigningSingleOnSlSrPress"}, |
| 2571 | {306, nullptr, "GetLastActiveNpad"}, | 2572 | {306, &HidSys::GetLastActiveNpad, "GetLastActiveNpad"}, |
| 2572 | {307, nullptr, "GetNpadSystemExtStyle"}, | 2573 | {307, nullptr, "GetNpadSystemExtStyle"}, |
| 2573 | {308, nullptr, "ApplyNpadSystemCommonPolicyFull"}, | 2574 | {308, nullptr, "ApplyNpadSystemCommonPolicyFull"}, |
| 2574 | {309, nullptr, "GetNpadFullKeyGripColor"}, | 2575 | {309, nullptr, "GetNpadFullKeyGripColor"}, |
| @@ -2624,7 +2625,7 @@ public: | |||
| 2624 | {700, nullptr, "ActivateUniquePad"}, | 2625 | {700, nullptr, "ActivateUniquePad"}, |
| 2625 | {702, nullptr, "AcquireUniquePadConnectionEventHandle"}, | 2626 | {702, nullptr, "AcquireUniquePadConnectionEventHandle"}, |
| 2626 | {703, nullptr, "GetUniquePadIds"}, | 2627 | {703, nullptr, "GetUniquePadIds"}, |
| 2627 | {751, nullptr, "AcquireJoyDetachOnBluetoothOffEventHandle"}, | 2628 | {751, &HidSys::AcquireJoyDetachOnBluetoothOffEventHandle, "AcquireJoyDetachOnBluetoothOffEventHandle"}, |
| 2628 | {800, nullptr, "ListSixAxisSensorHandles"}, | 2629 | {800, nullptr, "ListSixAxisSensorHandles"}, |
| 2629 | {801, nullptr, "IsSixAxisSensorUserCalibrationSupported"}, | 2630 | {801, nullptr, "IsSixAxisSensorUserCalibrationSupported"}, |
| 2630 | {802, nullptr, "ResetSixAxisSensorCalibrationValues"}, | 2631 | {802, nullptr, "ResetSixAxisSensorCalibrationValues"}, |
| @@ -2650,7 +2651,7 @@ public: | |||
| 2650 | {830, nullptr, "SetNotificationLedPattern"}, | 2651 | {830, nullptr, "SetNotificationLedPattern"}, |
| 2651 | {831, nullptr, "SetNotificationLedPatternWithTimeout"}, | 2652 | {831, nullptr, "SetNotificationLedPatternWithTimeout"}, |
| 2652 | {832, nullptr, "PrepareHidsForNotificationWake"}, | 2653 | {832, nullptr, "PrepareHidsForNotificationWake"}, |
| 2653 | {850, nullptr, "IsUsbFullKeyControllerEnabled"}, | 2654 | {850, &HidSys::IsUsbFullKeyControllerEnabled, "IsUsbFullKeyControllerEnabled"}, |
| 2654 | {851, nullptr, "EnableUsbFullKeyController"}, | 2655 | {851, nullptr, "EnableUsbFullKeyController"}, |
| 2655 | {852, nullptr, "IsUsbConnected"}, | 2656 | {852, nullptr, "IsUsbConnected"}, |
| 2656 | {870, nullptr, "IsHandheldButtonPressedOnConsoleMode"}, | 2657 | {870, nullptr, "IsHandheldButtonPressedOnConsoleMode"}, |
| @@ -2682,7 +2683,7 @@ public: | |||
| 2682 | {1150, nullptr, "SetTouchScreenMagnification"}, | 2683 | {1150, nullptr, "SetTouchScreenMagnification"}, |
| 2683 | {1151, nullptr, "GetTouchScreenFirmwareVersion"}, | 2684 | {1151, nullptr, "GetTouchScreenFirmwareVersion"}, |
| 2684 | {1152, nullptr, "SetTouchScreenDefaultConfiguration"}, | 2685 | {1152, nullptr, "SetTouchScreenDefaultConfiguration"}, |
| 2685 | {1153, nullptr, "GetTouchScreenDefaultConfiguration"}, | 2686 | {1153, &HidSys::GetTouchScreenDefaultConfiguration, "GetTouchScreenDefaultConfiguration"}, |
| 2686 | {1154, nullptr, "IsFirmwareAvailableForNotification"}, | 2687 | {1154, nullptr, "IsFirmwareAvailableForNotification"}, |
| 2687 | {1155, nullptr, "SetForceHandheldStyleVibration"}, | 2688 | {1155, nullptr, "SetForceHandheldStyleVibration"}, |
| 2688 | {1156, nullptr, "SendConnectionTriggerWithoutTimeoutEvent"}, | 2689 | {1156, nullptr, "SendConnectionTriggerWithoutTimeoutEvent"}, |
| @@ -2749,6 +2750,8 @@ public: | |||
| 2749 | // clang-format on | 2750 | // clang-format on |
| 2750 | 2751 | ||
| 2751 | RegisterHandlers(functions); | 2752 | RegisterHandlers(functions); |
| 2753 | |||
| 2754 | joy_detach_event = service_context.CreateEvent("HidSys::JoyDetachEvent"); | ||
| 2752 | } | 2755 | } |
| 2753 | 2756 | ||
| 2754 | private: | 2757 | private: |
| @@ -2760,17 +2763,66 @@ private: | |||
| 2760 | rb.Push(ResultSuccess); | 2763 | rb.Push(ResultSuccess); |
| 2761 | } | 2764 | } |
| 2762 | 2765 | ||
| 2766 | void GetLastActiveNpad(HLERequestContext& ctx) { | ||
| 2767 | LOG_DEBUG(Service_HID, "(STUBBED) called"); | ||
| 2768 | |||
| 2769 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 2770 | rb.Push(ResultSuccess); | ||
| 2771 | rb.PushEnum(Core::HID::NpadIdType::Handheld); | ||
| 2772 | } | ||
| 2773 | |||
| 2763 | void GetUniquePadsFromNpad(HLERequestContext& ctx) { | 2774 | void GetUniquePadsFromNpad(HLERequestContext& ctx) { |
| 2764 | IPC::RequestParser rp{ctx}; | 2775 | IPC::RequestParser rp{ctx}; |
| 2765 | const auto npad_id_type{rp.PopEnum<Core::HID::NpadIdType>()}; | 2776 | const auto npad_id_type{rp.PopEnum<Core::HID::NpadIdType>()}; |
| 2766 | 2777 | ||
| 2767 | const s64 total_entries = 0; | ||
| 2768 | LOG_WARNING(Service_HID, "(STUBBED) called, npad_id_type={}", npad_id_type); | 2778 | LOG_WARNING(Service_HID, "(STUBBED) called, npad_id_type={}", npad_id_type); |
| 2769 | 2779 | ||
| 2780 | const std::vector<Core::HID::UniquePadId> unique_pads{}; | ||
| 2781 | |||
| 2782 | ctx.WriteBuffer(unique_pads); | ||
| 2783 | |||
| 2770 | IPC::ResponseBuilder rb{ctx, 3}; | 2784 | IPC::ResponseBuilder rb{ctx, 3}; |
| 2771 | rb.Push(ResultSuccess); | 2785 | rb.Push(ResultSuccess); |
| 2772 | rb.Push(total_entries); | 2786 | rb.Push(static_cast<u32>(unique_pads.size())); |
| 2773 | } | 2787 | } |
| 2788 | |||
| 2789 | void AcquireJoyDetachOnBluetoothOffEventHandle(HLERequestContext& ctx) { | ||
| 2790 | LOG_INFO(Service_AM, "called"); | ||
| 2791 | |||
| 2792 | IPC::ResponseBuilder rb{ctx, 2, 1}; | ||
| 2793 | rb.Push(ResultSuccess); | ||
| 2794 | rb.PushCopyObjects(joy_detach_event->GetReadableEvent()); | ||
| 2795 | } | ||
| 2796 | |||
| 2797 | void IsUsbFullKeyControllerEnabled(HLERequestContext& ctx) { | ||
| 2798 | const bool is_enabled = false; | ||
| 2799 | |||
| 2800 | LOG_WARNING(Service_HID, "(STUBBED) called, is_enabled={}", is_enabled); | ||
| 2801 | |||
| 2802 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 2803 | rb.Push(ResultSuccess); | ||
| 2804 | rb.Push(is_enabled); | ||
| 2805 | } | ||
| 2806 | |||
| 2807 | void GetTouchScreenDefaultConfiguration(HLERequestContext& ctx) { | ||
| 2808 | LOG_WARNING(Service_HID, "(STUBBED) called"); | ||
| 2809 | |||
| 2810 | Core::HID::TouchScreenConfigurationForNx touchscreen_config{ | ||
| 2811 | .mode = Core::HID::TouchScreenModeForNx::Finger, | ||
| 2812 | }; | ||
| 2813 | |||
| 2814 | if (touchscreen_config.mode != Core::HID::TouchScreenModeForNx::Heat2 && | ||
| 2815 | touchscreen_config.mode != Core::HID::TouchScreenModeForNx::Finger) { | ||
| 2816 | touchscreen_config.mode = Core::HID::TouchScreenModeForNx::UseSystemSetting; | ||
| 2817 | } | ||
| 2818 | |||
| 2819 | IPC::ResponseBuilder rb{ctx, 6}; | ||
| 2820 | rb.Push(ResultSuccess); | ||
| 2821 | rb.PushRaw(touchscreen_config); | ||
| 2822 | } | ||
| 2823 | |||
| 2824 | Kernel::KEvent* joy_detach_event; | ||
| 2825 | KernelHelpers::ServiceContext service_context; | ||
| 2774 | }; | 2826 | }; |
| 2775 | 2827 | ||
| 2776 | void LoopProcess(Core::System& system) { | 2828 | void LoopProcess(Core::System& system) { |