forked from BRichter99/Xbox360-Controller-with-BLE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProfiles.h
40 lines (35 loc) · 980 Bytes
/
Profiles.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
#ifndef PROFILES_H
#define PROFILES_H
#include <stdint.h>
#include "GamepadPins.h"
#include "BleGamepad.h"
#define N_PROFILES 4
#define SWITCH_PIN BUTTON_XBOX
#define MOVING_AVG 5
struct {
uint64_t buttons;
uint8_t dpad;
int8_t axes[N_AXES];
} typedef inputs_t;
class Profiles {
private:
inputs_t inputs_tmp;
int currentProfile;
int consecutiveSwitchPresses;
int8_t **analogAvg; // 2-dimensional array for average calculation
uint8_t cyclingAveragePointer;// points to the current analog-array
static void p0(inputs_t*, int8_t**, uint8_t);
static void p1(inputs_t*, int8_t**, uint8_t);
static void p2(inputs_t*, int8_t**, uint8_t);
static void p3(inputs_t*, int8_t**, uint8_t);
void (*profiles[N_PROFILES])(inputs_t*, int8_t**, uint8_t)
= { &p0, &p1, &p2, &p3, };
public:
Profiles();
inputs_t inputs;
SemaphoreHandle_t inputsMutex;
SemaphoreHandle_t inputsSemaphore;
int scanInputs();
int getCurrentProfile();
};
#endif