diff options
| -rw-r--r-- | src/common/input.h | 12 | ||||
| -rw-r--r-- | src/core/hid/emulated_console.cpp | 21 | ||||
| -rw-r--r-- | src/core/hid/emulated_console.h | 4 | ||||
| -rw-r--r-- | src/core/hid/emulated_controller.cpp | 95 | ||||
| -rw-r--r-- | src/core/hid/emulated_controller.h | 13 | ||||
| -rw-r--r-- | src/core/hid/emulated_devices.cpp | 66 | ||||
| -rw-r--r-- | src/core/hid/emulated_devices.h | 11 | ||||
| -rw-r--r-- | src/input_common/helpers/stick_from_buttons.cpp | 75 | ||||
| -rw-r--r-- | src/input_common/helpers/touch_from_buttons.cpp | 11 | ||||
| -rw-r--r-- | src/input_common/input_poller.cpp | 39 |
10 files changed, 192 insertions, 155 deletions
diff --git a/src/common/input.h b/src/common/input.h index 0b92449bc..f775a4c01 100644 --- a/src/common/input.h +++ b/src/common/input.h | |||
| @@ -227,7 +227,7 @@ struct CallbackStatus { | |||
| 227 | 227 | ||
| 228 | // Triggered once every input change | 228 | // Triggered once every input change |
| 229 | struct InputCallback { | 229 | struct InputCallback { |
| 230 | std::function<void(CallbackStatus)> on_change; | 230 | std::function<void(const CallbackStatus&)> on_change; |
| 231 | }; | 231 | }; |
| 232 | 232 | ||
| 233 | /// An abstract class template for an input device (a button, an analog input, etc.). | 233 | /// An abstract class template for an input device (a button, an analog input, etc.). |
| @@ -236,14 +236,10 @@ public: | |||
| 236 | virtual ~InputDevice() = default; | 236 | virtual ~InputDevice() = default; |
| 237 | 237 | ||
| 238 | // Request input device to update if necessary | 238 | // Request input device to update if necessary |
| 239 | virtual void SoftUpdate() { | 239 | virtual void SoftUpdate() {} |
| 240 | return; | ||
| 241 | } | ||
| 242 | 240 | ||
| 243 | // Force input device to update data regardless of the current state | 241 | // Force input device to update data regardless of the current state |
| 244 | virtual void ForceUpdate() { | 242 | virtual void ForceUpdate() {} |
| 245 | return; | ||
| 246 | } | ||
| 247 | 243 | ||
| 248 | // Sets the function to be triggered when input changes | 244 | // Sets the function to be triggered when input changes |
| 249 | void SetCallback(InputCallback callback_) { | 245 | void SetCallback(InputCallback callback_) { |
| @@ -251,7 +247,7 @@ public: | |||
| 251 | } | 247 | } |
| 252 | 248 | ||
| 253 | // Triggers the function set in the callback | 249 | // Triggers the function set in the callback |
| 254 | void TriggerOnChange(CallbackStatus status) { | 250 | void TriggerOnChange(const CallbackStatus& status) { |
| 255 | if (callback.on_change) { | 251 | if (callback.on_change) { |
| 256 | callback.on_change(status); | 252 | callback.on_change(status); |
| 257 | } | 253 | } |
diff --git a/src/core/hid/emulated_console.cpp b/src/core/hid/emulated_console.cpp index 80db8e9c6..685ec080c 100644 --- a/src/core/hid/emulated_console.cpp +++ b/src/core/hid/emulated_console.cpp | |||
| @@ -66,9 +66,10 @@ void EmulatedConsole::ReloadInput() { | |||
| 66 | 66 | ||
| 67 | motion_devices = Common::Input::CreateDevice<Common::Input::InputDevice>(motion_params); | 67 | motion_devices = Common::Input::CreateDevice<Common::Input::InputDevice>(motion_params); |
| 68 | if (motion_devices) { | 68 | if (motion_devices) { |
| 69 | Common::Input::InputCallback motion_callback{ | 69 | motion_devices->SetCallback({ |
| 70 | [this](Common::Input::CallbackStatus callback) { SetMotion(callback); }}; | 70 | .on_change = |
| 71 | motion_devices->SetCallback(motion_callback); | 71 | [this](const Common::Input::CallbackStatus& callback) { SetMotion(callback); }, |
| 72 | }); | ||
| 72 | } | 73 | } |
| 73 | 74 | ||
| 74 | // Unique index for identifying touch device source | 75 | // Unique index for identifying touch device source |
| @@ -78,9 +79,12 @@ void EmulatedConsole::ReloadInput() { | |||
| 78 | if (!touch_device) { | 79 | if (!touch_device) { |
| 79 | continue; | 80 | continue; |
| 80 | } | 81 | } |
| 81 | Common::Input::InputCallback touch_callback{ | 82 | touch_device->SetCallback({ |
| 82 | [this, index](Common::Input::CallbackStatus callback) { SetTouch(callback, index); }}; | 83 | .on_change = |
| 83 | touch_device->SetCallback(touch_callback); | 84 | [this, index](const Common::Input::CallbackStatus& callback) { |
| 85 | SetTouch(callback, index); | ||
| 86 | }, | ||
| 87 | }); | ||
| 84 | index++; | 88 | index++; |
| 85 | } | 89 | } |
| 86 | } | 90 | } |
| @@ -127,7 +131,7 @@ void EmulatedConsole::SetMotionParam(Common::ParamPackage param) { | |||
| 127 | ReloadInput(); | 131 | ReloadInput(); |
| 128 | } | 132 | } |
| 129 | 133 | ||
| 130 | void EmulatedConsole::SetMotion(Common::Input::CallbackStatus callback) { | 134 | void EmulatedConsole::SetMotion(const Common::Input::CallbackStatus& callback) { |
| 131 | std::lock_guard lock{mutex}; | 135 | std::lock_guard lock{mutex}; |
| 132 | auto& raw_status = console.motion_values.raw_status; | 136 | auto& raw_status = console.motion_values.raw_status; |
| 133 | auto& emulated = console.motion_values.emulated; | 137 | auto& emulated = console.motion_values.emulated; |
| @@ -162,8 +166,7 @@ void EmulatedConsole::SetMotion(Common::Input::CallbackStatus callback) { | |||
| 162 | TriggerOnChange(ConsoleTriggerType::Motion); | 166 | TriggerOnChange(ConsoleTriggerType::Motion); |
| 163 | } | 167 | } |
| 164 | 168 | ||
| 165 | void EmulatedConsole::SetTouch(Common::Input::CallbackStatus callback, | 169 | void EmulatedConsole::SetTouch(const Common::Input::CallbackStatus& callback, std::size_t index) { |
| 166 | [[maybe_unused]] std::size_t index) { | ||
| 167 | if (index >= console.touch_values.size()) { | 170 | if (index >= console.touch_values.size()) { |
| 168 | return; | 171 | return; |
| 169 | } | 172 | } |
diff --git a/src/core/hid/emulated_console.h b/src/core/hid/emulated_console.h index bb3d7ab90..3afd284d5 100644 --- a/src/core/hid/emulated_console.h +++ b/src/core/hid/emulated_console.h | |||
| @@ -155,14 +155,14 @@ private: | |||
| 155 | * Updates the motion status of the console | 155 | * Updates the motion status of the console |
| 156 | * @param callback A CallbackStatus containing gyro and accelerometer data | 156 | * @param callback A CallbackStatus containing gyro and accelerometer data |
| 157 | */ | 157 | */ |
| 158 | void SetMotion(Common::Input::CallbackStatus callback); | 158 | void SetMotion(const Common::Input::CallbackStatus& callback); |
| 159 | 159 | ||
| 160 | /** | 160 | /** |
| 161 | * Updates the touch status of the console | 161 | * Updates the touch status of the console |
| 162 | * @param callback A CallbackStatus containing the touch position | 162 | * @param callback A CallbackStatus containing the touch position |
| 163 | * @param index Finger ID to be updated | 163 | * @param index Finger ID to be updated |
| 164 | */ | 164 | */ |
| 165 | void SetTouch(Common::Input::CallbackStatus callback, std::size_t index); | 165 | void SetTouch(const Common::Input::CallbackStatus& callback, std::size_t index); |
| 166 | 166 | ||
| 167 | /** | 167 | /** |
| 168 | * Triggers a callback that something has changed on the console status | 168 | * Triggers a callback that something has changed on the console status |
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp index fbb19f230..eb2e0ab4f 100644 --- a/src/core/hid/emulated_controller.cpp +++ b/src/core/hid/emulated_controller.cpp | |||
| @@ -205,11 +205,12 @@ void EmulatedController::ReloadInput() { | |||
| 205 | continue; | 205 | continue; |
| 206 | } | 206 | } |
| 207 | const auto uuid = Common::UUID{button_params[index].Get("guid", "")}; | 207 | const auto uuid = Common::UUID{button_params[index].Get("guid", "")}; |
| 208 | Common::Input::InputCallback button_callback{ | 208 | button_devices[index]->SetCallback({ |
| 209 | [this, index, uuid](Common::Input::CallbackStatus callback) { | 209 | .on_change = |
| 210 | SetButton(callback, index, uuid); | 210 | [this, index, uuid](const Common::Input::CallbackStatus& callback) { |
| 211 | }}; | 211 | SetButton(callback, index, uuid); |
| 212 | button_devices[index]->SetCallback(button_callback); | 212 | }, |
| 213 | }); | ||
| 213 | button_devices[index]->ForceUpdate(); | 214 | button_devices[index]->ForceUpdate(); |
| 214 | } | 215 | } |
| 215 | 216 | ||
| @@ -218,11 +219,12 @@ void EmulatedController::ReloadInput() { | |||
| 218 | continue; | 219 | continue; |
| 219 | } | 220 | } |
| 220 | const auto uuid = Common::UUID{stick_params[index].Get("guid", "")}; | 221 | const auto uuid = Common::UUID{stick_params[index].Get("guid", "")}; |
| 221 | Common::Input::InputCallback stick_callback{ | 222 | stick_devices[index]->SetCallback({ |
| 222 | [this, index, uuid](Common::Input::CallbackStatus callback) { | 223 | .on_change = |
| 223 | SetStick(callback, index, uuid); | 224 | [this, index, uuid](const Common::Input::CallbackStatus& callback) { |
| 224 | }}; | 225 | SetStick(callback, index, uuid); |
| 225 | stick_devices[index]->SetCallback(stick_callback); | 226 | }, |
| 227 | }); | ||
| 226 | stick_devices[index]->ForceUpdate(); | 228 | stick_devices[index]->ForceUpdate(); |
| 227 | } | 229 | } |
| 228 | 230 | ||
| @@ -231,11 +233,12 @@ void EmulatedController::ReloadInput() { | |||
| 231 | continue; | 233 | continue; |
| 232 | } | 234 | } |
| 233 | const auto uuid = Common::UUID{trigger_params[index].Get("guid", "")}; | 235 | const auto uuid = Common::UUID{trigger_params[index].Get("guid", "")}; |
| 234 | Common::Input::InputCallback trigger_callback{ | 236 | trigger_devices[index]->SetCallback({ |
| 235 | [this, index, uuid](Common::Input::CallbackStatus callback) { | 237 | .on_change = |
| 236 | SetTrigger(callback, index, uuid); | 238 | [this, index, uuid](const Common::Input::CallbackStatus& callback) { |
| 237 | }}; | 239 | SetTrigger(callback, index, uuid); |
| 238 | trigger_devices[index]->SetCallback(trigger_callback); | 240 | }, |
| 241 | }); | ||
| 239 | trigger_devices[index]->ForceUpdate(); | 242 | trigger_devices[index]->ForceUpdate(); |
| 240 | } | 243 | } |
| 241 | 244 | ||
| @@ -243,9 +246,12 @@ void EmulatedController::ReloadInput() { | |||
| 243 | if (!battery_devices[index]) { | 246 | if (!battery_devices[index]) { |
| 244 | continue; | 247 | continue; |
| 245 | } | 248 | } |
| 246 | Common::Input::InputCallback battery_callback{ | 249 | battery_devices[index]->SetCallback({ |
| 247 | [this, index](Common::Input::CallbackStatus callback) { SetBattery(callback, index); }}; | 250 | .on_change = |
| 248 | battery_devices[index]->SetCallback(battery_callback); | 251 | [this, index](const Common::Input::CallbackStatus& callback) { |
| 252 | SetBattery(callback, index); | ||
| 253 | }, | ||
| 254 | }); | ||
| 249 | battery_devices[index]->ForceUpdate(); | 255 | battery_devices[index]->ForceUpdate(); |
| 250 | } | 256 | } |
| 251 | 257 | ||
| @@ -253,9 +259,12 @@ void EmulatedController::ReloadInput() { | |||
| 253 | if (!motion_devices[index]) { | 259 | if (!motion_devices[index]) { |
| 254 | continue; | 260 | continue; |
| 255 | } | 261 | } |
| 256 | Common::Input::InputCallback motion_callback{ | 262 | motion_devices[index]->SetCallback({ |
| 257 | [this, index](Common::Input::CallbackStatus callback) { SetMotion(callback, index); }}; | 263 | .on_change = |
| 258 | motion_devices[index]->SetCallback(motion_callback); | 264 | [this, index](const Common::Input::CallbackStatus& callback) { |
| 265 | SetMotion(callback, index); | ||
| 266 | }, | ||
| 267 | }); | ||
| 259 | motion_devices[index]->ForceUpdate(); | 268 | motion_devices[index]->ForceUpdate(); |
| 260 | } | 269 | } |
| 261 | 270 | ||
| @@ -267,22 +276,24 @@ void EmulatedController::ReloadInput() { | |||
| 267 | if (!tas_button_devices[index]) { | 276 | if (!tas_button_devices[index]) { |
| 268 | continue; | 277 | continue; |
| 269 | } | 278 | } |
| 270 | Common::Input::InputCallback button_callback{ | 279 | tas_button_devices[index]->SetCallback({ |
| 271 | [this, index, tas_uuid](Common::Input::CallbackStatus callback) { | 280 | .on_change = |
| 272 | SetButton(callback, index, tas_uuid); | 281 | [this, index, tas_uuid](const Common::Input::CallbackStatus& callback) { |
| 273 | }}; | 282 | SetButton(callback, index, tas_uuid); |
| 274 | tas_button_devices[index]->SetCallback(button_callback); | 283 | }, |
| 284 | }); | ||
| 275 | } | 285 | } |
| 276 | 286 | ||
| 277 | for (std::size_t index = 0; index < tas_stick_devices.size(); ++index) { | 287 | for (std::size_t index = 0; index < tas_stick_devices.size(); ++index) { |
| 278 | if (!tas_stick_devices[index]) { | 288 | if (!tas_stick_devices[index]) { |
| 279 | continue; | 289 | continue; |
| 280 | } | 290 | } |
| 281 | Common::Input::InputCallback stick_callback{ | 291 | tas_stick_devices[index]->SetCallback({ |
| 282 | [this, index, tas_uuid](Common::Input::CallbackStatus callback) { | 292 | .on_change = |
| 283 | SetStick(callback, index, tas_uuid); | 293 | [this, index, tas_uuid](const Common::Input::CallbackStatus& callback) { |
| 284 | }}; | 294 | SetStick(callback, index, tas_uuid); |
| 285 | tas_stick_devices[index]->SetCallback(stick_callback); | 295 | }, |
| 296 | }); | ||
| 286 | } | 297 | } |
| 287 | } | 298 | } |
| 288 | 299 | ||
| @@ -440,7 +451,7 @@ void EmulatedController::SetButtonParam(std::size_t index, Common::ParamPackage | |||
| 440 | if (index >= button_params.size()) { | 451 | if (index >= button_params.size()) { |
| 441 | return; | 452 | return; |
| 442 | } | 453 | } |
| 443 | button_params[index] = param; | 454 | button_params[index] = std::move(param); |
| 444 | ReloadInput(); | 455 | ReloadInput(); |
| 445 | } | 456 | } |
| 446 | 457 | ||
| @@ -448,7 +459,7 @@ void EmulatedController::SetStickParam(std::size_t index, Common::ParamPackage p | |||
| 448 | if (index >= stick_params.size()) { | 459 | if (index >= stick_params.size()) { |
| 449 | return; | 460 | return; |
| 450 | } | 461 | } |
| 451 | stick_params[index] = param; | 462 | stick_params[index] = std::move(param); |
| 452 | ReloadInput(); | 463 | ReloadInput(); |
| 453 | } | 464 | } |
| 454 | 465 | ||
| @@ -456,11 +467,11 @@ void EmulatedController::SetMotionParam(std::size_t index, Common::ParamPackage | |||
| 456 | if (index >= motion_params.size()) { | 467 | if (index >= motion_params.size()) { |
| 457 | return; | 468 | return; |
| 458 | } | 469 | } |
| 459 | motion_params[index] = param; | 470 | motion_params[index] = std::move(param); |
| 460 | ReloadInput(); | 471 | ReloadInput(); |
| 461 | } | 472 | } |
| 462 | 473 | ||
| 463 | void EmulatedController::SetButton(Common::Input::CallbackStatus callback, std::size_t index, | 474 | void EmulatedController::SetButton(const Common::Input::CallbackStatus& callback, std::size_t index, |
| 464 | Common::UUID uuid) { | 475 | Common::UUID uuid) { |
| 465 | if (index >= controller.button_values.size()) { | 476 | if (index >= controller.button_values.size()) { |
| 466 | return; | 477 | return; |
| @@ -600,7 +611,7 @@ void EmulatedController::SetButton(Common::Input::CallbackStatus callback, std:: | |||
| 600 | TriggerOnChange(ControllerTriggerType::Button, true); | 611 | TriggerOnChange(ControllerTriggerType::Button, true); |
| 601 | } | 612 | } |
| 602 | 613 | ||
| 603 | void EmulatedController::SetStick(Common::Input::CallbackStatus callback, std::size_t index, | 614 | void EmulatedController::SetStick(const Common::Input::CallbackStatus& callback, std::size_t index, |
| 604 | Common::UUID uuid) { | 615 | Common::UUID uuid) { |
| 605 | if (index >= controller.stick_values.size()) { | 616 | if (index >= controller.stick_values.size()) { |
| 606 | return; | 617 | return; |
| @@ -650,8 +661,8 @@ void EmulatedController::SetStick(Common::Input::CallbackStatus callback, std::s | |||
| 650 | TriggerOnChange(ControllerTriggerType::Stick, true); | 661 | TriggerOnChange(ControllerTriggerType::Stick, true); |
| 651 | } | 662 | } |
| 652 | 663 | ||
| 653 | void EmulatedController::SetTrigger(Common::Input::CallbackStatus callback, std::size_t index, | 664 | void EmulatedController::SetTrigger(const Common::Input::CallbackStatus& callback, |
| 654 | Common::UUID uuid) { | 665 | std::size_t index, Common::UUID uuid) { |
| 655 | if (index >= controller.trigger_values.size()) { | 666 | if (index >= controller.trigger_values.size()) { |
| 656 | return; | 667 | return; |
| 657 | } | 668 | } |
| @@ -692,7 +703,8 @@ void EmulatedController::SetTrigger(Common::Input::CallbackStatus callback, std: | |||
| 692 | TriggerOnChange(ControllerTriggerType::Trigger, true); | 703 | TriggerOnChange(ControllerTriggerType::Trigger, true); |
| 693 | } | 704 | } |
| 694 | 705 | ||
| 695 | void EmulatedController::SetMotion(Common::Input::CallbackStatus callback, std::size_t index) { | 706 | void EmulatedController::SetMotion(const Common::Input::CallbackStatus& callback, |
| 707 | std::size_t index) { | ||
| 696 | if (index >= controller.motion_values.size()) { | 708 | if (index >= controller.motion_values.size()) { |
| 697 | return; | 709 | return; |
| 698 | } | 710 | } |
| @@ -730,7 +742,8 @@ void EmulatedController::SetMotion(Common::Input::CallbackStatus callback, std:: | |||
| 730 | TriggerOnChange(ControllerTriggerType::Motion, true); | 742 | TriggerOnChange(ControllerTriggerType::Motion, true); |
| 731 | } | 743 | } |
| 732 | 744 | ||
| 733 | void EmulatedController::SetBattery(Common::Input::CallbackStatus callback, std::size_t index) { | 745 | void EmulatedController::SetBattery(const Common::Input::CallbackStatus& callback, |
| 746 | std::size_t index) { | ||
| 734 | if (index >= controller.battery_values.size()) { | 747 | if (index >= controller.battery_values.size()) { |
| 735 | return; | 748 | return; |
| 736 | } | 749 | } |
| @@ -1110,7 +1123,7 @@ void EmulatedController::TriggerOnChange(ControllerTriggerType type, bool is_npa | |||
| 1110 | 1123 | ||
| 1111 | int EmulatedController::SetCallback(ControllerUpdateCallback update_callback) { | 1124 | int EmulatedController::SetCallback(ControllerUpdateCallback update_callback) { |
| 1112 | std::lock_guard lock{mutex}; | 1125 | std::lock_guard lock{mutex}; |
| 1113 | callback_list.insert_or_assign(last_callback_key, update_callback); | 1126 | callback_list.insert_or_assign(last_callback_key, std::move(update_callback)); |
| 1114 | return last_callback_key++; | 1127 | return last_callback_key++; |
| 1115 | } | 1128 | } |
| 1116 | 1129 | ||
diff --git a/src/core/hid/emulated_controller.h b/src/core/hid/emulated_controller.h index 425b3e7c4..e42aafebc 100644 --- a/src/core/hid/emulated_controller.h +++ b/src/core/hid/emulated_controller.h | |||
| @@ -328,35 +328,38 @@ private: | |||
| 328 | * @param callback A CallbackStatus containing the button status | 328 | * @param callback A CallbackStatus containing the button status |
| 329 | * @param index Button ID of the to be updated | 329 | * @param index Button ID of the to be updated |
| 330 | */ | 330 | */ |
| 331 | void SetButton(Common::Input::CallbackStatus callback, std::size_t index, Common::UUID uuid); | 331 | void SetButton(const Common::Input::CallbackStatus& callback, std::size_t index, |
| 332 | Common::UUID uuid); | ||
| 332 | 333 | ||
| 333 | /** | 334 | /** |
| 334 | * Updates the analog stick status of the controller | 335 | * Updates the analog stick status of the controller |
| 335 | * @param callback A CallbackStatus containing the analog stick status | 336 | * @param callback A CallbackStatus containing the analog stick status |
| 336 | * @param index stick ID of the to be updated | 337 | * @param index stick ID of the to be updated |
| 337 | */ | 338 | */ |
| 338 | void SetStick(Common::Input::CallbackStatus callback, std::size_t index, Common::UUID uuid); | 339 | void SetStick(const Common::Input::CallbackStatus& callback, std::size_t index, |
| 340 | Common::UUID uuid); | ||
| 339 | 341 | ||
| 340 | /** | 342 | /** |
| 341 | * Updates the trigger status of the controller | 343 | * Updates the trigger status of the controller |
| 342 | * @param callback A CallbackStatus containing the trigger status | 344 | * @param callback A CallbackStatus containing the trigger status |
| 343 | * @param index trigger ID of the to be updated | 345 | * @param index trigger ID of the to be updated |
| 344 | */ | 346 | */ |
| 345 | void SetTrigger(Common::Input::CallbackStatus callback, std::size_t index, Common::UUID uuid); | 347 | void SetTrigger(const Common::Input::CallbackStatus& callback, std::size_t index, |
| 348 | Common::UUID uuid); | ||
| 346 | 349 | ||
| 347 | /** | 350 | /** |
| 348 | * Updates the motion status of the controller | 351 | * Updates the motion status of the controller |
| 349 | * @param callback A CallbackStatus containing gyro and accelerometer data | 352 | * @param callback A CallbackStatus containing gyro and accelerometer data |
| 350 | * @param index motion ID of the to be updated | 353 | * @param index motion ID of the to be updated |
| 351 | */ | 354 | */ |
| 352 | void SetMotion(Common::Input::CallbackStatus callback, std::size_t index); | 355 | void SetMotion(const Common::Input::CallbackStatus& callback, std::size_t index); |
| 353 | 356 | ||
| 354 | /** | 357 | /** |
| 355 | * Updates the battery status of the controller | 358 | * Updates the battery status of the controller |
| 356 | * @param callback A CallbackStatus containing the battery status | 359 | * @param callback A CallbackStatus containing the battery status |
| 357 | * @param index Button ID of the to be updated | 360 | * @param index Button ID of the to be updated |
| 358 | */ | 361 | */ |
| 359 | void SetBattery(Common::Input::CallbackStatus callback, std::size_t index); | 362 | void SetBattery(const Common::Input::CallbackStatus& callback, std::size_t index); |
| 360 | 363 | ||
| 361 | /** | 364 | /** |
| 362 | * Triggers a callback that something has changed on the controller status | 365 | * Triggers a callback that something has changed on the controller status |
diff --git a/src/core/hid/emulated_devices.cpp b/src/core/hid/emulated_devices.cpp index 874780ec2..708480f2d 100644 --- a/src/core/hid/emulated_devices.cpp +++ b/src/core/hid/emulated_devices.cpp | |||
| @@ -70,50 +70,55 @@ void EmulatedDevices::ReloadInput() { | |||
| 70 | if (!mouse_button_devices[index]) { | 70 | if (!mouse_button_devices[index]) { |
| 71 | continue; | 71 | continue; |
| 72 | } | 72 | } |
| 73 | Common::Input::InputCallback button_callback{ | 73 | mouse_button_devices[index]->SetCallback({ |
| 74 | [this, index](Common::Input::CallbackStatus callback) { | 74 | .on_change = |
| 75 | SetMouseButton(callback, index); | 75 | [this, index](const Common::Input::CallbackStatus& callback) { |
| 76 | }}; | 76 | SetMouseButton(callback, index); |
| 77 | mouse_button_devices[index]->SetCallback(button_callback); | 77 | }, |
| 78 | }); | ||
| 78 | } | 79 | } |
| 79 | 80 | ||
| 80 | for (std::size_t index = 0; index < mouse_analog_devices.size(); ++index) { | 81 | for (std::size_t index = 0; index < mouse_analog_devices.size(); ++index) { |
| 81 | if (!mouse_analog_devices[index]) { | 82 | if (!mouse_analog_devices[index]) { |
| 82 | continue; | 83 | continue; |
| 83 | } | 84 | } |
| 84 | Common::Input::InputCallback button_callback{ | 85 | mouse_analog_devices[index]->SetCallback({ |
| 85 | [this, index](Common::Input::CallbackStatus callback) { | 86 | .on_change = |
| 86 | SetMouseAnalog(callback, index); | 87 | [this, index](const Common::Input::CallbackStatus& callback) { |
| 87 | }}; | 88 | SetMouseAnalog(callback, index); |
| 88 | mouse_analog_devices[index]->SetCallback(button_callback); | 89 | }, |
| 90 | }); | ||
| 89 | } | 91 | } |
| 90 | 92 | ||
| 91 | if (mouse_stick_device) { | 93 | if (mouse_stick_device) { |
| 92 | Common::Input::InputCallback button_callback{ | 94 | mouse_stick_device->SetCallback({ |
| 93 | [this](Common::Input::CallbackStatus callback) { SetMouseStick(callback); }}; | 95 | .on_change = |
| 94 | mouse_stick_device->SetCallback(button_callback); | 96 | [this](const Common::Input::CallbackStatus& callback) { SetMouseStick(callback); }, |
| 97 | }); | ||
| 95 | } | 98 | } |
| 96 | 99 | ||
| 97 | for (std::size_t index = 0; index < keyboard_devices.size(); ++index) { | 100 | for (std::size_t index = 0; index < keyboard_devices.size(); ++index) { |
| 98 | if (!keyboard_devices[index]) { | 101 | if (!keyboard_devices[index]) { |
| 99 | continue; | 102 | continue; |
| 100 | } | 103 | } |
| 101 | Common::Input::InputCallback button_callback{ | 104 | keyboard_devices[index]->SetCallback({ |
| 102 | [this, index](Common::Input::CallbackStatus callback) { | 105 | .on_change = |
| 103 | SetKeyboardButton(callback, index); | 106 | [this, index](const Common::Input::CallbackStatus& callback) { |
| 104 | }}; | 107 | SetKeyboardButton(callback, index); |
| 105 | keyboard_devices[index]->SetCallback(button_callback); | 108 | }, |
| 109 | }); | ||
| 106 | } | 110 | } |
| 107 | 111 | ||
| 108 | for (std::size_t index = 0; index < keyboard_modifier_devices.size(); ++index) { | 112 | for (std::size_t index = 0; index < keyboard_modifier_devices.size(); ++index) { |
| 109 | if (!keyboard_modifier_devices[index]) { | 113 | if (!keyboard_modifier_devices[index]) { |
| 110 | continue; | 114 | continue; |
| 111 | } | 115 | } |
| 112 | Common::Input::InputCallback button_callback{ | 116 | keyboard_modifier_devices[index]->SetCallback({ |
| 113 | [this, index](Common::Input::CallbackStatus callback) { | 117 | .on_change = |
| 114 | SetKeyboardModifier(callback, index); | 118 | [this, index](const Common::Input::CallbackStatus& callback) { |
| 115 | }}; | 119 | SetKeyboardModifier(callback, index); |
| 116 | keyboard_modifier_devices[index]->SetCallback(button_callback); | 120 | }, |
| 121 | }); | ||
| 117 | } | 122 | } |
| 118 | } | 123 | } |
| 119 | 124 | ||
| @@ -159,7 +164,8 @@ void EmulatedDevices::RestoreConfig() { | |||
| 159 | ReloadFromSettings(); | 164 | ReloadFromSettings(); |
| 160 | } | 165 | } |
| 161 | 166 | ||
| 162 | void EmulatedDevices::SetKeyboardButton(Common::Input::CallbackStatus callback, std::size_t index) { | 167 | void EmulatedDevices::SetKeyboardButton(const Common::Input::CallbackStatus& callback, |
| 168 | std::size_t index) { | ||
| 163 | if (index >= device_status.keyboard_values.size()) { | 169 | if (index >= device_status.keyboard_values.size()) { |
| 164 | return; | 170 | return; |
| 165 | } | 171 | } |
| @@ -216,7 +222,7 @@ void EmulatedDevices::UpdateKey(std::size_t key_index, bool status) { | |||
| 216 | } | 222 | } |
| 217 | } | 223 | } |
| 218 | 224 | ||
| 219 | void EmulatedDevices::SetKeyboardModifier(Common::Input::CallbackStatus callback, | 225 | void EmulatedDevices::SetKeyboardModifier(const Common::Input::CallbackStatus& callback, |
| 220 | std::size_t index) { | 226 | std::size_t index) { |
| 221 | if (index >= device_status.keyboard_moddifier_values.size()) { | 227 | if (index >= device_status.keyboard_moddifier_values.size()) { |
| 222 | return; | 228 | return; |
| @@ -286,7 +292,8 @@ void EmulatedDevices::SetKeyboardModifier(Common::Input::CallbackStatus callback | |||
| 286 | TriggerOnChange(DeviceTriggerType::KeyboardModdifier); | 292 | TriggerOnChange(DeviceTriggerType::KeyboardModdifier); |
| 287 | } | 293 | } |
| 288 | 294 | ||
| 289 | void EmulatedDevices::SetMouseButton(Common::Input::CallbackStatus callback, std::size_t index) { | 295 | void EmulatedDevices::SetMouseButton(const Common::Input::CallbackStatus& callback, |
| 296 | std::size_t index) { | ||
| 290 | if (index >= device_status.mouse_button_values.size()) { | 297 | if (index >= device_status.mouse_button_values.size()) { |
| 291 | return; | 298 | return; |
| 292 | } | 299 | } |
| @@ -347,7 +354,8 @@ void EmulatedDevices::SetMouseButton(Common::Input::CallbackStatus callback, std | |||
| 347 | TriggerOnChange(DeviceTriggerType::Mouse); | 354 | TriggerOnChange(DeviceTriggerType::Mouse); |
| 348 | } | 355 | } |
| 349 | 356 | ||
| 350 | void EmulatedDevices::SetMouseAnalog(Common::Input::CallbackStatus callback, std::size_t index) { | 357 | void EmulatedDevices::SetMouseAnalog(const Common::Input::CallbackStatus& callback, |
| 358 | std::size_t index) { | ||
| 351 | if (index >= device_status.mouse_analog_values.size()) { | 359 | if (index >= device_status.mouse_analog_values.size()) { |
| 352 | return; | 360 | return; |
| 353 | } | 361 | } |
| @@ -374,7 +382,7 @@ void EmulatedDevices::SetMouseAnalog(Common::Input::CallbackStatus callback, std | |||
| 374 | TriggerOnChange(DeviceTriggerType::Mouse); | 382 | TriggerOnChange(DeviceTriggerType::Mouse); |
| 375 | } | 383 | } |
| 376 | 384 | ||
| 377 | void EmulatedDevices::SetMouseStick(Common::Input::CallbackStatus callback) { | 385 | void EmulatedDevices::SetMouseStick(const Common::Input::CallbackStatus& callback) { |
| 378 | std::lock_guard lock{mutex}; | 386 | std::lock_guard lock{mutex}; |
| 379 | const auto touch_value = TransformToTouch(callback); | 387 | const auto touch_value = TransformToTouch(callback); |
| 380 | 388 | ||
| @@ -435,7 +443,7 @@ void EmulatedDevices::TriggerOnChange(DeviceTriggerType type) { | |||
| 435 | 443 | ||
| 436 | int EmulatedDevices::SetCallback(InterfaceUpdateCallback update_callback) { | 444 | int EmulatedDevices::SetCallback(InterfaceUpdateCallback update_callback) { |
| 437 | std::lock_guard lock{mutex}; | 445 | std::lock_guard lock{mutex}; |
| 438 | callback_list.insert_or_assign(last_callback_key, update_callback); | 446 | callback_list.insert_or_assign(last_callback_key, std::move(update_callback)); |
| 439 | return last_callback_key++; | 447 | return last_callback_key++; |
| 440 | } | 448 | } |
| 441 | 449 | ||
diff --git a/src/core/hid/emulated_devices.h b/src/core/hid/emulated_devices.h index c72327681..790d3b411 100644 --- a/src/core/hid/emulated_devices.h +++ b/src/core/hid/emulated_devices.h | |||
| @@ -156,35 +156,34 @@ private: | |||
| 156 | * @param callback A CallbackStatus containing the key status | 156 | * @param callback A CallbackStatus containing the key status |
| 157 | * @param index key ID to be updated | 157 | * @param index key ID to be updated |
| 158 | */ | 158 | */ |
| 159 | void SetKeyboardButton(Common::Input::CallbackStatus callback, std::size_t index); | 159 | void SetKeyboardButton(const Common::Input::CallbackStatus& callback, std::size_t index); |
| 160 | 160 | ||
| 161 | /** | 161 | /** |
| 162 | * Updates the keyboard status of the keyboard device | 162 | * Updates the keyboard status of the keyboard device |
| 163 | * @param callback A CallbackStatus containing the modifier key status | 163 | * @param callback A CallbackStatus containing the modifier key status |
| 164 | * @param index modifier key ID to be updated | 164 | * @param index modifier key ID to be updated |
| 165 | */ | 165 | */ |
| 166 | void SetKeyboardModifier(Common::Input::CallbackStatus callback, std::size_t index); | 166 | void SetKeyboardModifier(const Common::Input::CallbackStatus& callback, std::size_t index); |
| 167 | 167 | ||
| 168 | /** | 168 | /** |
| 169 | * Updates the mouse button status of the mouse device | 169 | * Updates the mouse button status of the mouse device |
| 170 | * @param callback A CallbackStatus containing the button status | 170 | * @param callback A CallbackStatus containing the button status |
| 171 | * @param index Button ID to be updated | 171 | * @param index Button ID to be updated |
| 172 | */ | 172 | */ |
| 173 | void SetMouseButton(Common::Input::CallbackStatus callback, std::size_t index); | 173 | void SetMouseButton(const Common::Input::CallbackStatus& callback, std::size_t index); |
| 174 | 174 | ||
| 175 | /** | 175 | /** |
| 176 | * Updates the mouse wheel status of the mouse device | 176 | * Updates the mouse wheel status of the mouse device |
| 177 | * @param callback A CallbackStatus containing the wheel status | 177 | * @param callback A CallbackStatus containing the wheel status |
| 178 | * @param index wheel ID to be updated | 178 | * @param index wheel ID to be updated |
| 179 | */ | 179 | */ |
| 180 | void SetMouseAnalog(Common::Input::CallbackStatus callback, std::size_t index); | 180 | void SetMouseAnalog(const Common::Input::CallbackStatus& callback, std::size_t index); |
| 181 | 181 | ||
| 182 | /** | 182 | /** |
| 183 | * Updates the mouse position status of the mouse device | 183 | * Updates the mouse position status of the mouse device |
| 184 | * @param callback A CallbackStatus containing the position status | 184 | * @param callback A CallbackStatus containing the position status |
| 185 | * @param index stick ID to be updated | ||
| 186 | */ | 185 | */ |
| 187 | void SetMouseStick(Common::Input::CallbackStatus callback); | 186 | void SetMouseStick(const Common::Input::CallbackStatus& callback); |
| 188 | 187 | ||
| 189 | /** | 188 | /** |
| 190 | * Triggers a callback that something has changed on the device status | 189 | * Triggers a callback that something has changed on the device status |
diff --git a/src/input_common/helpers/stick_from_buttons.cpp b/src/input_common/helpers/stick_from_buttons.cpp index 77fcd655e..e23394f5f 100644 --- a/src/input_common/helpers/stick_from_buttons.cpp +++ b/src/input_common/helpers/stick_from_buttons.cpp | |||
| @@ -19,23 +19,36 @@ public: | |||
| 19 | : up(std::move(up_)), down(std::move(down_)), left(std::move(left_)), | 19 | : up(std::move(up_)), down(std::move(down_)), left(std::move(left_)), |
| 20 | right(std::move(right_)), modifier(std::move(modifier_)), modifier_scale(modifier_scale_), | 20 | right(std::move(right_)), modifier(std::move(modifier_)), modifier_scale(modifier_scale_), |
| 21 | modifier_angle(modifier_angle_) { | 21 | modifier_angle(modifier_angle_) { |
| 22 | Common::Input::InputCallback button_up_callback{ | 22 | up->SetCallback({ |
| 23 | [this](Common::Input::CallbackStatus callback_) { UpdateUpButtonStatus(callback_); }}; | 23 | .on_change = |
| 24 | Common::Input::InputCallback button_down_callback{ | 24 | [this](const Common::Input::CallbackStatus& callback_) { |
| 25 | [this](Common::Input::CallbackStatus callback_) { UpdateDownButtonStatus(callback_); }}; | 25 | UpdateUpButtonStatus(callback_); |
| 26 | Common::Input::InputCallback button_left_callback{ | 26 | }, |
| 27 | [this](Common::Input::CallbackStatus callback_) { UpdateLeftButtonStatus(callback_); }}; | 27 | }); |
| 28 | Common::Input::InputCallback button_right_callback{ | 28 | down->SetCallback({ |
| 29 | [this](Common::Input::CallbackStatus callback_) { | 29 | .on_change = |
| 30 | UpdateRightButtonStatus(callback_); | 30 | [this](const Common::Input::CallbackStatus& callback_) { |
| 31 | }}; | 31 | UpdateDownButtonStatus(callback_); |
| 32 | Common::Input::InputCallback button_modifier_callback{ | 32 | }, |
| 33 | [this](Common::Input::CallbackStatus callback_) { UpdateModButtonStatus(callback_); }}; | 33 | }); |
| 34 | up->SetCallback(button_up_callback); | 34 | left->SetCallback({ |
| 35 | down->SetCallback(button_down_callback); | 35 | .on_change = |
| 36 | left->SetCallback(button_left_callback); | 36 | [this](const Common::Input::CallbackStatus& callback_) { |
| 37 | right->SetCallback(button_right_callback); | 37 | UpdateLeftButtonStatus(callback_); |
| 38 | modifier->SetCallback(button_modifier_callback); | 38 | }, |
| 39 | }); | ||
| 40 | right->SetCallback({ | ||
| 41 | .on_change = | ||
| 42 | [this](const Common::Input::CallbackStatus& callback_) { | ||
| 43 | UpdateRightButtonStatus(callback_); | ||
| 44 | }, | ||
| 45 | }); | ||
| 46 | modifier->SetCallback({ | ||
| 47 | .on_change = | ||
| 48 | [this](const Common::Input::CallbackStatus& callback_) { | ||
| 49 | UpdateModButtonStatus(callback_); | ||
| 50 | }, | ||
| 51 | }); | ||
| 39 | last_x_axis_value = 0.0f; | 52 | last_x_axis_value = 0.0f; |
| 40 | last_y_axis_value = 0.0f; | 53 | last_y_axis_value = 0.0f; |
| 41 | } | 54 | } |
| @@ -133,27 +146,27 @@ public: | |||
| 133 | } | 146 | } |
| 134 | } | 147 | } |
| 135 | 148 | ||
| 136 | void UpdateUpButtonStatus(Common::Input::CallbackStatus button_callback) { | 149 | void UpdateUpButtonStatus(const Common::Input::CallbackStatus& button_callback) { |
| 137 | up_status = button_callback.button_status.value; | 150 | up_status = button_callback.button_status.value; |
| 138 | UpdateStatus(); | 151 | UpdateStatus(); |
| 139 | } | 152 | } |
| 140 | 153 | ||
| 141 | void UpdateDownButtonStatus(Common::Input::CallbackStatus button_callback) { | 154 | void UpdateDownButtonStatus(const Common::Input::CallbackStatus& button_callback) { |
| 142 | down_status = button_callback.button_status.value; | 155 | down_status = button_callback.button_status.value; |
| 143 | UpdateStatus(); | 156 | UpdateStatus(); |
| 144 | } | 157 | } |
| 145 | 158 | ||
| 146 | void UpdateLeftButtonStatus(Common::Input::CallbackStatus button_callback) { | 159 | void UpdateLeftButtonStatus(const Common::Input::CallbackStatus& button_callback) { |
| 147 | left_status = button_callback.button_status.value; | 160 | left_status = button_callback.button_status.value; |
| 148 | UpdateStatus(); | 161 | UpdateStatus(); |
| 149 | } | 162 | } |
| 150 | 163 | ||
| 151 | void UpdateRightButtonStatus(Common::Input::CallbackStatus button_callback) { | 164 | void UpdateRightButtonStatus(const Common::Input::CallbackStatus& button_callback) { |
| 152 | right_status = button_callback.button_status.value; | 165 | right_status = button_callback.button_status.value; |
| 153 | UpdateStatus(); | 166 | UpdateStatus(); |
| 154 | } | 167 | } |
| 155 | 168 | ||
| 156 | void UpdateModButtonStatus(Common::Input::CallbackStatus button_callback) { | 169 | void UpdateModButtonStatus(const Common::Input::CallbackStatus& button_callback) { |
| 157 | modifier_status = button_callback.button_status.value; | 170 | modifier_status = button_callback.button_status.value; |
| 158 | UpdateStatus(); | 171 | UpdateStatus(); |
| 159 | } | 172 | } |
| @@ -265,18 +278,18 @@ private: | |||
| 265 | Button left; | 278 | Button left; |
| 266 | Button right; | 279 | Button right; |
| 267 | Button modifier; | 280 | Button modifier; |
| 268 | float modifier_scale; | 281 | float modifier_scale{}; |
| 269 | float modifier_angle; | 282 | float modifier_angle{}; |
| 270 | float angle{}; | 283 | float angle{}; |
| 271 | float goal_angle{}; | 284 | float goal_angle{}; |
| 272 | float amplitude{}; | 285 | float amplitude{}; |
| 273 | bool up_status; | 286 | bool up_status{}; |
| 274 | bool down_status; | 287 | bool down_status{}; |
| 275 | bool left_status; | 288 | bool left_status{}; |
| 276 | bool right_status; | 289 | bool right_status{}; |
| 277 | bool modifier_status; | 290 | bool modifier_status{}; |
| 278 | float last_x_axis_value; | 291 | float last_x_axis_value{}; |
| 279 | float last_y_axis_value; | 292 | float last_y_axis_value{}; |
| 280 | const Common::Input::AnalogProperties properties{0.0f, 1.0f, 0.5f, 0.0f, false}; | 293 | const Common::Input::AnalogProperties properties{0.0f, 1.0f, 0.5f, 0.0f, false}; |
| 281 | std::chrono::time_point<std::chrono::steady_clock> last_update; | 294 | std::chrono::time_point<std::chrono::steady_clock> last_update; |
| 282 | }; | 295 | }; |
diff --git a/src/input_common/helpers/touch_from_buttons.cpp b/src/input_common/helpers/touch_from_buttons.cpp index 35d60bc90..ece1e3b32 100644 --- a/src/input_common/helpers/touch_from_buttons.cpp +++ b/src/input_common/helpers/touch_from_buttons.cpp | |||
| @@ -14,10 +14,13 @@ public: | |||
| 14 | using Button = std::unique_ptr<Common::Input::InputDevice>; | 14 | using Button = std::unique_ptr<Common::Input::InputDevice>; |
| 15 | TouchFromButtonDevice(Button button_, int touch_id_, float x_, float y_) | 15 | TouchFromButtonDevice(Button button_, int touch_id_, float x_, float y_) |
| 16 | : button(std::move(button_)), touch_id(touch_id_), x(x_), y(y_) { | 16 | : button(std::move(button_)), touch_id(touch_id_), x(x_), y(y_) { |
| 17 | Common::Input::InputCallback button_up_callback{ | ||
| 18 | [this](Common::Input::CallbackStatus callback_) { UpdateButtonStatus(callback_); }}; | ||
| 19 | last_button_value = false; | 17 | last_button_value = false; |
| 20 | button->SetCallback(button_up_callback); | 18 | button->SetCallback({ |
| 19 | .on_change = | ||
| 20 | [this](const Common::Input::CallbackStatus& callback_) { | ||
| 21 | UpdateButtonStatus(callback_); | ||
| 22 | }, | ||
| 23 | }); | ||
| 21 | button->ForceUpdate(); | 24 | button->ForceUpdate(); |
| 22 | } | 25 | } |
| 23 | 26 | ||
| @@ -47,7 +50,7 @@ public: | |||
| 47 | return status; | 50 | return status; |
| 48 | } | 51 | } |
| 49 | 52 | ||
| 50 | void UpdateButtonStatus(Common::Input::CallbackStatus button_callback) { | 53 | void UpdateButtonStatus(const Common::Input::CallbackStatus& button_callback) { |
| 51 | const Common::Input::CallbackStatus status{ | 54 | const Common::Input::CallbackStatus status{ |
| 52 | .type = Common::Input::InputType::Touch, | 55 | .type = Common::Input::InputType::Touch, |
| 53 | .touch_status = GetStatus(button_callback.button_status.value), | 56 | .touch_status = GetStatus(button_callback.button_status.value), |
diff --git a/src/input_common/input_poller.cpp b/src/input_common/input_poller.cpp index c56d5e0c2..7b370335f 100644 --- a/src/input_common/input_poller.cpp +++ b/src/input_common/input_poller.cpp | |||
| @@ -12,8 +12,7 @@ namespace InputCommon { | |||
| 12 | 12 | ||
| 13 | class DummyInput final : public Common::Input::InputDevice { | 13 | class DummyInput final : public Common::Input::InputDevice { |
| 14 | public: | 14 | public: |
| 15 | explicit DummyInput() {} | 15 | explicit DummyInput() = default; |
| 16 | ~DummyInput() {} | ||
| 17 | }; | 16 | }; |
| 18 | 17 | ||
| 19 | class InputFromButton final : public Common::Input::InputDevice { | 18 | class InputFromButton final : public Common::Input::InputDevice { |
| @@ -33,7 +32,7 @@ public: | |||
| 33 | callback_key = input_engine->SetCallback(input_identifier); | 32 | callback_key = input_engine->SetCallback(input_identifier); |
| 34 | } | 33 | } |
| 35 | 34 | ||
| 36 | ~InputFromButton() { | 35 | ~InputFromButton() override { |
| 37 | input_engine->DeleteCallback(callback_key); | 36 | input_engine->DeleteCallback(callback_key); |
| 38 | } | 37 | } |
| 39 | 38 | ||
| @@ -45,7 +44,7 @@ public: | |||
| 45 | }; | 44 | }; |
| 46 | } | 45 | } |
| 47 | 46 | ||
| 48 | void ForceUpdate() { | 47 | void ForceUpdate() override { |
| 49 | const Common::Input::CallbackStatus status{ | 48 | const Common::Input::CallbackStatus status{ |
| 50 | .type = Common::Input::InputType::Button, | 49 | .type = Common::Input::InputType::Button, |
| 51 | .button_status = GetStatus(), | 50 | .button_status = GetStatus(), |
| @@ -94,7 +93,7 @@ public: | |||
| 94 | callback_key = input_engine->SetCallback(input_identifier); | 93 | callback_key = input_engine->SetCallback(input_identifier); |
| 95 | } | 94 | } |
| 96 | 95 | ||
| 97 | ~InputFromHatButton() { | 96 | ~InputFromHatButton() override { |
| 98 | input_engine->DeleteCallback(callback_key); | 97 | input_engine->DeleteCallback(callback_key); |
| 99 | } | 98 | } |
| 100 | 99 | ||
| @@ -106,7 +105,7 @@ public: | |||
| 106 | }; | 105 | }; |
| 107 | } | 106 | } |
| 108 | 107 | ||
| 109 | void ForceUpdate() { | 108 | void ForceUpdate() override { |
| 110 | const Common::Input::CallbackStatus status{ | 109 | const Common::Input::CallbackStatus status{ |
| 111 | .type = Common::Input::InputType::Button, | 110 | .type = Common::Input::InputType::Button, |
| 112 | .button_status = GetStatus(), | 111 | .button_status = GetStatus(), |
| @@ -167,7 +166,7 @@ public: | |||
| 167 | callback_key_y = input_engine->SetCallback(y_input_identifier); | 166 | callback_key_y = input_engine->SetCallback(y_input_identifier); |
| 168 | } | 167 | } |
| 169 | 168 | ||
| 170 | ~InputFromStick() { | 169 | ~InputFromStick() override { |
| 171 | input_engine->DeleteCallback(callback_key_x); | 170 | input_engine->DeleteCallback(callback_key_x); |
| 172 | input_engine->DeleteCallback(callback_key_y); | 171 | input_engine->DeleteCallback(callback_key_y); |
| 173 | } | 172 | } |
| @@ -190,7 +189,7 @@ public: | |||
| 190 | return status; | 189 | return status; |
| 191 | } | 190 | } |
| 192 | 191 | ||
| 193 | void ForceUpdate() { | 192 | void ForceUpdate() override { |
| 194 | const Common::Input::CallbackStatus status{ | 193 | const Common::Input::CallbackStatus status{ |
| 195 | .type = Common::Input::InputType::Stick, | 194 | .type = Common::Input::InputType::Stick, |
| 196 | .stick_status = GetStatus(), | 195 | .stick_status = GetStatus(), |
| @@ -266,7 +265,7 @@ public: | |||
| 266 | callback_key_y = input_engine->SetCallback(y_input_identifier); | 265 | callback_key_y = input_engine->SetCallback(y_input_identifier); |
| 267 | } | 266 | } |
| 268 | 267 | ||
| 269 | ~InputFromTouch() { | 268 | ~InputFromTouch() override { |
| 270 | input_engine->DeleteCallback(callback_key_button); | 269 | input_engine->DeleteCallback(callback_key_button); |
| 271 | input_engine->DeleteCallback(callback_key_x); | 270 | input_engine->DeleteCallback(callback_key_x); |
| 272 | input_engine->DeleteCallback(callback_key_y); | 271 | input_engine->DeleteCallback(callback_key_y); |
| @@ -352,7 +351,7 @@ public: | |||
| 352 | axis_callback_key = input_engine->SetCallback(axis_input_identifier); | 351 | axis_callback_key = input_engine->SetCallback(axis_input_identifier); |
| 353 | } | 352 | } |
| 354 | 353 | ||
| 355 | ~InputFromTrigger() { | 354 | ~InputFromTrigger() override { |
| 356 | input_engine->DeleteCallback(callback_key_button); | 355 | input_engine->DeleteCallback(callback_key_button); |
| 357 | input_engine->DeleteCallback(axis_callback_key); | 356 | input_engine->DeleteCallback(axis_callback_key); |
| 358 | } | 357 | } |
| @@ -419,7 +418,7 @@ public: | |||
| 419 | callback_key = input_engine->SetCallback(input_identifier); | 418 | callback_key = input_engine->SetCallback(input_identifier); |
| 420 | } | 419 | } |
| 421 | 420 | ||
| 422 | ~InputFromAnalog() { | 421 | ~InputFromAnalog() override { |
| 423 | input_engine->DeleteCallback(callback_key); | 422 | input_engine->DeleteCallback(callback_key); |
| 424 | } | 423 | } |
| 425 | 424 | ||
| @@ -466,7 +465,7 @@ public: | |||
| 466 | callback_key = input_engine->SetCallback(input_identifier); | 465 | callback_key = input_engine->SetCallback(input_identifier); |
| 467 | } | 466 | } |
| 468 | 467 | ||
| 469 | ~InputFromBattery() { | 468 | ~InputFromBattery() override { |
| 470 | input_engine->DeleteCallback(callback_key); | 469 | input_engine->DeleteCallback(callback_key); |
| 471 | } | 470 | } |
| 472 | 471 | ||
| @@ -474,7 +473,7 @@ public: | |||
| 474 | return static_cast<Common::Input::BatteryLevel>(input_engine->GetBattery(identifier)); | 473 | return static_cast<Common::Input::BatteryLevel>(input_engine->GetBattery(identifier)); |
| 475 | } | 474 | } |
| 476 | 475 | ||
| 477 | void ForceUpdate() { | 476 | void ForceUpdate() override { |
| 478 | const Common::Input::CallbackStatus status{ | 477 | const Common::Input::CallbackStatus status{ |
| 479 | .type = Common::Input::InputType::Battery, | 478 | .type = Common::Input::InputType::Battery, |
| 480 | .battery_status = GetStatus(), | 479 | .battery_status = GetStatus(), |
| @@ -518,7 +517,7 @@ public: | |||
| 518 | callback_key = input_engine->SetCallback(input_identifier); | 517 | callback_key = input_engine->SetCallback(input_identifier); |
| 519 | } | 518 | } |
| 520 | 519 | ||
| 521 | ~InputFromMotion() { | 520 | ~InputFromMotion() override { |
| 522 | input_engine->DeleteCallback(callback_key); | 521 | input_engine->DeleteCallback(callback_key); |
| 523 | } | 522 | } |
| 524 | 523 | ||
| @@ -593,7 +592,7 @@ public: | |||
| 593 | callback_key_z = input_engine->SetCallback(z_input_identifier); | 592 | callback_key_z = input_engine->SetCallback(z_input_identifier); |
| 594 | } | 593 | } |
| 595 | 594 | ||
| 596 | ~InputFromAxisMotion() { | 595 | ~InputFromAxisMotion() override { |
| 597 | input_engine->DeleteCallback(callback_key_x); | 596 | input_engine->DeleteCallback(callback_key_x); |
| 598 | input_engine->DeleteCallback(callback_key_y); | 597 | input_engine->DeleteCallback(callback_key_y); |
| 599 | input_engine->DeleteCallback(callback_key_z); | 598 | input_engine->DeleteCallback(callback_key_z); |
| @@ -618,7 +617,7 @@ public: | |||
| 618 | return status; | 617 | return status; |
| 619 | } | 618 | } |
| 620 | 619 | ||
| 621 | void ForceUpdate() { | 620 | void ForceUpdate() override { |
| 622 | const Common::Input::CallbackStatus status{ | 621 | const Common::Input::CallbackStatus status{ |
| 623 | .type = Common::Input::InputType::Motion, | 622 | .type = Common::Input::InputType::Motion, |
| 624 | .motion_status = GetStatus(), | 623 | .motion_status = GetStatus(), |
| @@ -668,16 +667,16 @@ public: | |||
| 668 | explicit OutputFromIdentifier(PadIdentifier identifier_, InputEngine* input_engine_) | 667 | explicit OutputFromIdentifier(PadIdentifier identifier_, InputEngine* input_engine_) |
| 669 | : identifier(identifier_), input_engine(input_engine_) {} | 668 | : identifier(identifier_), input_engine(input_engine_) {} |
| 670 | 669 | ||
| 671 | virtual void SetLED(const Common::Input::LedStatus& led_status) { | 670 | void SetLED(const Common::Input::LedStatus& led_status) override { |
| 672 | input_engine->SetLeds(identifier, led_status); | 671 | input_engine->SetLeds(identifier, led_status); |
| 673 | } | 672 | } |
| 674 | 673 | ||
| 675 | virtual Common::Input::VibrationError SetVibration( | 674 | Common::Input::VibrationError SetVibration( |
| 676 | const Common::Input::VibrationStatus& vibration_status) { | 675 | const Common::Input::VibrationStatus& vibration_status) override { |
| 677 | return input_engine->SetRumble(identifier, vibration_status); | 676 | return input_engine->SetRumble(identifier, vibration_status); |
| 678 | } | 677 | } |
| 679 | 678 | ||
| 680 | virtual Common::Input::PollingError SetPollingMode(Common::Input::PollingMode polling_mode) { | 679 | Common::Input::PollingError SetPollingMode(Common::Input::PollingMode polling_mode) override { |
| 681 | return input_engine->SetPollingMode(identifier, polling_mode); | 680 | return input_engine->SetPollingMode(identifier, polling_mode); |
| 682 | } | 681 | } |
| 683 | 682 | ||