Print evdev input device resolution, enable cursor on fbdev

This commit is contained in:
Kuba Szczodrzyński 2024-02-08 22:01:53 +01:00
parent 9693ef361a
commit ed6b17cfd7
No known key found for this signature in database
GPG Key ID: 43037AC62A600562
2 changed files with 36 additions and 14 deletions

View File

@ -86,6 +86,9 @@ void TftFbdevDrv::init(int32_t w, int h)
fbdev_init();
fbdev_get_sizes((uint32_t*)&_width, (uint32_t*)&_height);
// show the splashscreen early
splashscreen();
tft_width = _width;
tft_height = _height;
@ -131,12 +134,16 @@ void TftFbdevDrv::init(int32_t w, int h)
}
// check which types are supported; judge LVGL device type
lv_indev_type_t dev_type;
if(ev_type[EV_ABS / 8] & (1 << (EV_ABS % 8))) {
dev_type = LV_INDEV_TYPE_POINTER;
} else if(ev_type[EV_REL / 8] & (1 << (EV_REL % 8))) {
dev_type = LV_INDEV_TYPE_POINTER;
const char* dev_type_name;
if(ev_type[EV_REL / 8] & (1 << (EV_REL % 8))) {
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))) {
dev_type = LV_INDEV_TYPE_KEYPAD;
dev_type = LV_INDEV_TYPE_KEYPAD;
dev_type_name = "EV_KEY";
} else {
close(fd);
continue;
@ -144,17 +151,26 @@ void TftFbdevDrv::init(int32_t w, int h)
// register the device
switch(dev_type) {
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;
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;
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;
}
evdev_register(dev_path, dev_type, NULL);
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);
}

View File

@ -294,7 +294,6 @@ void guiSetup()
// register a touchscreen/mouse driver - only on real hardware and SDL2
// Win32 and POSIX handles input drivers in tft_driver
#if TOUCH_DRIVER != -1 || USE_MONITOR
/* Initialize the touch pad */
static lv_indev_drv_t indev_drv;
lv_indev_drv_init(&indev_drv);
@ -306,6 +305,13 @@ void guiSetup()
#endif
lv_indev_t* mouse_indev = lv_indev_drv_register(&indev_drv);
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*/
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 */
lv_img_set_src(cursor, &mouse_cursor_icon); /*Set the image source*/
#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_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_opa(cursor, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_COVER);
#endif
gui_hide_pointer(false);
lv_indev_set_cursor(mouse_indev, cursor); /*Connect the image object to the driver*/
#endif // TOUCH_DRIVER != -1 || USE_MONITOR
if(mouse_indev != NULL) {
lv_indev_set_cursor(mouse_indev, cursor); /*Connect the image object to the driver*/
}
#if HASP_TARGET_ARDUINO
// drv_touch_init(gui_settings.rotation); // Touch driver