Problem with shift key
Posted: Sat Oct 29, 2005 11:48 am
I downloaded Bran's tutorial and was modifying it like crazy until it wasn't Bran's tutorial anymore Now I'm working on implementing the shift keys. The keys get detected as being pressed and a debug message prints, but nothing happens when they get released. (The caps lock that just won't turn off...) Here's the relevant part of my KB code:
Code: Select all
bool SHIFT_PRESSED = 0;
// ...
unsigned char scancode;
/* Read from the keyboard's data buffer */
scancode = inportb(0x60);
/* If the top bit of the byte we read from the keyboard is
* set, that means that a key has just been released */
if (scancode & 0x80)
{
/* You can use this one to see if the user released the
* shift, alt, or control keys... */
if (scancode == 42 || scancode == 54) //42 and 54 are left/right shift scancodes
{
SHIFT_PRESSED = 0;
puts("debug: Shift released"); //this never gets printed
}
}
if (scancode == 42 || scancode == 54)
{
//then it was shift
SHIFT_PRESSED = 1;
puts("debug: Shift pressed"); //this gets printed
}
else
//normal keypress code - removed from this post for shortness