Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 30 Mar 2020 15:29:39 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r359439 - head/sys/dev/usb/input
Message-ID:  <202003301529.02UFTd1e098269@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Mon Mar 30 15:29:39 2020
New Revision: 359439
URL: https://svnweb.freebsd.org/changeset/base/359439

Log:
  Evaluate modifier keys before the regular keys, so that if a modifier
  key is pressed at the same time as a regular key, that means key with
  modifier is output. Some automated USB keyboards like Yubikeys need this.
  
  This fixes a regression issue after r357861.
  
  Reported by:	Adam McDougall <mcdouga9@egr.msu.edu>
  PR:		224592
  PR:		233884
  MFC after:	3 days
  Sponsored by:	Mellanox Technologies

Modified:
  head/sys/dev/usb/input/ukbd.c

Modified: head/sys/dev/usb/input/ukbd.c
==============================================================================
--- head/sys/dev/usb/input/ukbd.c	Mon Mar 30 14:24:03 2020	(r359438)
+++ head/sys/dev/usb/input/ukbd.c	Mon Mar 30 15:29:39 2020	(r359439)
@@ -499,6 +499,21 @@ ukbd_interrupt(struct ukbd_softc *sc)
 
 	UKBD_LOCK_ASSERT();
 
+	/* Check for modifier key changes first */
+	for (key = 0xe0; key != 0xe8; key++) {
+		const uint64_t mask = 1ULL << (key % 64);
+		const uint64_t delta =
+		    sc->sc_odata.bitmap[key / 64] ^
+		    sc->sc_ndata.bitmap[key / 64];
+
+		if (delta & mask) {
+			if (sc->sc_odata.bitmap[key / 64] & mask)
+				ukbd_put_key(sc, key | KEY_RELEASE);
+			else
+				ukbd_put_key(sc, key | KEY_PRESS);
+		}
+	}
+
 	/* Check for key changes */
 	for (key = 0; key != UKBD_NKEYCODE; key++) {
 		const uint64_t mask = 1ULL << (key % 64);
@@ -509,6 +524,8 @@ ukbd_interrupt(struct ukbd_softc *sc)
 		if (mask == 1 && delta == 0) {
 			key += 63;
 			continue;	/* skip empty areas */
+		} else if (ukbd_is_modifier_key(key)) {
+			continue;
 		} else if (delta & mask) {
 			if (sc->sc_odata.bitmap[key / 64] & mask) {
 				ukbd_put_key(sc, key | KEY_RELEASE);
@@ -518,9 +535,6 @@ ukbd_interrupt(struct ukbd_softc *sc)
 					sc->sc_repeat_key = 0;
 			} else {
 				ukbd_put_key(sc, key | KEY_PRESS);
-
-				if (ukbd_is_modifier_key(key))
-					continue;
 
 				sc->sc_co_basetime = sbinuptime();
 				sc->sc_delay = sc->sc_kbd.kb_delay1;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202003301529.02UFTd1e098269>