-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathibp.h
64 lines (48 loc) · 1.7 KB
/
ibp.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
63
64
#ifndef IBP_H_
#define IBP_H_
#include <string>
#include <string_view>
#include "FreeRTOS.h"
#include "base.h"
#include "semphr.h"
extern "C" {
#include "ibp_lib.h"
}
class IBPDeviceBase : public virtual KeyboardOutputDevice,
public virtual MouseOutputDevice,
public virtual GenericInputDevice,
public virtual IBPDriverBase {
public:
IBPDeviceBase();
// No need to run anything on the output task as it's likely subclass will
// have its own task for communication.
void OutputTick() override {}
// Input task
void SendKeycode(uint8_t keycode) override;
void SendKeycode(const std::vector<uint8_t>& keycode) override;
void SendConsumerKeycode(uint16_t keycode) override;
void ChangeActiveLayers(const std::vector<bool>& layers) override;
void MouseKeycode(uint8_t keycode) override;
void MouseMovement(int8_t x, int8_t y) override;
void Pan(int8_t x, int8_t y) override;
void StartOfInputTick() override;
void FinalizeInputTickOutput() override;
void SetConfigMode(bool is_config_mode) { is_config_mode_ = is_config_mode; }
void InputLoopStart() override {}
void InputTick() override;
protected:
std::string GetOutPacket();
// Full packet with the transaction header.
void SetInPacket(const std::string& packet);
private:
bool is_config_mode_;
bool has_update_[IBP_TOTAL];
IBPSegment segments_[IBP_TOTAL];
std::string inbound_packet_;
std::string outbound_packet_;
// Protects both the inbound and outbound packets. One lock is enough because
// there are usually only two tasks involved: the input task and the low level
// protocol task.
SemaphoreHandle_t packet_semaphore_;
};
#endif /* IBP_H_ */