-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathKeyboard.cpp
More file actions
72 lines (65 loc) · 1.36 KB
/
Keyboard.cpp
File metadata and controls
72 lines (65 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#pragma once
#include "Typedefs.cpp"
#include "TextPrint.cpp"
bool LeftShiftPressed = false;
bool RightShiftPressed = false;
uint_8 LastScancode;
void StandardKeyboardHandler(uint_8 scanCode, uint_8 chr) {
if (chr != 0) {
switch (LeftShiftPressed | RightShiftPressed)
{
case true:
PrintChar(chr - 32);
break;
case false:
PrintChar(chr);
break;
}
}
else {
switch (scanCode) {
case 0x8E: //Backspace
SetCursorPosition(CursorPosition - 1);
PrintChar(' ');
SetCursorPosition(CursorPosition - 1);
break;
case 0x2A: //Left Shift
LeftShiftPressed = true;
break;
case 0xAA: //Left Shift Released
LeftShiftPressed = false;
case 0x36: //Right Shift
RightShiftPressed = true;
break;
case 0xB6: //Right Shift Released
RightShiftPressed = false;
break;
case 0x9C: //Enter
PrintString("\n\r");
break;
}
}
}
void KeyboardHandler0xE0(uint_8 scanCode) {
switch (scanCode)
{
case 0x50:
SetCursorPosition(CursorPosition + VGA_WIDTH);
break;
case 0x48:
SetCursorPosition(CursorPosition - VGA_WIDTH);
break;
default:
break;
}
}
void KeyboardHandler(uint_8 scanCode, uint_8 chr) {
switch (LastScancode) {
case 0xE0:
KeyboardHandler0xE0(scanCode);
break;
default:
StandardKeyboardHandler(scanCode, chr);
}
LastScancode = scanCode;
}