aboutsummaryrefslogtreecommitdiff
path: root/recovery_ui/ui.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'recovery_ui/ui.cpp')
-rw-r--r--recovery_ui/ui.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/recovery_ui/ui.cpp b/recovery_ui/ui.cpp
index 8bc02444..9b0fd94c 100644
--- a/recovery_ui/ui.cpp
+++ b/recovery_ui/ui.cpp
@@ -197,8 +197,23 @@ bool RecoveryUI::Init(const std::string& /* locale */) {
return true;
}
+enum SwipeDirection { UP, DOWN, RIGHT, LEFT };
+
+static SwipeDirection FlipSwipeDirection(SwipeDirection direction) {
+ switch (direction) {
+ case UP:
+ return SwipeDirection::DOWN;
+ case DOWN:
+ return SwipeDirection::UP;
+ case RIGHT:
+ return SwipeDirection::LEFT;
+ case LEFT:
+ return SwipeDirection::RIGHT;
+ }
+}
+
void RecoveryUI::OnTouchDetected(int dx, int dy) {
- enum SwipeDirection { UP, DOWN, RIGHT, LEFT } direction;
+ SwipeDirection direction;
// We only consider a valid swipe if:
// - the delta along one axis is below touch_low_threshold_;
@@ -219,6 +234,11 @@ void RecoveryUI::OnTouchDetected(int dx, int dy) {
return;
}
+ // Flip swipe direction if screen is rotated upside down
+ if (gr_get_rotation() == GRRotation::DOWN) {
+ direction = FlipSwipeDirection(direction);
+ }
+
LOG(DEBUG) << "Swipe direction=" << direction;
switch (direction) {
case SwipeDirection::UP: