Use touch events from LVGL
This commit is contained in:
committed by
Raphael Coeffic
parent
8f68af094c
commit
731ac128dc
@@ -62,38 +62,54 @@ extern "C" void keyboardDriverRead(lv_indev_drv_t *drv, lv_indev_data_t *data)
|
|||||||
MainWindow::instance()->checkEvents();
|
MainWindow::instance()->checkEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void copy_ts_to_indev_data(const TouchState &st, lv_indev_data_t *data)
|
||||||
|
{
|
||||||
|
#if defined(LCD_VERTICAL_INVERT)
|
||||||
|
data->point.x = LCD_W - st.x;
|
||||||
|
data->point.y = LCD_H - st.y;
|
||||||
|
#else
|
||||||
|
data->point.x = st.x;
|
||||||
|
data->point.y = st.y;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static lv_indev_data_t indev_data_backup;
|
||||||
|
|
||||||
|
static void backup_indev_data(lv_indev_data_t* data)
|
||||||
|
{
|
||||||
|
memcpy(&indev_data_backup, data, sizeof(lv_indev_data_t));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void copy_indev_data_backup(lv_indev_data_t* data)
|
||||||
|
{
|
||||||
|
memcpy(data, &indev_data_backup, sizeof(lv_indev_data_t));
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" void touchDriverRead(lv_indev_drv_t *drv, lv_indev_data_t *data)
|
extern "C" void touchDriverRead(lv_indev_drv_t *drv, lv_indev_data_t *data)
|
||||||
{
|
{
|
||||||
#if defined(HARDWARE_TOUCH)
|
#if defined(HARDWARE_TOUCH)
|
||||||
if(!touchPanelEventOccured())
|
if(!touchPanelEventOccured()) {
|
||||||
|
copy_indev_data_backup(data);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
touchOccured = true;
|
touchOccured = true;
|
||||||
|
|
||||||
TouchState st = touchPanelRead();
|
TouchState st = touchPanelRead();
|
||||||
lastState = st; // hack for now
|
lastState = st; // hack for now
|
||||||
|
|
||||||
if(st.event == TE_NONE)
|
if(st.event == TE_NONE) {
|
||||||
return;
|
TRACE("TE_NONE");
|
||||||
if(st.event == TE_DOWN || st.event == TE_SLIDE)
|
} else if(st.event == TE_DOWN || st.event == TE_SLIDE) {
|
||||||
{
|
TRACE("INDEV_STATE_PRESSED");
|
||||||
#if defined (LCD_VERTICAL_INVERT)
|
|
||||||
data->point.x = LCD_W - st.x;
|
|
||||||
data->point.y = LCD_H - st.y;
|
|
||||||
#else
|
|
||||||
data->point.x = st.x;
|
|
||||||
data->point.y = st.y;
|
|
||||||
#endif
|
|
||||||
data->state = LV_INDEV_STATE_PRESSED;
|
data->state = LV_INDEV_STATE_PRESSED;
|
||||||
|
copy_ts_to_indev_data(st, data);
|
||||||
} else {
|
} else {
|
||||||
#if defined (LCD_VERTICAL_INVERT)
|
TRACE("INDEV_STATE_RELEASED");
|
||||||
data->point.x = LCD_W - st.x;
|
|
||||||
data->point.y = LCD_H - st.y;
|
|
||||||
#else
|
|
||||||
data->point.x = st.x;
|
|
||||||
data->point.y = st.y;
|
|
||||||
#endif
|
|
||||||
data->state = LV_INDEV_STATE_RELEASED;
|
data->state = LV_INDEV_STATE_RELEASED;
|
||||||
|
copy_ts_to_indev_data(st, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
backup_indev_data(data);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Vendored
+1
-1
Submodule radio/src/thirdparty/libopenui updated: 36dfc84476...44ec2db4a1
Reference in New Issue
Block a user