NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/60918: Keyboard modifier keys are not checked correctly when sent simultaneously



"Michael van Elst via gnats" <gnats-admin%NetBSD.org@localhost> writes:

>  Another possibility is to generate events for the modifier keycodes
>  224..231 first, or by simply scanning the keycodes in reverse order.

I've tested this, and scanning in reverse order does fix it; see the
patch below.

-Phil

From 7b573278d25787b4028d37bce780d815a09345b2 Mon Sep 17 00:00:00 2001
From: Phil Hagelberg <phil%hagelb.org@localhost>
Subject: [PATCH] Reverse order of keys added in ukbd_decode.

If a single USB report is received that sets both the shift key and A
at the same time, it should be interpreted as A, but it currently
results in lower-case a, because the A key is handled first, and then
the shift key is handled.

Reversing the order is a little cheesy, but it ensures that the shift
key is handled first.
---
 sys/dev/usb/ukbd.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sys/dev/usb/ukbd.c b/sys/dev/usb/ukbd.c
index 4c81c78f5834..d646abe2b231 100644
--- a/sys/dev/usb/ukbd.c
+++ b/sys/dev/usb/ukbd.c
@@ -821,7 +821,9 @@ ukbd_decode(struct ukbd_softc *sc, struct ukbd_data *ud)
 		ukbd_translate_keycodes(sc, ud, trtab_apple_iso);

 	nkeys = 0;
-	for (i = 0; i < MAXKEYS; i++) {
+	/* traverse in reverse order so that modifiers are processed first since
+	 * they can affect the other keys. */
+	for (i = MAXKEYS - 1; i >= 0; i--) {
 #ifdef GDIUM_KEYBOARD_HACK
 			if (sc->sc_flags & FLAG_GDIUM_FN && i == 0x82) {
 				if (isset(ud->keys, i))
--
2.55.0

Attachment: signature.asc
Description: PGP signature



Home | Main Index | Thread Index | Old Index