mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-08-18 16:05:05 +00:00
55 lines
2.1 KiB
C
55 lines
2.1 KiB
C
#include <tactility/device.h>
|
|
#include <tactility/drivers/display.h>
|
|
#include <tactility/drivers/keyboard.h>
|
|
#include <tactility/drivers/pointer.h>
|
|
#include <tactility/log.h>
|
|
#include <tactility/lvgl_display.h>
|
|
#include <tactility/lvgl_keyboard.h>
|
|
#include <tactility/lvgl_pointer.h>
|
|
|
|
#include <lvgl.h>
|
|
|
|
#define TAG "lvgl"
|
|
|
|
void lvgl_devices_attach() {
|
|
lv_disp_t* lvgl_display = NULL;
|
|
struct Device* kernel_display_device = device_find_first_by_type(&DISPLAY_TYPE);
|
|
if (kernel_display_device != NULL) {
|
|
struct LvglDisplayConfig lvgl_display_config = {};
|
|
if (lvgl_display_add(kernel_display_device, &lvgl_display_config, &lvgl_display) == ERROR_NONE) {
|
|
LOG_I(TAG, "Bound %s to LVGL", kernel_display_device->name);
|
|
} else {
|
|
LOG_E(TAG, "Failed to bind %s to LVGL", kernel_display_device->name);
|
|
}
|
|
}
|
|
|
|
struct Device* kernel_pointer_device = device_find_first_by_type(&POINTER_TYPE);
|
|
lv_indev_t* lvgl_pointer_device;
|
|
if (kernel_pointer_device != NULL) {
|
|
if (lvgl_pointer_add(kernel_pointer_device, lvgl_display, &lvgl_pointer_device) == ERROR_NONE) {
|
|
LOG_I(TAG, "Bound %s to LVGL", kernel_pointer_device->name);
|
|
} else {
|
|
LOG_E(TAG, "Failed to bind %s to LVG", kernel_pointer_device->name);
|
|
}
|
|
}
|
|
|
|
struct Device* kernel_keyboard_device = device_find_first_by_type(&KEYBOARD_TYPE);
|
|
lv_indev_t* lvgl_keyboard_device;
|
|
if (kernel_keyboard_device != NULL) {
|
|
if (lvgl_keyboard_add(kernel_keyboard_device, lvgl_display, &lvgl_keyboard_device) == ERROR_NONE) {
|
|
LOG_I(TAG, "Bound %s to LVGL", kernel_keyboard_device->name);
|
|
} else {
|
|
LOG_E(TAG, "Failed to bind %s to LVGL", kernel_keyboard_device->name);
|
|
}
|
|
}
|
|
}
|
|
|
|
void lvgl_devices_detach() {
|
|
lv_indev_t* device = lv_indev_get_next(NULL);
|
|
while (device != NULL) {
|
|
lv_indev_delete(device);
|
|
// Always get the first item, because getting the next one doesn't work as the current pointer just became corrupt
|
|
device = lv_indev_get_next(NULL);
|
|
}
|
|
}
|