Skip to content

Commit 1a1c5ba

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

File tree

1 file changed

+41
-45
lines changed

1 file changed

+41
-45
lines changed

BleGamepad.h

Lines changed: 41 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -16,59 +16,38 @@
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+
1935
std::string deviceManufacturer;
2036
std::string deviceName;
37+
2138
uint8_t tempHidReportDescriptor[150];
2239
int hidReportDescriptorSize;
2340
uint8_t hidReportSize;
2441
uint8_t numOfButtonBytes;
2542
bool enableOutputReport;
2643
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;
5644
bool nusInitialized;
5745

58-
//BleGamepadConfiguration configuration;
59-
6046
BleConnectionStatus *connectionStatus;
61-
6247
BleOutputReceiver *outputReceiver;
63-
64-
NimBLEServer *pServer;
65-
BleNUS* nus;
6648

67-
NimBLEHIDDevice *hid;
6849
NimBLECharacteristic *inputGamepad;
6950
NimBLECharacteristic *outputGamepad;
70-
NimBLECharacteristic *pCharacteristic_Power_State;
71-
7251
uint8_t *outputBackupBuffer;
7352

7453
void rawAction(uint8_t msg[], char msgSize);
@@ -77,16 +56,21 @@ class BleGamepad
7756

7857
public:
7958
BleGamepadConfiguration configuration;
80-
59+
8160
BleGamepad(std::string deviceName = "ESP32 BLE Gamepad", std::string deviceManufacturer = "Espressif", uint8_t batteryLevel = 100, bool delayAdvertising = false);
61+
8262
void begin(BleGamepadConfiguration *config = new BleGamepadConfiguration());
8363
void end(void);
64+
8465
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);
8566
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);
86-
void press(uint8_t b = BUTTON_1); // press BUTTON_1 by default
87-
void release(uint8_t b = BUTTON_1); // release BUTTON_1 by default
67+
68+
void press(uint8_t b = BUTTON_1);
69+
void release(uint8_t b = BUTTON_1);
70+
8871
void pressSpecialButton(uint8_t b);
8972
void releaseSpecialButton(uint8_t b);
73+
9074
void pressStart();
9175
void releaseStart();
9276
void pressSelect();
@@ -103,61 +87,73 @@ class BleGamepad
10387
void releaseVolumeDec();
10488
void pressVolumeMute();
10589
void releaseVolumeMute();
90+
10691
void setLeftThumb(int16_t x = 0, int16_t y = 0);
10792
void setRightThumb(int16_t z = 0, int16_t rZ = 0);
10893
void setRightThumbAndroid(int16_t z = 0, int16_t rX = 0);
10994
void setLeftTrigger(int16_t rX = 0);
11095
void setRightTrigger(int16_t rY = 0);
11196
void setTriggers(int16_t rX = 0, int16_t rY = 0);
97+
11298
void setHats(signed char hat1 = 0, signed char hat2 = 0, signed char hat3 = 0, signed char hat4 = 0);
11399
void setHat(signed char hat = 0);
114100
void setHat1(signed char hat1 = 0);
115101
void setHat2(signed char hat2 = 0);
116102
void setHat3(signed char hat3 = 0);
117103
void setHat4(signed char hat4 = 0);
104+
118105
void setX(int16_t x = 0);
119106
void setY(int16_t y = 0);
120107
void setZ(int16_t z = 0);
121108
void setRZ(int16_t rZ = 0);
122109
void setRX(int16_t rX = 0);
123110
void setRY(int16_t rY = 0);
111+
124112
void setSliders(int16_t slider1 = 0, int16_t slider2 = 0);
125113
void setSlider(int16_t slider = 0);
126114
void setSlider1(int16_t slider1 = 0);
127115
void setSlider2(int16_t slider2 = 0);
116+
128117
void setRudder(int16_t rudder = 0);
129118
void setThrottle(int16_t throttle = 0);
130119
void setAccelerator(int16_t accelerator = 0);
131120
void setBrake(int16_t brake = 0);
132121
void setSteering(int16_t steering = 0);
122+
133123
void setSimulationControls(int16_t rudder = 0, int16_t throttle = 0, int16_t accelerator = 0, int16_t brake = 0, int16_t steering = 0);
124+
134125
void sendReport();
135-
bool isPressed(uint8_t b = BUTTON_1); // check BUTTON_1 by default
126+
bool isPressed(uint8_t b = BUTTON_1);
136127
bool isConnected(void);
137128
void resetButtons();
129+
138130
void setBatteryLevel(uint8_t level);
139131
void setPowerStateAll(uint8_t batteryPowerInformation, uint8_t dischargingState, uint8_t chargingState, uint8_t powerLevel);
140132
void setBatteryPowerInformation(uint8_t batteryPowerInformation);
141133
void setDischargingState(uint8_t dischargingState);
142134
void setChargingState(uint8_t chargingState);
143135
void setPowerLevel(uint8_t powerLevel);
136+
144137
void setTXPowerLevel(int8_t level = 9);
145138
int8_t getTXPowerLevel();
146-
uint8_t batteryLevel;
147-
bool delayAdvertising;
139+
148140
bool isOutputReceived();
149141
uint8_t* getOutputBuffer();
142+
150143
bool deleteBond(bool resetBoard = false);
151144
bool deleteAllBonds(bool resetBoard = false);
152145
bool enterPairingMode();
146+
153147
NimBLEAddress getAddress();
154148
String getStringAddress();
155149
NimBLEConnInfo getPeerInfo();
156150
String getDeviceName();
157151
String getDeviceManufacturer();
152+
158153
void setGyroscope(int16_t gX = 0, int16_t gY = 0, int16_t gZ = 0);
159154
void setAccelerometer(int16_t aX = 0, int16_t aY = 0, int16_t aZ = 0);
160155
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+
161157
void beginNUS();
162158
void sendDataOverNUS(const uint8_t* data, size_t length);
163159
void setNUSDataReceivedCallback(void (*callback)(const uint8_t* data, size_t length));
@@ -169,4 +165,4 @@ class BleGamepad
169165

170166
#endif // CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
171167
#endif // CONFIG_BT_ENABLED
172-
#endif // ESP32_BLE_GAMEPAD_H
168+
#endif // ESP32_BLE_GAMEPAD_H

0 commit comments

Comments
 (0)