From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 908D5C433EF for ; Fri, 17 Dec 2021 16:38:37 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AA4C68369E; Fri, 17 Dec 2021 17:38:09 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="BHg2rAYx"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8268283007; Fri, 17 Dec 2021 17:37:42 +0100 (CET) Received: from mail-vk1-xa35.google.com (mail-vk1-xa35.google.com [IPv6:2607:f8b0:4864:20::a35]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A27468314C for ; Fri, 17 Dec 2021 17:37:30 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@google.com Received: by mail-vk1-xa35.google.com with SMTP id m185so1905140vkm.5 for ; Fri, 17 Dec 2021 08:37:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=6COKoQJhel/88ahDkaDmIB+xRRDaJw9chGn6UT0w3RU=; b=BHg2rAYxLL9+yzEda0wI+kTJr+snCFTnA1YjkQi1fFvjx0S75PU5X/6iBGEaggkBAM rokwWadUJf76iWr0U/KbL8NAQ22PTzkcmR495Q5rSaicgiQpc+r51oZOLux78MSphJAX e+aXqFwS3bo3BrJb2C5ihQOovn2WHEWmqqoVA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6COKoQJhel/88ahDkaDmIB+xRRDaJw9chGn6UT0w3RU=; b=Y+zH71i3ZyE98O+RqxYmgBEvJwaBYAzBBO5a4Bu2bq3+aIczgfLYmNc3JXBIC+GYQP I+a5lAQ+b1UEIIgZoAhfxK6TRKY8ifkBL1J+BB4YFUD9/uYSYwmlPeA+geBScSuTVKnb +HmZ25Jm/vWuEyStpfQcAL2Z1t30GDJfVOAbJ/ruwupknyIM/DRcuCKW5E2EM3Rs9PBZ 8AVdvpjwkp6+2FUfHFNX3E0HSSCy1YyCMINWGSqrnu2xyG+Tn94oHjox9v9ZdJALQ+EP 8NMzyVqh4jMkNiarqDIRCsn9dNhouzisSEFrKbUFtqNKCG6XLtsC+HlsgWwFpd34lisB w7mA== X-Gm-Message-State: AOAM533vyKYJQ64BXx7GtmRu632nHwNAdrW1SIWgvkt1xBA60kzBvLYZ LIN/JAohLzV2z66XNp6JfOo7c86EjIKJDjoPWFgTJg== X-Google-Smtp-Source: ABdhPJx0vGdcVgXpkfpuVwOKkAtNFEkNRGja5kd+MQDIqV7TXKhx2Xem4ehpMwqlbA71naKv4Zphpc87+a60QAvN2MU= X-Received: by 2002:a1f:2bc7:: with SMTP id r190mr1666555vkr.16.1639759049113; Fri, 17 Dec 2021 08:37:29 -0800 (PST) MIME-Version: 1.0 References: <20211204155657.2913911-1-sjg@chromium.org> <20211204155657.2913911-2-sjg@chromium.org> <28446e66-5e90-f8cc-a2a8-9de1d132bc3a@gmx.de> In-Reply-To: <28446e66-5e90-f8cc-a2a8-9de1d132bc3a@gmx.de> From: Simon Glass Date: Fri, 17 Dec 2021 09:37:17 -0700 Message-ID: Subject: Re: [PATCH v5 05/28] efi: serial: Support arrow keys To: Heinrich Schuchardt Cc: Ilias Apalodimas , Christian Melki , Bin Meng , Tom Rini , Alexander Graf , U-Boot Mailing List Content-Type: text/plain; charset="UTF-8" X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Hi Heinrich, On Thu, 9 Dec 2021 at 12:44, Heinrich Schuchardt wrote: > > On 12/4/21 07:56, Simon Glass wrote: > > At present only the backspace key is supported in U-Boot, when running as > > an EFI app. Add support for arrows, home and end as well, to make the CLI > > more friendly. > > > > Signed-off-by: Simon Glass > > --- > > > > (no changes since v1) > > > > drivers/serial/serial_efi.c | 11 +++++++++-- > > 1 file changed, 9 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/serial/serial_efi.c b/drivers/serial/serial_efi.c > > index 33ddbd6080c..0067576389d 100644 > > --- a/drivers/serial/serial_efi.c > > +++ b/drivers/serial/serial_efi.c > > @@ -24,6 +24,9 @@ struct serial_efi_priv { > > bool have_key; > > }; > > > > +/* Convert a lower-case character to its ctrl-char equivalent */ > > +#define CTL_CH(c) ((c) - 'a' + 1) > > + > > int serial_efi_setbrg(struct udevice *dev, int baudrate) > > { > > return 0; > > @@ -49,6 +52,7 @@ static int serial_efi_get_key(struct serial_efi_priv *priv) > > static int serial_efi_getc(struct udevice *dev) > > { > > struct serial_efi_priv *priv = dev_get_priv(dev); > > + char conv_scan[10] = {0, 'p', 'n', 'f', 'b', 'a', 'e', 0, 8}; > > int ret, ch; > > > > ret = serial_efi_get_key(priv); > > @@ -63,8 +67,11 @@ static int serial_efi_getc(struct udevice *dev) > > * key scan code of 8. Handle this so that backspace works correctly > > * in the U-Boot command line. > > */ > > - if (!ch && priv->key.scan_code == 8) > > - ch = 8; > > + if (!ch && priv->key.scan_code < sizeof(conv_scan)) { > > + ch = conv_scan[priv->key.scan_code]; > > + if (ch >= 'a') > > + ch -= 'a' - 1; > > This is not what a serial console would use in Linux. Just try U-Boot's > conitrace command. If you use the following, we get compatibility with > the rest of U-Boot: > > 1b 5b 32 7e - insert > 1b 5b 33 7e - delete > 1b 5b 35 7e - page up > 1b 5b 36 7e - page down > 1b 5b 41 - up > 1b 5b 42 - down > 1b 5b 43 - right > 1b 5b 44 - left > 1b 5b 46 - end > 1b 5b 48 - home That's more complicated since it requires the serial driver to convert one character into multiple. We can always add it later if needed. But this does command-line history, etc. working in the app. Regards, Simon