shithub: riscv

Download patch

ref: d6598a2a31e48d2c42a245bc18d4c3d15e0caaa2
parent: 2614fa02f727daa957ea7e9cc38df108de27c210
author: Ori Bernstein <[email protected]>
date: Sat Apr 25 16:46:45 EDT 2020

Support for neo2 keyboard layout

Modify aux/kbdfs to work with neo2 layout.
- add new modifier, increase limit on layers.
- Add Kaltgr for mod3
- Add mod4

This change only implements the alphanumeric
block of the keyboard in the kbmap, as neo2
is mainly used for blind typing and is not
needed that much anywhere else, this leaves
the numpad like it is.

(Thanks, [email protected])

--- a/sys/src/cmd/aux/kbdfs/kbdfs.c
+++ b/sys/src/cmd/aux/kbdfs/kbdfs.c
@@ -42,6 +42,7 @@
 	int	ctl;
 	int	alt;
 	int	altgr;
+	int	mod4;
 	int	leds;
 };
 
@@ -285,6 +286,46 @@
 [0x78]	0,	0,	0,	0,	0,	0,	0,	0,
 };
 
+Rune kbtabmod4[Nscan] =
+{
+[0x00]	0,	0,	0,	0,	0,	0,	0,	0,
+[0x08]	0,	0,	0,	0,	0,	0,	0,	0,
+[0x10]	0,	0,	0,	0,	0,	0,	0,	0,
+[0x18]	0,	0,	0,	0,	0,	0,	0,	0,
+[0x20]	0,	0,	0,	0,	0,	0,	0,	0,
+[0x28]	0,	0,	0,	0,	0,	0,	0,	0,
+[0x30]	0,	0,	0,	0,	0,	0,	0,	0,
+[0x38]	0,	0,	0,	0,	0,	0,	0,	0,
+[0x40]	0,	0,	0,	0,	0,	0,	0,	0,
+[0x48]	0,	0,	0,	0,	0,	0,	0,	0,
+[0x50]	0,	0,	0,	0,	0,	0,	0,	0,
+[0x58]	0,	0,	0,	0,	0,	0,	0,	0,
+[0x60]	0,	0,	0,	0,	0,	0,	0,	0,
+[0x68]	0,	0,	0,	0,	0,	0,	0,	0,
+[0x70]	0,	0,	0,	0,	0,	0,	0,	0,
+[0x78]	0,	0,	0,	0,	0,	0,	0,	0,
+};
+
+Rune kbtabaltgrmod4[Nscan] =
+{
+[0x00]	0,	0,	0,	0,	0,	0,	0,	0,
+[0x08]	0,	0,	0,	0,	0,	0,	0,	0,
+[0x10]	0,	0,	0,	0,	0,	0,	0,	0,
+[0x18]	0,	0,	0,	0,	0,	0,	0,	0,
+[0x20]	0,	0,	0,	0,	0,	0,	0,	0,
+[0x28]	0,	0,	0,	0,	0,	0,	0,	0,
+[0x30]	0,	0,	0,	0,	0,	0,	0,	0,
+[0x38]	0,	0,	0,	0,	0,	0,	0,	0,
+[0x40]	0,	0,	0,	0,	0,	0,	0,	0,
+[0x48]	0,	0,	0,	0,	0,	0,	0,	0,
+[0x50]	0,	0,	0,	0,	0,	0,	0,	0,
+[0x58]	0,	0,	0,	0,	0,	0,	0,	0,
+[0x60]	0,	0,	0,	0,	0,	0,	0,	0,
+[0x68]	0,	0,	0,	0,	0,	0,	0,	0,
+[0x70]	0,	0,	0,	0,	0,	0,	0,	0,
+[0x78]	0,	0,	0,	0,	0,	0,	0,	0,
+};
+
 char*
 dev(char *file)
 {
@@ -368,6 +409,10 @@
 		key.r = kbtabshiftesc1[c];
 	else if(scan->esc1)
 		key.r = kbtabesc1[c];
+	else if(scan->altgr && scan->mod4 && kbtabaltgrmod4[c] != 0)
+		key.r = kbtabaltgrmod4[c];
+	else if(scan->mod4 && kbtabmod4[c] != 0)
+		key.r = kbtabmod4[c];
 	else if(scan->shift && scan->altgr && kbtabshiftaltgr[c] != 0)
 		key.r = kbtabshiftaltgr[c];
 	else if(scan->shift)
@@ -403,6 +448,9 @@
 	case Kaltgr:
 		scan->altgr = key.down;
 		break;
+	case Kmod4:
+		scan->mod4 = key.down;
+		break;
 	case Kalt:
 		scan->alt = key.down;
 		break;
@@ -470,6 +518,8 @@
 			a->shift = k.down;
 		else if(k.r == Kaltgr)
 			a->altgr = k.down;
+		else if(k.r == Kmod4)
+			a->mod4 = k.down;
 		else if(k.r == Kctl)
 			a->ctl = k.down;
 		send(keychan, &k);
@@ -664,6 +714,7 @@
 		case Knum:
 		case Kshift:
 		case Kaltgr:
+		case Kmod4:
 			/* ignore modifiers */
 			continue;
 
@@ -1081,6 +1132,8 @@
 	/* 5 */	kbtabctrlesc1,
 	/* 6 */	kbtabshiftesc1,
 	/* 7 */	kbtabshiftaltgr,
+	/* 8 */ kbtabmod4,
+	/* 9 */ kbtabaltgrmod4,
 	};
 	if(t >= 0 && t < nelem(tabs) && sc >= 0 && sc < Nscan)
 		return &tabs[t][sc];
@@ -1116,6 +1169,7 @@
 	static Rune o = Spec|0x60, tab[] = {
 		Kshift, Kbreak, Kctl, Kalt,
 		Kcaps, Knum, Kmiddle, Kaltgr,
+		Kmod4,
 	};
 	if(r >= o && r < o+nelem(tab))
 		return tab[r - o];