[Concept,04/14] mouse: Add method to show/hide the system pointer
Commit Message
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(+)
@@ -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",
@@ -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