Skip to content

Commit 33a3dee

Browse files
authored
Constructor variable order - fix warning
1 parent 1a1c5ba commit 33a3dee

File tree

2 files changed

+43
-43
lines changed

2 files changed

+43
-43
lines changed

BleGamepad.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ BleGamepad::BleGamepad(std::string deviceName, std::string deviceManufacturer, u
7171
_powerLevel(0),
7272
hid(0),
7373
pCharacteristic_Power_State(0),
74+
configuration(),
7475
pServer(nullptr),
75-
nus(nullptr),
76-
configuration()
76+
nus(nullptr)
7777
{
7878
this->resetButtons();
7979
this->deviceName = deviceName;

BleGamepad.h

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -16,38 +16,55 @@
1616
class BleGamepad
1717
{
1818
private:
19-
uint8_t _buttons[16]; // 8 bits x 16 bytes = 128 bits --> 128 button max
20-
uint8_t _specialButtons;
21-
22-
int16_t _x, _y, _z, _rX, _rY, _rZ, _slider1, _slider2;
23-
int16_t _rudder, _throttle, _accelerator, _brake, _steering;
24-
int16_t _hat1, _hat2, _hat3, _hat4;
25-
int16_t _gX, _gY, _gZ, _aX, _aY, _aZ;
26-
27-
uint8_t _batteryPowerInformation, _dischargingState, _chargingState, _powerLevel;
28-
29-
NimBLEHIDDevice *hid;
30-
NimBLECharacteristic *pCharacteristic_Power_State;
31-
32-
NimBLEServer *pServer;
33-
BleNUS *nus;
34-
3519
std::string deviceManufacturer;
3620
std::string deviceName;
37-
3821
uint8_t tempHidReportDescriptor[150];
3922
int hidReportDescriptorSize;
4023
uint8_t hidReportSize;
4124
uint8_t numOfButtonBytes;
4225
bool enableOutputReport;
4326
uint16_t outputReportLength;
27+
uint8_t _buttons[16]; // 8 bits x 16 bytes = 128 bits --> 128 button max
28+
uint8_t _specialButtons;
29+
int16_t _x;
30+
int16_t _y;
31+
int16_t _z;
32+
int16_t _rX;
33+
int16_t _rY;
34+
int16_t _rZ;
35+
int16_t _slider1;
36+
int16_t _slider2;
37+
int16_t _rudder;
38+
int16_t _throttle;
39+
int16_t _accelerator;
40+
int16_t _brake;
41+
int16_t _steering;
42+
int16_t _hat1;
43+
int16_t _hat2;
44+
int16_t _hat3;
45+
int16_t _hat4;
46+
int16_t _gX;
47+
int16_t _gY;
48+
int16_t _gZ;
49+
int16_t _aX;
50+
int16_t _aY;
51+
int16_t _aZ;
52+
uint8_t _batteryPowerInformation;
53+
uint8_t _dischargingState;
54+
uint8_t _chargingState;
55+
uint8_t _powerLevel;
4456
bool nusInitialized;
4557

4658
BleConnectionStatus *connectionStatus;
4759
BleOutputReceiver *outputReceiver;
60+
NimBLEServer *pServer;
61+
BleNUS* nus;
4862

63+
NimBLEHIDDevice *hid;
4964
NimBLECharacteristic *inputGamepad;
5065
NimBLECharacteristic *outputGamepad;
66+
NimBLECharacteristic *pCharacteristic_Power_State;
67+
5168
uint8_t *outputBackupBuffer;
5269

5370
void rawAction(uint8_t msg[], char msgSize);
@@ -56,21 +73,16 @@ class BleGamepad
5673

5774
public:
5875
BleGamepadConfiguration configuration;
59-
60-
BleGamepad(std::string deviceName = "ESP32 BLE Gamepad", std::string deviceManufacturer = "Espressif", uint8_t batteryLevel = 100, bool delayAdvertising = false);
6176

77+
BleGamepad(std::string deviceName = "ESP32 BLE Gamepad", std::string deviceManufacturer = "Espressif", uint8_t batteryLevel = 100, bool delayAdvertising = false);
6278
void begin(BleGamepadConfiguration *config = new BleGamepadConfiguration());
6379
void end(void);
64-
6580
void setAxes(int16_t x = 0, int16_t y = 0, int16_t z = 0, int16_t rX = 0, int16_t rY = 0, int16_t rZ = 0, int16_t slider1 = 0, int16_t slider2 = 0);
6681
void setHIDAxes(int16_t x = 0, int16_t y = 0, int16_t z = 0, int16_t rZ = 0, int16_t rX = 0, int16_t rY = 0, int16_t slider1 = 0, int16_t slider2 = 0);
67-
68-
void press(uint8_t b = BUTTON_1);
69-
void release(uint8_t b = BUTTON_1);
70-
82+
void press(uint8_t b = BUTTON_1); // press BUTTON_1 by default
83+
void release(uint8_t b = BUTTON_1); // release BUTTON_1 by default
7184
void pressSpecialButton(uint8_t b);
7285
void releaseSpecialButton(uint8_t b);
73-
7486
void pressStart();
7587
void releaseStart();
7688
void pressSelect();
@@ -87,73 +99,61 @@ class BleGamepad
8799
void releaseVolumeDec();
88100
void pressVolumeMute();
89101
void releaseVolumeMute();
90-
91102
void setLeftThumb(int16_t x = 0, int16_t y = 0);
92103
void setRightThumb(int16_t z = 0, int16_t rZ = 0);
93104
void setRightThumbAndroid(int16_t z = 0, int16_t rX = 0);
94105
void setLeftTrigger(int16_t rX = 0);
95106
void setRightTrigger(int16_t rY = 0);
96107
void setTriggers(int16_t rX = 0, int16_t rY = 0);
97-
98108
void setHats(signed char hat1 = 0, signed char hat2 = 0, signed char hat3 = 0, signed char hat4 = 0);
99109
void setHat(signed char hat = 0);
100110
void setHat1(signed char hat1 = 0);
101111
void setHat2(signed char hat2 = 0);
102112
void setHat3(signed char hat3 = 0);
103113
void setHat4(signed char hat4 = 0);
104-
105114
void setX(int16_t x = 0);
106115
void setY(int16_t y = 0);
107116
void setZ(int16_t z = 0);
108117
void setRZ(int16_t rZ = 0);
109118
void setRX(int16_t rX = 0);
110119
void setRY(int16_t rY = 0);
111-
112120
void setSliders(int16_t slider1 = 0, int16_t slider2 = 0);
113121
void setSlider(int16_t slider = 0);
114122
void setSlider1(int16_t slider1 = 0);
115123
void setSlider2(int16_t slider2 = 0);
116-
117124
void setRudder(int16_t rudder = 0);
118125
void setThrottle(int16_t throttle = 0);
119126
void setAccelerator(int16_t accelerator = 0);
120127
void setBrake(int16_t brake = 0);
121128
void setSteering(int16_t steering = 0);
122-
123129
void setSimulationControls(int16_t rudder = 0, int16_t throttle = 0, int16_t accelerator = 0, int16_t brake = 0, int16_t steering = 0);
124-
125130
void sendReport();
126-
bool isPressed(uint8_t b = BUTTON_1);
131+
bool isPressed(uint8_t b = BUTTON_1); // check BUTTON_1 by default
127132
bool isConnected(void);
128133
void resetButtons();
129-
130134
void setBatteryLevel(uint8_t level);
131135
void setPowerStateAll(uint8_t batteryPowerInformation, uint8_t dischargingState, uint8_t chargingState, uint8_t powerLevel);
132136
void setBatteryPowerInformation(uint8_t batteryPowerInformation);
133137
void setDischargingState(uint8_t dischargingState);
134138
void setChargingState(uint8_t chargingState);
135139
void setPowerLevel(uint8_t powerLevel);
136-
137140
void setTXPowerLevel(int8_t level = 9);
138141
int8_t getTXPowerLevel();
139-
142+
uint8_t batteryLevel;
143+
bool delayAdvertising;
140144
bool isOutputReceived();
141145
uint8_t* getOutputBuffer();
142-
143146
bool deleteBond(bool resetBoard = false);
144147
bool deleteAllBonds(bool resetBoard = false);
145148
bool enterPairingMode();
146-
147149
NimBLEAddress getAddress();
148150
String getStringAddress();
149151
NimBLEConnInfo getPeerInfo();
150152
String getDeviceName();
151153
String getDeviceManufacturer();
152-
153154
void setGyroscope(int16_t gX = 0, int16_t gY = 0, int16_t gZ = 0);
154155
void setAccelerometer(int16_t aX = 0, int16_t aY = 0, int16_t aZ = 0);
155156
void setMotionControls(int16_t gX = 0, int16_t gY = 0, int16_t gZ = 0, int16_t aX = 0, int16_t aY = 0, int16_t aZ = 0);
156-
157157
void beginNUS();
158158
void sendDataOverNUS(const uint8_t* data, size_t length);
159159
void setNUSDataReceivedCallback(void (*callback)(const uint8_t* data, size_t length));
@@ -165,4 +165,4 @@ class BleGamepad
165165

166166
#endif // CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
167167
#endif // CONFIG_BT_ENABLED
168-
#endif // ESP32_BLE_GAMEPAD_H
168+
#endif // ESP32_BLE_GAMEPAD_H

0 commit comments

Comments
 (0)