Skip to content

Commit 245bde6

Browse files
authored
Update BleGamepad.cpp
Formatting
1 parent cc04551 commit 245bde6

File tree

1 file changed

+27
-31
lines changed

1 file changed

+27
-31
lines changed

BleGamepad.cpp

+27-31
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include "NimBLEHIDDevice.h"
55
#include "HIDTypes.h"
66
#include "HIDKeyboardTypes.h"
7-
#include <driver/adc.h>
87
#include "sdkconfig.h"
98

109
#include "BleConnectionStatus.h"
@@ -662,7 +661,7 @@ void BleGamepad::setAxes(int16_t x, int16_t y, int16_t z, int16_t rZ, int16_t rX
662661
slider2 = axesMin;
663662
}
664663

665-
if (x > axesMax)
664+
if (x > axesMax)
666665
{
667666
x = axesMax;
668667
}
@@ -733,7 +732,7 @@ void BleGamepad::setSimulationControls(int16_t rudder, int16_t throttle, int16_t
733732
steering = simulationMin;
734733
}
735734

736-
if (rudder > simulationMax)
735+
if (rudder > simulationMax)
737736
{
738737
rudder = simulationMax;
739738
}
@@ -789,8 +788,8 @@ void BleGamepad::setSliders(int16_t slider1, int16_t slider2)
789788
{
790789
slider2 = axesMin;
791790
}
792-
793-
if (slider1 > axesMax)
791+
792+
if (slider1 > axesMax)
794793
{
795794
slider1 = axesMax;
796795
}
@@ -1094,7 +1093,7 @@ void BleGamepad::setLeftThumb(int16_t x, int16_t y)
10941093
y = axesMin;
10951094
}
10961095

1097-
if (x > axesMax)
1096+
if (x > axesMax)
10981097
{
10991098
x = axesMax;
11001099
}
@@ -1123,7 +1122,7 @@ void BleGamepad::setRightThumb(int16_t z, int16_t rZ)
11231122
rZ = axesMin;
11241123
}
11251124

1126-
if (z > axesMax)
1125+
if (z > axesMax)
11271126
{
11281127
z = axesMax;
11291128
}
@@ -1148,7 +1147,7 @@ void BleGamepad::setLeftTrigger(int16_t rX)
11481147
rX = axesMin;
11491148
}
11501149

1151-
if (rX > axesMax)
1150+
if (rX > axesMax)
11521151
{
11531152
rX = axesMax;
11541153
}
@@ -1168,7 +1167,7 @@ void BleGamepad::setRightTrigger(int16_t rY)
11681167
rY = axesMin;
11691168
}
11701169

1171-
if (rY > axesMax)
1170+
if (rY > axesMax)
11721171
{
11731172
rY = axesMax;
11741173
}
@@ -1187,15 +1186,17 @@ void BleGamepad::setTriggers(int16_t rX, int16_t rY)
11871186
{
11881187
rX = axesMin;
11891188
}
1189+
11901190
if (rY < axesMin)
11911191
{
11921192
rY = axesMin;
11931193
}
11941194

1195-
if (rX > axesMax)
1195+
if (rX > axesMax)
11961196
{
11971197
rX = axesMax;
11981198
}
1199+
11991200
if (rY > axesMax)
12001201
{
12011202
rY = axesMax;
@@ -1267,7 +1268,7 @@ void BleGamepad::setX(int16_t x)
12671268
x = axesMin;
12681269
}
12691270

1270-
if (x > axesMax)
1271+
if (x > axesMax)
12711272
{
12721273
x = axesMax;
12731274
}
@@ -1287,7 +1288,7 @@ void BleGamepad::setY(int16_t y)
12871288
y = axesMin;
12881289
}
12891290

1290-
if (y > axesMax)
1291+
if (y > axesMax)
12911292
{
12921293
y = axesMax;
12931294
}
@@ -1307,7 +1308,7 @@ void BleGamepad::setZ(int16_t z)
13071308
z = axesMin;
13081309
}
13091310

1310-
if (z > axesMax)
1311+
if (z > axesMax)
13111312
{
13121313
z = axesMax;
13131314
}
@@ -1327,7 +1328,7 @@ void BleGamepad::setRZ(int16_t rZ)
13271328
rZ = axesMin;
13281329
}
13291330

1330-
if (rZ > axesMax)
1331+
if (rZ > axesMax)
13311332
{
13321333
rZ = axesMax;
13331334
}
@@ -1347,7 +1348,7 @@ void BleGamepad::setRX(int16_t rX)
13471348
rX = axesMin;
13481349
}
13491350

