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_t *indev; 24 lv_indev_data_t pending_event; 25 lv_indev_data_t previous_event; 26 }; 27 28 int lvgl_input_register_driver(lv_indev_type_t indev_type, const struct device *dev); 29 int lvgl_init_input_devices(void); 30 31 #define LVGL_INPUT_EVENT_MSGQ(inst, type) lvgl_input_msgq_##type##_##inst 32 #define LVGL_INPUT_DEVICE(inst) DEVICE_DT_GET_OR_NULL(DT_INST_PHANDLE(inst, input)) 33 34 #define LVGL_COORD_VALID(coord) IN_RANGE(coord, LV_COORD_MIN, LV_COORD_MAX) 35 #define LVGL_KEY_VALID(key) IN_RANGE(key, 0, UINT8_MAX) 36 37 #define LVGL_INPUT_DEFINE(inst, type, msgq_size, process_evt_cb) \ 38 INPUT_CALLBACK_DEFINE_NAMED(LVGL_INPUT_DEVICE(inst), process_evt_cb, \ 39 (void *)DEVICE_DT_INST_GET(inst), process_evt_cb_##inst); \ 40 K_MSGQ_DEFINE(lvgl_input_msgq_##type##_##inst, sizeof(lv_indev_data_t), msgq_size, 4) 41 42 #ifdef __cplusplus 43 } 44 #endif 45 46 /** @} */ 47 48 #endif /* ZEPHYR_MODULES_LVGL_LVGL_COMMON_INPUT_H_ */ 49