-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
67 lines (60 loc) · 999 Bytes
/
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
#include "mk20dx128.h"
#include "WProgram.h"
#include "ps2host.h"
#include "flags.h"
#include "constants.h"
#include "keymap.h"
#include "keyState.h"
#include "translator.h"
#include "usbSender.h"
void setup()
{
pinMode(CLOCK, INPUT);
pinMode(DATA, INPUT);
pinMode(LED, OUTPUT);
digitalWriteFast(LED, LOW);
delay(3000);
// Trigger when signal changes level.
attachInterrupt(CLOCK, ps2ClockChangedHandler, CHANGE);
}
void loop()
{
if (ReadPS2BitNow) // Priority 1
{
readPs2Bit();
ReadPS2BitNow = false;
return;
}
if (ScancodeReady) // Priority 2
{
TranslateScancodeToKeycode();
ScancodeReady = false;
return;
}
if (KeycodeReady) // Priority 3
{
ProcessKey();
KeycodeReady = false;
return;
}
if (TranslateReady) // Priority 4
{
TranslateToUsb();
TranslateReady = false;
return;
}
if (UsbKeysReady) // Priority 5
{
SendUSB();
UsbKeysReady = false;
return;
}
}
int main(void)
{
setup();
while (true)
{
loop();
}
}