From patchwork Mon Sep 15 19:35:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 341 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=1757964957; bh=Oit+OY3OoH8rysB/8KmdsxCUgw4Y0LdBP3kCmJrYKbU=; 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=PSYoBPwidtkzJZJv0SCF0nzpRC4dUyaBGZKCr4oULyUsmnGptTmcTo654ECWbqQnn H0ntNUnl8vzixf7BakiU4ygHbb0nsN3XFRG4ALy4msI6Q5b+D6UauJ5Nabw3EfuDMb srDbXdD4W356FihttwladYlzjL4uMj/hA9u2IrLlw0kHZ8ySTlyx5FKYTN3KLPwY1t slFW1x5xYs7Tdzgm9ZiE9g4TkCTFjA8GbDSZbZ+ksn4LM/jNbIEbFWMZbrDzAUR/nw LNM18Gebb4uZ80xjQZ7ZLDFPhn0JLcKynFdAiNeGCh0FU9aCZM9u1O6ImoEE5FmkV/ Rd5HV/wzukJlg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1692667BE9 for ; Mon, 15 Sep 2025 13:35:57 -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 iW5JuxVgiHNz for ; Mon, 15 Sep 2025 13:35:57 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757964957; bh=Oit+OY3OoH8rysB/8KmdsxCUgw4Y0LdBP3kCmJrYKbU=; 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=PSYoBPwidtkzJZJv0SCF0nzpRC4dUyaBGZKCr4oULyUsmnGptTmcTo654ECWbqQnn H0ntNUnl8vzixf7BakiU4ygHbb0nsN3XFRG4ALy4msI6Q5b+D6UauJ5Nabw3EfuDMb srDbXdD4W356FihttwladYlzjL4uMj/hA9u2IrLlw0kHZ8ySTlyx5FKYTN3KLPwY1t slFW1x5xYs7Tdzgm9ZiE9g4TkCTFjA8GbDSZbZ+ksn4LM/jNbIEbFWMZbrDzAUR/nw LNM18Gebb4uZ80xjQZ7ZLDFPhn0JLcKynFdAiNeGCh0FU9aCZM9u1O6ImoEE5FmkV/ Rd5HV/wzukJlg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0648A67B51 for ; Mon, 15 Sep 2025 13:35:57 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757964955; bh=7wqfTGJPEuHtIOZp2zZ5NaeP0iZ2CF7iG2q7NWylxK4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kccLXZ7YCDT2oLVmvkQnvHoefKfVXH5sl2nNtWWk0BnvTsJf/Z6t9Kc4PGAmnFvrU UjcZ6BW9aMOXyWcby4tkCLL4o9lOaqsWgYPVPJInaZIvFOBQjLhByoyEKVVHOnGITS 6l7Ct88FPSIYpGPHwQSG4s4MP4gFbhhqwJ0u6YN3H7kS53LX1u/YNpYFtSq9Bh4PD+ efDyhvyk53tFexeKQ0+Qh58X+mn17q58BrqoD1gYlrYrpnETd3A5mTnnq+0x2VtHuv IUyUo4Zh99TwpOdy8NngV8Fo9xgrSoLCxzE8yr1fuKFRR5zxuuOmQ8XM4GPJ1DM/sb 2niLB8zimiYlg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0BF2967BC8; Mon, 15 Sep 2025 13:35:55 -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 hlUHCiid0tmc; Mon, 15 Sep 2025 13:35:54 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757964950; bh=KQWJdB9IjCYysvyC19gTwKf5Y8U1fO2C88AwHA+L7cw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I9UxKxbksPj8flfm2dAk2Gx5BCFsWeTTyCLGEmLPxDLZAB+d/2Jgyhz5R8Qi8546X QNXsxGGbwEAm+ksqm0ei8R3tROG3TgGhIApWxKL0UGUDsYxYAt1crcwqvXIQLZvXoo 5WzKhaA7jHDAeq5XboDv1tksOBj69IXD1lHxew3+fa+X9j9q7P67Y8Sc6bEmmsi/7a LaaD1DUduX5AlAJH+AfmEnKmI5IkBDbmR1jhjMSLP/M4UqH4OUii7CFZMvAvVVQpX/ uXWQYtJPI4ObDBZDzKr4eHxOhUNwRsz9MVA/ruRNTaWqi2G4pkLvkLFpul93xN2bCk 50GaRAjYYgGNQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 1549467B47; Mon, 15 Sep 2025 13:35:50 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 15 Sep 2025 13:35:34 -0600 Message-ID: <20250915193538.2316642-2-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250915193538.2316642-1-sjg@u-boot.org> References: <20250915193538.2316642-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: YZXHJ2KJYPQZW2HF4X6V3RVCX556KOL2 X-Message-ID-Hash: YZXHJ2KJYPQZW2HF4X6V3RVCX556KOL2 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 2/3] mouse: Allow selecting the device to use 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 Enhance the mouse dump command to support selecting a specific mouse device by number. This allows testing multiple mouse devices when available in the system. Add some documentation while we are here. Co-developed-by: Claude Signed-off-by: Simon Glass --- cmd/mouse.c | 16 +++++++--- doc/usage/cmd/mouse.rst | 66 +++++++++++++++++++++++++++++++++++++++++ doc/usage/index.rst | 1 + 3 files changed, 79 insertions(+), 4 deletions(-) create mode 100644 doc/usage/cmd/mouse.rst diff --git a/cmd/mouse.c b/cmd/mouse.c index 60210b9f868..ee19bb07aea 100644 --- a/cmd/mouse.c +++ b/cmd/mouse.c @@ -18,13 +18,21 @@ static int do_mouse_dump(struct cmd_tbl *cmdtp, int flag, int argc, struct udevice *dev; bool running; int count; + int mouse_dev = 0; int ret; - ret = uclass_first_device_err(UCLASS_MOUSE, &dev); + /* Parse optional device number */ + if (argc > 1) + mouse_dev = dectoul(argv[1], NULL); + + /* Get the specified mouse device */ + ret = uclass_get_device(UCLASS_MOUSE, mouse_dev, &dev); if (ret) { - printf("Mouse not found (err=%d)\n", ret); + printf("Mouse device %d not found (err=%d)\n", mouse_dev, ret); return CMD_RET_FAILURE; } + + printf("Using mouse device %d: %s\n", mouse_dev, dev->name); for (running = true, count = 0; running;) { struct mouse_event evt; @@ -63,7 +71,7 @@ static int do_mouse_dump(struct cmd_tbl *cmdtp, int flag, int argc, } static char mouse_help_text[] = - "dump - Dump input from a mouse"; + "dump [dev] - Dump input from mouse device (default: 0)"; U_BOOT_CMD_WITH_SUBCMDS(mouse, "Mouse input", mouse_help_text, - U_BOOT_SUBCMD_MKENT(dump, 1, 1, do_mouse_dump)); + U_BOOT_SUBCMD_MKENT(dump, 2, 1, do_mouse_dump)); diff --git a/doc/usage/cmd/mouse.rst b/doc/usage/cmd/mouse.rst new file mode 100644 index 00000000000..665980111ae --- /dev/null +++ b/doc/usage/cmd/mouse.rst @@ -0,0 +1,66 @@ +.. SPDX-License-Identifier: GPL-2.0+: + +.. index:: + single: mouse (command) + +mouse command +============= + +Synopsis +-------- + +:: + + mouse dump [dev] + +The mouse command is used to access mouse input devices. + +mouse dump +---------- + +Dump input events from a mouse device in real-time. Events are displayed +until the user presses Ctrl+C to stop. + +dev + Optional device number (default: 0). Use this to select a specific mouse + device when multiple mouse devices are available. + +The command displays: +- Motion events with absolute/relative coordinates and button state +- Button events (left, right, middle) with press/release state and position +- Event count when finished + +Example +------- + +:: + + => mouse dump + Using mouse device 0: xhci_pci.p0.usb_hub.p6.usb_mo + motion: Xrel=-27, Yrel=84, X=0, Y=84, but=0 + motion: Xrel=-78, Yrel=87, X=0, Y=171, but=0 + motion: Xrel=-1, Yrel=87, X=0, Y=258, but=0 + motion: Xrel=76, Yrel=88, X=76, Y=346, but=0 + button: button==0, press=1, clicks=1, X=76, Y=346 + motion: Xrel=76, Yrel=88, X=152, Y=434, but=1 + motion: Xrel=76, Yrel=88, X=228, Y=522, but=1 + motion: Xrel=76, Yrel=88, X=304, Y=610, but=1 + motion: Xrel=76, Yrel=88, X=380, Y=698, but=1 + button: button==0, press=0, clicks=1, X=380, Y=698 + motion: Xrel=76, Yrel=88, X=456, Y=786, but=0 + motion: Xrel=76, Yrel=88, X=532, Y=874, but=0 + motion: Xrel=50, Yrel=88, X=582, Y=962, but=0 + motion: Xrel=-1, Yrel=87, X=581, Y=1049, but=0 + motion: Xrel=76, Yrel=87, X=657, Y=1136, but=0 + motion: Xrel=-104, Yrel=86, X=553, Y=1222, but=0 + motion: Xrel=24, Yrel=86, X=577, Y=1308, but=0 + motion: Xrel=-104, Yrel=85, X=473, Y=1393, but=0 + 18 events received + + => mouse dump 1 + Mouse device 1 not found (err=-19) + +Configuration +------------- + +The mouse command is available when CONFIG_CMD_MOUSE is enabled. diff --git a/doc/usage/index.rst b/doc/usage/index.rst index eeda632b1a0..c03ea7df7c4 100644 --- a/doc/usage/index.rst +++ b/doc/usage/index.rst @@ -94,6 +94,7 @@ Shell commands cmd/mbr cmd/md cmd/mmc + cmd/mouse cmd/msr cmd/mtest cmd/mtrr