I'm trying to do a PS/2 keyboard controller, and I can't get it work.
outb(0x60, 0xED);
outb(0x60, 2); /* Turn on CapsLock LED (doesn't works)*/
char c = 0;
while (c != 1)
{
if (inb(0x60) != c)
{
c = inb(0x60);
if (c > 0)
putch(scan2char(c));
}
}
scan2char function:
char scan2char(char scn)
{
char keych;
switch (scn)
{
case 0x15:
keych = 'q';
break;
case 0x1D:
keych = 'w';
break;
case 0x24:
keych = 'e';
break;
case 0x2D:
keych = 'r';
break;
case 0x2C:
keych = 't';
break;
case 0x35:
keych = 'y';
break;
}
return keych;
}
It reads the keys, but the keyboard layout shifted in an weird way; e.x: if I press 9 I get q, if I press 0 I get w, you understand. At first I thought it might be the putch function, but doing some tests, I saw that putch wasn't the problem.