on the one hand. there's no reason not to accept input from multiple keyboards at the same time (we already do if one is usb and one is ps/2), but on the other hand, scan codes shouldn't get interleaved. at least any more than they have to be. a longer term solution will be to keep the keyboards distinct down into the kbd driver. Reference: /n/atom/patch/applied/kbinmultikbd Date: Thu Mar 27 07:01:38 CET 2014 Signed-off-by: quanstro@quanstro.net --- /sys/src/nix/port/devkbin.c Thu Mar 27 06:59:42 2014 +++ /sys/src/nix/port/devkbin.c Thu Mar 27 06:59:43 2014 @@ -22,8 +22,7 @@ "kbin", {Qkbd, 0}, 0, 0200, }; -Lock kbinlck; -int kbinbusy; +static QLock kbdput; static Chan * kbinattach(char *spec) @@ -48,27 +47,12 @@ { if(!iseve()) error(Eperm); - if(c->qid.path == Qkbd){ - lock(&kbinlck); - if(kbinbusy){ - unlock(&kbinlck); - error(Einuse); - } - kbinbusy++; - unlock(&kbinlck); - } return devopen(c, omode, kbintab, nelem(kbintab), devgen); } static void -kbinclose(Chan *c) +kbinclose(Chan*) { - if(c->aux){ - free(c->aux); - c->aux = nil; - } - if(c->qid.path == Qkbd) - kbinbusy = 0; } static long @@ -83,14 +67,22 @@ kbinwrite(Chan *c, void *a, long n, vlong) { int i; - uchar *p = a; + uchar *p; + p = a; if(c->qid.type == QTDIR) error(Eisdir); switch((int)c->qid.path){ case Qkbd: + qlock(&kbdput); + if(waserror()){ + qunlock(&kbdput); + nexterror(); + } for(i = 0; i < n; i++) kbdputsc(*p++, 1); /* external source */ + poperror(); + qunlock(&kbdput); break; default: error(Egreg);