sandbox: mouse: Implement set_ptr_visible()

Implement this new method using the SDL layer.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2025-10-03 07:23:22 -06:00
parent e99d2dc8ec
commit 53aad73a6b
3 changed files with 24 additions and 0 deletions

View File

@@ -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);
}

View File

@@ -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

View File

@@ -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[] = {