1350-
if (rX > axesMax)
1351+
if (rX > axesMax)
13511352
{
13521353
rX = axesMax;
13531354
}
@@ -1367,7 +1368,7 @@ void BleGamepad::setRY(int16_t rY)
13671368
rY = axesMin;
13681369
}
13691370

1370-
if (rY > axesMax)
1371+
if (rY > axesMax)
13711372
{
13721373
rY = axesMax;
13731374
}
@@ -1387,7 +1388,7 @@ void BleGamepad::setSlider(int16_t slider)
13871388
slider = axesMin;
13881389
}
13891390

1390-
if (slider > axesMax)
1391+
if (slider > axesMax)
13911392
{
13921393
slider = axesMax;
13931394
}
@@ -1407,7 +1408,7 @@ void BleGamepad::setSlider1(int16_t slider1)
14071408
slider1 = axesMin;
14081409
}
14091410

1410-
if (slider1 > axesMax)
1411+
if (slider1 > axesMax)
14111412
{
14121413
slider1 = axesMax;
14131414
}
@@ -1427,7 +1428,7 @@ void BleGamepad::setSlider2(int16_t slider2)
14271428
slider2 = axesMin;
14281429
}
14291430

1430-
if (slider2 > axesMax)
1431+
if (slider2 > axesMax)
14311432
{
14321433
slider2 = axesMax;
14331434
}
@@ -1447,7 +1448,7 @@ void BleGamepad::setRudder(int16_t rudder)
14471448
rudder = simulationMin;
14481449
}
14491450

1450-
if (rudder > simulationMax)
1451+
if (rudder > simulationMax)
14511452
{
14521453
rudder = simulationMax;
14531454
}
@@ -1467,7 +1468,7 @@ void BleGamepad::setThrottle(int16_t throttle)
14671468
throttle = simulationMin;
14681469
}
14691470

1470-
if (throttle > simulationMax)
1471+
if (throttle > simulationMax)
14711472
{
14721473
throttle = simulationMax;
14731474
}
@@ -1487,7 +1488,7 @@ void BleGamepad::setAccelerator(int16_t accelerator)
14871488
accelerator = simulationMin;
14881489
}
14891490

1490-
if (accelerator > simulationMax)
1491+
if (accelerator > simulationMax)
14911492
{
14921493
accelerator = simulationMax;
14931494
}
@@ -1507,7 +1508,7 @@ void BleGamepad::setBrake(int16_t brake)
15071508
brake = simulationMin;
15081509
}
15091510

1510-
if (brake > simulationMax)
1511+
if (brake > simulationMax)
15111512
{
15121513
brake = simulationMax;
15131514
}
@@ -1527,7 +1528,7 @@ void BleGamepad::setSteering(int16_t steering)
15271528
steering = simulationMin;
15281529
}
15291530

1530-
if (steering > simulationMax)
1531+
if (steering > simulationMax)
15311532
{
15321533
steering = simulationMax;
15331534
}
@@ -1590,11 +1591,6 @@ uint8_t* BleGamepad::getOutputBuffer(){
15901591
void BleGamepad::taskServer(void *pvParameter)
15911592
{
15921593
BleGamepad *BleGamepadInstance = (BleGamepad *)pvParameter; // static_cast<BleGamepad *>(pvParameter);
1593-
1594-
// Use the procedure below to set a custom Bluetooth MAC address
1595-
// Compiler adds 0x02 to the last value of board's base MAC address to get the BT MAC address, so take 0x02 away from the value you actually want when setting
1596-
//uint8_t newMACAddress[] = {0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF - 0x02};
1597-
//esp_base_mac_addr_set(&newMACAddress[0]); // Set new MAC address
15981594

15991595
NimBLEDevice::init(BleGamepadInstance->deviceName);
16001596
NimBLEServer *pServer = NimBLEDevice::createServer();
@@ -1649,8 +1645,8 @@ void BleGamepad::taskServer(void *pvParameter)
16491645
BleGamepadInstance->hid->setPnp(0x01, vid, pid, guidVersion);
16501646
BleGamepadInstance->hid->setHidInfo(0x00, 0x01);
16511647

1652-
// NimBLEDevice::setSecurityAuth(BLE_SM_PAIR_AUTHREQ_BOND);
1653-
NimBLEDevice::setSecurityAuth(true, false, false); // enable bonding, no MITM, no SC
1648+
// NimBLEDevice::setSecurityAuth(BLE_SM_PAIR_AUTHREQ_BOND);
1649+
NimBLEDevice::setSecurityAuth(true, false, false); // enable bonding, no MITM, no SC
16541650

16551651

16561652
uint8_t *customHidReportDescriptor = new uint8_t[hidReportDescriptorSize];

0 commit comments

Comments
 (0)