keyboard.h
1 #ifndef KEYBOARD_H 2 #define KEYBOARD_H 3 4 #include "types.h" 5 #include "idt.h" 6 7 // Keyboard scan codes (Set 1) 8 #define KEY_ESC 0x01 9 #define KEY_1 0x02 10 #define KEY_2 0x03 11 #define KEY_3 0x04 12 #define KEY_4 0x05 13 #define KEY_5 0x06 14 #define KEY_6 0x07 15 #define KEY_7 0x08 16 #define KEY_8 0x09 17 #define KEY_9 0x0A 18 #define KEY_0 0x0B 19 #define KEY_MINUS 0x0C 20 #define KEY_EQUALS 0x0D 21 #define KEY_BACKSPACE 0x0E 22 #define KEY_TAB 0x0F 23 #define KEY_Q 0x10 24 #define KEY_ENTER 0x1C 25 #define KEY_LCTRL 0x1D 26 #define KEY_A 0x1E 27 #define KEY_LSHIFT 0x2A 28 #define KEY_RSHIFT 0x36 29 #define KEY_LALT 0x38 30 #define KEY_SPACE 0x39 31 #define KEY_CAPSLOCK 0x3A 32 #define KEY_F1 0x3B 33 #define KEY_UP 0x48 34 #define KEY_LEFT 0x4B 35 #define KEY_RIGHT 0x4D 36 #define KEY_DOWN 0x50 37 38 // Key states 39 #define KEY_STATE_SHIFT (1 << 0) 40 #define KEY_STATE_CTRL (1 << 1) 41 #define KEY_STATE_ALT (1 << 2) 42 #define KEY_STATE_CAPS (1 << 3) 43 44 // Keyboard buffer 45 #define KEYBOARD_BUFFER_SIZE 256 46 47 // Keyboard functions 48 void keyboard_init(void); 49 void keyboard_handler(void); 50 char keyboard_getchar(void); 51 int keyboard_haschar(void); 52 void keyboard_set_leds(uint8_t leds); 53 54 // Keyboard callback 55 typedef void (*keyboard_callback_t)(char ch); 56 void keyboard_set_callback(keyboard_callback_t callback); 57 58 #endif // KEYBOARD_H