summaryrefslogtreecommitdiff
path: root/src/input_common/helpers/stick_from_buttons.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/input_common/helpers/stick_from_buttons.cpp')
-rw-r--r--src/input_common/helpers/stick_from_buttons.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/input_common/helpers/stick_from_buttons.cpp b/src/input_common/helpers/stick_from_buttons.cpp
index 1d5948f79..77fcd655e 100644
--- a/src/input_common/helpers/stick_from_buttons.cpp
+++ b/src/input_common/helpers/stick_from_buttons.cpp
@@ -36,6 +36,8 @@ public:
36 left->SetCallback(button_left_callback); 36 left->SetCallback(button_left_callback);
37 right->SetCallback(button_right_callback); 37 right->SetCallback(button_right_callback);
38 modifier->SetCallback(button_modifier_callback); 38 modifier->SetCallback(button_modifier_callback);
39 last_x_axis_value = 0.0f;
40 last_y_axis_value = 0.0f;
39 } 41 }
40 42
41 bool IsAngleGreater(float old_angle, float new_angle) const { 43 bool IsAngleGreater(float old_angle, float new_angle) const {
@@ -199,6 +201,8 @@ public:
199 .type = Common::Input::InputType::Stick, 201 .type = Common::Input::InputType::Stick,
200 .stick_status = GetStatus(), 202 .stick_status = GetStatus(),
201 }; 203 };
204 last_x_axis_value = status.stick_status.x.raw_value;
205 last_y_axis_value = status.stick_status.y.raw_value;
202 TriggerOnChange(status); 206 TriggerOnChange(status);
203 } 207 }
204 208
@@ -215,6 +219,12 @@ public:
215 .type = Common::Input::InputType::Stick, 219 .type = Common::Input::InputType::Stick,
216 .stick_status = GetStatus(), 220 .stick_status = GetStatus(),
217 }; 221 };
222 if (last_x_axis_value == status.stick_status.x.raw_value &&
223 last_y_axis_value == status.stick_status.y.raw_value) {
224 return;
225 }
226 last_x_axis_value = status.stick_status.x.raw_value;
227 last_y_axis_value = status.stick_status.y.raw_value;
218 TriggerOnChange(status); 228 TriggerOnChange(status);
219 } 229 }
220 230
@@ -265,6 +275,8 @@ private:
265 bool left_status; 275 bool left_status;
266 bool right_status; 276 bool right_status;
267 bool modifier_status; 277 bool modifier_status;
278 float last_x_axis_value;
279 float last_y_axis_value;
268 const Common::Input::AnalogProperties properties{0.0f, 1.0f, 0.5f, 0.0f, false}; 280 const Common::Input::AnalogProperties properties{0.0f, 1.0f, 0.5f, 0.0f, false};
269 std::chrono::time_point<std::chrono::steady_clock> last_update; 281 std::chrono::time_point<std::chrono::steady_clock> last_update;
270}; 282};