From d5bb26bf3e0a98382231fe933914cd6bbddbbb61 Mon Sep 17 00:00:00 2001 From: EmulationEnjoyer Date: Wed, 22 Jan 2025 20:42:58 +0000 Subject: [PATCH] Implement HID function stub "SetGestureOutputRanges" (#105) Add function stub for "SetGestureOutputRanges" in HID service Fixes userspace panic when booting Donkey Kong Country Returns HD: > Debug core\hle\service\service.cpp:operator ():78: Assertion Failed! Unknown / unimplemented function '92()': port='hid' cmd_buf={[0]=0x6, [1]=0x8000000C, [2]=0x1, [3]=0x0, [4]=0x4F434653, [5]=0x0, [6]=0x0, [7]=0x0, [8]=0x49434653} > Service.AM core\hle\service\am\service\application_functions.cpp:SetTerminateResult:187: (STUBBED) called, result=0x1a80a (2010-0212) > Debug.Emulated core\hle\kernel\svc\svc_exception.cpp:Break:52: Userspace PANIC! info1=0x0000001086D02C4C, info2=0x0000000000000004 > Debug.Emulated core\hle\kernel\svc\svc_exception.cpp:operator ():33: debug_buffer_err_code=1A80A > Debug.Emulated core\hle\kernel\svc\svc_exception.cpp:Break:102: Emulated program broke execution! reason=0x0000000000000000, info1=0x0000001086D02C4C, info2=0x0000000000000004 ref: https://git.citron-emu.org/Citron/Citron/commit/132077e18f491d12d305e94f594470d6b93e8d8d ![](https://i.imgur.com/hbBnlYs.png) Reviewed-on: http://vub63vv26q6v27xzv2dtcd25xumubshogm67yrpaz2rculqxs7jlfqad.onion/torzu-emu/torzu/pulls/105 Co-authored-by: EmulationEnjoyer Co-committed-by: EmulationEnjoyer --- src/core/hle/service/hid/hid_server.cpp | 10 ++++++++++ src/core/hle/service/hid/hid_server.h | 1 + 2 files changed, 11 insertions(+) diff --git a/src/core/hle/service/hid/hid_server.cpp b/src/core/hle/service/hid/hid_server.cpp index 926a3bfe99..d38a8c04fa 100644 --- a/src/core/hle/service/hid/hid_server.cpp +++ b/src/core/hle/service/hid/hid_server.cpp @@ -89,6 +89,7 @@ IHidServer::IHidServer(Core::System& system_, std::shared_ptr r {88, C<&IHidServer::GetSixAxisSensorIcInformation>, "GetSixAxisSensorIcInformation"}, {89, C<&IHidServer::ResetIsSixAxisSensorDeviceNewlyAssigned>, "ResetIsSixAxisSensorDeviceNewlyAssigned"}, {91, C<&IHidServer::ActivateGesture>, "ActivateGesture"}, + {92, C<&IHidServer::SetGestureOutputRanges>, "SetGestureOutputRanges"}, {100, C<&IHidServer::SetSupportedNpadStyleSet>, "SetSupportedNpadStyleSet"}, {101, C<&IHidServer::GetSupportedNpadStyleSet>, "GetSupportedNpadStyleSet"}, {102, C<&IHidServer::SetSupportedNpadIdType>, "SetSupportedNpadIdType"}, @@ -576,6 +577,15 @@ Result IHidServer::ActivateGesture(u32 basic_gesture_id, ClientAppletResourceUse R_RETURN(GetResourceManager()->GetGesture()->Activate(aruid.pid, basic_gesture_id)); } +Result IHidServer::SetGestureOutputRanges(u32 param1, u32 param2, u32 param3, u32 param4) { + // https://switchbrew.org/wiki/HID_services , Undocumented. 92 [18.0.0+] SetGestureOutputRanges + LOG_WARNING( + Service_HID, + "(STUBBED) called, param1={}, param2={}, param3={}, param4={}", + param1, param2, param3, param4); + R_SUCCEED(); +} + Result IHidServer::SetSupportedNpadStyleSet(Core::HID::NpadStyleSet supported_style_set, ClientAppletResourceUserId aruid) { LOG_DEBUG(Service_HID, "called, supported_style_set={}, applet_resource_user_id={}", diff --git a/src/core/hle/service/hid/hid_server.h b/src/core/hle/service/hid/hid_server.h index cfa31c2dee..9fdb25d5ca 100644 --- a/src/core/hle/service/hid/hid_server.h +++ b/src/core/hle/service/hid/hid_server.h @@ -104,6 +104,7 @@ private: Result ResetIsSixAxisSensorDeviceNewlyAssigned(Core::HID::SixAxisSensorHandle sixaxis_handle, ClientAppletResourceUserId aruid); Result ActivateGesture(u32 basic_gesture_id, ClientAppletResourceUserId aruid); + Result SetGestureOutputRanges(u32 param1, u32 param2, u32 param3, u32 param4); Result SetSupportedNpadStyleSet(Core::HID::NpadStyleSet supported_style_set, ClientAppletResourceUserId aruid); Result GetSupportedNpadStyleSet(Out out_supported_style_set,