summaryrefslogtreecommitdiff
path: root/src/input_common
diff options
context:
space:
mode:
Diffstat (limited to 'src/input_common')
-rw-r--r--src/input_common/drivers/sdl_driver.cpp5
-rw-r--r--src/input_common/helpers/stick_from_buttons.cpp30
-rw-r--r--src/input_common/helpers/touch_from_buttons.cpp1
3 files changed, 28 insertions, 8 deletions
diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp
index 577bf5c31..b031a8523 100644
--- a/src/input_common/drivers/sdl_driver.cpp
+++ b/src/input_common/drivers/sdl_driver.cpp
@@ -181,11 +181,10 @@ public:
181 case SDL_JOYSTICK_POWER_EMPTY: 181 case SDL_JOYSTICK_POWER_EMPTY:
182 return BatteryLevel::Empty; 182 return BatteryLevel::Empty;
183 case SDL_JOYSTICK_POWER_LOW: 183 case SDL_JOYSTICK_POWER_LOW:
184 return BatteryLevel::Critical;
185 case SDL_JOYSTICK_POWER_MEDIUM:
186 return BatteryLevel::Low; 184 return BatteryLevel::Low;
187 case SDL_JOYSTICK_POWER_FULL: 185 case SDL_JOYSTICK_POWER_MEDIUM:
188 return BatteryLevel::Medium; 186 return BatteryLevel::Medium;
187 case SDL_JOYSTICK_POWER_FULL:
189 case SDL_JOYSTICK_POWER_MAX: 188 case SDL_JOYSTICK_POWER_MAX:
190 return BatteryLevel::Full; 189 return BatteryLevel::Full;
191 case SDL_JOYSTICK_POWER_UNKNOWN: 190 case SDL_JOYSTICK_POWER_UNKNOWN:
diff --git a/src/input_common/helpers/stick_from_buttons.cpp b/src/input_common/helpers/stick_from_buttons.cpp
index e23394f5f..31e6f62ab 100644
--- a/src/input_common/helpers/stick_from_buttons.cpp
+++ b/src/input_common/helpers/stick_from_buttons.cpp
@@ -167,12 +167,34 @@ public:
167 } 167 }
168 168
169 void UpdateModButtonStatus(const Common::Input::CallbackStatus& button_callback) { 169 void UpdateModButtonStatus(const Common::Input::CallbackStatus& button_callback) {
170 modifier_status = button_callback.button_status.value; 170 const auto& new_status = button_callback.button_status;
171 const bool new_button_value = new_status.inverted ? !new_status.value : new_status.value;
172 modifier_status.toggle = new_status.toggle;
173
174 // Update button status with current
175 if (!modifier_status.toggle) {
176 modifier_status.locked = false;
177 if (modifier_status.value != new_button_value) {
178 modifier_status.value = new_button_value;
179 }
180 } else {
181 // Toggle button and lock status
182 if (new_button_value && !modifier_status.locked) {
183 modifier_status.locked = true;
184 modifier_status.value = !modifier_status.value;
185 }
186
187 // Unlock button ready for next press
188 if (!new_button_value && modifier_status.locked) {
189 modifier_status.locked = false;
190 }
191 }
192
171 UpdateStatus(); 193 UpdateStatus();
172 } 194 }
173 195
174 void UpdateStatus() { 196 void UpdateStatus() {
175 const float coef = modifier_status ? modifier_scale : 1.0f; 197 const float coef = modifier_status.value ? modifier_scale : 1.0f;
176 198
177 bool r = right_status; 199 bool r = right_status;
178 bool l = left_status; 200 bool l = left_status;
@@ -266,7 +288,7 @@ public:
266 if (down_status) { 288 if (down_status) {
267 --y; 289 --y;
268 } 290 }
269 const float coef = modifier_status ? modifier_scale : 1.0f; 291 const float coef = modifier_status.value ? modifier_scale : 1.0f;
270 status.x.raw_value = static_cast<float>(x) * coef * (y == 0 ? 1.0f : SQRT_HALF); 292 status.x.raw_value = static_cast<float>(x) * coef * (y == 0 ? 1.0f : SQRT_HALF);
271 status.y.raw_value = static_cast<float>(y) * coef * (x == 0 ? 1.0f : SQRT_HALF); 293 status.y.raw_value = static_cast<float>(y) * coef * (x == 0 ? 1.0f : SQRT_HALF);
272 return status; 294 return status;
@@ -287,9 +309,9 @@ private:
287 bool down_status{}; 309 bool down_status{};
288 bool left_status{}; 310 bool left_status{};
289 bool right_status{}; 311 bool right_status{};
290 bool modifier_status{};
291 float last_x_axis_value{}; 312 float last_x_axis_value{};
292 float last_y_axis_value{}; 313 float last_y_axis_value{};
314 Common::Input::ButtonStatus modifier_status{};
293 const Common::Input::AnalogProperties properties{0.0f, 1.0f, 0.5f, 0.0f, false}; 315 const Common::Input::AnalogProperties properties{0.0f, 1.0f, 0.5f, 0.0f, false};
294 std::chrono::time_point<std::chrono::steady_clock> last_update; 316 std::chrono::time_point<std::chrono::steady_clock> last_update;
295}; 317};
diff --git a/src/input_common/helpers/touch_from_buttons.cpp b/src/input_common/helpers/touch_from_buttons.cpp
index ece1e3b32..f1b57d03a 100644
--- a/src/input_common/helpers/touch_from_buttons.cpp
+++ b/src/input_common/helpers/touch_from_buttons.cpp
@@ -4,7 +4,6 @@
4 4
5#include <algorithm> 5#include <algorithm>
6#include "common/settings.h" 6#include "common/settings.h"
7#include "core/frontend/framebuffer_layout.h"
8#include "input_common/helpers/touch_from_buttons.h" 7#include "input_common/helpers/touch_from_buttons.h"
9 8
10namespace InputCommon { 9namespace InputCommon {