-
Notifications
You must be signed in to change notification settings - Fork 83
/
Copy pathmain.cpp
executable file
·69 lines (60 loc) · 1.24 KB
/
main.cpp
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
#include <library.h>
#include "../../os_host/source/framework/Console.h"
#include "../../os_host/source/framework/SimpleApp.h"
#include "keyboard.h"
/*
PS/2 socket pinout
CLK N/C
GND, DAT, N/C, VCC
+-----------+
/ C /|
/ . . / |
/ . . . . / |
/ G D V / |
/ / |
+ -----------+ |
| DAT | |
| o o | |
| GND VCC | +
| o o | /
| || | /
| o || o | /
| CLK |/
+------------+
*/
#ifdef _ARM
__attribute__((__section__(".entry")))
#endif
int _main(void)
{
APP::Init("PS2 keyboard test");
APP::Status("P1: Clock, P2: Data");
BIOS::KEY::EKey key;
CKeyboard keyboard;
keyboard.Attach();
bool cursor = false;
while ((key = BIOS::KEY::GetKey()) != BIOS::KEY::EKey::Escape)
{
char c = keyboard.Get();
bool blink = false;
EVERY(800)
{
blink = true;
}
if (blink && cursor || c)
{
CONSOLE::Print(" \x08");
cursor = false;
} else if (blink)
{
CONSOLE::Print("_\x08");
cursor = true;
}
if (c)
CONSOLE::Print("%c", c);
if (c==8)
CONSOLE::Print(" \x08");
}
keyboard.Detach();
return 0;
}