forked from jthlim/javelin-steno-rp2040
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhid_keyboard_report_builder.h
62 lines (46 loc) · 1.4 KB
/
hid_keyboard_report_builder.h
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
//---------------------------------------------------------------------------
#pragma once
#include "hid_report_buffer.h"
#include "javelin/key_code.h"
#include <stddef.h>
#include <stdint.h>
//---------------------------------------------------------------------------
struct HidKeyboardReportBuilder {
public:
void Press(uint8_t key);
void Release(uint8_t key);
void FlushIfRequired();
void Flush();
void SendNextReport() { reportBuffer.SendNextReport(); }
void Reset();
size_t GetAvailableBufferCount() const {
return reportBuffer.GetAvailableBufferCount();
}
bool IsCompatibilityMode() const { return compatibilityMode; }
void SetCompatibilityMode(bool mode) { compatibilityMode = mode; }
void PrintInfo() const;
static HidKeyboardReportBuilder instance;
private:
HidKeyboardReportBuilder();
struct Buffer {
union {
uint8_t data[32];
uint32_t data32[8];
};
union {
uint8_t presenceFlags[32];
uint16_t presenceFlags16[16];
uint32_t presenceFlags32[8];
};
};
bool compatibilityMode = false;
uint8_t modifiers = 0;
uint8_t maxPressIndex = 0;
Buffer buffers[2];
HidReportBuffer<17> reportBuffer;
bool HasData() const;
void SendKeyboardPageReportIfRequired();
void SendConsumerPageReportIfRequired();
friend class SplitHidReportBuffer;
};
//---------------------------------------------------------------------------