From patchwork Mon Oct 6 20:58:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 524 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759784382; bh=mCFblMxlSahL0hQDls2sHf5PToXGif06GZ2POA2ic8A=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=MuVlL12rQxXir+/7LW5xacp21oTlpfJ7RO+JqQBmUOoyfDPrD5hArxJ/01uYDKmND 8oZwgo2ioq8bErGhw2cpIgDX6tKcJP3JeiVShHZOqRPnVdqRAoGL0Q4Q71aLPqZbrg zSWxB85hL+HN+j1hdShBpUzBZe4ZLVoVBZGK1+Vlfq6FWeXjxnfTXCpsf8cp0ki7EA EIo1ovJz6gSJq9TGZffeQpuSivQhNnB9mLnTGo11z/MdO8BqvuBTMejtklSvqANRd/ 08YcLigtwtxvGSkJmWtw/GpLGxbXUETnjDq5F6NaJ8eVRg9Kia/cA0oKRgP+GkGVdc Jpdw0/LrchwrQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9C12B67FA7 for ; Mon, 6 Oct 2025 14:59:42 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id Yy9j1WOultSf for ; Mon, 6 Oct 2025 14:59:42 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759784382; bh=mCFblMxlSahL0hQDls2sHf5PToXGif06GZ2POA2ic8A=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=MuVlL12rQxXir+/7LW5xacp21oTlpfJ7RO+JqQBmUOoyfDPrD5hArxJ/01uYDKmND 8oZwgo2ioq8bErGhw2cpIgDX6tKcJP3JeiVShHZOqRPnVdqRAoGL0Q4Q71aLPqZbrg zSWxB85hL+HN+j1hdShBpUzBZe4ZLVoVBZGK1+Vlfq6FWeXjxnfTXCpsf8cp0ki7EA EIo1ovJz6gSJq9TGZffeQpuSivQhNnB9mLnTGo11z/MdO8BqvuBTMejtklSvqANRd/ 08YcLigtwtxvGSkJmWtw/GpLGxbXUETnjDq5F6NaJ8eVRg9Kia/cA0oKRgP+GkGVdc Jpdw0/LrchwrQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8365167F8D for ; Mon, 6 Oct 2025 14:59:42 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759784381; bh=Z6SByUSFF+XksMzRhBYG/PsyiyYByPcSyKVfJj81oXI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g0LVGVNsDBt+I7yEMbuSOF56Fg5RK/VjDg15O4Sdt7kwdIC7wPdD1HSnSfRHBLq8C F1upwfh0Y2XYRitBfghW742snRvz8b6lH2VSVY80qOU4Th7lAV1C19fTyMxtKtImuf nZP5WQggY2CItX2FSAAH5CY3GLOTzcoE/l1aR3PRsqL84A1b2QrWfhUGKj33rqCEiV 2O7zXJ0E9A3re4svdxCy/F4tzSMDhJJVtygmAqOvFK2ac11jyMrpiUeUUY+Vlb5E21 yE9CU6HheaaMoHD3xxSf3lCIUBckcTfFPopn7rVWq8+YGdMZoP0HCwkmuGKz3J9mhT zgtfJTZMn0PEg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 46E0167F03; Mon, 6 Oct 2025 14:59:41 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id ROp8JD1y760N; Mon, 6 Oct 2025 14:59:41 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759784375; bh=fPeaWo9JQ8FBTESOGfgivSBw2kW2CzniNm2788Z3vWw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k1FgXnK3sgK3GIO8Lp+/dCRDMe8pW4G26311c+cOUU0Y6GyV0rOJcFIW3MBJIDks5 hqi9klFU5V1wkXOLiYD7iNRIdjKDuixTcupXQ176cS4dCVTAJjntCsJ/40f30XsEHk JQOduvQ+MwO/+2JDh9bLBrPuVYpFzESlhLlld0NsoDtRnkOSO6Su1TuqA/OKXIQ9g5 e6GR2c6Mi51GbTNhybGw0lZN6wRsIh7+Opby0BkzZqAd21JAweRlKH+BP0K6GnEZfV XfymwJhbSGSJ54XrTdQJP57S/1J+VUjfwzL7gvjGOqbMmU2yPLu/n7UgkbrXaUAarz CqU6acRb61JLw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 18D9167EE4; Mon, 6 Oct 2025 14:59:35 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 6 Oct 2025 14:58:41 -0600 Message-ID: <20251006205856.2009292-8-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251006205856.2009292-1-sjg@u-boot.org> References: <20251006205856.2009292-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: ZO3I4DEQ675T7FSUNQQJFPXNSMDENLAV X-Message-ID-Hash: ZO3I4DEQ675T7FSUNQQJFPXNSMDENLAV X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 07/14] sandbox: mouse: Add test for pointer visibility List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add a test for the mouse set_ptr_visible() method. This uses a back-door function to read the visibility state from the sandbox mouse driver. Also add documentation for struct sandbox_mouse_priv. Co-developed-by: Claude Signed-off-by: Simon Glass --- arch/sandbox/include/asm/test.h | 8 ++++++++ drivers/input/sandbox_mouse.c | 25 +++++++++++++++++++++++++ test/dm/mouse.c | 22 ++++++++++++++++++++++ 3 files changed, 55 insertions(+) diff --git a/arch/sandbox/include/asm/test.h b/arch/sandbox/include/asm/test.h index 499db42804c..ba8f269d86f 100644 --- a/arch/sandbox/include/asm/test.h +++ b/arch/sandbox/include/asm/test.h @@ -378,4 +378,12 @@ void sandbox_mouse_set_test_mode(struct udevice *dev, bool test_mode); */ void sandbox_mouse_inject(struct udevice *dev, struct mouse_event *event); +/** + * sandbox_mouse_get_ptr_visible() - Get pointer visibility state + * + * @dev: Mouse device + * Return: true if pointer is visible, false if hidden + */ +bool sandbox_mouse_get_ptr_visible(struct udevice *dev); + #endif diff --git a/drivers/input/sandbox_mouse.c b/drivers/input/sandbox_mouse.c index add7401c4ec..faebb09ba3c 100644 --- a/drivers/input/sandbox_mouse.c +++ b/drivers/input/sandbox_mouse.c @@ -8,10 +8,19 @@ #include #include +/** + * struct sandbox_mouse_priv - Private data for sandbox mouse driver + * + * @test_mode: true to use test mode (inject events), false to use SDL + * @test_event: Event to return when in test mode + * @test_event_pending: true if test_event is pending + * @ptr_visible: Current visibility state of mouse pointer + */ struct sandbox_mouse_priv { bool test_mode; struct mouse_event test_event; bool test_event_pending; + bool ptr_visible; }; static int mouse_sandbox_get_event(struct udevice *dev, @@ -38,6 +47,9 @@ static int mouse_sandbox_get_event(struct udevice *dev, static int mouse_sandbox_set_ptr_visible(struct udevice *dev, bool visible) { + struct sandbox_mouse_priv *priv = dev_get_priv(dev); + + priv->ptr_visible = visible; sandbox_sdl_set_cursor_visible(visible); return 0; @@ -83,6 +95,19 @@ void sandbox_mouse_inject(struct udevice *dev, struct mouse_event *event) } } +/** + * sandbox_mouse_get_ptr_visible() - Get pointer visibility state + * + * @dev: Mouse device + * Return: true if pointer is visible, false if hidden + */ +bool sandbox_mouse_get_ptr_visible(struct udevice *dev) +{ + struct sandbox_mouse_priv *priv = dev_get_priv(dev); + + return priv->ptr_visible; +} + U_BOOT_DRIVER(mouse_sandbox) = { .name = "mouse_sandbox", .id = UCLASS_MOUSE, diff --git a/test/dm/mouse.c b/test/dm/mouse.c index 3efff4a0d7d..c22cd026cb2 100644 --- a/test/dm/mouse.c +++ b/test/dm/mouse.c @@ -214,3 +214,25 @@ static int dm_test_mouse_right_button(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_mouse_right_button, UTF_SCAN_PDATA | UTF_SCAN_FDT); + +static int dm_test_mouse_ptr_visible(struct unit_test_state *uts) +{ + struct udevice *dev; + + ut_assertok(uclass_first_device_err(UCLASS_MOUSE, &dev)); + + /* test hiding the pointer */ + ut_assertok(mouse_set_ptr_visible(dev, false)); + ut_asserteq(false, sandbox_mouse_get_ptr_visible(dev)); + + /* test showing the pointer */ + ut_assertok(mouse_set_ptr_visible(dev, true)); + ut_asserteq(true, sandbox_mouse_get_ptr_visible(dev)); + + /* test hiding again */ + ut_assertok(mouse_set_ptr_visible(dev, false)); + ut_asserteq(false, sandbox_mouse_get_ptr_visible(dev)); + + return 0; +} +DM_TEST(dm_test_mouse_ptr_visible, UTF_SCAN_PDATA | UTF_SCAN_FDT);