From: Yamasaki Yuu Subject: [PATCH 5/7] hidkbd: don't claim the console when another keyboard already has it To: tech@openbsd.org Date: Wed, 11 Nov 2026 11:46:50 +0900 Add wskbd_cnattached() to tell whether a console keyboard has been attached, and check it in hidkbd(4). When more than one keyboard driver is a console candidate, as with hvkbd(4) on amd64 without pckbc(4), the first keyboard to attach wins. A USB keyboard showing up later must not call wskbd_cnattach() a second time. --- sys/dev/hid/hidkbd.c | 3 ++- sys/dev/wscons/wskbd.c | 6 ++++++ sys/dev/wscons/wskbdvar.h | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git sys/dev/hid/hidkbd.c sys/dev/hid/hidkbd.c index 53fd6a53fd5..cf20151cbf5 100644 --- sys/dev/hid/hidkbd.c +++ sys/dev/hid/hidkbd.c @@ -277,7 +277,8 @@ hidkbd_attach(struct device *self, struct hidkbd *kbd, int console, * but what else can we really do? */ if (console) { - kbd->sc_console_keyboard = hidkbd_is_console; + kbd->sc_console_keyboard = hidkbd_is_console && + !wskbd_cnattached(); /* Don't let any other keyboard have it. */ hidkbd_is_console = 0; } diff --git sys/dev/wscons/wskbd.c sys/dev/wscons/wskbd.c index d99032b0adc..75ebc8d8f9d 100644 --- sys/dev/wscons/wskbd.c +++ sys/dev/wscons/wskbd.c @@ -551,6 +551,12 @@ wskbd_cnattach(const struct wskbd_consops *consops, void *conscookie, wskbd_console_initted = 1; } +int +wskbd_cnattached(void) +{ + return (wskbd_console_initted); +} + void wskbd_cndetach(void) { diff --git sys/dev/wscons/wskbdvar.h sys/dev/wscons/wskbdvar.h index 557a816c743..706b19b9007 100644 --- sys/dev/wscons/wskbdvar.h +++ sys/dev/wscons/wskbdvar.h @@ -87,6 +87,7 @@ struct wskbddev_attach_args { */ void wskbd_cnattach(const struct wskbd_consops *, void *, const struct wskbd_mapdata *); +int wskbd_cnattached(void); void wskbd_cndetach(void); int wskbddevprint(void *, const char *);