Skip to content

Commit

Permalink
Handle touch when release touch + prevent touch when swiping #bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
spaceAngel committed Sep 7, 2022
1 parent b1e2c42 commit 7cccc27
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/UserInterface/UserInterfaceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,26 @@ bool UserInterfaceManager::handleTouch() {
!TTGOClass::getWatch()->getTouch(x, y)
|| ((x == 257) && (y == 2)) //some kind of HW error in my LILLYGO T-Watch (short circuit?)
) {
if (
this->touchFromInactivity == false
&& this->touchReleased == false
&& this->swipeWasHandled == false
) {
MainScreen::getInstance()->handleTouch(this->lastTouchX, this->lastTouchY);
}
this->touchReleased = true;
this->swipeWasHandled = false;
this->touchFromInactivity = InactivityWatcher::getInstance()->isInactive();

}

if (
TTGOClass::getWatch()->getTouch(x, y)
&& ((x != 257) && (y != 2)) //some kind of HW error in my LILLYGO T-Watch (short circuit?)
) {
this->lastTouchX = x;
this->lastTouchY = y;
if (this->touchReleased == true) {
if (this->touchFromInactivity == false) {
MainScreen::getInstance()->handleTouch(x, y);
}
this->touchFromInactivity = InactivityWatcher::getInstance()->isInactive();
this->touchReleased = false;
}
Expand Down Expand Up @@ -102,6 +110,7 @@ void UserInterfaceManager::handleSwipeHorizontal(uint x) {
MainScreen::getInstance()->handleSwipeHorizontal(
(this->swipeVectorHorizontal == VECTOR_LEFT) ? -1 : 1
);
this->swipeWasHandled = true;
}
}

Expand Down Expand Up @@ -144,6 +153,7 @@ void UserInterfaceManager::handleSwipeVertical(uint y) {
MainScreen::getInstance()->handleSwipeVertical(
(this->swipeVectorVertical == VECTOR_UP) ? -1 : 1
);
this->swipeWasHandled = true;
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/UserInterface/UserInterfaceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ class UserInterfaceManager {
bool touchReleased = true;
bool touchFromInactivity = false;;

int16_t lastTouchX;
int16_t lastTouchY;
bool swipeWasHandled = false;

UserInterfaceManager() {
}

Expand Down

0 comments on commit 7cccc27

Please sign in to comment.