service: hid: Implement EnableSixAxisSensorUnalteredPassthrough and IsSixAxisSensorUnalteredPassthroughEnabled
Needed by Nintendo Switch Sports
This commit is contained in:
parent
762a30d0db
commit
c889a5805e
4 changed files with 88 additions and 2 deletions
|
@ -1074,6 +1074,32 @@ ResultCode Controller_NPad::IsFirmwareUpdateAvailableForSixAxisSensor(
|
||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ResultCode Controller_NPad::EnableSixAxisSensorUnalteredPassthrough(
|
||||||
|
const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool is_enabled) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto& sixaxis = GetSixaxisState(sixaxis_handle);
|
||||||
|
sixaxis.unaltered_passtrough = is_enabled;
|
||||||
|
return ResultSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
ResultCode Controller_NPad::IsSixAxisSensorUnalteredPassthroughEnabled(
|
||||||
|
const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool& is_enabled) 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto& sixaxis = GetSixaxisState(sixaxis_handle);
|
||||||
|
is_enabled = sixaxis.unaltered_passtrough;
|
||||||
|
return ResultSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
ResultCode Controller_NPad::SetSixAxisEnabled(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
ResultCode Controller_NPad::SetSixAxisEnabled(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
||||||
bool sixaxis_status) {
|
bool sixaxis_status) {
|
||||||
const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
|
const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
|
||||||
|
|
|
@ -151,6 +151,10 @@ public:
|
||||||
bool& is_at_rest) const;
|
bool& is_at_rest) const;
|
||||||
ResultCode IsFirmwareUpdateAvailableForSixAxisSensor(
|
ResultCode IsFirmwareUpdateAvailableForSixAxisSensor(
|
||||||
const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool& is_firmware_available) const;
|
const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool& is_firmware_available) const;
|
||||||
|
ResultCode EnableSixAxisSensorUnalteredPassthrough(
|
||||||
|
const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool is_enabled);
|
||||||
|
ResultCode IsSixAxisSensorUnalteredPassthroughEnabled(
|
||||||
|
const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool& is_enabled) const;
|
||||||
ResultCode SetSixAxisEnabled(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
ResultCode SetSixAxisEnabled(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
||||||
bool sixaxis_status);
|
bool sixaxis_status);
|
||||||
ResultCode IsSixAxisSensorFusionEnabled(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
ResultCode IsSixAxisSensorFusionEnabled(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
|
||||||
|
@ -468,6 +472,7 @@ private:
|
||||||
|
|
||||||
struct SixaxisParameters {
|
struct SixaxisParameters {
|
||||||
bool is_fusion_enabled{true};
|
bool is_fusion_enabled{true};
|
||||||
|
bool unaltered_passtrough{false};
|
||||||
Core::HID::SixAxisSensorFusionParameters fusion{};
|
Core::HID::SixAxisSensorFusionParameters fusion{};
|
||||||
GyroscopeZeroDriftMode gyroscope_zero_drift_mode{GyroscopeZeroDriftMode::Standard};
|
GyroscopeZeroDriftMode gyroscope_zero_drift_mode{GyroscopeZeroDriftMode::Standard};
|
||||||
};
|
};
|
||||||
|
|
|
@ -257,8 +257,8 @@ Hid::Hid(Core::System& system_)
|
||||||
{81, &Hid::ResetGyroscopeZeroDriftMode, "ResetGyroscopeZeroDriftMode"},
|
{81, &Hid::ResetGyroscopeZeroDriftMode, "ResetGyroscopeZeroDriftMode"},
|
||||||
{82, &Hid::IsSixAxisSensorAtRest, "IsSixAxisSensorAtRest"},
|
{82, &Hid::IsSixAxisSensorAtRest, "IsSixAxisSensorAtRest"},
|
||||||
{83, &Hid::IsFirmwareUpdateAvailableForSixAxisSensor, "IsFirmwareUpdateAvailableForSixAxisSensor"},
|
{83, &Hid::IsFirmwareUpdateAvailableForSixAxisSensor, "IsFirmwareUpdateAvailableForSixAxisSensor"},
|
||||||
{84, nullptr, "EnableSixAxisSensorUnalteredPassthrough"},
|
{84, &Hid::EnableSixAxisSensorUnalteredPassthrough, "EnableSixAxisSensorUnalteredPassthrough"},
|
||||||
{85, nullptr, "IsSixAxisSensorUnalteredPassthroughEnabled"},
|
{85, &Hid::IsSixAxisSensorUnalteredPassthroughEnabled, "IsSixAxisSensorUnalteredPassthroughEnabled"},
|
||||||
{86, nullptr, "StoreSixAxisSensorCalibrationParameter"},
|
{86, nullptr, "StoreSixAxisSensorCalibrationParameter"},
|
||||||
{87, nullptr, "LoadSixAxisSensorCalibrationParameter"},
|
{87, nullptr, "LoadSixAxisSensorCalibrationParameter"},
|
||||||
{88, nullptr, "GetSixAxisSensorIcInformation"},
|
{88, nullptr, "GetSixAxisSensorIcInformation"},
|
||||||
|
@ -817,6 +817,59 @@ void Hid::IsFirmwareUpdateAvailableForSixAxisSensor(Kernel::HLERequestContext& c
|
||||||
rb.Push(is_firmware_available);
|
rb.Push(is_firmware_available);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Hid::EnableSixAxisSensorUnalteredPassthrough(Kernel::HLERequestContext& ctx) {
|
||||||
|
IPC::RequestParser rp{ctx};
|
||||||
|
struct Parameters {
|
||||||
|
bool enabled;
|
||||||
|
Core::HID::SixAxisSensorHandle sixaxis_handle;
|
||||||
|
u64 applet_resource_user_id;
|
||||||
|
};
|
||||||
|
static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
|
||||||
|
|
||||||
|
const auto parameters{rp.PopRaw<Parameters>()};
|
||||||
|
|
||||||
|
auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad);
|
||||||
|
const auto result = controller.EnableSixAxisSensorUnalteredPassthrough(
|
||||||
|
parameters.sixaxis_handle, parameters.enabled);
|
||||||
|
|
||||||
|
LOG_WARNING(Service_HID,
|
||||||
|
"(STUBBED) called, enabled={}, npad_type={}, npad_id={}, device_index={}, "
|
||||||
|
"applet_resource_user_id={}",
|
||||||
|
parameters.enabled, parameters.sixaxis_handle.npad_type,
|
||||||
|
parameters.sixaxis_handle.npad_id, parameters.sixaxis_handle.device_index,
|
||||||
|
parameters.applet_resource_user_id);
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
|
rb.Push(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Hid::IsSixAxisSensorUnalteredPassthroughEnabled(Kernel::HLERequestContext& ctx) {
|
||||||
|
IPC::RequestParser rp{ctx};
|
||||||
|
struct Parameters {
|
||||||
|
Core::HID::SixAxisSensorHandle sixaxis_handle;
|
||||||
|
INSERT_PADDING_WORDS_NOINIT(1);
|
||||||
|
u64 applet_resource_user_id;
|
||||||
|
};
|
||||||
|
static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
|
||||||
|
|
||||||
|
const auto parameters{rp.PopRaw<Parameters>()};
|
||||||
|
|
||||||
|
bool is_unaltered_sisxaxis_enabled{};
|
||||||
|
auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad);
|
||||||
|
const auto result = controller.IsSixAxisSensorUnalteredPassthroughEnabled(
|
||||||
|
parameters.sixaxis_handle, is_unaltered_sisxaxis_enabled);
|
||||||
|
|
||||||
|
LOG_WARNING(
|
||||||
|
Service_HID,
|
||||||
|
"(STUBBED) called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}",
|
||||||
|
parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id,
|
||||||
|
parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id);
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
|
rb.Push(result);
|
||||||
|
rb.Push(is_unaltered_sisxaxis_enabled);
|
||||||
|
}
|
||||||
|
|
||||||
void Hid::ActivateGesture(Kernel::HLERequestContext& ctx) {
|
void Hid::ActivateGesture(Kernel::HLERequestContext& ctx) {
|
||||||
IPC::RequestParser rp{ctx};
|
IPC::RequestParser rp{ctx};
|
||||||
struct Parameters {
|
struct Parameters {
|
||||||
|
|
|
@ -113,6 +113,8 @@ private:
|
||||||
void ResetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx);
|
void ResetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx);
|
||||||
void IsSixAxisSensorAtRest(Kernel::HLERequestContext& ctx);
|
void IsSixAxisSensorAtRest(Kernel::HLERequestContext& ctx);
|
||||||
void IsFirmwareUpdateAvailableForSixAxisSensor(Kernel::HLERequestContext& ctx);
|
void IsFirmwareUpdateAvailableForSixAxisSensor(Kernel::HLERequestContext& ctx);
|
||||||
|
void EnableSixAxisSensorUnalteredPassthrough(Kernel::HLERequestContext& ctx);
|
||||||
|
void IsSixAxisSensorUnalteredPassthroughEnabled(Kernel::HLERequestContext& ctx);
|
||||||
void ActivateGesture(Kernel::HLERequestContext& ctx);
|
void ActivateGesture(Kernel::HLERequestContext& ctx);
|
||||||
void SetSupportedNpadStyleSet(Kernel::HLERequestContext& ctx);
|
void SetSupportedNpadStyleSet(Kernel::HLERequestContext& ctx);
|
||||||
void GetSupportedNpadStyleSet(Kernel::HLERequestContext& ctx);
|
void GetSupportedNpadStyleSet(Kernel::HLERequestContext& ctx);
|
||||||
|
|
Loading…
Reference in a new issue