[Concept,06/14] sandbox: mouse: Implement set_ptr_visible()

Message ID 20251006205856.2009292-7-sjg@u-boot.org
State New
Headers
Series expo: More mouse development for expo |

Commit Message

Simon Glass Oct. 6, 2025, 8:58 p.m. UTC
  From: Simon Glass <sjg@chromium.org>

Implement this new method using the SDL layer.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/sandbox/cpu/sdl.c         |  5 +++++
 arch/sandbox/include/asm/sdl.h | 11 +++++++++++
 drivers/input/sandbox_mouse.c  |  8 ++++++++
 3 files changed, 24 insertions(+)
  

Patch

diff --git a/arch/sandbox/cpu/sdl.c b/arch/sandbox/cpu/sdl.c
index 65d55b0085d..c3745fa660e 100644
--- a/arch/sandbox/cpu/sdl.c
+++ b/arch/sandbox/cpu/sdl.c
@@ -646,3 +646,8 @@  int sandbox_sdl_sound_stop(void)
 
 	return 0;
 }
+
+void sandbox_sdl_set_cursor_visible(bool visible)
+{
+	SDL_ShowCursor(visible ? SDL_ENABLE : SDL_DISABLE);
+}
diff --git a/arch/sandbox/include/asm/sdl.h b/arch/sandbox/include/asm/sdl.h
index b97773c8a4f..a80db51ad19 100644
--- a/arch/sandbox/include/asm/sdl.h
+++ b/arch/sandbox/include/asm/sdl.h
@@ -119,6 +119,13 @@  int sandbox_sdl_set_bpp(struct udevice *dev, enum video_log2_bpp l2bpp);
  */
 int sandbox_sdl_get_mouse_event(struct mouse_event *evt);
 
+/**
+ * sandbox_sdl_set_cursor_visible() - Show or hide the SDL cursor
+ *
+ * @visible: true to show the cursor, false to hide it
+ */
+void sandbox_sdl_set_cursor_visible(bool visible);
+
 #else
 static inline int sandbox_sdl_init_display(int width, int height, int log2_bpp,
 					   bool double_size)
@@ -178,6 +185,10 @@  static inline int sandbox_sdl_get_mouse_event(struct mouse_event *evt)
 	return -ENODEV;
 }
 
+static inline void sandbox_sdl_set_cursor_visible(bool visible)
+{
+}
+
 #endif
 
 #endif
diff --git a/drivers/input/sandbox_mouse.c b/drivers/input/sandbox_mouse.c
index ba271242b1a..add7401c4ec 100644
--- a/drivers/input/sandbox_mouse.c
+++ b/drivers/input/sandbox_mouse.c
@@ -36,8 +36,16 @@  static int mouse_sandbox_get_event(struct udevice *dev,
 	return ret;
 }
 
+static int mouse_sandbox_set_ptr_visible(struct udevice *dev, bool visible)
+{
+	sandbox_sdl_set_cursor_visible(visible);
+
+	return 0;
+}
+
 const struct mouse_ops mouse_sandbox_ops = {
 	.get_event	= mouse_sandbox_get_event,
+	.set_ptr_visible = mouse_sandbox_set_ptr_visible,
 };
 
 static const struct udevice_id mouse_sandbox_ids[] = {