From patchwork Mon Aug 25 20:40:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 142 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=1756154442; bh=zp0B9EYopsMDRoS+2H1yrkl7v05mWMi2yt745GFxztE=; 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=kE9IH/kgPrLlHWwPYDTdIWUdX5IWIpLNyruLedkEo1d/iF5kBiNj0cBDKL0v4BEQA g2YwKECbwICJq59IE7RG+b32KZb148/EkpLGrI8rLpM0fJdNBjadqm9TYPlBR4J5RK d1HFCX3UfrgCmRkj7+eouHRGWxDtJLrGe/rXWNcaYaLQRa2SQFV4tl99te7pCyrJaO zE+zUM5jckpdgk4M0v1E4E5EyRh2Gwv0ozS+2C23faBCVKYN3dHUE3jnyp56imsIFk d6n+FChSBg7+tPYhu8retueG8dEdHMejTHSw1ufLgTay5mTpEXcZak2sLuEN0TmAbP +6PhndVSfiTLQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6CA316771F for ; Mon, 25 Aug 2025 14:40: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 YkykObcr93Jl for ; Mon, 25 Aug 2025 14:40:42 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756154440; bh=zp0B9EYopsMDRoS+2H1yrkl7v05mWMi2yt745GFxztE=; 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=sdgpLu1XBc5RPYapyaFh7vltUiBuLi2A2+oeESRaPw0ttpvgPwsSXIeyaAFIZtQau r68w63pLcpuxXBw6UqCil3cxf1Ss8FpcDnj1nFeRY+zpmPiF9admwP252t4RScD358 67a5wvDwZqQoxP9PElQkCOEXRaXp/ovRUjd0Tdt4Br8iQkLQ6w47tFj8mVUomXMfjP procFcIjc0YqXcDldl+j8zYYFg45N6cr1BilWZXKy100OSXYKnXUaklkmephcOYTEi Ee4XNmDmhZ4GIBK1LPdxVMyFnDlRgcjSOsVwX69XS7vX6OF067DP+Cp1pVR65xaopD TdkO326Lwj55Q== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8414867719 for ; Mon, 25 Aug 2025 14:40:40 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756154438; bh=11RyFqxk4SAmnJuvfjXtImB26gPzfqIaHKdMG/xEJXE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JbDSioCa8ZHScnsHlb9M8JRMyU+Fu9yhhS/g8EkeAuZ0S+glF1ewPZKOSvz4Pln+N WnvQTA/IqhQt+hoeNnpMU13BZHz25g6TyLoeUdLOoSpKc/4gsz2VdY3mH6Ae8XydCY AtFR/zg8u4LSz/UH0UNwho4kSUjh/LDf7jxTpWUZ90IGSDXCBZFAcM5aVgCoeDriQR DL7H8YFiaOWltuSvxxUh/XxPGM8M056jFmz07mYXQJzePhD/GWNZ5xmNwqk2T42XF5 XAA70O4P8NK0DXqtNxQUBn1AE8i07StYbINIfWoOcQuo4DUKuSOXMBQo0vDtW/UdAw hVbH5FS2ixe4w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4E2376778C; Mon, 25 Aug 2025 14:40:38 -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 oGn8EXcEakNz; Mon, 25 Aug 2025 14:40:38 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756154437; bh=bXp00nolNzDkWHF5QYpAPMi8oMPGz5t1WUaYtLGF13M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ArIkm3qV7AXudhkWfpxDQxiOnbJC9Fk7flI57OcdCooWiuCJeBpvegVAgAwGc5GQv OkRWXJIKrKr1HyBMO7JQg1daZenVWCQoImB4Otkk6bHO1L6pBre6wY3TMTUclivMjO EhzjGvs6VMhQRvNt16gajYXdvxLXefZ4M7VpWE7tG7QEmNRWQj9eXK4woL7pvISr3M Ns8USmRdO1UuPxdVyrdN7oXGY6hzrwA5g0tbXlZGiDaTLFwvrOKU011zrJ+o0UU1ey gWS7kMboWCqkXnCbnbX+TmpGZHXaF+WU/QZ5pgIWp5Qju1YfC1H457MOlfSKuATewW mo80q28VmZeNw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id C9F4567709; Mon, 25 Aug 2025 14:40:36 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 25 Aug 2025 14:40:18 -0600 Message-ID: <20250825144018.5.Ifebe6452f38904689e3e2142fc08a623131ed0de@changeid> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250825204022.3655799-1-sjg@u-boot.org> References: <20250825204022.3655799-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 2W7DPVQBYQQYHCSWRVE5SJR46MCYUZPL X-Message-ID-Hash: 2W7DPVQBYQQYHCSWRVE5SJR46MCYUZPL 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 5/6] input: Add a command to show mouse input 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 This reads mouse input and shows it on the terminal. It is useful for testing mice. Signed-off-by: Simon Glass --- cmd/Kconfig | 9 +++++++ cmd/Makefile | 1 + cmd/mouse.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 cmd/mouse.c diff --git a/cmd/Kconfig b/cmd/Kconfig index 882a4ee02e3..1a879d1fe90 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -2934,6 +2934,15 @@ config CMD_LOG maximum log level for emitting of records). It also provides access to a command used for testing the log system. +config CMD_MOUSE + bool "mouse - Show mouse input" + default y if MOUSE + help + This shows the data produced by a mouse. If a mouse device is + available records are printed when the mouse is moved. This can be + useful for checking that a mouse is working correctly within + U-Boot. + config CMD_TRACE bool "trace - Support tracing of function calls and timing" depends on TRACE diff --git a/cmd/Makefile b/cmd/Makefile index 407056b778b..2a9c39f18e2 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -128,6 +128,7 @@ obj-$(CONFIG_CMD_CLONE) += clone.o ifneq ($(CONFIG_CMD_NAND)$(CONFIG_CMD_SF),) obj-y += legacy-mtd-utils.o endif +obj-$(CONFIG_CMD_MOUSE) += mouse.o obj-$(CONFIG_CMD_MUX) += mux.o obj-$(CONFIG_CMD_NAND) += nand.o ifdef CONFIG_NET diff --git a/cmd/mouse.c b/cmd/mouse.c new file mode 100644 index 00000000000..94434afa0c4 --- /dev/null +++ b/cmd/mouse.c @@ -0,0 +1,70 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Mouse testing + * + * Copyright 2020 Google LLC + * Written by Simon Glass + */ + +#include +#include +#include +#include +#include + +static int do_mouse_dump(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + struct udevice *dev; + bool running; + int count; + int ret; + + ret = uclass_first_device_err(UCLASS_MOUSE, &dev); + if (ret) { + printf("Mouse not found (err=%d)\n", ret); + return CMD_RET_FAILURE; + } + for (running = true, count = 0; running;) { + struct mouse_event evt; + + ret = mouse_get_event(dev, &evt); + if (!ret) { + switch (evt.type) { + case MOUSE_EV_BUTTON: { + struct mouse_button *but = &evt.button; + + printf("button: button==%d, press=%d, clicks=%d, X=%d, Y=%d\n", + but->button, but->press_state, + but->clicks, but->x, but->y); + break; + } + case MOUSE_EV_MOTION: { + struct mouse_motion *motion = &evt.motion; + + printf("motion: Xrel=%d, Yrel=%d, X=%d, Y=%d, but=%d\n", + motion->xrel, motion->yrel, motion->x, + motion->y, motion->state); + break; + } + case MOUSE_EV_NULL: + break; + } + count++; + } else if (ret != -EAGAIN) { + return log_msg_ret("get_event", ret); + } + schedule(); + if (ctrlc()) + running = false; + } + printf("%d events received\n", count); + + return 0; +} + +static char mouse_help_text[] = + "dump - Dump input from a mouse"; + +U_BOOT_CMD_WITH_SUBCMDS(mouse, "Mouse input", mouse_help_text, + U_BOOT_SUBCMD_MKENT(dump, 1, 1, do_mouse_dump));