keyboard problem
Posted: Sat Aug 14, 2004 1:28 pm
hello
i have a small keyboard problem. When i press shift and type i get capital letters but even after releasing shift i get capital letters. But sometimes this problem doesnt happen and everything works fine. But with caps lock it works perfectly all the time. I took the code from geezer's osd8 kernel. I modified it slightly
heres part of that code
static unsigned short kbd_status=0;
static unsigned short saw_break_code=0;
static unsigned convert(byte key)
{
unsigned short temp=0;
/* check for break key (i.e. a key is released) */
if(key >= 0x80)
{
saw_break_code = 1;
key &= 0x7F;
}
/* the only break codes we're interested in are Shift, Ctrl, Alt */
if(saw_break_code)
{
if(key == RAW1_LEFT_ALT || key == RAW1_RIGHT_ALT)
kbd_status &= ~KBD_META_ALT;
else if(key == RAW1_LEFT_CTRL || key == RAW1_RIGHT_CTRL)
kbd_status &= ~KBD_META_CTRL;
else if((key == RAW1_LEFT_SHIFT) || (key == RAW1_RIGHT_SHIFT))
{
kbd_status &= ~KBD_META_SHIFT;
}
saw_break_code = 0;
return 0;
}
/* it's a make key: check the "meta" keys, as above */
if(key == RAW1_LEFT_ALT || key == RAW1_RIGHT_ALT)
{
kbd_status |= KBD_META_ALT;
return 0;
}
if(key == RAW1_LEFT_CTRL || key == RAW1_RIGHT_CTRL)
{
kbd_status |= KBD_META_CTRL;
return 0;
}
if(key == RAW1_LEFT_SHIFT || key == RAW1_RIGHT_SHIFT)
{
kbd_status |= KBD_META_SHIFT;
return 0;
}
if(key == RAW1_CAPS_LOCK)
{
kbd_status ^= KBD_META_CAPS;
write_kbd(0x60, 0xED); /* "set LEDs" command */
temp = 0;
if(kbd_status & KBD_META_CAPS)
temp |= 4;
write_kbd(0x60, temp); /* bottom 3 bits set LEDs */
return 0;
}
/* ignore invalid scan codes */
if(key >= sizeof(set1_map) / sizeof(set1_map[0]))
return 0;
/* convert raw scancode in key to ASCII in temp */
if((kbd_status & KBD_META_SHIFT) || (kbd_status & KBD_META_CAPS))
{
temp = set1_map[key][1];
/*Column 1 for shifted characters/*
}
else
{
temp = set1_map[key][0];
/*Column 0 for shifted characters/*
}
if(temp == 0)
return temp;
return temp;
}
void kbd_handler(void)
{
byte key, i;
/* get scancode from port 0x60 */
key = inportb(0x60);
i = convert(key);
if(i != 0)
printc(i);
}
kiran
i have a small keyboard problem. When i press shift and type i get capital letters but even after releasing shift i get capital letters. But sometimes this problem doesnt happen and everything works fine. But with caps lock it works perfectly all the time. I took the code from geezer's osd8 kernel. I modified it slightly
heres part of that code
static unsigned short kbd_status=0;
static unsigned short saw_break_code=0;
static unsigned convert(byte key)
{
unsigned short temp=0;
/* check for break key (i.e. a key is released) */
if(key >= 0x80)
{
saw_break_code = 1;
key &= 0x7F;
}
/* the only break codes we're interested in are Shift, Ctrl, Alt */
if(saw_break_code)
{
if(key == RAW1_LEFT_ALT || key == RAW1_RIGHT_ALT)
kbd_status &= ~KBD_META_ALT;
else if(key == RAW1_LEFT_CTRL || key == RAW1_RIGHT_CTRL)
kbd_status &= ~KBD_META_CTRL;
else if((key == RAW1_LEFT_SHIFT) || (key == RAW1_RIGHT_SHIFT))
{
kbd_status &= ~KBD_META_SHIFT;
}
saw_break_code = 0;
return 0;
}
/* it's a make key: check the "meta" keys, as above */
if(key == RAW1_LEFT_ALT || key == RAW1_RIGHT_ALT)
{
kbd_status |= KBD_META_ALT;
return 0;
}
if(key == RAW1_LEFT_CTRL || key == RAW1_RIGHT_CTRL)
{
kbd_status |= KBD_META_CTRL;
return 0;
}
if(key == RAW1_LEFT_SHIFT || key == RAW1_RIGHT_SHIFT)
{
kbd_status |= KBD_META_SHIFT;
return 0;
}
if(key == RAW1_CAPS_LOCK)
{
kbd_status ^= KBD_META_CAPS;
write_kbd(0x60, 0xED); /* "set LEDs" command */
temp = 0;
if(kbd_status & KBD_META_CAPS)
temp |= 4;
write_kbd(0x60, temp); /* bottom 3 bits set LEDs */
return 0;
}
/* ignore invalid scan codes */
if(key >= sizeof(set1_map) / sizeof(set1_map[0]))
return 0;
/* convert raw scancode in key to ASCII in temp */
if((kbd_status & KBD_META_SHIFT) || (kbd_status & KBD_META_CAPS))
{
temp = set1_map[key][1];
/*Column 1 for shifted characters/*
}
else
{
temp = set1_map[key][0];
/*Column 0 for shifted characters/*
}
if(temp == 0)
return temp;
return temp;
}
void kbd_handler(void)
{
byte key, i;
/* get scancode from port 0x60 */
key = inportb(0x60);
i = convert(key);
if(i != 0)
printc(i);
}
kiran