mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-25 20:26:41 +00:00
Print evdev input device resolution, enable cursor on fbdev
This commit is contained in:
parent
9693ef361a
commit
ed6b17cfd7
@ -86,6 +86,9 @@ void TftFbdevDrv::init(int32_t w, int h)
|
|||||||
fbdev_init();
|
fbdev_init();
|
||||||
fbdev_get_sizes((uint32_t*)&_width, (uint32_t*)&_height);
|
fbdev_get_sizes((uint32_t*)&_width, (uint32_t*)&_height);
|
||||||
|
|
||||||
|
// show the splashscreen early
|
||||||
|
splashscreen();
|
||||||
|
|
||||||
tft_width = _width;
|
tft_width = _width;
|
||||||
tft_height = _height;
|
tft_height = _height;
|
||||||
|
|
||||||
@ -131,12 +134,16 @@ void TftFbdevDrv::init(int32_t w, int h)
|
|||||||
}
|
}
|
||||||
// check which types are supported; judge LVGL device type
|
// check which types are supported; judge LVGL device type
|
||||||
lv_indev_type_t dev_type;
|
lv_indev_type_t dev_type;
|
||||||
if(ev_type[EV_ABS / 8] & (1 << (EV_ABS % 8))) {
|
const char* dev_type_name;
|
||||||
dev_type = LV_INDEV_TYPE_POINTER;
|
if(ev_type[EV_REL / 8] & (1 << (EV_REL % 8))) {
|
||||||
} else if(ev_type[EV_REL / 8] & (1 << (EV_REL % 8))) {
|
dev_type = LV_INDEV_TYPE_POINTER;
|
||||||
dev_type = LV_INDEV_TYPE_POINTER;
|
dev_type_name = "EV_REL";
|
||||||
|
} else if(ev_type[EV_ABS / 8] & (1 << (EV_ABS % 8))) {
|
||||||
|
dev_type = LV_INDEV_TYPE_POINTER;
|
||||||
|
dev_type_name = "EV_ABS";
|
||||||
} else if(ev_type[EV_KEY / 8] & (1 << (EV_KEY % 8))) {
|
} else if(ev_type[EV_KEY / 8] & (1 << (EV_KEY % 8))) {
|
||||||
dev_type = LV_INDEV_TYPE_KEYPAD;
|
dev_type = LV_INDEV_TYPE_KEYPAD;
|
||||||
|
dev_type_name = "EV_KEY";
|
||||||
} else {
|
} else {
|
||||||
close(fd);
|
close(fd);
|
||||||
continue;
|
continue;
|
||||||
@ -144,17 +151,26 @@ void TftFbdevDrv::init(int32_t w, int h)
|
|||||||
// register the device
|
// register the device
|
||||||
switch(dev_type) {
|
switch(dev_type) {
|
||||||
case LV_INDEV_TYPE_POINTER:
|
case LV_INDEV_TYPE_POINTER:
|
||||||
LOG_VERBOSE(TAG_TFT, F("Pointer : %s (%s)"), dev_path, dev_name);
|
LOG_VERBOSE(TAG_TFT, F("Pointer : %s %s (%s)"), dev_path, dev_type_name, dev_name);
|
||||||
break;
|
break;
|
||||||
case LV_INDEV_TYPE_KEYPAD:
|
case LV_INDEV_TYPE_KEYPAD:
|
||||||
LOG_VERBOSE(TAG_TFT, F("Keypad : %s (%s)"), dev_path, dev_name);
|
LOG_VERBOSE(TAG_TFT, F("Keypad : %s %s (%s)"), dev_path, dev_type_name, dev_name);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LOG_VERBOSE(TAG_TFT, F("Input : %s (%s)"), dev_path, dev_name);
|
LOG_VERBOSE(TAG_TFT, F("Input : %s %s (%s)"), dev_path, dev_type_name, dev_name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
evdev_register(dev_path, dev_type, NULL);
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
// print verbose resolution info
|
||||||
|
lv_indev_t* indev;
|
||||||
|
if(!evdev_register(dev_path, dev_type, &indev) || indev == NULL) {
|
||||||
|
printf("Failed to register evdev\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
evdev_data_t* user_data = (evdev_data_t*)indev->driver.user_data;
|
||||||
|
LOG_VERBOSE(TAG_TFT, F("Resolution : X=%d (%d..%d), Y=%d (%d..%d)"), user_data->x_max,
|
||||||
|
user_data->x_absinfo.minimum, user_data->x_absinfo.maximum, user_data->y_max,
|
||||||
|
user_data->y_absinfo.minimum, user_data->y_absinfo.maximum);
|
||||||
}
|
}
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
}
|
}
|
||||||
|
@ -294,7 +294,6 @@ void guiSetup()
|
|||||||
// register a touchscreen/mouse driver - only on real hardware and SDL2
|
// register a touchscreen/mouse driver - only on real hardware and SDL2
|
||||||
// Win32 and POSIX handles input drivers in tft_driver
|
// Win32 and POSIX handles input drivers in tft_driver
|
||||||
#if TOUCH_DRIVER != -1 || USE_MONITOR
|
#if TOUCH_DRIVER != -1 || USE_MONITOR
|
||||||
|
|
||||||
/* Initialize the touch pad */
|
/* Initialize the touch pad */
|
||||||
static lv_indev_drv_t indev_drv;
|
static lv_indev_drv_t indev_drv;
|
||||||
lv_indev_drv_init(&indev_drv);
|
lv_indev_drv_init(&indev_drv);
|
||||||
@ -306,6 +305,13 @@ void guiSetup()
|
|||||||
#endif
|
#endif
|
||||||
lv_indev_t* mouse_indev = lv_indev_drv_register(&indev_drv);
|
lv_indev_t* mouse_indev = lv_indev_drv_register(&indev_drv);
|
||||||
mouse_indev->driver.type = LV_INDEV_TYPE_POINTER;
|
mouse_indev->driver.type = LV_INDEV_TYPE_POINTER;
|
||||||
|
#else
|
||||||
|
// find the first registered input device to add a cursor to
|
||||||
|
lv_indev_t* mouse_indev = NULL;
|
||||||
|
while((mouse_indev = lv_indev_get_next(mouse_indev))) {
|
||||||
|
if(mouse_indev->driver.type == LV_INDEV_TYPE_POINTER) break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*Set a cursor for the mouse*/
|
/*Set a cursor for the mouse*/
|
||||||
LOG_TRACE(TAG_GUI, F("Initialize Cursor"));
|
LOG_TRACE(TAG_GUI, F("Initialize Cursor"));
|
||||||
@ -326,16 +332,16 @@ void guiSetup()
|
|||||||
cursor = lv_img_create(mouse_layer, NULL); /*Create an image object for the cursor */
|
cursor = lv_img_create(mouse_layer, NULL); /*Create an image object for the cursor */
|
||||||
lv_img_set_src(cursor, &mouse_cursor_icon); /*Set the image source*/
|
lv_img_set_src(cursor, &mouse_cursor_icon); /*Set the image source*/
|
||||||
#else
|
#else
|
||||||
cursor = lv_obj_create(mouse_layer, NULL); // show cursor object on every page
|
cursor = lv_obj_create(mouse_layer, NULL); // show cursor object on every page
|
||||||
lv_obj_set_size(cursor, 9, 9);
|
lv_obj_set_size(cursor, 9, 9);
|
||||||
lv_obj_set_style_local_radius(cursor, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
|
lv_obj_set_style_local_radius(cursor, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
|
||||||
lv_obj_set_style_local_bg_color(cursor, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_RED);
|
lv_obj_set_style_local_bg_color(cursor, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_RED);
|
||||||
lv_obj_set_style_local_bg_opa(cursor, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_COVER);
|
lv_obj_set_style_local_bg_opa(cursor, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_COVER);
|
||||||
#endif
|
#endif
|
||||||
gui_hide_pointer(false);
|
gui_hide_pointer(false);
|
||||||
lv_indev_set_cursor(mouse_indev, cursor); /*Connect the image object to the driver*/
|
if(mouse_indev != NULL) {
|
||||||
|
lv_indev_set_cursor(mouse_indev, cursor); /*Connect the image object to the driver*/
|
||||||
#endif // TOUCH_DRIVER != -1 || USE_MONITOR
|
}
|
||||||
|
|
||||||
#if HASP_TARGET_ARDUINO
|
#if HASP_TARGET_ARDUINO
|
||||||
// drv_touch_init(gui_settings.rotation); // Touch driver
|
// drv_touch_init(gui_settings.rotation); // Touch driver
|
||||||
|
Loading…
x
Reference in New Issue
Block a user