diff options
| author | Simon Glass <[email protected]> | 2025-05-02 08:46:24 -0600 |
|---|---|---|
| committer | Simon Glass <[email protected]> | 2025-05-30 09:49:32 +0100 |
| commit | 9f44b544e1d8b23dec51567c657e81488a289d6d (patch) | |
| tree | 6d8232cd634cc5a8b8c8b28543a6085f8eec6517 /boot | |
| parent | c43791c4871a0635594b1f08c57a54c4a533c710 (diff) | |
expo: Provide access to the current menu item
Add functions to allow a caller to find out the current menu item and to
select a different one.
Update the event handling so that an attempt to change the current item
(e.g. by pressing the up-arrow key) is reported to the caller, since
this may be used to cancel an autoboot timeout.
Signed-off-by: Simon Glass <[email protected]>
Diffstat (limited to 'boot')
| -rw-r--r-- | boot/scene_menu.c | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/boot/scene_menu.c b/boot/scene_menu.c index 17150af145d..06d7e9fc913 100644 --- a/boot/scene_menu.c +++ b/boot/scene_menu.c @@ -121,12 +121,21 @@ static int update_pointers(struct scene_obj_menu *menu, uint id, bool point) * * Sets the currently pointed-to / highlighted menu item */ -static void menu_point_to_item(struct scene_obj_menu *menu, uint item_id) +static int menu_point_to_item(struct scene_obj_menu *menu, uint item_id) { - if (menu->cur_item_id) - update_pointers(menu, menu->cur_item_id, false); + int ret; + + if (menu->cur_item_id) { + ret = update_pointers(menu, menu->cur_item_id, false); + if (ret) + return log_msg_ret("mpi", ret); + } menu->cur_item_id = item_id; - update_pointers(menu, item_id, true); + ret = update_pointers(menu, item_id, true); + if (ret) + return log_msg_ret("mpu", ret); + + return 0; } void scene_menu_calc_bbox(struct scene_obj_menu *menu, @@ -483,6 +492,33 @@ int scene_menu_set_pointer(struct scene *scn, uint id, uint pointer_id) return 0; } +int scene_menu_select_item(struct scene *scn, uint id, uint cur_item_id) +{ + struct scene_obj_menu *menu; + int ret; + + menu = scene_obj_find(scn, id, SCENEOBJT_MENU); + if (!menu) + return log_msg_ret("menu", -ENOENT); + + ret = menu_point_to_item(menu, cur_item_id); + if (ret) + return log_msg_ret("msi", ret); + + return 0; +} + +int scene_menu_get_cur_item(struct scene *scn, uint id) +{ + struct scene_obj_menu *menu; + + menu = scene_obj_find(scn, id, SCENEOBJT_MENU); + if (!menu) + return log_msg_ret("menu", -ENOENT); + + return menu->cur_item_id; +} + int scene_menu_display(struct scene_obj_menu *menu) { struct scene *scn = menu->obj.scene; |
