4
4
#include " NimBLEHIDDevice.h"
5
5
#include " HIDTypes.h"
6
6
#include " HIDKeyboardTypes.h"
7
- #include < driver/adc.h>
8
7
#include " sdkconfig.h"
9
8
10
9
#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
662
661
slider2 = axesMin;
663
662
}
664
663
665
- if (x > axesMax)
664
+ if (x > axesMax)
666
665
{
667
666
x = axesMax;
668
667
}
@@ -733,7 +732,7 @@ void BleGamepad::setSimulationControls(int16_t rudder, int16_t throttle, int16_t
733
732
steering = simulationMin;
734
733
}
735
734
736
- if (rudder > simulationMax)
735
+ if (rudder > simulationMax)
737
736
{
738
737
rudder = simulationMax;
739
738
}
@@ -789,8 +788,8 @@ void BleGamepad::setSliders(int16_t slider1, int16_t slider2)
789
788
{
790
789
slider2 = axesMin;
791
790
}
792
-
793
- if (slider1 > axesMax)
791
+
792
+ if (slider1 > axesMax)
794
793
{
795
794
slider1 = axesMax;
796
795
}
@@ -1094,7 +1093,7 @@ void BleGamepad::setLeftThumb(int16_t x, int16_t y)
1094
1093
y = axesMin;
1095
1094
}
1096
1095
1097
- if (x > axesMax)
1096
+ if (x > axesMax)
1098
1097
{
1099
1098
x = axesMax;
1100
1099
}
@@ -1123,7 +1122,7 @@ void BleGamepad::setRightThumb(int16_t z, int16_t rZ)
1123
1122
rZ = axesMin;
1124
1123
}
1125
1124
1126
- if (z > axesMax)
1125
+ if (z > axesMax)
1127
1126
{
1128
1127
z = axesMax;
1129
1128
}
@@ -1148,7 +1147,7 @@ void BleGamepad::setLeftTrigger(int16_t rX)
1148
1147
rX = axesMin;
1149
1148
}
1150
1149
1151
- if (rX > axesMax)
1150
+ if (rX > axesMax)
1152
1151
{
1153
1152
rX = axesMax;
1154
1153
}
@@ -1168,7 +1167,7 @@ void BleGamepad::setRightTrigger(int16_t rY)
1168
1167
rY = axesMin;
1169
1168
}
1170
1169
1171
- if (rY > axesMax)
1170
+ if (rY > axesMax)
1172
1171
{
1173
1172
rY = axesMax;
1174
1173
}
@@ -1187,15 +1186,17 @@ void BleGamepad::setTriggers(int16_t rX, int16_t rY)
1187
1186
{
1188
1187
rX = axesMin;
1189
1188
}
1189
+
1190
1190
if (rY < axesMin)
1191
1191
{
1192
1192
rY = axesMin;
1193
1193
}
1194
1194
1195
- if (rX > axesMax)
1195
+ if (rX > axesMax)
1196
1196
{
1197
1197
rX = axesMax;
1198
1198
}
1199
+
1199
1200
if (rY > axesMax)
1200
1201
{
1201
1202
rY = axesMax;
@@ -1267,7 +1268,7 @@ void BleGamepad::setX(int16_t x)
1267
1268
x = axesMin;
1268
1269
}
1269
1270
1270
- if (x > axesMax)
1271
+ if (x > axesMax)
1271
1272
{
1272
1273
x = axesMax;
1273
1274
}
@@ -1287,7 +1288,7 @@ void BleGamepad::setY(int16_t y)
1287
1288
y = axesMin;
1288
1289
}
1289
1290
1290
- if (y > axesMax)
1291
+ if (y > axesMax)
1291
1292
{
1292
1293
y = axesMax;
1293
1294
}
@@ -1307,7 +1308,7 @@ void BleGamepad::setZ(int16_t z)
1307
1308
z = axesMin;
1308
1309
}
1309
1310
1310
- if (z > axesMax)
1311
+ if (z > axesMax)
1311
1312
{
1312
1313
z = axesMax;
1313
1314
}
@@ -1327,7 +1328,7 @@ void BleGamepad::setRZ(int16_t rZ)
1327
1328
rZ = axesMin;
1328
1329
}
1329
1330
1330
- if (rZ > axesMax)
1331
+ if (rZ > axesMax)
1331
1332
{
1332
1333
rZ = axesMax;
1333
1334
}
@@ -1347,7 +1348,7 @@ void BleGamepad::setRX(int16_t rX)
1347
1348
rX = axesMin;
1348
1349
}
1349
1350
1350
- if (rX > axesMax)
1351
+ if (rX > axesMax)
1351
1352
{
1352
1353
rX = axesMax;
1353
1354
}
@@ -1367,7 +1368,7 @@ void BleGamepad::setRY(int16_t rY)
1367
1368
rY = axesMin;
1368
1369
}
1369
1370
1370
- if (rY > axesMax)
1371
+ if (rY > axesMax)
1371
1372
{
1372
1373
rY = axesMax;
1373
1374
}
@@ -1387,7 +1388,7 @@ void BleGamepad::setSlider(int16_t slider)
1387
1388
slider = axesMin;
1388
1389
}
1389
1390
1390
- if (slider > axesMax)
1391
+ if (slider > axesMax)
1391
1392
{
1392
1393
slider = axesMax;
1393
1394
}
@@ -1407,7 +1408,7 @@ void BleGamepad::setSlider1(int16_t slider1)
1407
1408
slider1 = axesMin;
1408
1409
}
1409
1410
1410
- if (slider1 > axesMax)
1411
+ if (slider1 > axesMax)
1411
1412
{
1412
1413
slider1 = axesMax;
1413
1414
}
@@ -1427,7 +1428,7 @@ void BleGamepad::setSlider2(int16_t slider2)
1427
1428
slider2 = axesMin;
1428
1429
}
1429
1430
1430
- if (slider2 > axesMax)
1431
+ if (slider2 > axesMax)
1431
1432
{
1432
1433
slider2 = axesMax;
1433
1434
}
@@ -1447,7 +1448,7 @@ void BleGamepad::setRudder(int16_t rudder)
1447
1448
rudder = simulationMin;
1448
1449
}
1449
1450
1450
- if (rudder > simulationMax)
1451
+ if (rudder > simulationMax)
1451
1452
{
1452
1453
rudder = simulationMax;
1453
1454
}
@@ -1467,7 +1468,7 @@ void BleGamepad::setThrottle(int16_t throttle)
1467
1468
throttle = simulationMin;
1468
1469
}
1469
1470
1470
- if (throttle > simulationMax)
1471
+ if (throttle > simulationMax)
1471
1472
{
1472
1473
throttle = simulationMax;
1473
1474
}
@@ -1487,7 +1488,7 @@ void BleGamepad::setAccelerator(int16_t accelerator)
1487
1488
accelerator = simulationMin;
1488
1489
}
1489
1490
1490
- if (accelerator > simulationMax)
1491
+ if (accelerator > simulationMax)
1491
1492
{
1492
1493
accelerator = simulationMax;
1493
1494
}
@@ -1507,7 +1508,7 @@ void BleGamepad::setBrake(int16_t brake)
1507
1508
brake = simulationMin;
1508
1509
}
1509
1510
1510
- if (brake > simulationMax)
1511
+ if (brake > simulationMax)
1511
1512
{
1512
1513
brake = simulationMax;
1513
1514
}
@@ -1527,7 +1528,7 @@ void BleGamepad::setSteering(int16_t steering)
1527
1528
steering = simulationMin;
1528
1529
}
1529
1530
1530
- if (steering > simulationMax)
1531
+ if (steering > simulationMax)
1531
1532
{
1532
1533
steering = simulationMax;
1533
1534
}
@@ -1590,11 +1591,6 @@ uint8_t* BleGamepad::getOutputBuffer(){
1590
1591
void BleGamepad::taskServer (void *pvParameter)
1591
1592
{
1592
1593
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
1598
1594
1599
1595
NimBLEDevice::init (BleGamepadInstance->deviceName );
1600
1596
NimBLEServer *pServer = NimBLEDevice::createServer ();
@@ -1649,8 +1645,8 @@ void BleGamepad::taskServer(void *pvParameter)
1649
1645
BleGamepadInstance->hid ->setPnp (0x01 , vid, pid, guidVersion);
1650
1646
BleGamepadInstance->hid ->setHidInfo (0x00 , 0x01 );
1651
1647
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
1654
1650
1655
1651
1656
1652
uint8_t *customHidReportDescriptor = new uint8_t [hidReportDescriptorSize];
0 commit comments