svn commit: r359559 - stable/11/sys/dev/usb/input

Hans Petter Selasky hselasky at FreeBSD.org
Thu Apr 2 07:42:47 UTC 2020


Author: hselasky
Date: Thu Apr  2 07:42:29 2020
New Revision: 359559
URL: https://svnweb.freebsd.org/changeset/base/359559

Log:
  MFC r359439:
  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 at egr.msu.edu>
  PR:		224592
  PR:		233884
  Sponsored by:	Mellanox Technologies

Modified:
  stable/11/sys/dev/usb/input/ukbd.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/usb/input/ukbd.c
==============================================================================
--- stable/11/sys/dev/usb/input/ukbd.c	Thu Apr  2 07:40:57 2020	(r359558)
+++ stable/11/sys/dev/usb/input/ukbd.c	Thu Apr  2 07:42:29 2020	(r359559)
@@ -520,6 +520,21 @@ ukbd_interrupt(struct ukbd_softc *sc)
 
 	UKBD_CTX_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);
@@ -530,6 +545,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);
@@ -539,9 +556,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;


More information about the svn-src-all mailing list