diff options
| author | 2023-01-05 19:16:55 -0600 | |
|---|---|---|
| committer | 2023-01-05 19:24:29 -0600 | |
| commit | 8042ce7e1999e7953db804f852799cb33d08f91c (patch) | |
| tree | 96ab15b1de43b16cae51d873332c67e301b4afcc /src/input_common/helpers/stick_from_buttons.cpp | |
| parent | Merge pull request #9518 from gidoly/revert-9504-pg2 (diff) | |
| download | yuzu-8042ce7e1999e7953db804f852799cb33d08f91c.tar.gz yuzu-8042ce7e1999e7953db804f852799cb33d08f91c.tar.xz yuzu-8042ce7e1999e7953db804f852799cb33d08f91c.zip | |
input_common: Create an update engine
Diffstat (limited to 'src/input_common/helpers/stick_from_buttons.cpp')
| -rw-r--r-- | src/input_common/helpers/stick_from_buttons.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/input_common/helpers/stick_from_buttons.cpp b/src/input_common/helpers/stick_from_buttons.cpp index 82aa6ac2f..f3a0b3419 100644 --- a/src/input_common/helpers/stick_from_buttons.cpp +++ b/src/input_common/helpers/stick_from_buttons.cpp | |||
| @@ -13,11 +13,11 @@ class Stick final : public Common::Input::InputDevice { | |||
| 13 | public: | 13 | public: |
| 14 | using Button = std::unique_ptr<Common::Input::InputDevice>; | 14 | using Button = std::unique_ptr<Common::Input::InputDevice>; |
| 15 | 15 | ||
| 16 | Stick(Button up_, Button down_, Button left_, Button right_, Button modifier_, | 16 | Stick(Button up_, Button down_, Button left_, Button right_, Button modifier_, Button updater_, |
| 17 | float modifier_scale_, float modifier_angle_) | 17 | float modifier_scale_, float modifier_angle_) |
| 18 | : up(std::move(up_)), down(std::move(down_)), left(std::move(left_)), | 18 | : up(std::move(up_)), down(std::move(down_)), left(std::move(left_)), |
| 19 | right(std::move(right_)), modifier(std::move(modifier_)), modifier_scale(modifier_scale_), | 19 | right(std::move(right_)), modifier(std::move(modifier_)), updater(std::move(updater_)), |
| 20 | modifier_angle(modifier_angle_) { | 20 | modifier_scale(modifier_scale_), modifier_angle(modifier_angle_) { |
| 21 | up->SetCallback({ | 21 | up->SetCallback({ |
| 22 | .on_change = | 22 | .on_change = |
| 23 | [this](const Common::Input::CallbackStatus& callback_) { | 23 | [this](const Common::Input::CallbackStatus& callback_) { |
| @@ -48,6 +48,9 @@ public: | |||
| 48 | UpdateModButtonStatus(callback_); | 48 | UpdateModButtonStatus(callback_); |
| 49 | }, | 49 | }, |
| 50 | }); | 50 | }); |
| 51 | updater->SetCallback({ | ||
| 52 | .on_change = [this](const Common::Input::CallbackStatus& callback_) { SoftUpdate(); }, | ||
| 53 | }); | ||
| 51 | last_x_axis_value = 0.0f; | 54 | last_x_axis_value = 0.0f; |
| 52 | last_y_axis_value = 0.0f; | 55 | last_y_axis_value = 0.0f; |
| 53 | } | 56 | } |
| @@ -248,7 +251,7 @@ public: | |||
| 248 | modifier->ForceUpdate(); | 251 | modifier->ForceUpdate(); |
| 249 | } | 252 | } |
| 250 | 253 | ||
| 251 | void SoftUpdate() override { | 254 | void SoftUpdate() { |
| 252 | Common::Input::CallbackStatus status{ | 255 | Common::Input::CallbackStatus status{ |
| 253 | .type = Common::Input::InputType::Stick, | 256 | .type = Common::Input::InputType::Stick, |
| 254 | .stick_status = GetStatus(), | 257 | .stick_status = GetStatus(), |
| @@ -308,6 +311,7 @@ private: | |||
| 308 | Button left; | 311 | Button left; |
| 309 | Button right; | 312 | Button right; |
| 310 | Button modifier; | 313 | Button modifier; |
| 314 | Button updater; | ||
| 311 | float modifier_scale{}; | 315 | float modifier_scale{}; |
| 312 | float modifier_angle{}; | 316 | float modifier_angle{}; |
| 313 | float angle{}; | 317 | float angle{}; |
| @@ -331,11 +335,12 @@ std::unique_ptr<Common::Input::InputDevice> StickFromButton::Create( | |||
| 331 | auto left = Common::Input::CreateInputDeviceFromString(params.Get("left", null_engine)); | 335 | auto left = Common::Input::CreateInputDeviceFromString(params.Get("left", null_engine)); |
| 332 | auto right = Common::Input::CreateInputDeviceFromString(params.Get("right", null_engine)); | 336 | auto right = Common::Input::CreateInputDeviceFromString(params.Get("right", null_engine)); |
| 333 | auto modifier = Common::Input::CreateInputDeviceFromString(params.Get("modifier", null_engine)); | 337 | auto modifier = Common::Input::CreateInputDeviceFromString(params.Get("modifier", null_engine)); |
| 338 | auto updater = Common::Input::CreateInputDeviceFromString("engine:updater,button:0"); | ||
| 334 | auto modifier_scale = params.Get("modifier_scale", 0.5f); | 339 | auto modifier_scale = params.Get("modifier_scale", 0.5f); |
| 335 | auto modifier_angle = params.Get("modifier_angle", 5.5f); | 340 | auto modifier_angle = params.Get("modifier_angle", 5.5f); |
| 336 | return std::make_unique<Stick>(std::move(up), std::move(down), std::move(left), | 341 | return std::make_unique<Stick>(std::move(up), std::move(down), std::move(left), |
| 337 | std::move(right), std::move(modifier), modifier_scale, | 342 | std::move(right), std::move(modifier), std::move(updater), |
| 338 | modifier_angle); | 343 | modifier_scale, modifier_angle); |
| 339 | } | 344 | } |
| 340 | 345 | ||
| 341 | } // namespace InputCommon | 346 | } // namespace InputCommon |