service: hid: Add multiprocess support to six axis input

This commit is contained in:
german77 2024-02-05 17:07:50 -06:00
parent 372897aac4
commit 8f192b494a
1 changed files with 130 additions and 124 deletions

View File

@ -28,11 +28,12 @@ void SixAxis::OnRelease() {}
void SixAxis::OnUpdate(const Core::Timing::CoreTiming& core_timing) { void SixAxis::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
std::scoped_lock shared_lock{*shared_mutex}; std::scoped_lock shared_lock{*shared_mutex};
const u64 aruid = applet_resource->GetActiveAruid();
auto* data = applet_resource->GetAruidData(aruid); for (std::size_t aruid_index = 0; aruid_index < AruidIndexMax; ++aruid_index) {
const auto* data = applet_resource->GetAruidDataByIndex(aruid_index);
if (data == nullptr || !data->flag.is_assigned) { if (data == nullptr || !data->flag.is_assigned) {
return; continue;
} }
if (!IsControllerActivated()) { if (!IsControllerActivated()) {
@ -44,6 +45,10 @@ void SixAxis::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
auto& controller = controller_data[i]; auto& controller = controller_data[i];
const auto& controller_type = controller.device->GetNpadStyleIndex(); const auto& controller_type = controller.device->GetNpadStyleIndex();
if (!data->flag.enable_six_axis_sensor) {
continue;
}
if (controller_type == Core::HID::NpadStyleIndex::None || if (controller_type == Core::HID::NpadStyleIndex::None ||
!controller.device->IsConnected()) { !controller.device->IsConnected()) {
continue; continue;
@ -165,6 +170,7 @@ void SixAxis::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
sixaxis_left_lifo.lifo.WriteNextEntry(sixaxis_left_lifo_state); sixaxis_left_lifo.lifo.WriteNextEntry(sixaxis_left_lifo_state);
sixaxis_right_lifo.lifo.WriteNextEntry(sixaxis_right_lifo_state); sixaxis_right_lifo.lifo.WriteNextEntry(sixaxis_right_lifo_state);
} }
}
} }
Result SixAxis::SetGyroscopeZeroDriftMode(const Core::HID::SixAxisSensorHandle& sixaxis_handle, Result SixAxis::SetGyroscopeZeroDriftMode(const Core::HID::SixAxisSensorHandle& sixaxis_handle,