diff options
| author | 2023-06-24 18:48:45 -0600 | |
|---|---|---|
| committer | 2023-06-24 18:59:55 -0600 | |
| commit | 5aa208e26417a455abced9c067f75e1b81f2cb80 (patch) | |
| tree | eff9bb064170291d8724fdc59ff2540f17b49b01 /src/input_common/helpers/joycon_driver.cpp | |
| parent | Merge pull request #10891 from german77/sdl28v2 (diff) | |
| download | yuzu-5aa208e26417a455abced9c067f75e1b81f2cb80.tar.gz yuzu-5aa208e26417a455abced9c067f75e1b81f2cb80.tar.xz yuzu-5aa208e26417a455abced9c067f75e1b81f2cb80.zip | |
input_common: Dont try to read/write data from 3rd party controllers
Diffstat (limited to 'src/input_common/helpers/joycon_driver.cpp')
| -rw-r--r-- | src/input_common/helpers/joycon_driver.cpp | 42 |
1 files changed, 33 insertions, 9 deletions
diff --git a/src/input_common/helpers/joycon_driver.cpp b/src/input_common/helpers/joycon_driver.cpp index 2c8c66951..ec984a647 100644 --- a/src/input_common/helpers/joycon_driver.cpp +++ b/src/input_common/helpers/joycon_driver.cpp | |||
| @@ -72,6 +72,7 @@ DriverResult JoyconDriver::InitializeDevice() { | |||
| 72 | nfc_enabled = false; | 72 | nfc_enabled = false; |
| 73 | passive_enabled = false; | 73 | passive_enabled = false; |
| 74 | irs_enabled = false; | 74 | irs_enabled = false; |
| 75 | input_only_device = false; | ||
| 75 | gyro_sensitivity = Joycon::GyroSensitivity::DPS2000; | 76 | gyro_sensitivity = Joycon::GyroSensitivity::DPS2000; |
| 76 | gyro_performance = Joycon::GyroPerformance::HZ833; | 77 | gyro_performance = Joycon::GyroPerformance::HZ833; |
| 77 | accelerometer_sensitivity = Joycon::AccelerometerSensitivity::G8; | 78 | accelerometer_sensitivity = Joycon::AccelerometerSensitivity::G8; |
| @@ -86,16 +87,23 @@ DriverResult JoyconDriver::InitializeDevice() { | |||
| 86 | rumble_protocol = std::make_unique<RumbleProtocol>(hidapi_handle); | 87 | rumble_protocol = std::make_unique<RumbleProtocol>(hidapi_handle); |
| 87 | 88 | ||
| 88 | // Get fixed joycon info | 89 | // Get fixed joycon info |
| 89 | generic_protocol->GetVersionNumber(version); | 90 | if (generic_protocol->GetVersionNumber(version) != DriverResult::Success) { |
| 90 | generic_protocol->SetLowPowerMode(false); | 91 | // If this command fails the device doesn't accept configuration commands |
| 91 | generic_protocol->GetColor(color); | 92 | input_only_device = true; |
| 92 | if (handle_device_type == ControllerType::Pro) { | ||
| 93 | // Some 3rd party controllers aren't pro controllers | ||
| 94 | generic_protocol->GetControllerType(device_type); | ||
| 95 | } else { | ||
| 96 | device_type = handle_device_type; | ||
| 97 | } | 93 | } |
| 98 | generic_protocol->GetSerialNumber(serial_number); | 94 | |
| 95 | if (!input_only_device) { | ||
| 96 | generic_protocol->SetLowPowerMode(false); | ||
| 97 | generic_protocol->GetColor(color); | ||
| 98 | if (handle_device_type == ControllerType::Pro) { | ||
| 99 | // Some 3rd party controllers aren't pro controllers | ||
| 100 | generic_protocol->GetControllerType(device_type); | ||
| 101 | } else { | ||
| 102 | device_type = handle_device_type; | ||
| 103 | } | ||
| 104 | generic_protocol->GetSerialNumber(serial_number); | ||
| 105 | } | ||
| 106 | |||
| 99 | supported_features = GetSupportedFeatures(); | 107 | supported_features = GetSupportedFeatures(); |
| 100 | 108 | ||
| 101 | // Get Calibration data | 109 | // Get Calibration data |
| @@ -261,6 +269,10 @@ DriverResult JoyconDriver::SetPollingMode() { | |||
| 261 | generic_protocol->EnableImu(false); | 269 | generic_protocol->EnableImu(false); |
| 262 | } | 270 | } |
| 263 | 271 | ||
| 272 | if (input_only_device) { | ||
| 273 | return DriverResult::NotSupported; | ||
| 274 | } | ||
| 275 | |||
| 264 | if (irs_protocol->IsEnabled()) { | 276 | if (irs_protocol->IsEnabled()) { |
| 265 | irs_protocol->DisableIrs(); | 277 | irs_protocol->DisableIrs(); |
| 266 | } | 278 | } |
| @@ -282,6 +294,7 @@ DriverResult JoyconDriver::SetPollingMode() { | |||
| 282 | } | 294 | } |
| 283 | irs_protocol->DisableIrs(); | 295 | irs_protocol->DisableIrs(); |
| 284 | LOG_ERROR(Input, "Error enabling IRS"); | 296 | LOG_ERROR(Input, "Error enabling IRS"); |
| 297 | return result; | ||
| 285 | } | 298 | } |
| 286 | 299 | ||
| 287 | if (nfc_enabled && supported_features.nfc) { | 300 | if (nfc_enabled && supported_features.nfc) { |
| @@ -291,6 +304,7 @@ DriverResult JoyconDriver::SetPollingMode() { | |||
| 291 | } | 304 | } |
| 292 | nfc_protocol->DisableNfc(); | 305 | nfc_protocol->DisableNfc(); |
| 293 | LOG_ERROR(Input, "Error enabling NFC"); | 306 | LOG_ERROR(Input, "Error enabling NFC"); |
| 307 | return result; | ||
| 294 | } | 308 | } |
| 295 | 309 | ||
| 296 | if (hidbus_enabled && supported_features.hidbus) { | 310 | if (hidbus_enabled && supported_features.hidbus) { |
| @@ -305,6 +319,7 @@ DriverResult JoyconDriver::SetPollingMode() { | |||
| 305 | ring_connected = false; | 319 | ring_connected = false; |
| 306 | ring_protocol->DisableRingCon(); | 320 | ring_protocol->DisableRingCon(); |
| 307 | LOG_ERROR(Input, "Error enabling Ringcon"); | 321 | LOG_ERROR(Input, "Error enabling Ringcon"); |
| 322 | return result; | ||
| 308 | } | 323 | } |
| 309 | 324 | ||
| 310 | if (passive_enabled && supported_features.passive) { | 325 | if (passive_enabled && supported_features.passive) { |
| @@ -333,6 +348,10 @@ JoyconDriver::SupportedFeatures JoyconDriver::GetSupportedFeatures() { | |||
| 333 | .vibration = true, | 348 | .vibration = true, |
| 334 | }; | 349 | }; |
| 335 | 350 | ||
| 351 | if (input_only_device) { | ||
| 352 | return features; | ||
| 353 | } | ||
| 354 | |||
| 336 | if (device_type == ControllerType::Right) { | 355 | if (device_type == ControllerType::Right) { |
| 337 | features.nfc = true; | 356 | features.nfc = true; |
| 338 | features.irs = true; | 357 | features.irs = true; |
| @@ -517,6 +536,11 @@ DriverResult JoyconDriver::StopNfcPolling() { | |||
| 517 | const auto result = nfc_protocol->StopNFCPollingMode(); | 536 | const auto result = nfc_protocol->StopNFCPollingMode(); |
| 518 | disable_input_thread = false; | 537 | disable_input_thread = false; |
| 519 | 538 | ||
| 539 | if (amiibo_detected) { | ||
| 540 | amiibo_detected = false; | ||
| 541 | joycon_poller->UpdateAmiibo({}); | ||
| 542 | } | ||
| 543 | |||
| 520 | return result; | 544 | return result; |
| 521 | } | 545 | } |
| 522 | 546 | ||