mirror of
https://github.com/cfenollosa/os-tutorial.git
synced 2024-10-27 20:34:19 +00:00
lesson 20 finished: timer + keyboard
This commit is contained in:
parent
46094a0e96
commit
5aaabf189d
@ -34,3 +34,6 @@ created with the definitions.
|
||||
`keyboard.c` also has a long table to translate scancodes to ASCII keys. For the time
|
||||
being, we will only implement a simple subset of the US keyboard. You can read
|
||||
more [about scancodes here](http://www.win.tue.nl/~aeb/linux/kbd/scancodes-1.html)
|
||||
|
||||
I don't know about you, but I'm thrilled! We are very close to building a simple shell.
|
||||
In the next chapter, we will expand a little bit on keyboard input
|
||||
|
@ -9,7 +9,7 @@ static void timer_callback(registers_t regs) {
|
||||
tick++;
|
||||
kprint("Tick: ");
|
||||
|
||||
char *tick_ascii;
|
||||
char tick_ascii[256];
|
||||
int_to_ascii(tick, tick_ascii);
|
||||
kprint(tick_ascii);
|
||||
kprint("\n");
|
||||
|
@ -197,11 +197,14 @@ void print_letter(u8 scancode) {
|
||||
break;
|
||||
default:
|
||||
/* 'keuyp' event corresponds to the 'keydown' + 0x80
|
||||
* it may still be a scancode we haven't implemented yet */
|
||||
if (scancode - 0x80 <= 0x39) {
|
||||
* it may still be a scancode we haven't implemented yet, or
|
||||
* maybe a control/escape sequence */
|
||||
if (scancode <= 0x7f) {
|
||||
kprint("Unknown key down");
|
||||
} else if (scancode <= 0x39 + 0x80) {
|
||||
kprint("key up ");
|
||||
print_letter(scancode - 0x80);
|
||||
} else kprint("Unknown");
|
||||
} else kprint("Unknown key up");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ void main() {
|
||||
isr_install();
|
||||
|
||||
asm volatile("sti");
|
||||
// init_timer(50);
|
||||
init_timer(50);
|
||||
/* Comment out the timer IRQ handler to read
|
||||
* the keyboard IRQs easier */
|
||||
init_keyboard();
|
||||
|
Loading…
Reference in New Issue
Block a user