From patchwork Fri Jan 30 03:58:31 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1784 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org Authentication-Results: mail.u-boot.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=GeLgeJM4; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 401EC697E8 for ; Thu, 29 Jan 2026 20:59:32 -0700 (MST) 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 JNbzimqTNHBN for ; Thu, 29 Jan 2026 20:59:32 -0700 (MST) Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 33BD4697DD for ; Thu, 29 Jan 2026 20:59:30 -0700 (MST) Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AABC0697C8 for ; Thu, 29 Jan 2026 20:59:27 -0700 (MST) 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 PbHzyptYH1QV for ; Thu, 29 Jan 2026 20:59:27 -0700 (MST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.160.54; helo=mail-oa1-f54.google.com; envelope-from=sjg@chromium.org; receiver=u-boot.org Received: from mail-oa1-f54.google.com (mail-oa1-f54.google.com [209.85.160.54]) by mail.u-boot.org (Postfix) with ESMTPS id 2E10869738 for ; Thu, 29 Jan 2026 20:59:22 -0700 (MST) Received: by mail-oa1-f54.google.com with SMTP id 586e51a60fabf-4094fbd1808so696649fac.1 for ; Thu, 29 Jan 2026 19:59:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1769745561; x=1770350361; darn=u-boot.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=E0CEEEc36T3w2clnLtK/xgCAr/WT5NGErmazRO316b8=; b=GeLgeJM47576YVSWcHG3LFvOvAgm3QLhjod6g3R1twqKOItkBT6pqBTkM3j5sZ+KPj +OkNkSp+Meet8E5rsFUrDGwNUec26mae6K0p11Ec39stzeWgCeflD87TaxZr7k8kf1cA xASg9cYHCqfUtRWt6r9gC+RKw9OiQdYYarGoQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769745561; x=1770350361; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=E0CEEEc36T3w2clnLtK/xgCAr/WT5NGErmazRO316b8=; b=W070bxCUH3+MURUUA8xqz8W+GsAVLTwOHxpUM5VyniGGwb67mHyFE1Yq/omQ+fIn2P 4zNOWOtg6PlgZ/FXLw+xOhYL/DxU7y1FoqPzzmkntZFXP19Dnc2gRwSzDcSrf04uE4Fk fpNaubpDUzCpC5PpQcAaaY+jB1Y3coTEsvhg976YfMhAfAgjb0RXqKAi4uG2j9XjmjxD kG0WdlzdNSj1EQviVGM3Xv1qu7axJlEgEBQaKufTOrWrC9e0rGvfelDKfISGlWRaLzY5 Hz8NlF8eyuUecdNCuMTCg96hiGhjiI8J0OMiC5KgM4iwULvO45LSVw06T7eob+Z10DK8 vcMQ== X-Gm-Message-State: AOJu0Yw4DMaes3kpFXhhrFTsA+gnGjx/tl7wCX5B+Bi9lG7zykI58Uyw YG0mvmgskGWPsOItjZUeYV+h0K7WNuUogK+OPGUptubahJV+ddBa+mb0EmNPTCUIKOlPIpUmWpf Kqn2uiw== X-Gm-Gg: AZuq6aIafJxAlDasMvp5dbymAbuCu+m4n8s6QlY44P/yzJEApNE5lMw+R+5+x+Jdrww zW5EhYSIHSIJ0m4LXVojMviUY9OjQd19+ezK8Edloyv1joWsHnHK/U4IwB1EKwqupStPGZIC4SL Aazshv5uyecbUcnLSCYqnVxjBxLdeq4ovVvLMEtwu3KHJvdFYzT6V2SAQqYv/kYRh+NuUGj9BeZ rjaJOfbfYapXa18PoVmsczhzzAXwEk/ltMjHg+IohFYBKHvdYGjOOXvW1ftWhYFKH9pY7pM/FPN SX96Ruj7igULT1RB4OA6LVpPcWJmjoTAyKrD1nbHDZqJx+PanJpVfx7EXm1kMTBTT4fTiCXm1Qz 1HAA3Z9i32cptjWaxe4wjKmoOFM4ICq6WcyvRZlaQR0DABsXGlZMA7oS3IODoZDNaWUTkBHWUrS PD5AyG8nUmkxuq589F X-Received: by 2002:a05:6820:1621:b0:663:12f:214d with SMTP id 006d021491bc7-6630f34f006mr802603eaf.27.1769745560677; Thu, 29 Jan 2026 19:59:20 -0800 (PST) Received: from chromium.org ([73.34.74.121]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-662f9a4e491sm4128687eaf.16.2026.01.29.19.59.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jan 2026 19:59:19 -0800 (PST) From: Simon Glass X-Google-Original-From: Simon Glass To: U-Boot Concept Date: Thu, 29 Jan 2026 20:58:31 -0700 Message-ID: <20260130035849.3580212-9-simon.glass@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260130035849.3580212-1-simon.glass@canonical.com> References: <20260130035849.3580212-1-simon.glass@canonical.com> MIME-Version: 1.0 Message-ID-Hash: RSCLIAIHSF7VSFNKTYVZATYBBIBESNO2 X-Message-ID-Hash: RSCLIAIHSF7VSFNKTYVZATYBBIBESNO2 X-MailFrom: sjg@chromium.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: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 08/19] input: Add Ctrl+arrow key support for sandbox SDL console List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Track the Ctrl modifier state in the input driver and generate the appropriate escape sequences (ESC [ 1 ; 5 D/C) when Ctrl+Left or Ctrl+Right arrow keys are pressed. This enables word navigation in the sandbox SDL console. There are no tests for this feature. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- drivers/input/input.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/input/input.c b/drivers/input/input.c index 3f146fb07e6..5206d6f68d6 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -28,6 +28,9 @@ enum { /* Special flag ORed with key code to indicate release */ KEY_RELEASE = 1 << 15, KEY_MASK = 0xfff, + + /* Modifier bits for config->modifiers */ + MOD_CTRL = 1 << 0, }; /* @@ -428,6 +431,31 @@ static int input_keycode_to_ansi364(struct input_config *config, int ch_count; int i; + /* Handle Ctrl+arrow keys for word navigation */ + if (config->modifiers & MOD_CTRL) { + const char *seq = NULL; + + switch (keycode) { + case KEY_LEFT: + seq = "[1;5D"; /* Ctrl+Left: backward-word */ + break; + case KEY_RIGHT: + seq = "[1;5C"; /* Ctrl+Right: forward-word */ + break; + } + if (seq) { + ch_count = 0; + output_ch[ch_count++] = 0x1b; + while (*seq) { + if (ch_count < max_chars) + output_ch[ch_count] = *seq; + ch_count++; + seq++; + } + return ch_count; + } + } + for (i = ch_count = 0; i < ARRAY_SIZE(kbd_to_ansi364); i++) { if (keycode != kbd_to_ansi364[i].kbd_scan_code) continue; @@ -483,6 +511,9 @@ static int input_keycodes_to_ascii(struct input_config *config, table = process_modifier(config, key, keycode[i] & KEY_RELEASE); } + /* Track Ctrl state for special key handling */ + if (key == KEY_LEFTCTRL || key == KEY_RIGHTCTRL) + config->modifiers |= MOD_CTRL; } /* Start conversion by looking for the first new keycode (by same). */