What MCU/Processor/Board and compiler are you using?
Simulator
What LVGL version are you using?
v9.1
What do you want to achieve?
I want to attach an event, that is fired when a key is pressed on the physical keyboard.
Code to reproduce
In the main.c
I’ve added an event listener
int main(void)
{
lv_init();
hal_setup();
// draw();
lv_demo_widgets();
lv_indev_add_event_cb(getLvKeyboard(), my_event_cb, LV_EVENT_CLICKED, NULL);
hal_loop();
}
It was necessary to add a getter getLvKeyboard
that is returning the lv_indev_t *lvKeyboard
object from the app_hal.c
file.
The code block(s) should be formatted like:
/*You code here*/
The callback basically currently only logs the input
static void my_event_cb(lv_event_t *event)
{
LV_LOG_USER("event code %i", event->code);
}
It seems, that the event is never fired.
I tried different events (key, click, all) and the only event I see, is the LV_EVENT_DELETE
event, when closing the simulator.
I found this article How to detect keyboard input in lvgl simulator? , but not sure if it’s still working like this for v9.1
From what I understand, the hal_setup
function already setup the sdl keyboard driver …