All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ps2: Don't send key release event for Lang1, Lang2 keys
@ 2023-02-27 17:33 Ross Lagerwall via
  2023-02-27 17:42 ` Daniel P. Berrangé
  0 siblings, 1 reply; 3+ messages in thread
From: Ross Lagerwall via @ 2023-02-27 17:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: Daniel P . Berrangé, Ross Lagerwall

The scancodes for the Lang1 and Lang2 keys (i.e. Hangeul, Hanja) are
special since they already have the 0x80 bit set which is commonly used
to indicate a key release in AT set 1. Reportedly, real hardware does
not send a key release scancode. So, skip sending a release for these
keys. This ensures that Windows behaves correctly and interprets it as a
single keypress rather than two consecutive keypresses.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
---
 hw/input/ps2.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/hw/input/ps2.c b/hw/input/ps2.c
index 3253ab6a92..45af76a837 100644
--- a/hw/input/ps2.c
+++ b/hw/input/ps2.c
@@ -402,6 +402,9 @@ static void ps2_keyboard_event(DeviceState *dev, QemuConsole *src,
                     ps2_put_keycode(s, 0xaa);
                 }
             }
+        } else if ((qcode == Q_KEY_CODE_LANG1 || qcode == Q_KEY_CODE_LANG2)
+                   && !key->down) {
+            /* Ignore release for these keys */
         } else {
             if (qcode < qemu_input_map_qcode_to_atset1_len) {
                 keycode = qemu_input_map_qcode_to_atset1[qcode];
@@ -497,6 +500,9 @@ static void ps2_keyboard_event(DeviceState *dev, QemuConsole *src,
                     ps2_put_keycode(s, 0x12);
                 }
             }
+        } else if ((qcode == Q_KEY_CODE_LANG1 || qcode == Q_KEY_CODE_LANG2) &&
+                   !key->down) {
+            /* Ignore release for these keys */
         } else {
             if (qcode < qemu_input_map_qcode_to_atset2_len) {
                 keycode = qemu_input_map_qcode_to_atset2[qcode];
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ps2: Don't send key release event for Lang1, Lang2 keys
  2023-02-27 17:33 [PATCH] ps2: Don't send key release event for Lang1, Lang2 keys Ross Lagerwall via
@ 2023-02-27 17:42 ` Daniel P. Berrangé
  2023-03-07 10:20   ` Daniel P. Berrangé
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel P. Berrangé @ 2023-02-27 17:42 UTC (permalink / raw)
  To: Ross Lagerwall; +Cc: qemu-devel

On Mon, Feb 27, 2023 at 05:33:08PM +0000, Ross Lagerwall wrote:
> The scancodes for the Lang1 and Lang2 keys (i.e. Hangeul, Hanja) are
> special since they already have the 0x80 bit set which is commonly used
> to indicate a key release in AT set 1. Reportedly, real hardware does
> not send a key release scancode. So, skip sending a release for these
> keys. This ensures that Windows behaves correctly and interprets it as a
> single keypress rather than two consecutive keypresses.

A reference for this assertion would be:

  https://www.win.tue.nl/~aeb/linux/kbd/scancodes-9.html

   "The Korean keyboard has two keys, the Korean/Chinese and
    the Korean/English toggles, that generate scancodes f1
    and f2 (respectively) when pressed, and nothing when
    released."

> 
> Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
> ---
>  hw/input/ps2.c | 6 ++++++
>  1 file changed, 6 insertions(+)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>

> 
> diff --git a/hw/input/ps2.c b/hw/input/ps2.c
> index 3253ab6a92..45af76a837 100644
> --- a/hw/input/ps2.c
> +++ b/hw/input/ps2.c
> @@ -402,6 +402,9 @@ static void ps2_keyboard_event(DeviceState *dev, QemuConsole *src,
>                      ps2_put_keycode(s, 0xaa);
>                  }
>              }
> +        } else if ((qcode == Q_KEY_CODE_LANG1 || qcode == Q_KEY_CODE_LANG2)
> +                   && !key->down) {
> +            /* Ignore release for these keys */
>          } else {
>              if (qcode < qemu_input_map_qcode_to_atset1_len) {
>                  keycode = qemu_input_map_qcode_to_atset1[qcode];
> @@ -497,6 +500,9 @@ static void ps2_keyboard_event(DeviceState *dev, QemuConsole *src,
>                      ps2_put_keycode(s, 0x12);
>                  }
>              }
> +        } else if ((qcode == Q_KEY_CODE_LANG1 || qcode == Q_KEY_CODE_LANG2) &&
> +                   !key->down) {
> +            /* Ignore release for these keys */
>          } else {
>              if (qcode < qemu_input_map_qcode_to_atset2_len) {
>                  keycode = qemu_input_map_qcode_to_atset2[qcode];
> -- 
> 2.31.1
> 

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ps2: Don't send key release event for Lang1, Lang2 keys
  2023-02-27 17:42 ` Daniel P. Berrangé
