I have a nasty issue with my keyboard driver. The problem is, as the title states, that W, T, U, V, and Y are somehow recognized as home, end, ect (lets call it "aliasing")
What i already tried:
- unsigned char insted of char
- cast the values of KEND, KHOME, ect
what can I do to fix this bug?
my code (the "crippled" keymap is on purpose, because I have a german keyboard, and I want the keys ä, ö, ü to do nothing, also most assignments of the keys !, @, #, $, %, ^, &, * are different, and some of chars don't work)
Code: Select all
unsigned char keymap_noshift[] =
{
NULL, ESC, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'ß', '´', BACKSPACE,
TAB, 'q', 'w', 'e', 'r', 't', 'z', 'u', 'i', 'o', 'p', 0, '+', ENTER, 0,
'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 0, 0, '#', 0, '\0',
'y', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '-', 0, 0, 0, ' ', 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
KHOME, KUP, KPGUP,'-', KLEFT, '5', KRIGHT, '+', KEND, KDOWN, KPGDN, KINS, KDEL, 0, 0, 0, 0, 0
};
unsigned char keymap_shift[] =
{
NULL, ESC, '!', '\0', '\0', '\0', '\0', '\0', '\0', '(', ')', '=', '?', '`', BACKSPACE,
TAB, 'Q', 'W', 'E', 'R', 'T', 'Z', 'U', 'I', 'O', 'P', 0, '*', ENTER, 0,
'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 0, 0, '\'', 0, '\0',
'Y', 'X', 'C', 'V', 'B', 'N', 'M', ';', ':', '_', 0, 0, 0, ' ', 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
KHOME, KUP, KPGUP, '-', KLEFT, '5', KRIGHT, '+', KEND, KDOWN, KPGDN, KINS, KDEL, 0, 0, 0, 0, 0
};
unsigned k_get_key()
{
unsigned char scancode;
unsigned char buffer;
scancode = inportb(0x60);
if(scancode & 0x80) //key released
{
scancode &= 0x7F;
if(scancode == KRSHIFT || scancode == KLSHIFT)
{
kbd_shiftdown = 0;
}
return 0;
}
else //key pressed
{
if(scancode == KRSHIFT || scancode == KLSHIFT)
{
kbd_shiftdown = 1;
return 0;
}
}
if(kbd_shiftdown)
{
buffer = keymap_shift[scancode];
}
else
{
buffer = keymap_noshift[scancode];
}
return buffer;
}
void keyboard_handler()
{
unsigned char key = k_get_key();
switch(key)
{
case KUP:
cursor_up();
break;
case KLEFT:
cursor_left();
break;
case KRIGHT:
cursor_right();
break;
case KDOWN:
cursor_down();
break;
case KEND:
cursor_end();
break;
case KHOME:
cursor_home();
break;
case KINS:
break;
case KDEL:
break;
case KPGDN:
break;
case KPGUP:
break;
default:
if(kbq.write >= kbq.read + kbq_size)
{
return;
}
if(!key)
{
return;
}
*kbq.head = (char) key;
kbq.head++;
kbq.write++;
if(kbq.head >= kbq.buffer + 32)
{
kbq.head = 0;
}
}
};
mogana100