mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-11-14 19:04:58 +00:00
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.
This commit is contained in:
parent
16e2e1c45f
commit
b92bf51ae1
2 changed files with 39 additions and 3 deletions
|
@ -924,12 +924,32 @@ void Hid::GetActualVibrationValue(Kernel::HLERequestContext& ctx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hid::GetVibrationDeviceInfo(Kernel::HLERequestContext& ctx) {
|
void Hid::GetVibrationDeviceInfo(Kernel::HLERequestContext& ctx) {
|
||||||
LOG_DEBUG(Service_HID, "called");
|
IPC::RequestParser rp{ctx};
|
||||||
|
const auto vibration_device_handle{rp.PopRaw<Controller_NPad::DeviceHandle>()};
|
||||||
|
|
||||||
|
VibrationDeviceInfo vibration_device_info;
|
||||||
|
|
||||||
|
vibration_device_info.type = VibrationDeviceType::LinearResonantActuator;
|
||||||
|
|
||||||
|
switch (vibration_device_handle.device_index) {
|
||||||
|
case Controller_NPad::DeviceIndex::Left:
|
||||||
|
vibration_device_info.position = VibrationDevicePosition::Left;
|
||||||
|
break;
|
||||||
|
case Controller_NPad::DeviceIndex::Right:
|
||||||
|
vibration_device_info.position = VibrationDevicePosition::Right;
|
||||||
|
break;
|
||||||
|
case Controller_NPad::DeviceIndex::None:
|
||||||
|
default:
|
||||||
|
vibration_device_info.position = VibrationDevicePosition::None;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_DEBUG(Service_HID, "called, vibration_device_type={}, vibration_device_position={}",
|
||||||
|
vibration_device_info.type, vibration_device_info.position);
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 4};
|
IPC::ResponseBuilder rb{ctx, 4};
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
rb.Push<u32>(1);
|
rb.PushRaw<VibrationDeviceInfo>(vibration_device_info);
|
||||||
rb.Push<u32>(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hid::CreateActiveVibrationDeviceList(Kernel::HLERequestContext& ctx) {
|
void Hid::CreateActiveVibrationDeviceList(Kernel::HLERequestContext& ctx) {
|
||||||
|
|
|
@ -146,6 +146,22 @@ private:
|
||||||
void SetIsPalmaAllConnectable(Kernel::HLERequestContext& ctx);
|
void SetIsPalmaAllConnectable(Kernel::HLERequestContext& ctx);
|
||||||
void SetPalmaBoostMode(Kernel::HLERequestContext& ctx);
|
void SetPalmaBoostMode(Kernel::HLERequestContext& ctx);
|
||||||
|
|
||||||
|
enum class VibrationDeviceType : u32 {
|
||||||
|
LinearResonantActuator = 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class VibrationDevicePosition : u32 {
|
||||||
|
None = 0,
|
||||||
|
Left = 1,
|
||||||
|
Right = 2,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct VibrationDeviceInfo {
|
||||||
|
VibrationDeviceType type{};
|
||||||
|
VibrationDevicePosition position{};
|
||||||
|
};
|
||||||
|
static_assert(sizeof(VibrationDeviceInfo) == 0x8, "VibrationDeviceInfo has incorrect size.");
|
||||||
|
|
||||||
std::shared_ptr<IAppletResource> applet_resource;
|
std::shared_ptr<IAppletResource> applet_resource;
|
||||||
Core::System& system;
|
Core::System& system;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue