-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathKeyboardParser.h
More file actions
41 lines (30 loc) · 816 Bytes
/
KeyboardParser.h
File metadata and controls
41 lines (30 loc) · 816 Bytes
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
#ifndef __kbdrptparser_h_
#define __kbdrptparser_h_
#include <Arduino.h>
#include "KeyboardReporter.h"
// comment if you're not using apple magic keyboard.
#define APPLE_MAGIC_KBD
class KbdRptParser : public HIDReportParser
{
public:
virtual void Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf);
};
bool ledOn = false;
void KbdRptParser::Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf)
{
#ifdef APPLE_MAGIC_KBD
// for apple magic keyboard, should also send report id (one byte before current *buf).
buf -= 1;
len += 1;
#endif
for (int i = 0; i < len; i ++) {
Serial.print(buf[i]);
Serial.print(" ");
}
Serial.print("\r\n");
ledOn = !ledOn;
if (ledOn) TXLED1;
else TXLED0;
KeyboardReporter.sendReport(buf, len);
};
#endif