From patchwork Mon Oct 6 16:54:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 511 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=1759769731; bh=sIXKeMJwSsgWLw2CLCSevkAC+FzplGIrM6W0j+dQihE=; 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=apyQmpW+SmtPaCfxJ2BFY5NQ41ZCmSRYrW8eDZqW3aobtpWiRV70Hchui6hc3nM20 K/BA4WsAHzhGQOFp0MWu0Nbh/i7UEfmNgYry0Lbia2eu/7WMvOymsbNqmS6NHbdsMi XfwPKUvEdUEqV0gFYCxHxSqG3V5qhl3Ps2uow8/oqtu+sU9x6chRxqDLFypuZqVDli MBJgJ7HsoDeUvlGzfKXAuNI0ERGStSgmuuBbXB7YA0hJf95YGmoa5bZ18uYl+5HwH7 GziD56Yagu5P3uOmKnLys5vBQwq9JILysjOtTJCfQIwHAowVTtFx7feZYhNVSQNn64 P9JQFxsv/ZGNg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B7C5967F8E for ; Mon, 6 Oct 2025 10:55:31 -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 O0LpH-3dwpLA for ; Mon, 6 Oct 2025 10:55:31 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759769731; bh=sIXKeMJwSsgWLw2CLCSevkAC+FzplGIrM6W0j+dQihE=; 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=apyQmpW+SmtPaCfxJ2BFY5NQ41ZCmSRYrW8eDZqW3aobtpWiRV70Hchui6hc3nM20 K/BA4WsAHzhGQOFp0MWu0Nbh/i7UEfmNgYry0Lbia2eu/7WMvOymsbNqmS6NHbdsMi XfwPKUvEdUEqV0gFYCxHxSqG3V5qhl3Ps2uow8/oqtu+sU9x6chRxqDLFypuZqVDli MBJgJ7HsoDeUvlGzfKXAuNI0ERGStSgmuuBbXB7YA0hJf95YGmoa5bZ18uYl+5HwH7 GziD56Yagu5P3uOmKnLys5vBQwq9JILysjOtTJCfQIwHAowVTtFx7feZYhNVSQNn64 P9JQFxsv/ZGNg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A5DA967F1D for ; Mon, 6 Oct 2025 10:55:31 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759769730; bh=yYy5O038dgDJTBdSjeAi0X93zDga+y30bGz62ysUZlY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=huX8Yvum5aTsm5FjNNpAHV7HMRKibLAcf3kD9AtTnGlsJv7lWbs4bXcMt+4UGd/MN ELXK+iP9JDpu4JlpT2OQfdd9COmjZoQQAPuVXbJ2ceJYe8vpTOtSlrLtdRWn6zNfWd 26d/aI6D9u3FUkOcGc3QhSr3kK8+hhqHg/nLsX7lFzef/8HAd3bEcS2FIABC13yKaH oQFU7HKX/jpvIj96If57bGwfkp7EAqBua3KilfVy7w2TlQch2CRgjOicB9Xx3Eter6 G0BVJ+7xjc3Nt6yPgZO5802ttuo74IRzFEBdJXIL8rEcUoVuKuJAlHX5VeYzQkflWz Rt2BC9j57g15g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4141567F03; Mon, 6 Oct 2025 10:55:30 -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 gARJz5WnvNKa; Mon, 6 Oct 2025 10:55:30 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759769726; bh=KSqKZWksYfN9qz55T7b5qHqUmDyH/SOmN8bGsYV4hFI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s/LnBiFwWJ6II1b/geLzWR3a0YSprd05u01RUqHl07H1z0tjDbZW0q2bZ3yr4EOpd 2hJ2BYxy5mlwEZdaxmxTaRNiQEdYgd/MdVHGcwID4Sj4mdHNB6/XgclUVD+ZO3SBeq sehWP3UZmrqkjOEq/hc3lkxrvmSh+WGh0SMJMeM+fP2vxnGSQEiV8WA6qnKn3cxrid 1RJivTPucwNRECM5bOrFne9WHgV/vmnIh6qIMUb7e+WDT4NwrH7vP9dhH1Gn5PJQx5 T5LEZMA8vmjZyF5jYEP9KvDk3JwS8ct6EttuTCKOVn+505FOeM+ibULdkZ7AeUlfgU SxT0ypo1aNodg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id E2FEA67EE4; Mon, 6 Oct 2025 10:55:25 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 6 Oct 2025 10:54:40 -0600 Message-ID: <20251006165452.1675349-9-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251006165452.1675349-1-sjg@u-boot.org> References: <20251006165452.1675349-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: K37CERKC57B33OA6SGQOV4RWFIONSKIS X-Message-ID-Hash: K37CERKC57B33OA6SGQOV4RWFIONSKIS 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 08/14] expo: Show the mouse when enabled 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 When the mouse is enabled, show it at its new position each time the expo is rendered. Signed-off-by: Simon Glass --- boot/expo.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/expo.h | 2 ++ 2 files changed, 61 insertions(+) diff --git a/boot/expo.c b/boot/expo.c index 42109b88e72..295b779dce8 100644 --- a/boot/expo.c +++ b/boot/expo.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -249,6 +250,56 @@ int expo_arrange(struct expo *exp) return 0; } +static int update_mouse_position(struct expo *exp) +{ + struct mouse_event event; + int ret; + + if (!IS_ENABLED(CONFIG_MOUSE) || !exp->mouse_enabled) + return 0; + + /* Process all available mouse events to get latest position */ + while (1) { + ret = mouse_get_event(exp->mouse, &event); + if (ret) + break; /* No more events available */ + + if (event.type == MOUSE_EV_MOTION) { + exp->mouse_pos.x = event.motion.x; + exp->mouse_pos.y = event.motion.y; + } else if (event.type == MOUSE_EV_BUTTON) { + exp->mouse_pos.x = event.button.x; + exp->mouse_pos.y = event.button.y; + } + } + + return 0; +} + +/** + * render_mouse_pointer() - Render the mouse pointer if enabled and visible + * + * @exp: Expo containing mouse state + * Return: 0 if OK, -ve on error + */ +static int render_mouse_pointer(struct expo *exp) +{ + struct udevice *dev = exp->display; + int ret; + + if (!IS_ENABLED(CONFIG_MOUSE) || !exp->mouse_enabled || !exp->mouse_ptr) + return 0; + + /* Use white (0xffffff) as transparent color */ + ret = video_bmp_displaya(dev, map_to_sysmem(exp->mouse_ptr), + exp->mouse_pos.x, exp->mouse_pos.y, false, true, + 0xffffff); + if (ret) + log_debug("Failed to display mouse pointer: %d\n", ret); + + return 0; +} + int expo_render(struct expo *exp) { struct udevice *dev = exp->display; @@ -274,6 +325,11 @@ int expo_render(struct expo *exp) return log_msg_ret("ren", ret); } + /* Render mouse pointer if mouse is enabled */ + ret = render_mouse_pointer(exp); + if (ret) + return log_msg_ret("mou", ret); + video_sync(dev, true); return scn ? 0 : -ECHILD; @@ -441,6 +497,9 @@ int expo_poll(struct expo *exp, struct expo_action *act) { int key, ret = -EAGAIN; + /* update mouse position if mouse is enabled */ + update_mouse_position(exp); + key = poll_keys(exp); if (key != -EAGAIN) { ret = expo_send_key(exp, key); diff --git a/include/expo.h b/include/expo.h index 3250ecee40e..622088f395b 100644 --- a/include/expo.h +++ b/include/expo.h @@ -134,6 +134,7 @@ struct expo_theme { * @mouse_enabled: true if the mouse is enabled * @mouse_ptr: Pointer to mouse pointer image data (BMP format) * @mouse_size: Size of mouse pointer (width and height in pixels) + * @mouse_pos: Current mouse position * @priv: Private data for the controller * @done: Indicates that a cedit session is complete and the user has quit * @save: Indicates that cedit data should be saved, rather than discarded @@ -158,6 +159,7 @@ struct expo { bool mouse_enabled; const void *mouse_ptr; struct vid_size mouse_size; + struct vid_pos mouse_pos; void *priv; bool done; bool save;