hid: Implement Get/ResetGyroscopeZeroDriftMode
- Used by Captain Toad Treasure Tracker
This commit is contained in:
parent
f98bf1025f
commit
0235915baa
4 changed files with 56 additions and 6 deletions
|
@ -566,6 +566,14 @@ void Controller_NPad::DisconnectNPad(u32 npad_id) {
|
||||||
connected_controllers[NPadIdToIndex(npad_id)].is_connected = false;
|
connected_controllers[NPadIdToIndex(npad_id)].is_connected = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Controller_NPad::SetGyroscopeZeroDriftMode(GyroscopeZeroDriftMode drift_mode) {
|
||||||
|
gyroscope_zero_drift_mode = drift_mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
Controller_NPad::GyroscopeZeroDriftMode Controller_NPad::GetGyroscopeZeroDriftMode() const {
|
||||||
|
return gyroscope_zero_drift_mode;
|
||||||
|
}
|
||||||
|
|
||||||
void Controller_NPad::StartLRAssignmentMode() {
|
void Controller_NPad::StartLRAssignmentMode() {
|
||||||
// Nothing internally is used for lr assignment mode. Since we have the ability to set the
|
// Nothing internally is used for lr assignment mode. Since we have the ability to set the
|
||||||
// controller types from boot, it doesn't really matter about showing a selection screen
|
// controller types from boot, it doesn't really matter about showing a selection screen
|
||||||
|
|
|
@ -58,6 +58,12 @@ public:
|
||||||
};
|
};
|
||||||
static_assert(sizeof(Vibration) == 0x10, "Vibration is an invalid size");
|
static_assert(sizeof(Vibration) == 0x10, "Vibration is an invalid size");
|
||||||
|
|
||||||
|
enum class GyroscopeZeroDriftMode : u32 {
|
||||||
|
Loose = 0,
|
||||||
|
Standard = 1,
|
||||||
|
Tight = 2,
|
||||||
|
};
|
||||||
|
|
||||||
enum class NpadHoldType : u64 {
|
enum class NpadHoldType : u64 {
|
||||||
Vertical = 0,
|
Vertical = 0,
|
||||||
Horizontal = 1,
|
Horizontal = 1,
|
||||||
|
@ -117,6 +123,8 @@ public:
|
||||||
|
|
||||||
void ConnectNPad(u32 npad_id);
|
void ConnectNPad(u32 npad_id);
|
||||||
void DisconnectNPad(u32 npad_id);
|
void DisconnectNPad(u32 npad_id);
|
||||||
|
void SetGyroscopeZeroDriftMode(GyroscopeZeroDriftMode drift_mode);
|
||||||
|
GyroscopeZeroDriftMode GetGyroscopeZeroDriftMode() const;
|
||||||
LedPattern GetLedPattern(u32 npad_id);
|
LedPattern GetLedPattern(u32 npad_id);
|
||||||
void SetVibrationEnabled(bool can_vibrate);
|
void SetVibrationEnabled(bool can_vibrate);
|
||||||
bool IsVibrationEnabled() const;
|
bool IsVibrationEnabled() const;
|
||||||
|
@ -324,8 +332,8 @@ private:
|
||||||
std::array<Kernel::EventPair, 10> styleset_changed_events;
|
std::array<Kernel::EventPair, 10> styleset_changed_events;
|
||||||
Vibration last_processed_vibration{};
|
Vibration last_processed_vibration{};
|
||||||
std::array<ControllerHolder, 10> connected_controllers{};
|
std::array<ControllerHolder, 10> connected_controllers{};
|
||||||
|
GyroscopeZeroDriftMode gyroscope_zero_drift_mode{GyroscopeZeroDriftMode::Standard};
|
||||||
bool can_controllers_vibrate{true};
|
bool can_controllers_vibrate{true};
|
||||||
|
|
||||||
std::array<ControllerPad, 10> npad_pad_states{};
|
std::array<ControllerPad, 10> npad_pad_states{};
|
||||||
bool is_in_lr_assignment_mode{false};
|
bool is_in_lr_assignment_mode{false};
|
||||||
Core::System& system;
|
Core::System& system;
|
||||||
|
|
|
@ -185,8 +185,8 @@ Hid::Hid(Core::System& system) : ServiceFramework("hid"), system(system) {
|
||||||
{77, nullptr, "GetAccelerometerPlayMode"},
|
{77, nullptr, "GetAccelerometerPlayMode"},
|
||||||
{78, nullptr, "ResetAccelerometerPlayMode"},
|
{78, nullptr, "ResetAccelerometerPlayMode"},
|
||||||
{79, &Hid::SetGyroscopeZeroDriftMode, "SetGyroscopeZeroDriftMode"},
|
{79, &Hid::SetGyroscopeZeroDriftMode, "SetGyroscopeZeroDriftMode"},
|
||||||
{80, nullptr, "GetGyroscopeZeroDriftMode"},
|
{80, &Hid::GetGyroscopeZeroDriftMode, "GetGyroscopeZeroDriftMode"},
|
||||||
{81, nullptr, "ResetGyroscopeZeroDriftMode"},
|
{81, &Hid::ResetGyroscopeZeroDriftMode, "ResetGyroscopeZeroDriftMode"},
|
||||||
{82, &Hid::IsSixAxisSensorAtRest, "IsSixAxisSensorAtRest"},
|
{82, &Hid::IsSixAxisSensorAtRest, "IsSixAxisSensorAtRest"},
|
||||||
{83, nullptr, "IsFirmwareUpdateAvailableForSixAxisSensor"},
|
{83, nullptr, "IsFirmwareUpdateAvailableForSixAxisSensor"},
|
||||||
{91, &Hid::ActivateGesture, "ActivateGesture"},
|
{91, &Hid::ActivateGesture, "ActivateGesture"},
|
||||||
|
@ -419,14 +419,46 @@ void Hid::SetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx) {
|
||||||
const auto drift_mode{rp.Pop<u32>()};
|
const auto drift_mode{rp.Pop<u32>()};
|
||||||
const auto applet_resource_user_id{rp.Pop<u64>()};
|
const auto applet_resource_user_id{rp.Pop<u64>()};
|
||||||
|
|
||||||
LOG_WARNING(Service_HID,
|
applet_resource->GetController<Controller_NPad>(HidController::NPad)
|
||||||
"(STUBBED) called, handle={}, drift_mode={}, applet_resource_user_id={}", handle,
|
.SetGyroscopeZeroDriftMode(Controller_NPad::GyroscopeZeroDriftMode{drift_mode});
|
||||||
|
|
||||||
|
LOG_DEBUG(Service_HID, "called, handle={}, drift_mode={}, applet_resource_user_id={}", handle,
|
||||||
drift_mode, applet_resource_user_id);
|
drift_mode, applet_resource_user_id);
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Hid::GetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx) {
|
||||||
|
IPC::RequestParser rp{ctx};
|
||||||
|
const auto handle{rp.Pop<u32>()};
|
||||||
|
const auto applet_resource_user_id{rp.Pop<u64>()};
|
||||||
|
|
||||||
|
LOG_DEBUG(Service_HID, "called, handle={}, applet_resource_user_id={}", handle,
|
||||||
|
applet_resource_user_id);
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
|
rb.Push(RESULT_SUCCESS);
|
||||||
|
rb.Push<u32>(
|
||||||
|
static_cast<u32>(applet_resource->GetController<Controller_NPad>(HidController::NPad)
|
||||||
|
.GetGyroscopeZeroDriftMode()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Hid::ResetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx) {
|
||||||
|
IPC::RequestParser rp{ctx};
|
||||||
|
const auto handle{rp.Pop<u32>()};
|
||||||
|
const auto applet_resource_user_id{rp.Pop<u64>()};
|
||||||
|
|
||||||
|
applet_resource->GetController<Controller_NPad>(HidController::NPad)
|
||||||
|
.SetGyroscopeZeroDriftMode(Controller_NPad::GyroscopeZeroDriftMode::Standard);
|
||||||
|
|
||||||
|
LOG_DEBUG(Service_HID, "called, handle={}, applet_resource_user_id={}", handle,
|
||||||
|
applet_resource_user_id);
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
|
rb.Push(RESULT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
void Hid::IsSixAxisSensorAtRest(Kernel::HLERequestContext& ctx) {
|
void Hid::IsSixAxisSensorAtRest(Kernel::HLERequestContext& ctx) {
|
||||||
IPC::RequestParser rp{ctx};
|
IPC::RequestParser rp{ctx};
|
||||||
const auto handle{rp.Pop<u32>()};
|
const auto handle{rp.Pop<u32>()};
|
||||||
|
|
|
@ -95,6 +95,8 @@ private:
|
||||||
void ActivateNpadWithRevision(Kernel::HLERequestContext& ctx);
|
void ActivateNpadWithRevision(Kernel::HLERequestContext& ctx);
|
||||||
void StartSixAxisSensor(Kernel::HLERequestContext& ctx);
|
void StartSixAxisSensor(Kernel::HLERequestContext& ctx);
|
||||||
void SetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx);
|
void SetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx);
|
||||||
|
void GetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx);
|
||||||
|
void ResetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx);
|
||||||
void IsSixAxisSensorAtRest(Kernel::HLERequestContext& ctx);
|
void IsSixAxisSensorAtRest(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