Workaround for the first touch that is taken twice into account.

This commit is contained in:
JF 2020-03-02 20:48:58 +01:00
parent 43ffeb15d1
commit d88ec8c2f0
2 changed files with 10 additions and 4 deletions

View File

@ -27,7 +27,7 @@ bool touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data) {
return lvgl->GetTouchPadInfo(data); return lvgl->GetTouchPadInfo(data);
} }
LittleVgl::LittleVgl(Pinetime::Drivers::St7789& lcd, Pinetime::Drivers::Cst816S& touchPanel) : lcd{lcd}, touchPanel{touchPanel} { LittleVgl::LittleVgl(Pinetime::Drivers::St7789& lcd, Pinetime::Drivers::Cst816S& touchPanel) : lcd{lcd}, touchPanel{touchPanel}, previousClick{0,0} {
lv_init(); lv_init();
InitTheme(); InitTheme();
InitDisplay(); InitDisplay();
@ -84,9 +84,13 @@ bool LittleVgl::GetTouchPadInfo(lv_indev_data_t *ptr) {
if((previousClick.x != info.x || previousClick.y != info.y) && if((previousClick.x != info.x || previousClick.y != info.y) &&
(info.gesture == Drivers::Cst816S::Gestures::SingleTap)) { (info.gesture == Drivers::Cst816S::Gestures::SingleTap)) {
ptr->state = LV_INDEV_STATE_PR; // TODO For an unknown reason, the first touch is taken twice into account.
previousClick.x = ptr->point.x; // 'firstTouch' is a quite'n'dirty workaound until I find a better solution
previousClick.y = ptr->point.y; if(firstTouch) ptr->state = LV_INDEV_STATE_REL;
else ptr->state = LV_INDEV_STATE_PR;
firstTouch = false;
previousClick.x = info.x;
previousClick.y = info.y;
} }
else { else {
ptr->state = LV_INDEV_STATE_REL; ptr->state = LV_INDEV_STATE_REL;

View File

@ -92,6 +92,8 @@ namespace Pinetime {
lv_style_t win_bg; lv_style_t win_bg;
lv_style_t win_header; lv_style_t win_header;
lv_style_t win_btn_pr; lv_style_t win_btn_pr;
bool firstTouch = true;
}; };
} }
} }