// send command byte to keyboard controller void keyboard_ctrl_send_cmd (uint8_t cmd) { // wait for keyboard controller input buffer to be clear while (1) if ( (keyboard_ctrl_read_status () & KEYBOARD_CTRL_STATS_MASK_IN_BUF) == 0) break; outportb (KEYBOARD_CTRL_CMD_REG, cmd); }
void isr_keyboard_int(void) { int code = 0; // read scan code only if the keyboard controller output buffer is full if ( (keyboard_ctrl_read_status() & KEYBOARD_CTRL_STATUS_MASK_OUT_BUF) != KB_SR_OUTPUT_BUFFER_FULL ) { return; } // read the scan code code = keyboard_enc_read_buf(); // Original XT Scan Code Set: // - make code < 0x80 // - break code >= 0x80 if (code >= 0x80) { // convert the break code into its make code equivelant code -= 0x80; //! grab the key int key = keyboard_scancode_std[code * 3]; // Update the special keys's status (CTRL, SHIFT, ALT) switch (key) { case KEY_LCTRL: case KEY_RCTRL: { ctrl = false; break; } case KEY_LSHIFT: case KEY_RSHIFT: { shift = false; break; } case KEY_LALT: case KEY_RALT: { alt = false; break; } default: { // nothing to do break; } } } else { scancode = code; int key = keyboard_scancode_std[code * 3]; //! test if user is holding down any special keys & set it switch (key) { // special keys case KEY_LCTRL: case KEY_RCTRL: { ctrl = true; break; } case KEY_LSHIFT: case KEY_RSHIFT: { shift = true; break; } case KEY_LALT: case KEY_RALT: { alt = true; break; } // LED keys case KEY_CAPSLOCK: { capslock = (capslock) ? false : true; keyboard_setleds(numlock, capslock, scrolllock); break; } case KEY_KP_NUMLOCK: { numlock = (numlock) ? false : true; keyboard_setleds(numlock, capslock, scrolllock); break; } case KEY_SCROLLLOCK: { scrolllock = (scrolllock) ? false : true; keyboard_setleds(numlock, capslock, scrolllock); break; } default: { char c; if (capslock || shift) { c = keyboard_scancode_std[code * 3 + 2]; } else { c = keyboard_scancode_std[code * 3 + 1]; } driver_kbd_inputc = c; driver_kbd_inputavailable = true; break; } } } }
static void keyboard_enc_send_cmd(uint8_t cmd) { while ( (keyboard_ctrl_read_status() & KEYBOARD_CTRL_STATUS_MASK_IN_BUF) != KB_SR_INPUT_BUFFER_EMPTY ) {}; outb(KEYBOARD_ENC_CMD_REG, cmd); }