shithub: barrera

Download patch

ref: ce05038a04e24c726f9b73f49f32c9c244801461
parent: 4d6ccebdb4abd39898e175237fbbda7d69079140
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Mon Jan 2 12:23:21 EST 2023

support control keys (Shift,Ctrl,Alt,AltGr,Mod4)

--- a/barrera.c
+++ b/barrera.c
@@ -413,6 +413,11 @@
 {0xef56,	3,	0xef, 0x80, 0x93},	// page down
 {0xef57,	3,	0xef, 0x80, 0x98},	// end
 {0xef63,	3,	0xef, 0x80, 0x94},	// ins
+{0xefe1, 	3,	0xef, 0x80, 0x96},	// shift (Kshift)
+{0xefe3,	3,	0xef, 0x80, 0x97},	// ctl (Kctl)
+{0xefe9,	3,	0xef, 0x80, 0x95},	// alt left (Kalt)
+{0xefea,	3,	0xef, 0xa1, 0xa7},	// alt right (Kaltgr)
+{0xefeb,	3,	0xef, 0xa1, 0xa8},	// windows key (Kmod4)
 {0xefff,	1,	0x7f, 0x00, 0x00},	// del
 {0x0000,	0,	0x00, 0x00, 0x00},
 };
@@ -426,58 +431,51 @@
 	USED(btn);
 	USED(repeat);
 
-	for(i=0; map[i][0]; i++){
-		if(map[i][0]<key)
-			continue;
-		if(map[i][0]==key){
-			n = map[i][1];
-			switch(n){
-			case 3:
-				b[0] = map[i][2]&0xff;
-				b[1] = map[i][3]&0xff;
-				b[2] = map[i][4]&0xff;
+	for(i=0; map[i][0]; i++)
+		if(map[i][0]>=key)
+			break;
+
+	if(map[i][0] == key){
+		n = map[i][1];
+		switch(n){
+		default:
+			return;
+		case 3:
+			b[2] = map[i][4]&0xff;
+		case 2:
+			b[1] = map[i][3]&0xff;
+		case 1:
+			b[0] = map[i][2]&0xff;
+		}
+	} else {
+		if(key&~0x7F)
+			return;
+		n = 1;
+		b[0] = key&0x7F;
+		if(mod == 2) {
+			switch(key) {
+			case 'h':
+				b[0] = 0x08;
 				break;
-			case 2:
-				b[0] = map[i][2]&0xff;
-				b[1] = map[i][3]&0xff;
+			case 'u':
+				b[0] = 0x15;
 				break;
-			case 1:
-				b[0] = map[i][2]&0xff;
+			case 'w':
+				b[0] = 0x17;
 				break;
-			}
-		} else {
-			if(key&~0x7F)
+			case 'd':
+				b[0] = 0x04;
 				break;
-			n = 1;
-			if(mod == 2) {
-				switch(key) {
-				case 'h':
-					b[0] = 0x08;
-					break;
-				case 'u':
-					b[0] = 0x15;
-					break;
-				case 'w':
-					b[0] = 0x17;
-					break;
-				case 'd':
-					b[0] = 0x04;
-					break;
-				case 'a':
-					b[0] = 0x01;
-					break;
-				case 'e':
-					b[0] = 0x05;
-					break;
-				default:
-					b[0] = key&0x7F;
-				}
-			}else
-				b[0] = key&0x7F;
+			case 'a':
+				b[0] = 0x01;
+				break;
+			case 'e':
+				b[0] = 0x05;
+				break;
+			}
 		}
-		fprint(kbdfd, "%c%.*s%c", ctl==Kup?'R':'r', n, (char*)b, 0);
-		break;
 	}
+	fprint(kbdfd, "%c%.*s%c", ctl==Kup?'R':'r', n, (char*)b, 0);
 }
 
 int