1 /* 2 * Copyright 2023 Fabian Blatz <fabianblatz@gmail.com> 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef ZEPHYR_MODULES_LVGL_LVGL_COMMON_INPUT_H_ 8 #define ZEPHYR_MODULES_LVGL_LVGL_COMMON_INPUT_H_ 9 10 #include <lvgl.h> 11 #include <zephyr/device.h> 12 #include <zephyr/input/input.h> 13 14 #ifdef __cplusplus 15 extern "C" { 16 #endif 17 18 struct lvgl_common_input_config { 19 struct k_msgq *event_msgq; 20 }; 21 22 struct lvgl_common_input_data { 23 lv_indev_drv_t indev_drv; 24 lv_indev_t *indev; 25 lv_indev_data_t pending_event; 26 lv_indev_data_t previous_event; 27 }; 28 29 int lvgl_input_register_driver(lv_indev_type_t indev_type, const struct device *dev); 30 int lvgl_init_input_devices(void); 31 32 #define LVGL_INPUT_EVENT_MSGQ(inst, type) lvgl_input_msgq_##type##_##inst 33 #define LVGL_INPUT_DEVICE(inst) DEVICE_DT_GET_OR_NULL(DT_INST_PHANDLE(inst, input)) 34 35 #define LVGL_COORD_VALID(coord) IN_RANGE(coord, LV_COORD_MIN, LV_COORD_MAX) 36 #define LVGL_KEY_VALID(key) IN_RANGE(key, 0, UINT8_MAX) 37 38 #define LVGL_INPUT_DEFINE(inst, type, msgq_size, process_evt_cb) \ 39 INPUT_CALLBACK_DEFINE(LVGL_INPUT_DEVICE(inst), process_evt_cb, \ 40 (void *)DEVICE_DT_INST_GET(inst)); \ 41 K_MSGQ_DEFINE(lvgl_input_msgq_##type##_##inst, sizeof(lv_indev_data_t), msgq_size, 4) 42 43 #ifdef __cplusplus 44 } 45 #endif 46 47 /** @} */ 48 49 #endif /* ZEPHYR_MODULES_LVGL_LVGL_COMMON_INPUT_H_ */ 50