Skip to content

Commit

Permalink
Touchscreen: Abort ongoing short taps if touch interaction mode chang…
Browse files Browse the repository at this point in the history
…es (#14305)
  • Loading branch information
grorp committed Jan 26, 2024
1 parent df9975f commit 2b99dab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/gui/touchscreengui.cpp
Expand Up @@ -1091,6 +1091,15 @@ void TouchScreenGUI::applyContextControls(const TouchInteractionMode &mode)

u64 now = porting::getTimeMs();

// If the meanings of short and long taps have been swapped, abort any ongoing
// short taps because they would do something else than the player expected.
// Long taps don't need this, they're adjusted to the swapped meanings instead.
if (mode != m_last_mode) {
m_dig_pressed_until = 0;
m_place_pressed_until = 0;
}
m_last_mode = mode;

switch (m_tap_state) {
case TapState::ShortTap:
if (mode == SHORT_DIG_LONG_PLACE) {
Expand Down
1 change: 1 addition & 0 deletions src/gui/touchscreengui.h
Expand Up @@ -314,6 +314,7 @@ class TouchScreenGUI

v2s32 getPointerPos();
void emitMouseEvent(EMOUSE_INPUT_EVENT type);
TouchInteractionMode m_last_mode = TouchInteractionMode_END;
TapState m_tap_state = TapState::None;

bool m_dig_pressed = false;
Expand Down

0 comments on commit 2b99dab

Please sign in to comment.