-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkbd.c
More file actions
42 lines (37 loc) · 1.36 KB
/
Copy pathkbd.c
File metadata and controls
42 lines (37 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "io.h"
/* Scancode-to-ASCII conversion table
* US Keyboard Layout
* Usage:
* unsigned char myChar = kdbUS[unsigned char scancode];
*
* From http://www.osdever.net/bkerndev/Docs/keyboard.htm
*/
/* Handles the keyboard interrupt */
void keyboard_handler(struct regs *r)
{
unsigned char scancode;
/* Read from the keyboard's data buffer */
scancode = inb(0x60);
/* If the top bit of the byte we read from the keyboard is
* set, that means that a key has just been released */
if (scancode & 0x80)
{
/* You can use this one to see if the user released the
* shift, alt, or control keys... */
}
else
{
/* Here, a key was just pressed. Please note that if you
* hold a key down, you will get repeated key press
* interrupts. */
/* Just to show you how this works, we simply translate
* the keyboard scancode into an ASCII value, and then
* display it to the screen. You can get creative and
* use some flags to see if a shift is pressed and use a
* different layout, or you can add another 128 entries
* to the above layout to correspond to 'shift' being
* held. If shift is held using the larger lookup table,
* you would add 128 to the scancode when you look for it */
write(kbdUS[scancode], 10, 80);
}
}