Skip to content

Commit

Permalink
Unify touch panel handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mark9064 authored and JF002 committed Oct 27, 2024
1 parent e6ee548 commit 0076962
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 24 deletions.
1 change: 0 additions & 1 deletion src/systemtask/Messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ namespace Pinetime {
enum class Messages : uint8_t {
GoToSleep,
GoToRunning,
TouchWakeUp,
OnNewTime,
OnNewNotification,
OnNewCall,
Expand Down
40 changes: 17 additions & 23 deletions src/systemtask/SystemTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,20 +198,6 @@ void SystemTask::Work() {
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;
Expand Down Expand Up @@ -260,8 +246,23 @@ void SystemTask::Work() {
// 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: {
Expand Down Expand Up @@ -493,14 +494,7 @@ void SystemTask::HandleButtonAction(Controllers::ButtonActions action) {
}

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) {
Expand Down

0 comments on commit 0076962

Please sign in to comment.