/dev/kbd: threat key combinations like shift+a as a virtual key and emit both a and A in that case

cinap_lenrek 2011-05-14 21:02:20 +00:00
parent d6679cfa90
commit a67e921c7f
1 changed files with 15 additions and 4 deletions

View File

@ -31,6 +31,7 @@ struct Key {
int down; int down;
int c; int c;
Rune r; Rune r;
Rune b;
}; };
struct Scan { struct Scan {
@ -258,6 +259,11 @@ kbdputsc(Scan *scan, int c)
break; break;
} }
if(scan->esc1)
key.b = key.r;
else
key.b = kbtab[key.c];
if(scan->caps && key.r<='z' && key.r>='a') if(scan->caps && key.r<='z' && key.r>='a')
key.r += 'A' - 'a'; key.r += 'A' - 'a';
@ -348,8 +354,8 @@ utfconv(Rune *r, int n)
void void
keyproc(void *) keyproc(void *)
{ {
Rune rb[Nscan*2];
int cb[Nscan]; int cb[Nscan];
Rune rb[Nscan];
Key key; Key key;
int i, nb; int i, nb;
char *s; char *s;
@ -376,16 +382,21 @@ keyproc(void *)
for(i=0; i<nb && cb[i] != key.c; i++) for(i=0; i<nb && cb[i] != key.c; i++)
; ;
if(!key.down){ if(!key.down){
if(i < nb){ while(i < nb && cb[i] == key.c){
memmove(cb+i, cb+i+1, (nb-i+1) * sizeof(cb[0])); memmove(cb+i, cb+i+1, (nb-i+1) * sizeof(cb[0]));
memmove(rb+i, rb+i+1, (nb-i+1) * sizeof(rb[0])); memmove(rb+i, rb+i+1, (nb-i+1) * sizeof(rb[0]));
nb--; nb--;
} }
} else if(i == nb && nb < nelem(cb) && key.r){ } else if(i == nb && nb < nelem(cb) && key.b){
cb[nb] = key.c;
rb[nb] = key.b;
nb++;
if(nb < nelem(cb) && key.r && key.b != key.r){
cb[nb] = key.c; cb[nb] = key.c;
rb[nb] = key.r; rb[nb] = key.r;
nb++; nb++;
} }
}
s = utfconv(rb, nb); s = utfconv(rb, nb);
if(nbsendp(kbdchan, s) <= 0) if(nbsendp(kbdchan, s) <= 0)
free(s); free(s);