-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Keyboard driver and fancy screens (#6)
* Keyboard basic input handling, basic screens * Cleaner screen handling * Use VNC by default with QEMU * Use pointer on functions to define screens * Add current commit to homepage * Silly box, improved vga api, improved headers * CRTC VGA cursor BS * Add colors test, fix cursor, no infinite buff cycling
- Loading branch information
1 parent
01848b4
commit d9c746b
Showing
23 changed files
with
729 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include "keyboard.h" | ||
#include "../../klibc/libc.h" | ||
#include "keyboard_internal.h" | ||
|
||
// TODO use partial init with ranges | ||
// http://www.osdever.net/bkerndev/Docs/keyboard.htm | ||
unsigned char us_scancode_1[128] = { | ||
0, 27, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', | ||
'=', '\b', '\t', 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', | ||
'[', ']', '\n', 0, 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', | ||
';', '\'', '`', 0, '\\', 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', | ||
'.', '*', 0, ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
0, 0, 0, 0, 0, 0, 0, '-', 0, 0, 0, '+', 0, | ||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
}; | ||
|
||
scancode kbd_get() { | ||
return (inb(KBD_IO_STATUS_REGISTER) & 1) ? inb(KBD_IO_DATA_PORT) : 0; | ||
} | ||
|
||
char kbd_code_to_ascii(scancode code) { | ||
return (code <= 127) ? us_scancode_1[code] : 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#ifndef KEYBOARD_H | ||
#define KEYBOARD_H | ||
|
||
#include <stdint.h> | ||
|
||
// scancode set 1 | ||
// https://wiki.osdev.org/PS/2_Keyboard#Scan_Code_Set_1 | ||
typedef enum scancode { | ||
KBD_ESCAPE = 0x1, | ||
KBD_BACKSPACE = 0x0E, | ||
KBD_TAB, | ||
KBD_ENTER = 0x1C, | ||
KBD_LEFT_CTRL, | ||
KBD_LEFT_SHIFT = 0x2A, | ||
KBD_RIGHT_SHIFT = 0x36, | ||
KBD_LEFT_ALT = 0x38, | ||
KBD_SPACE, | ||
KBD_CAPS_LOCK, | ||
KBD_F1, | ||
KBD_F2, | ||
KBD_F3, | ||
KBD_F4, | ||
KBD_F5, | ||
KBD_F6, | ||
KBD_F7, | ||
KBD_F8, | ||
KBD_F9, | ||
KBD_F10, | ||
KBD_NUMLOCK, | ||
KBD_SCROLLLOCK, | ||
KBD_F11 = 0x57, | ||
KBD_F12, | ||
// Hack from here, only released | ||
KBD_HOME = 0xC7, | ||
KBD_CURSOR_UP, | ||
KBD_PAGE_UP, | ||
KBD_CURSOR_LEFT = 0xCB, | ||
KBD_CURSOR_RIGHT = 0xCD, | ||
KBD_END = 0xCF, | ||
KBD_CURSOR_DOWN, | ||
KBD_PAGE_DOWN, | ||
KBD_INSERT, | ||
KBD_DELETE, | ||
} scancode; | ||
|
||
// http://www.osdever.net/bkerndev/Docs/keyboard.htm | ||
extern unsigned char us_scancode_1[128]; | ||
|
||
/// @brief returns a keyboard scancode | ||
/// @return keyboard scancode | ||
scancode kbd_get(); | ||
|
||
char kbd_code_to_ascii(scancode code); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#ifndef KEYBOARD_INTERNAL_H | ||
#define KEYBOARD_INTERNAL_H | ||
|
||
// PS/2 controller I/O registers | ||
#define KBD_IO_DATA_PORT 0x60 | ||
#define KBD_IO_STATUS_REGISTER 0x64 | ||
#define KBD_IO_COMMAND_REGISTER 0x64 | ||
|
||
#endif |
Oops, something went wrong.