summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Morph2020-10-06 05:08:52 -0400
committerGravatar Morph2020-11-15 23:33:20 -0500
commitb92bf51ae1a08eca22bf0ce98b234692b9d59207 (patch)
tree9b7347d407509503d91d3987cb037bc0bcab679e /src
parenthid: Stub InitializeVibrationDevice (diff)
downloadyuzu-b92bf51ae1a08eca22bf0ce98b234692b9d59207.tar.gz
yuzu-b92bf51ae1a08eca22bf0ce98b234692b9d59207.tar.xz
yuzu-b92bf51ae1a08eca22bf0ce98b234692b9d59207.zip
hid: Implement GetVibrationDeviceInfo
The first u32 describes the vibration device type which is a Linear Resonant Actuator used in Nintendo Switch controller hardware. The second u32 describes the vibration device position, in this case distinguishing between left and right vibration actuators. Pro Controllers have 2 LRAs each that can vibrate independently of each other, which means they have 2 distinct vibration device handles to distinguish between the two actuators. Similarly for joycons, the left joycon can be distinguished from the right joycon through the vibration device handle since each joycon has 1 LRA.
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/hid/hid.cpp26
-rw-r--r--src/core/hle/service/hid/hid.h16
2 files changed, 39 insertions, 3 deletions
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp
index 86b83dcc6..993738f36 100644
--- a/src/core/hle/service/hid/hid.cpp
+++ b/src/core/hle/service/hid/hid.cpp
@@ -924,12 +924,32 @@ void Hid::GetActualVibrationValue(Kernel::HLERequestContext& ctx) {
924} 924}
925 925
926void Hid::GetVibrationDeviceInfo(Kernel::HLERequestContext& ctx) { 926void Hid::GetVibrationDeviceInfo(Kernel::HLERequestContext& ctx) {
927 LOG_DEBUG(Service_HID, "called"); 927 IPC::RequestParser rp{ctx};
928 const auto vibration_device_handle{rp.PopRaw<Controller_NPad::DeviceHandle>()};
929
930 VibrationDeviceInfo vibration_device_info;
931
932 vibration_device_info.type = VibrationDeviceType::LinearResonantActuator;
933
934 switch (vibration_device_handle.device_index) {
935 case Controller_NPad::DeviceIndex::Left:
936 vibration_device_info.position = VibrationDevicePosition::Left;
937 break;
938 case Controller_NPad::DeviceIndex::Right:
939 vibration_device_info.position = VibrationDevicePosition::Right;
940 break;
941 case Controller_NPad::DeviceIndex::None:
942 default:
943 vibration_device_info.position = VibrationDevicePosition::None;
944 break;
945 }
946
947 LOG_DEBUG(Service_HID, "called, vibration_device_type={}, vibration_device_position={}",
948 vibration_device_info.type, vibration_device_info.position);
928 949
929 IPC::ResponseBuilder rb{ctx, 4}; 950 IPC::ResponseBuilder rb{ctx, 4};
930 rb.Push(RESULT_SUCCESS); 951 rb.Push(RESULT_SUCCESS);
931 rb.Push<u32>(1); 952 rb.PushRaw<VibrationDeviceInfo>(vibration_device_info);
932 rb.Push<u32>(0);
933} 953}
934 954
935void Hid::CreateActiveVibrationDeviceList(Kernel::HLERequestContext& ctx) { 955void Hid::CreateActiveVibrationDeviceList(Kernel::HLERequestContext& ctx) {
diff --git a/src/core/hle/service/hid/hid.h b/src/core/hle/service/hid/hid.h
index fd0372b18..2f7483170 100644
--- a/src/core/hle/service/hid/hid.h
+++ b/src/core/hle/service/hid/hid.h
@@ -146,6 +146,22 @@ private:
146 void SetIsPalmaAllConnectable(Kernel::HLERequestContext& ctx); 146 void SetIsPalmaAllConnectable(Kernel::HLERequestContext& ctx);
147 void SetPalmaBoostMode(Kernel::HLERequestContext& ctx); 147 void SetPalmaBoostMode(Kernel::HLERequestContext& ctx);
148 148
149 enum class VibrationDeviceType : u32 {
150 LinearResonantActuator = 1,
151 };
152
153 enum class VibrationDevicePosition : u32 {
154 None = 0,
155 Left = 1,
156 Right = 2,
157 };
158
159 struct VibrationDeviceInfo {
160 VibrationDeviceType type{};
161 VibrationDevicePosition position{};
162 };
163 static_assert(sizeof(VibrationDeviceInfo) == 0x8, "VibrationDeviceInfo has incorrect size.");
164
149 std::shared_ptr<IAppletResource> applet_resource; 165 std::shared_ptr<IAppletResource> applet_resource;
150 Core::System& system; 166 Core::System& system;
151}; 167};