diff options
Diffstat (limited to 'src/input_common/helpers/joycon_driver.cpp')
| -rw-r--r-- | src/input_common/helpers/joycon_driver.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/input_common/helpers/joycon_driver.cpp b/src/input_common/helpers/joycon_driver.cpp index 4159e5717..8f94c9f45 100644 --- a/src/input_common/helpers/joycon_driver.cpp +++ b/src/input_common/helpers/joycon_driver.cpp | |||
| @@ -86,6 +86,7 @@ DriverResult JoyconDriver::InitializeDevice() { | |||
| 86 | 86 | ||
| 87 | // Get fixed joycon info | 87 | // Get fixed joycon info |
| 88 | generic_protocol->GetVersionNumber(version); | 88 | generic_protocol->GetVersionNumber(version); |
| 89 | generic_protocol->SetLowPowerMode(false); | ||
| 89 | generic_protocol->GetColor(color); | 90 | generic_protocol->GetColor(color); |
| 90 | if (handle_device_type == ControllerType::Pro) { | 91 | if (handle_device_type == ControllerType::Pro) { |
| 91 | // Some 3rd party controllers aren't pro controllers | 92 | // Some 3rd party controllers aren't pro controllers |
| @@ -161,14 +162,14 @@ void JoyconDriver::InputThread(std::stop_token stop_token) { | |||
| 161 | } | 162 | } |
| 162 | 163 | ||
| 163 | void JoyconDriver::OnNewData(std::span<u8> buffer) { | 164 | void JoyconDriver::OnNewData(std::span<u8> buffer) { |
| 164 | const auto report_mode = static_cast<InputReport>(buffer[0]); | 165 | const auto report_mode = static_cast<ReportMode>(buffer[0]); |
| 165 | 166 | ||
| 166 | // Packages can be a litte bit inconsistent. Average the delta time to provide a smoother motion | 167 | // Packages can be a litte bit inconsistent. Average the delta time to provide a smoother motion |
| 167 | // experience | 168 | // experience |
| 168 | switch (report_mode) { | 169 | switch (report_mode) { |
| 169 | case InputReport::STANDARD_FULL_60HZ: | 170 | case ReportMode::STANDARD_FULL_60HZ: |
| 170 | case InputReport::NFC_IR_MODE_60HZ: | 171 | case ReportMode::NFC_IR_MODE_60HZ: |
| 171 | case InputReport::SIMPLE_HID_MODE: { | 172 | case ReportMode::SIMPLE_HID_MODE: { |
| 172 | const auto now = std::chrono::steady_clock::now(); | 173 | const auto now = std::chrono::steady_clock::now(); |
| 173 | const auto new_delta_time = static_cast<u64>( | 174 | const auto new_delta_time = static_cast<u64>( |
| 174 | std::chrono::duration_cast<std::chrono::microseconds>(now - last_update).count()); | 175 | std::chrono::duration_cast<std::chrono::microseconds>(now - last_update).count()); |
| @@ -189,7 +190,7 @@ void JoyconDriver::OnNewData(std::span<u8> buffer) { | |||
| 189 | }; | 190 | }; |
| 190 | 191 | ||
| 191 | // TODO: Remove this when calibration is properly loaded and not calculated | 192 | // TODO: Remove this when calibration is properly loaded and not calculated |
| 192 | if (ring_connected && report_mode == InputReport::STANDARD_FULL_60HZ) { | 193 | if (ring_connected && report_mode == ReportMode::STANDARD_FULL_60HZ) { |
| 193 | InputReportActive data{}; | 194 | InputReportActive data{}; |
| 194 | memcpy(&data, buffer.data(), sizeof(InputReportActive)); | 195 | memcpy(&data, buffer.data(), sizeof(InputReportActive)); |
| 195 | calibration_protocol->GetRingCalibration(ring_calibration, data.ring_input); | 196 | calibration_protocol->GetRingCalibration(ring_calibration, data.ring_input); |
| @@ -227,16 +228,16 @@ void JoyconDriver::OnNewData(std::span<u8> buffer) { | |||
| 227 | } | 228 | } |
| 228 | 229 | ||
| 229 | switch (report_mode) { | 230 | switch (report_mode) { |
| 230 | case InputReport::STANDARD_FULL_60HZ: | 231 | case ReportMode::STANDARD_FULL_60HZ: |
| 231 | joycon_poller->ReadActiveMode(buffer, motion_status, ring_status); | 232 | joycon_poller->ReadActiveMode(buffer, motion_status, ring_status); |
| 232 | break; | 233 | break; |
| 233 | case InputReport::NFC_IR_MODE_60HZ: | 234 | case ReportMode::NFC_IR_MODE_60HZ: |
| 234 | joycon_poller->ReadNfcIRMode(buffer, motion_status); | 235 | joycon_poller->ReadNfcIRMode(buffer, motion_status); |
| 235 | break; | 236 | break; |
| 236 | case InputReport::SIMPLE_HID_MODE: | 237 | case ReportMode::SIMPLE_HID_MODE: |
| 237 | joycon_poller->ReadPassiveMode(buffer); | 238 | joycon_poller->ReadPassiveMode(buffer); |
| 238 | break; | 239 | break; |
| 239 | case InputReport::SUBCMD_REPLY: | 240 | case ReportMode::SUBCMD_REPLY: |
| 240 | LOG_DEBUG(Input, "Unhandled command reply"); | 241 | LOG_DEBUG(Input, "Unhandled command reply"); |
| 241 | break; | 242 | break; |
| 242 | default: | 243 | default: |
| @@ -324,6 +325,8 @@ DriverResult JoyconDriver::SetPollingMode() { | |||
| 324 | if (result != DriverResult::Success) { | 325 | if (result != DriverResult::Success) { |
| 325 | LOG_ERROR(Input, "Error enabling active mode"); | 326 | LOG_ERROR(Input, "Error enabling active mode"); |
| 326 | } | 327 | } |
| 328 | // Switch calls this function after enabling active mode | ||
| 329 | generic_protocol->TriggersElapsed(); | ||
| 327 | 330 | ||
| 328 | disable_input_thread = false; | 331 | disable_input_thread = false; |
| 329 | return result; | 332 | return result; |