Remapping the Keyboard
Given most of the work is done with the "basic shift logic" how hard could it be?
The basic shift logic:
Well much harder than expected, here is the schematic:
Now many will recognise this as a PLA (Programmable Logic Array).
Designing a PLA
The first step is to generate a truth table. The problem is this is not that simple. It gets pretty confusing with 128 cases to consider.
Really the first step is to write a program to generate the truth table. So here is a simple C code program that creates the truth table:
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
int main(void) {
FILE *F1;
int a,x;
int a0,a1,a2,a3,a4,a5,a6;
int x0,x1,x2,x3,x4,x5,x6;
F1=fopen("KeyBoardMapping.txt","w");
fprintf(F1,"a0,a1,a2,a3,a4,a5,shift,,x0,x1,x2,x3,x4,x5,x6\n");
for (a=0;a<127;a++) {
// Shift mapping
x=a;
if ((a>=32)&&(a<=63)) x=a+64; // lower case "'" to "Del"
if ((a>=16)&&(a<=31)) x=a+16; // Keys "0" to "?"
if ((a>=0)&&(a<=15)) x=a; // Ctrl keys as is
if ((a>=96)&&(a<=127)) x=a-32; // Shift: Upper case "@" to "_"
if ((a>=80)&&(a<=95)) x=a-48; // Keys "Space" to "/"
if ((a>=0)&&(a<=15)) x=a-64; // Shift: Ctrl keys as is
// Special key mapping
if (x==95) x=127; // "_" is now "Del"
if (x==32) x=95; // "Shift 0" is now "_"
if (x==1) x=32; // key 0 is "Space"
if (x==2) x=24; // "Can" or Break/^C
if (x==3) x=27; // "Esc"
a0=a&0x01;
a1=(a>>1)&0x01;
a2=(a>>2)&0x01;
a3=(a>>3)&0x01;
a4=(a>>4)&0x01;
a5=(a>>5)&0x01;
a6=(a>>6)&0x01;
x0=x&0x01;
x1=(x>>1)&0x01;
x2=(x>>2)&0x01;
x3=(x>>3)&0x01;
x4=(x>>4)&0x01;
x5=(x>>5)&0x01;
x6=(x>>6)&0x01;
fprintf(F1,"%d,%d,%d,%d,%d,%d,%d,,%d,%d,%d,%d,%d,%d,%d\n",a0,a1,a2,a3,a4,a5,a6,x0,x1,x2,x3,x4,x5,x6);
}
fclose(F1);
return(0);
}
Once we have a truth table we determine the Prime Indicants (PIs). I use Logic Friday:
LogicFriday is a front end for Espresso by Richard Rudell (rudell@ic.Berkeley.EDU).
Here are the PIs table used to design the PLA:
So I was not wrong in saying that remapping a few keys is expensive.
(Now I did try adding the PLA after the "basic shift logic" but the result were just as bad.)
Interface
The keyboard interface pretty basic, a byte with the D7 (Key Pressed) used for polling or an interrupt.
Limitations
Note the missing Ctrl and Alt keys. So it will be up the the program to set how extended key codes are entered.
AlanX
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.