Skip to content

Commit

Permalink
Merge pull request #164 from userx14/master
Browse files Browse the repository at this point in the history
Add support for custom guid version.
  • Loading branch information
lemmingDev authored Mar 5, 2023
2 parents f74c1a5 + 4ac2cd8 commit 756dc28
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
8 changes: 7 additions & 1 deletion BleGamepad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ uint8_t reportSize = 0;
uint8_t numOfButtonBytes = 0;
uint16_t vid;
uint16_t pid;
uint16_t guidVersion;
uint16_t axesMin;
uint16_t axesMax;
uint16_t simulationMin;
Expand Down Expand Up @@ -89,6 +90,7 @@ void BleGamepad::begin(BleGamepadConfiguration *config)

vid = configuration.getVid();
pid = configuration.getPid();
guidVersion = configuration.getGuidVersion();

uint8_t high = highByte(vid);
uint8_t low = lowByte(vid);
Expand All @@ -99,6 +101,10 @@ void BleGamepad::begin(BleGamepadConfiguration *config)
low = lowByte(pid);

pid = low << 8 | high;

high = highByte(guidVersion);
low = lowByte(guidVersion);
guidVersion = low << 8 | high;

uint8_t buttonPaddingBits = 8 - (configuration.getButtonCount() % 8);
if (buttonPaddingBits == 8)
Expand Down Expand Up @@ -1400,7 +1406,7 @@ void BleGamepad::taskServer(void *pvParameter)
);
pCharacteristic_Hardware_Revision->setValue(hardwareRevision);

BleGamepadInstance->hid->pnp(0x01, vid, pid, 0x0110);
BleGamepadInstance->hid->pnp(0x01, vid, pid, guidVersion);
BleGamepadInstance->hid->hidInfo(0x00, 0x01);

NimBLEDevice::setSecurityAuth(BLE_SM_PAIR_AUTHREQ_BOND);
Expand Down
3 changes: 3 additions & 0 deletions BleGamepadConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ BleGamepadConfiguration::BleGamepadConfiguration() : _controllerType(CONTROLLER_
_whichSimulationControls{false, false, false, false, false},
_vid(0xe502),
_pid(0xbbab),
_guidVersion(0x0110),
_axesMin(0x0000),
_axesMax(0x7FFF),
_simulationMin(0x0000),
Expand Down Expand Up @@ -79,6 +80,7 @@ uint8_t BleGamepadConfiguration::getSimulationCount()

uint16_t BleGamepadConfiguration::getVid(){ return _vid; }
uint16_t BleGamepadConfiguration::getPid(){ return _pid; }
uint16_t BleGamepadConfiguration::getGuidVersion(){ return _guidVersion; }
int16_t BleGamepadConfiguration::getAxesMin(){ return _axesMin; }
int16_t BleGamepadConfiguration::getAxesMax(){ return _axesMax; }
int16_t BleGamepadConfiguration::getSimulationMin(){ return _simulationMin; }
Expand Down Expand Up @@ -179,6 +181,7 @@ void BleGamepadConfiguration::setIncludeBrake(bool value) { _whichSimulationCont
void BleGamepadConfiguration::setIncludeSteering(bool value) { _whichSimulationControls[STEERING] = value; }
void BleGamepadConfiguration::setVid(uint16_t value) { _vid = value; }
void BleGamepadConfiguration::setPid(uint16_t value) { _pid = value; }
void BleGamepadConfiguration::setGuidVersion(uint16_t value) { _guidVersion = value; }
void BleGamepadConfiguration::setAxesMin(int16_t value) { _axesMin = value; }
void BleGamepadConfiguration::setAxesMax(int16_t value) { _axesMax = value; }
void BleGamepadConfiguration::setSimulationMin(int16_t value) { _simulationMin = value; }
Expand Down
3 changes: 3 additions & 0 deletions BleGamepadConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ class BleGamepadConfiguration
bool _whichSimulationControls[POSSIBLESIMULATIONCONTROLS];
uint16_t _vid;
uint16_t _pid;
uint16_t _guidVersion;
int16_t _axesMin;
int16_t _axesMax;
int16_t _simulationMin;
Expand Down Expand Up @@ -261,6 +262,7 @@ class BleGamepadConfiguration
const bool *getWhichSimulationControls() const;
uint16_t getVid();
uint16_t getPid();
uint16_t getGuidVersion();
int16_t getAxesMin();
int16_t getAxesMax();
int16_t getSimulationMin();
Expand Down Expand Up @@ -302,6 +304,7 @@ class BleGamepadConfiguration
void setWhichSimulationControls(bool rudder, bool throttle, bool accelerator, bool brake, bool steering);
void setVid(uint16_t value);
void setPid(uint16_t value);
void setGuidVersion(uint16_t value);
void setAxesMin(int16_t value);
void setAxesMax(int16_t value);
void setSimulationMin(int16_t value);
Expand Down
2 changes: 2 additions & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ getIncludeSteering KEYWORD2
getWhichSimulationControls KEYWORD2
getVid KEYWORD2
getPid KEYWORD2
getGuidVersion KEYWORD2
getAxesMin KEYWORD2
getAxesMax KEYWORD2
getSimulationMin KEYWORD2
Expand All @@ -141,6 +142,7 @@ getFirmwareRevision KEYWORD2
getHardwareRevision KEYWORD2
setVid KEYWORD2
setPid KEYWORD2
setGuidVersion KEYWORD2
setAxesMin KEYWORD2
setAxesMax KEYWORD2
setSimulationMin KEYWORD2
Expand Down

0 comments on commit 756dc28

Please sign in to comment.