aboutsummaryrefslogtreecommitdiff
path: root/src/GlobalHotkeysJoystick.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2025-01-23 21:49:07 +0100
committerdec05eba <dec05eba@protonmail.com>2025-01-23 21:49:07 +0100
commit5b84d7421f44c8bc00999071f2b3d46d238a9946 (patch)
treeb4cfc25421b4935dd55a5b191a83a6b04b2132ed /src/GlobalHotkeysJoystick.cpp
parent1d9d4d6398e989d0628cb4dab0273293b79b4816 (diff)
Fix controller double click not working sometimes1.1.0
Diffstat (limited to 'src/GlobalHotkeysJoystick.cpp')
-rw-r--r--src/GlobalHotkeysJoystick.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/GlobalHotkeysJoystick.cpp b/src/GlobalHotkeysJoystick.cpp
index 55c6e43..b79e799 100644
--- a/src/GlobalHotkeysJoystick.cpp
+++ b/src/GlobalHotkeysJoystick.cpp
@@ -155,15 +155,20 @@ namespace gsr {
return;
if(event.number == 8 && event.value == 1) {
- ++num_times_clicked;
- if(num_times_clicked == 1)
- double_click_clock.restart();
- else if(num_times_clicked == 2 && double_click_clock.restart() >= double_click_timeout_seconds)
- num_times_clicked = 0;
-
- if(num_times_clicked == 2) {
- save_replay = true;
- num_times_clicked = 0;
+ const double now = double_click_clock.get_elapsed_time_seconds();
+ if(!prev_time_clicked.has_value()) {
+ prev_time_clicked = now;
+ return;
+ }
+
+ if(prev_time_clicked.has_value()) {
+ const bool double_clicked = (now - prev_time_clicked.value()) < double_click_timeout_seconds;
+ if(double_clicked) {
+ save_replay = true;
+ prev_time_clicked.reset();
+ } else {
+ prev_time_clicked = now;
+ }
}
}
}