-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgamepad.h
More file actions
40 lines (34 loc) · 916 Bytes
/
Copy pathgamepad.h
File metadata and controls
40 lines (34 loc) · 916 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
#include <BleGamepad.h>
#include <map>
#include "esp_log.h"
#include "mode.h"
#include "pins.h"
#include "config.h"
#ifndef GAMEPAD_H
#define GAMEPAD_H
class GamepadMode : public Mode {
private:
bool reportDirty = false;
TaskHandle_t reportTaskHandle = NULL;
SemaphoreHandle_t mutex = NULL;
BleGamepad gamepad;
std::map<ButtonType, uint8_t> buttonMap = {
{ ButtonType::Hold, BUTTON_1 },
{ ButtonType::CCW, BUTTON_2 },
{ ButtonType::CW, BUTTON_3 },
{ ButtonType::Left, BUTTON_4 },
{ ButtonType::Right, BUTTON_5 },
{ ButtonType::HardDrop, BUTTON_6 },
{ ButtonType::SoftDrop, BUTTON_7 },
{ ButtonType::Zone, BUTTON_8 },
};
public:
GamepadMode() { };
~GamepadMode() { };
void setup();
void teardown();
void pressButton(ButtonType button);
void releaseButton(ButtonType button);
void sendReport();
};
#endif