@ 2023-03-07 10:20   ` Daniel P. Berrangé
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel P. Berrangé @ 2023-03-07 10:20 UTC (permalink / raw)
  To: Ross Lagerwall, qemu-devel

We don't have any nominated maintainer for this ps2.c file. Unless
anyone objects, i'll pick this patch up into my next set of misc
fixes to be sent for this release.

On Mon, Feb 27, 2023 at 05:42:34PM +0000, Daniel P. Berrangé wrote:
> On Mon, Feb 27, 2023 at 05:33:08PM +0000, Ross Lagerwall wrote:
> > The scancodes for the Lang1 and Lang2 keys (i.e. Hangeul, Hanja) are
> > special since they already have the 0x80 bit set which is commonly used
> > to indicate a key release in AT set 1. Reportedly, real hardware does
> > not send a key release scancode. So, skip sending a release for these
> > keys. This ensures that Windows behaves correctly and interprets it as a
> > single keypress rather than two consecutive keypresses.
> 
> A reference for this assertion would be:
> 
>   https://www.win.tue.nl/~aeb/linux/kbd/scancodes-9.html
> 
>    "The Korean keyboard has two keys, the Korean/Chinese and
>     the Korean/English toggles, that generate scancodes f1
>     and f2 (respectively) when pressed, and nothing when
>     released."
> 
> > 
> > Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
> > ---
> >  hw/input/ps2.c | 6 ++++++
> >  1 file changed, 6 insertions(+)
> 
> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
> 
> > 
> > diff --git a/hw/input/ps2.c b/hw/input/ps2.c
> > index 3253ab6a92..45af76a837 100644
> > --- a/hw/input/ps2.c
> > +++ b/hw/input/ps2.c
> > @@ -402,6 +402,9 @@ static void ps2_keyboard_event(DeviceState *dev, QemuConsole *src,
> >                      ps2_put_keycode(s, 0xaa);
> >                  }
> >              }
> > +        } else if ((qcode == Q_KEY_CODE_LANG1 || qcode == Q_KEY_CODE_LANG2)
> > +                   && !key->down) {
> > +            /* Ignore release for these keys */
> >          } else {
> >              if (qcode < qemu_input_map_qcode_to_atset1_len) {
> >                  keycode = qemu_input_map_qcode_to_atset1[qcode];
> > @@ -497,6 +500,9 @@ static void ps2_keyboard_event(DeviceState *dev, QemuConsole *src,
> >                      ps2_put_keycode(s, 0x12);
> >                  }
> >              }
> > +        } else if ((qcode == Q_KEY_CODE_LANG1 || qcode == Q_KEY_CODE_LANG2) &&
> > +                   !key->down) {
> > +            /* Ignore release for these keys */
> >          } else {
> >              if (qcode < qemu_input_map_qcode_to_atset2_len) {
> >                  keycode = qemu_input_map_qcode_to_atset2[qcode];
> > -- 
> > 2.31.1
> > 
> 
> With regards,
> Daniel
> -- 
> |: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
> |: https://libvirt.org         -o-            https://fstop138.berrange.com :|
> |: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
> 
> 

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-03-07 10:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-27 17:33 [PATCH] ps2: Don't send key release event for Lang1, Lang2 keys Ross Lagerwall via
2023-02-27 17:42 ` Daniel P. Berrangé
2023-03-07 10:20   ` Daniel P. Berrangé

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.