From 240f59a4c8319ec5f0c0e5fd34e8f9c5a458751e Mon Sep 17 00:00:00 2001 From: german77 Date: Sat, 21 May 2022 17:10:20 -0500 Subject: service: hid: Implement LoadSixAxisSensorCalibrationParameter and GetSixAxisSensorIcInformation Needed by Nintendo Switch Sports --- src/core/hle/service/hid/controllers/npad.cpp | 32 ++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'src/core/hle/service/hid/controllers/npad.cpp') diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index c9909ad5a..9ce25c641 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp @@ -66,7 +66,7 @@ ResultCode Controller_NPad::VerifyValidSixAxisSensorHandle( if (!device_index) { return NpadDeviceIndexOutOfRange; } - // This doesn't get validaded on nnsdk + // This doesn't get validated on nnsdk const bool npad_type = device_handle.npad_type < Core::HID::NpadStyleIndex::MaxNpadType; if (!npad_type) { return NpadInvalidHandle; @@ -1100,6 +1100,36 @@ ResultCode Controller_NPad::IsSixAxisSensorUnalteredPassthroughEnabled( return ResultSuccess; } +ResultCode Controller_NPad::LoadSixAxisSensorCalibrationParameter( + const Core::HID::SixAxisSensorHandle& sixaxis_handle, + Core::HID::SixAxisSensorCalibrationParameter& calibration) const { + const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle); + if (is_valid.IsError()) { + LOG_ERROR(Service_HID, "Invalid handle, error_code={}", is_valid.raw); + return is_valid; + } + + // TODO: Request this data to the controller. On error return 0xd8ca + const auto& sixaxis = GetSixaxisState(sixaxis_handle); + calibration = sixaxis.calibration; + return ResultSuccess; +} + +ResultCode Controller_NPad::GetSixAxisSensorIcInformation( + const Core::HID::SixAxisSensorHandle& sixaxis_handle, + Core::HID::SixAxisSensorIcInformation& ic_information) const { + const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle); + if (is_valid.IsError()) { + LOG_ERROR(Service_HID, "Invalid handle, error_code={}", is_valid.raw); + return is_valid; + } + + // TODO: Request this data to the controller. On error return 0xd8ca + const auto& sixaxis = GetSixaxisState(sixaxis_handle); + ic_information = sixaxis.ic_information; + return ResultSuccess; +} + ResultCode Controller_NPad::SetSixAxisEnabled(const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool sixaxis_status) { const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle); -- cgit v1.2.3