
From: Simon Glass <sjg@chromium.org> In some cases it is useful to use expo with a mouse (or touchpad). Add a way to tell expo to find and record a mouse device. Signed-off-by: Simon Glass <sjg@chromium.org> --- boot/expo.c | 19 +++++++++++++++++++ include/expo.h | 13 +++++++++++++ test/boot/expo.c | 22 ++++++++++++++++++++++ 3 files changed, 54 insertions(+) diff --git a/boot/expo.c b/boot/expo.c index 6f05c47aba6..e18f149a22f 100644 --- a/boot/expo.c +++ b/boot/expo.c @@ -13,6 +13,7 @@ #include <log.h> #include <malloc.h> #include <menu.h> +#include <mouse.h> #include <video.h> #include <watchdog.h> #include <linux/delay.h> @@ -163,6 +164,24 @@ void expo_set_text_mode(struct expo *exp, bool text_mode) exp->text_mode = text_mode; } +int expo_set_mouse_enable(struct expo *exp, bool enable) +{ + int ret; + + if (!enable) { + exp->mouse_enabled = false; + return 0; + } + + ret = uclass_first_device_err(UCLASS_MOUSE, &exp->mouse); + if (ret) + return log_msg_ret("sme", ret); + + exp->mouse_enabled = true; + + return 0; +} + struct scene *expo_lookup_scene_id(struct expo *exp, uint scene_id) { struct scene *scn; diff --git a/include/expo.h b/include/expo.h index c025e5494a1..f49a6fc5dce 100644 --- a/include/expo.h +++ b/include/expo.h @@ -109,6 +109,7 @@ struct expo_theme { * @name: Name of the expo (allocated) * @display: Display to use (`UCLASS_VIDEO`), or NULL to use text mode * @cons: Console to use (`UCLASS_VIDEO_CONSOLE`), or NULL to use text mode + * @mouse: Mouse to use (`UCLASS_MOUSE`), or NULL if no mouse * @scene_id: Current scene ID (0 if none) * @next_id: Next ID number to use, for automatic allocation * @action: Action selected by user. At present only one is supported, with the @@ -118,6 +119,7 @@ struct expo_theme { * @text_mode: true to use text mode for the menu (no vidconsole) * @popup: true to use popup menus, instead of showing all items * @show_highlight: show a highlight bar on the selected menu item + * @mouse_enabled: true if the mouse is enabled * @priv: Private data for the controller * @done: Indicates that a cedit session is complete and the user has quit * @save: Indicates that cedit data should be saved, rather than discarded @@ -130,6 +132,7 @@ struct expo { char *name; struct udevice *display; struct udevice *cons; + struct udevice *mouse; uint scene_id; uint next_id; struct expo_action action; @@ -138,6 +141,7 @@ struct expo { bool text_mode; bool popup; bool show_highlight; + bool mouse_enabled; void *priv; bool done; bool save; @@ -667,6 +671,15 @@ int expo_arrange(struct expo *exp); */ void expo_set_text_mode(struct expo *exp, bool text_mode); +/** + * expo_set_mouse_enable() - Controls whether the expo enables mouse input + * + * @exp: Expo to update + * @enable: true to enable mouse input, false to disable + * Returns: 0 if OK, or -ve error if no mouse found + */ +int expo_set_mouse_enable(struct expo *exp, bool enable); + /** * scene_new() - create a new scene in a expo * diff --git a/test/boot/expo.c b/test/boot/expo.c index 634bab8f203..9ee2c312f86 100644 --- a/test/boot/expo.c +++ b/test/boot/expo.c @@ -928,3 +928,25 @@ static int expo_test_build(struct unit_test_state *uts) return 0; } BOOTSTD_TEST(expo_test_build, UTF_DM); + +/* test expo_set_mouse_enable() */ +static int expo_mouse_enable(struct unit_test_state *uts) +{ + struct udevice *dev; + struct expo *exp; + + ut_assertok(uclass_first_device_err(UCLASS_VIDEO, &dev)); + ut_assertok(expo_new(EXPO_NAME, NULL, &exp)); + ut_assertok(expo_set_display(exp, dev)); + + ut_asserteq(false, exp->mouse_enabled); + + ut_assertok(expo_set_mouse_enable(exp, true)); + ut_assertnonnull(exp->mouse); + ut_asserteq(UCLASS_MOUSE, device_get_uclass_id(exp->mouse)); + + expo_destroy(exp); + + return 0; +} +BOOTSTD_TEST(expo_mouse_enable, UTF_DM | UTF_SCAN_FDT); -- 2.43.0