git: 9front

Download patch

ref: f03b2310f68df5739f1a18b3156a13f1a439d180
parent: a38ac7a9c70f955d3e2eb9e59aa065307f9650a3
author: cinap_lenrek <cinap_lenrek@localhost>
date: Sat May 14 17:02:20 EDT 2011

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

--- a/sys/src/cmd/aux/kbdfs.c
+++ b/sys/src/cmd/aux/kbdfs.c
@@ -31,6 +31,7 @@
 	int	down;
 	int	c;
 	Rune	r;
+	Rune	b;
 };
 
 struct Scan {
@@ -258,6 +259,11 @@
 		break;
 	}
 
+	if(scan->esc1)
+		key.b = key.r;
+	else
+		key.b = kbtab[key.c];
+
 	if(scan->caps && key.r<='z' && key.r>='a')
 		key.r += 'A' - 'a';
 
@@ -348,8 +354,8 @@
 void
 keyproc(void *)
 {
+	Rune rb[Nscan*2];
 	int cb[Nscan];
-	Rune rb[Nscan];
 	Key key;
 	int i, nb;
 	char *s;
@@ -376,15 +382,20 @@
 		for(i=0; i<nb && cb[i] != key.c; i++)
 			;
 		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(rb+i, rb+i+1, (nb-i+1) * sizeof(rb[0]));
 				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.r;
+			rb[nb] = key.b;
 			nb++;
+			if(nb < nelem(cb) && key.r && key.b != key.r){
+				cb[nb] = key.c;
+				rb[nb] = key.r;
+				nb++;
+			}
 		}
 		s = utfconv(rb, nb);
 		if(nbsendp(kbdchan, s) <= 0)
--