Skip to content

Commit beed5c6

Browse files
committed
Code formatting
1 parent 91a78b2 commit beed5c6

File tree

1 file changed

+35
-12
lines changed

1 file changed

+35
-12
lines changed

src/common/hid_BLE.cpp

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,9 @@ class BleConnectionStatus : public BLEServerCallbacks
308308
BLEDevice::startAdvertising();
309309
OnDisconnected::notify();
310310
if (autoPowerOffTimer != nullptr)
311-
esp_timer_start_once(autoPowerOffTimer, AUTO_POWER_OFF_DELAY_SECS * 1000000);
311+
esp_timer_start_once(
312+
autoPowerOffTimer,
313+
AUTO_POWER_OFF_DELAY_SECS * 1000000);
312314
};
313315

314316
} connectionStatus;
@@ -323,7 +325,10 @@ class FeatureReport : public BLECharacteristicCallbacks
323325
void onWrite(BLECharacteristic *pCharacteristic) override;
324326
void onRead(BLECharacteristic *pCharacteristic) override;
325327
FeatureReport(uint8_t RID, uint16_t size);
326-
static void attachTo(BLEHIDDeviceFix *hidDevice, uint8_t RID, uint16_t size);
328+
static void attachTo(
329+
BLEHIDDeviceFix *hidDevice,
330+
uint8_t RID,
331+
uint16_t size);
327332

328333
private:
329334
uint8_t _reportID;
@@ -354,7 +359,10 @@ FeatureReport::FeatureReport(uint8_t RID, uint16_t size)
354359
}
355360

356361
// Attach to HID device
357-
void FeatureReport::attachTo(BLEHIDDeviceFix *hidDevice, uint8_t RID, uint16_t size)
362+
void FeatureReport::attachTo(
363+
BLEHIDDeviceFix *hidDevice,
364+
uint8_t RID,
365+
uint16_t size)
358366
{
359367
BLECharacteristic *reportCharacteristic = hidDevice->featureReport(RID);
360368
if (!reportCharacteristic)
@@ -445,20 +453,28 @@ void internals::hid::begin(
445453
pServer->setCallbacks(&connectionStatus);
446454
BLESecurity *pSecurity = new BLESecurity();
447455
pSecurity->setAuthenticationMode(ESP_LE_AUTH_REQ_SC_MITM_BOND);
448-
pSecurity->setInitEncryptionKey(ESP_BLE_ENC_KEY_MASK | ESP_BLE_ID_KEY_MASK);
456+
pSecurity->setInitEncryptionKey(
457+
ESP_BLE_ENC_KEY_MASK | ESP_BLE_ID_KEY_MASK);
449458

450459
// HID initialization
451460
hidDevice = new BLEHIDDeviceFix(pServer);
452461
if (!hidDevice)
453462
throw std::runtime_error("Unable to create HID device");
454463

455-
hidDevice->manufacturer()->setValue(String(deviceManufacturer.c_str())); // Workaround for bug in `hidDevice->manufacturer(deviceManufacturer)`
464+
hidDevice->manufacturer()->setValue(
465+
// Workaround for bug in
466+
// `hidDevice->manufacturer(deviceManufacturer)`
467+
String(deviceManufacturer.c_str()));
456468

457469
// Note: Workaround for bug in ESP-Arduino as of version 3.0.3
458470
uint16_t debugged_vid = byteswap(vendorID);
459471
uint16_t debugged_pid = byteswap(productID);
460472

461-
hidDevice->pnp(BLE_VENDOR_SOURCE, debugged_vid, debugged_pid, PRODUCT_REVISION);
473+
hidDevice->pnp(
474+
BLE_VENDOR_SOURCE,
475+
debugged_vid,
476+
debugged_pid,
477+
PRODUCT_REVISION);
462478
hidDevice->hidInfo(0x00, 0x01);
463479
hidDevice->reportMap((uint8_t *)hid_descriptor, sizeof(hid_descriptor));
464480

@@ -469,10 +485,13 @@ void internals::hid::begin(
469485
BLEService *deviceInfo = hidDevice->deviceInfo();
470486
if (deviceInfo)
471487
{
472-
BLECharacteristic *serialNumChr = deviceInfo->getCharacteristic(serialNumberChrUuid);
488+
BLECharacteristic *serialNumChr =
489+
deviceInfo->getCharacteristic(serialNumberChrUuid);
473490
if (!serialNumChr)
474491
serialNumChr =
475-
deviceInfo->createCharacteristic(serialNumberChrUuid, BLECharacteristic::PROPERTY_READ);
492+
deviceInfo->createCharacteristic(
493+
serialNumberChrUuid,
494+
BLECharacteristic::PROPERTY_READ);
476495
if (serialNumChr)
477496
{
478497
char serialAsStr[9];
@@ -485,10 +504,14 @@ void internals::hid::begin(
485504

486505
// Create HID reports
487506
inputGamePad = hidDevice->inputReport(RID_INPUT_GAMEPAD);
488-
FeatureReport::attachTo(hidDevice, RID_FEATURE_CAPABILITIES, CAPABILITIES_REPORT_SIZE);
489-
FeatureReport::attachTo(hidDevice, RID_FEATURE_CONFIG, CONFIG_REPORT_SIZE);
490-
FeatureReport::attachTo(hidDevice, RID_FEATURE_BUTTONS_MAP, BUTTONS_MAP_REPORT_SIZE);
491-
FeatureReport::attachTo(hidDevice, RID_FEATURE_HARDWARE_ID, HARDWARE_ID_REPORT_SIZE);
507+
FeatureReport::attachTo(
508+
hidDevice, RID_FEATURE_CAPABILITIES, CAPABILITIES_REPORT_SIZE);
509+
FeatureReport::attachTo(
510+
hidDevice, RID_FEATURE_CONFIG, CONFIG_REPORT_SIZE);
511+
FeatureReport::attachTo(
512+
hidDevice, RID_FEATURE_BUTTONS_MAP, BUTTONS_MAP_REPORT_SIZE);
513+
FeatureReport::attachTo(
514+
hidDevice, RID_FEATURE_HARDWARE_ID, HARDWARE_ID_REPORT_SIZE);
492515
OutputReport::attachTo(hidDevice, RID_OUTPUT_POWERTRAIN);
493516
OutputReport::attachTo(hidDevice, RID_OUTPUT_ECU);
494517
OutputReport::attachTo(hidDevice, RID_OUTPUT_RACE_CONTROL);

0 commit comments

Comments
 (0)