From: Simon Glass <sjg@chromium.org> Add a new set_ptr_visible() method to the mouse uclass to allow hiding and showing the system mouse pointer. This is useful with sandbox when rendering a custom mouse pointer, such as in expo mode. The method is optional and returns -ENOSYS if not supported by the driver. Co-developed-by: Claude <noreply@anthropic.com> Signed-off-by: Simon Glass <sjg@chromium.org> --- drivers/input/mouse-uclass.c | 10 ++++++++++ include/mouse.h | 24 ++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/drivers/input/mouse-uclass.c b/drivers/input/mouse-uclass.c index ee983397ef3..efb52d3377b 100644 --- a/drivers/input/mouse-uclass.c +++ b/drivers/input/mouse-uclass.c @@ -83,6 +83,16 @@ int mouse_get_pos(struct udevice *dev, struct vid_pos *pos) return 0; } +int mouse_set_ptr_visible(struct udevice *dev, bool visible) +{ + struct mouse_ops *ops = mouse_get_ops(dev); + + if (!ops->set_ptr_visible) + return -ENOSYS; + + return ops->set_ptr_visible(dev, visible); +} + UCLASS_DRIVER(mouse) = { .id = UCLASS_MOUSE, .name = "mouse", diff --git a/include/mouse.h b/include/mouse.h index 8212a1e89d4..98f54f73d88 100644 --- a/include/mouse.h +++ b/include/mouse.h @@ -99,6 +99,18 @@ struct mouse_ops { * supported */ int (*get_event)(struct udevice *dev, struct mouse_event *event); + + /** + * set_ptr_visible() - Show or hide the system mouse pointer + * + * This is used to hide the system pointer when expo is rendering its + * own custom mouse pointer. + * + * @dev: Mouse device + * @visible: true to show the pointer, false to hide it + * Returns: 0 if OK, -ENOSYS if not supported + */ + int (*set_ptr_visible)(struct udevice *dev, bool visible); }; #define mouse_get_ops(dev) ((struct mouse_ops *)(dev)->driver->ops) @@ -135,4 +147,16 @@ int mouse_get_click(struct udevice *dev, struct vid_pos *pos); */ int mouse_get_pos(struct udevice *dev, struct vid_pos *pos); +/** + * mouse_set_ptr_visible() - Show or hide the system mouse pointer + * + * This is used to hide the system pointer when rendering a custom mouse + * pointer (e.g., in expo mode). + * + * @dev: Mouse device + * @visible: true to show the pointer, false to hide it + * Returns: 0 if OK, -ENOSYS if not supported + */ +int mouse_set_ptr_visible(struct udevice *dev, bool visible); + #endif -- 2.43.0