I'm having problems with this code:
Code: Select all
/* Handles the keyboard interrupt */
void keyboard_handler(struct regs *r)
{
unsigned char scancode;
/* Read from the keyboard's data buffer */
scancode = inportb(0x60);
if (scancode & 0x80)
{
if (scancode==42) { shift=0; } // check values of shift, ctrl and alt
if (scancode==54) { shift=0; }
if (scancode==29) { ctrl=0; }
if (scancode==56) { alt=0; }
}
else
{
/* Here, a key was just pressed. */
if (scancode==42) { shift=1; } // check values of shift, ctrl and alt
if (scancode==54) { shift=1; }
if (scancode==29) { ctrl=1; }
if (scancode==56) { alt=1; }
if (alt!=1) { // keypresses do not count if alt or ctrl are
if (ctrl!=1) { // being held down during the keypress.
if (shift==1) {
if (showkeypresses==1) { // use caps if shift is held down
putch(kbdcaps[scancode]);
}
} else {
if (showkeypresses==1) { // otherwise use normal lowercase letters
putch(kbd[scancode]); }
}
}
}
}
}
Code: Select all
If a key was released:
check if the released key was SHIFT, CTRL, or ALT
if so, set the it's variable to 0.
If a key was pressed:
check if SHIFT, CTRL, or ALT were pressed. if so:
set the key's variable to 1.
otherwise:
if shift is pressed display using the caps layout
if alt is pressed display nothing at all
if ctrl is pressed display nothing at all
The same happens for the CTRL and ALT keys - if I press one of those the input is disabled until a reboot.
Why might this be?