diff options
| author | 2022-12-22 20:47:51 -0600 | |
|---|---|---|
| committer | 2023-01-19 18:05:22 -0600 | |
| commit | 1c08d532e059fab603facb43f758f37fe148c1fc (patch) | |
| tree | 7451b6e38166cb3c422b22678ae0b989cd447de3 /src/core/hid/emulated_controller.cpp | |
| parent | input_common: Implement joycon nfc (diff) | |
| download | yuzu-1c08d532e059fab603facb43f758f37fe148c1fc.tar.gz yuzu-1c08d532e059fab603facb43f758f37fe148c1fc.tar.xz yuzu-1c08d532e059fab603facb43f758f37fe148c1fc.zip | |
core: hid: Fix input regressions
Diffstat (limited to 'src/core/hid/emulated_controller.cpp')
| -rw-r--r-- | src/core/hid/emulated_controller.cpp | 55 |
1 files changed, 35 insertions, 20 deletions
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp index 1e4ec4add..1ed57f949 100644 --- a/src/core/hid/emulated_controller.cpp +++ b/src/core/hid/emulated_controller.cpp | |||
| @@ -107,6 +107,8 @@ void EmulatedController::ReloadFromSettings() { | |||
| 107 | .button = GetNpadColor(player.button_color_right), | 107 | .button = GetNpadColor(player.button_color_right), |
| 108 | }; | 108 | }; |
| 109 | 109 | ||
| 110 | ring_params[0] = Common::ParamPackage(Settings::values.ringcon_analogs); | ||
| 111 | |||
| 110 | // Other or debug controller should always be a pro controller | 112 | // Other or debug controller should always be a pro controller |
| 111 | if (npad_id_type != NpadIdType::Other) { | 113 | if (npad_id_type != NpadIdType::Other) { |
| 112 | SetNpadStyleIndex(MapSettingsTypeToNPad(player.controller_type)); | 114 | SetNpadStyleIndex(MapSettingsTypeToNPad(player.controller_type)); |
| @@ -144,14 +146,15 @@ void EmulatedController::LoadDevices() { | |||
| 144 | battery_params[RightIndex].Set("battery", true); | 146 | battery_params[RightIndex].Set("battery", true); |
| 145 | 147 | ||
| 146 | camera_params = Common::ParamPackage{"engine:camera,camera:1"}; | 148 | camera_params = Common::ParamPackage{"engine:camera,camera:1"}; |
| 147 | nfc_params = right_joycon; | 149 | ring_params[1] = Common::ParamPackage{"engine:joycon,axis_x:100,axis_y:101"}; |
| 148 | nfc_params.Set("nfc", true); | 150 | nfc_params[0] = Common::ParamPackage{"engine:virtual_amiibo,nfc:1"}; |
| 149 | ring_params = Common::ParamPackage{"engine:joycon,axis_x:100,axis_y:101"}; | 151 | nfc_params[1] = right_joycon; |
| 152 | nfc_params[1].Set("nfc", true); | ||
| 150 | 153 | ||
| 151 | output_params[LeftIndex] = left_joycon; | 154 | output_params[LeftIndex] = left_joycon; |
| 152 | output_params[RightIndex] = right_joycon; | 155 | output_params[RightIndex] = right_joycon; |
| 153 | output_params[2] = camera_params; | 156 | output_params[2] = camera_params; |
| 154 | output_params[3] = nfc_params; | 157 | output_params[3] = nfc_params[0]; |
| 155 | output_params[LeftIndex].Set("output", true); | 158 | output_params[LeftIndex].Set("output", true); |
| 156 | output_params[RightIndex].Set("output", true); | 159 | output_params[RightIndex].Set("output", true); |
| 157 | output_params[2].Set("output", true); | 160 | output_params[2].Set("output", true); |
| @@ -169,8 +172,9 @@ void EmulatedController::LoadDevices() { | |||
| 169 | Common::Input::CreateInputDevice); | 172 | Common::Input::CreateInputDevice); |
| 170 | std::ranges::transform(color_params, color_devices.begin(), Common::Input::CreateInputDevice); | 173 | std::ranges::transform(color_params, color_devices.begin(), Common::Input::CreateInputDevice); |
| 171 | camera_devices = Common::Input::CreateInputDevice(camera_params); | 174 | camera_devices = Common::Input::CreateInputDevice(camera_params); |
| 172 | ring_analog_device = Common::Input::CreateInputDevice(ring_params); | 175 | std::ranges::transform(ring_params, ring_analog_devices.begin(), |
| 173 | nfc_devices = Common::Input::CreateInputDevice(nfc_params); | 176 | Common::Input::CreateInputDevice); |
| 177 | std::ranges::transform(nfc_params, nfc_devices.begin(), Common::Input::CreateInputDevice); | ||
| 174 | std::ranges::transform(output_params, output_devices.begin(), | 178 | std::ranges::transform(output_params, output_devices.begin(), |
| 175 | Common::Input::CreateOutputDevice); | 179 | Common::Input::CreateOutputDevice); |
| 176 | 180 | ||
| @@ -366,21 +370,26 @@ void EmulatedController::ReloadInput() { | |||
| 366 | camera_devices->ForceUpdate(); | 370 | camera_devices->ForceUpdate(); |
| 367 | } | 371 | } |
| 368 | 372 | ||
| 369 | if (ring_analog_device) { | 373 | for (std::size_t index = 0; index < ring_analog_devices.size(); ++index) { |
| 370 | ring_analog_device->SetCallback({ | 374 | if (!ring_analog_devices[index]) { |
| 375 | continue; | ||
| 376 | } | ||
| 377 | ring_analog_devices[index]->SetCallback({ | ||
| 371 | .on_change = | 378 | .on_change = |
| 372 | [this](const Common::Input::CallbackStatus& callback) { SetRingAnalog(callback); }, | 379 | [this](const Common::Input::CallbackStatus& callback) { SetRingAnalog(callback); }, |
| 373 | }); | 380 | }); |
| 381 | ring_analog_devices[index]->ForceUpdate(); | ||
| 374 | } | 382 | } |
| 375 | 383 | ||
| 376 | if (nfc_devices) { | 384 | for (std::size_t index = 0; index < nfc_devices.size(); ++index) { |
| 377 | if (npad_id_type == NpadIdType::Handheld || npad_id_type == NpadIdType::Player1) { | 385 | if (!nfc_devices[index]) { |
| 378 | nfc_devices->SetCallback({ | 386 | continue; |
| 379 | .on_change = | ||
| 380 | [this](const Common::Input::CallbackStatus& callback) { SetNfc(callback); }, | ||
| 381 | }); | ||
| 382 | nfc_devices->ForceUpdate(); | ||
| 383 | } | 387 | } |
| 388 | nfc_devices[index]->SetCallback({ | ||
| 389 | .on_change = | ||
| 390 | [this](const Common::Input::CallbackStatus& callback) { SetNfc(callback); }, | ||
| 391 | }); | ||
| 392 | nfc_devices[index]->ForceUpdate(); | ||
| 384 | } | 393 | } |
| 385 | 394 | ||
| 386 | // Register TAS devices. No need to force update | 395 | // Register TAS devices. No need to force update |
| @@ -469,8 +478,12 @@ void EmulatedController::UnloadInput() { | |||
| 469 | stick.reset(); | 478 | stick.reset(); |
| 470 | } | 479 | } |
| 471 | camera_devices.reset(); | 480 | camera_devices.reset(); |
| 472 | ring_analog_device.reset(); | 481 | for (auto& ring : ring_analog_devices) { |
| 473 | nfc_devices.reset(); | 482 | ring.reset(); |
| 483 | } | ||
| 484 | for (auto& nfc : nfc_devices) { | ||
| 485 | nfc.reset(); | ||
| 486 | } | ||
| 474 | } | 487 | } |
| 475 | 488 | ||
| 476 | void EmulatedController::EnableConfiguration() { | 489 | void EmulatedController::EnableConfiguration() { |
| @@ -540,7 +553,9 @@ void EmulatedController::SaveCurrentConfig() { | |||
| 540 | for (std::size_t index = 0; index < player.motions.size(); ++index) { | 553 | for (std::size_t index = 0; index < player.motions.size(); ++index) { |
| 541 | player.motions[index] = motion_params[index].Serialize(); | 554 | player.motions[index] = motion_params[index].Serialize(); |
| 542 | } | 555 | } |
| 543 | Settings::values.ringcon_analogs = ring_params.Serialize(); | 556 | if (npad_id_type == NpadIdType::Player1) { |
| 557 | Settings::values.ringcon_analogs = ring_params[0].Serialize(); | ||
| 558 | } | ||
| 544 | } | 559 | } |
| 545 | 560 | ||
| 546 | void EmulatedController::RestoreConfig() { | 561 | void EmulatedController::RestoreConfig() { |
| @@ -1215,11 +1230,11 @@ bool EmulatedController::SetCameraFormat( | |||
| 1215 | } | 1230 | } |
| 1216 | 1231 | ||
| 1217 | Common::ParamPackage EmulatedController::GetRingParam() const { | 1232 | Common::ParamPackage EmulatedController::GetRingParam() const { |
| 1218 | return ring_params; | 1233 | return ring_params[0]; |
| 1219 | } | 1234 | } |
| 1220 | 1235 | ||
| 1221 | void EmulatedController::SetRingParam(Common::ParamPackage param) { | 1236 | void EmulatedController::SetRingParam(Common::ParamPackage param) { |
| 1222 | ring_params = std::move(param); | 1237 | ring_params[0] = std::move(param); |
| 1223 | ReloadInput(); | 1238 | ReloadInput(); |
| 1224 | } | 1239 | } |
| 1225 | 1240 | ||