Fix double-click page turn

This commit is contained in:
jpirnay
2026-04-27 14:02:38 +02:00
parent adc0a52af1
commit d4c0073b00
+15 -6
View File
@@ -6,6 +6,7 @@
#include <cstdint> #include <cstdint>
#include "ButtonEventManager.h"
#include "MappedInputManager.h" #include "MappedInputManager.h"
namespace ReaderUtils { namespace ReaderUtils {
@@ -90,13 +91,21 @@ inline PageTurnResult detectPageTurn(const MappedInputManager& input) {
// Only treat wasReleased as a page turn when the button's short-press action is default. // Only treat wasReleased as a page turn when the button's short-press action is default.
// Non-default short-press actions are dispatched by the global dispatcher in main.cpp; // Non-default short-press actions are dispatched by the global dispatcher in main.cpp;
// counting wasReleased as well would double-fire the action. // counting wasReleased as well would double-fire the action.
// Also suppress immediate page-turns if a double-click action is configured for the button,
// because the button event system delays short events until the double-click window expires.
using BA = CrossPointSettings::BUTTON_ACTION; using BA = CrossPointSettings::BUTTON_ACTION;
const bool prev = const bool prev = (SETTINGS.btnShortPageBack == BA::BTN_DEFAULT &&
(SETTINGS.btnShortPageBack == BA::BTN_DEFAULT && input.wasReleased(MappedInputManager::Button::PageBack)) || !ButtonEventManager::hasDoubleAction(MappedInputManager::Button::PageBack) &&
(SETTINGS.btnShortLeft == BA::BTN_DEFAULT && input.wasReleased(MappedInputManager::Button::Left)); input.wasReleased(MappedInputManager::Button::PageBack)) ||
const bool next = (SETTINGS.btnShortLeft == BA::BTN_DEFAULT &&
(SETTINGS.btnShortPageForward == BA::BTN_DEFAULT && input.wasReleased(MappedInputManager::Button::PageForward)) || !ButtonEventManager::hasDoubleAction(MappedInputManager::Button::Left) &&
(SETTINGS.btnShortRight == BA::BTN_DEFAULT && input.wasReleased(MappedInputManager::Button::Right)); input.wasReleased(MappedInputManager::Button::Left));
const bool next = (SETTINGS.btnShortPageForward == BA::BTN_DEFAULT &&
!ButtonEventManager::hasDoubleAction(MappedInputManager::Button::PageForward) &&
input.wasReleased(MappedInputManager::Button::PageForward)) ||
(SETTINGS.btnShortRight == BA::BTN_DEFAULT &&
!ButtonEventManager::hasDoubleAction(MappedInputManager::Button::Right) &&
input.wasReleased(MappedInputManager::Button::Right));
return {prev, next}; return {prev, next};
} }