InfiniTime.git

commit 00769625881e318e6fe29e926c7bd944c5f049bd

Author: mark9064 <30447455+mark9064@users.noreply.github.com>

Unify touch panel handling

 src/systemtask/Messages.h | 1 
 src/systemtask/SystemTask.cpp | 40 +++++++++++++++---------------------


diff --git a/src/systemtask/Messages.h b/src/systemtask/Messages.h
index 39fb4114a03ea020ca99c4424958507560919dab..fee94bb7478576dfb229cd292064509797e96d99 100644
--- a/src/systemtask/Messages.h
+++ b/src/systemtask/Messages.h
@@ -6,7 +6,6 @@   namespace System {
     enum class Messages : uint8_t {
       GoToSleep,
       GoToRunning,
-      TouchWakeUp,
       OnNewTime,
       OnNewNotification,
       OnNewCall,




diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp
index 1bfae4c6046390a75c6d601d45adcdb05abbe86d..ed0fd7446c01fdda53228375c9e3f52b20cb1ea9 100644
--- a/src/systemtask/SystemTask.cpp
+++ b/src/systemtask/SystemTask.cpp
@@ -198,20 +198,6 @@           break;
         case Messages::GoToRunning:
           GoToRunning();
           break;
-        case Messages::TouchWakeUp: {
-          if (touchHandler.ProcessTouchInfo(touchPanel.GetTouchInfo())) {
-            auto gesture = touchHandler.GestureGet();
-            if (settingsController.GetNotificationStatus() != Controllers::Settings::Notification::Sleep &&
-                gesture != Pinetime::Applications::TouchEvents::None &&
-                ((gesture == Pinetime::Applications::TouchEvents::DoubleTap &&
-                  settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) ||
-                 (gesture == Pinetime::Applications::TouchEvents::Tap &&
-                  settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::SingleTap)))) {
-              GoToRunning();
-            }
-          }
-          break;
-        }
         case Messages::GoToSleep:
           GoToSleep();
           break;
@@ -260,8 +246,23 @@           wakeLocksHeld--;
           // TODO add intent of fs access icon or something
           break;
         case Messages::OnTouchEvent:
-          if (touchHandler.ProcessTouchInfo(touchPanel.GetTouchInfo())) {
+          // Finish immediately if no new events
+          if (!touchHandler.ProcessTouchInfo(touchPanel.GetTouchInfo())) {
+            break;
+          }
+          if (state == SystemTaskState::Running) {
             displayApp.PushMessage(Pinetime::Applications::Display::Messages::TouchEvent);
+          } else {
+            // If asleep, check for touch panel wake triggers
+            auto gesture = touchHandler.GestureGet();
+            if (settingsController.GetNotificationStatus() != Controllers::Settings::Notification::Sleep &&
+                gesture != Pinetime::Applications::TouchEvents::None &&
+                ((gesture == Pinetime::Applications::TouchEvents::DoubleTap &&
+                  settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) ||
+                 (gesture == Pinetime::Applications::TouchEvents::Tap &&
+                  settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::SingleTap)))) {
+              GoToRunning();
+            }
           }
           break;
         case Messages::HandleButtonEvent: {
@@ -493,14 +494,7 @@   fastWakeUpDone = false;
 }
 
 void SystemTask::OnTouchEvent() {
-  if (state == SystemTaskState::Running) {
-    PushMessage(Messages::OnTouchEvent);
-  } else {
-    if (settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::SingleTap) or
-        settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) {
-      PushMessage(Messages::TouchWakeUp);
-    }
-  }
+  PushMessage(Messages::OnTouchEvent);
 }
 
 void SystemTask::PushMessage(System::Messages msg) {