@@ -30,37 +30,39 @@ void TouchHandler::Process(void* instance) {
3030}
3131
3232void TouchHandler::Work () {
33- Pinetime::Drivers::Cst816S::Gestures prevGesture = Pinetime::Drivers::Cst816S::Gestures::None ;
33+ bool slideReleased = true ;
3434 while (true ) {
3535 vTaskSuspend (taskHandle);
3636
3737 info = touchPanel.GetTouchInfo ();
3838
39- if (info.gesture != Pinetime::Drivers::Cst816S::Gestures::None) {
40- if (prevGesture != info.gesture ) {
41- if (info.gesture == Pinetime::Drivers::Cst816S::Gestures::SlideDown || info.gesture == Pinetime::Drivers::Cst816S::Gestures::SlideLeft ||
42- info.gesture == Pinetime::Drivers::Cst816S::Gestures::SlideUp || info.gesture == Pinetime::Drivers::Cst816S::Gestures::SlideRight) {
43- prevGesture = info.gesture ;
39+ if (info.isValid ) {
40+ if (info.gesture != Pinetime::Drivers::Cst816S::Gestures::None) {
41+ if (slideReleased) {
42+ if (info.gesture == Pinetime::Drivers::Cst816S::Gestures::SlideDown ||
43+ info.gesture == Pinetime::Drivers::Cst816S::Gestures::SlideLeft ||
44+ info.gesture == Pinetime::Drivers::Cst816S::Gestures::SlideUp ||
45+ info.gesture == Pinetime::Drivers::Cst816S::Gestures::SlideRight) {
46+ slideReleased = false ;
47+ }
48+ gesture = info.gesture ;
4449 }
45- gesture = info.gesture ;
4650 }
47- }
4851
49- if (systemTask->IsSleeping ()) {
50- systemTask->PushMessage (System::Messages::TouchWakeUp);
51- } else {
52- if (info.touching ) {
53- if (!isCancelled) {
54- lvgl.SetNewTouchPoint (info.x , info.y , true );
55- }
56- } else {
57- if (isCancelled) {
58- lvgl.SetNewTouchPoint (-1 , -1 , false );
59- isCancelled = false ;
52+ if (!systemTask->IsSleeping ()) {
53+ if (info.touching ) {
54+ if (!isCancelled) {
55+ lvgl.SetNewTouchPoint (info.x , info.y , true );
56+ }
6057 } else {
61- lvgl.SetNewTouchPoint (info.x , info.y , false );
58+ if (isCancelled) {
59+ lvgl.SetNewTouchPoint (-1 , -1 , false );
60+ isCancelled = false ;
61+ } else {
62+ lvgl.SetNewTouchPoint (info.x , info.y , false );
63+ }
64+ slideReleased = true ;
6265 }
63- prevGesture = Pinetime::Drivers::Cst816S::Gestures::None;
6466 }
6567 systemTask->OnTouchEvent ();
6668 }
0 commit comments