Fix double-click page turn
This commit is contained in:
@@ -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};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user