-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The examples and readme treated R/L triggers as signed chars, however they are now correctly referenced as chars (0 ~ 255) The HID descriptor was correct, but now people using the library will have a better chance of using the triggers correctly ;)
- Loading branch information
1 parent
ce8cf9e
commit 34fb08f
Showing
3 changed files
with
56 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include <Bounce2.h> // https://github.com/thomasfredericks/Bounce2 | ||
#include <BleGamepad.h> // https://github.com/lemmingDev/ESP32-BLE-Gamepad | ||
|
||
#define BUTTON_PIN 2 | ||
#define LED_PIN 13 | ||
|
||
Bounce debouncer = Bounce(); // Instantiate a Bounce object | ||
BleGamepad bleGamepad; // Instantiate a BleGamepad object | ||
|
||
void setup() | ||
{ | ||
bleGamepad.begin(); // Begin the gamepad | ||
|
||
pinMode(BUTTON_PIN, INPUT_PULLUP); // Setup the button with an internal pull-up | ||
|
||
debouncer.attach(BUTTON_PIN); // After setting up the button, setup the Bounce instance : | ||
debouncer.interval(5); // interval in ms | ||
|
||
pinMode(LED_PIN, OUTPUT); // Setup the LED : | ||
} | ||
|
||
void loop() | ||
{ | ||
if(bleGamepad.isConnected()) | ||
{ | ||
debouncer.update(); // Update the Bounce instance | ||
|
||
int value = debouncer.read(); // Get the updated value | ||
|
||
// Press gamepad button and turn on or off the LED as determined by the state | ||
if (value == LOW) | ||
{ | ||
digitalWrite(LED_PIN, HIGH); | ||
bleGamepad.press(BUTTON_1); | ||
} | ||
else | ||
{ | ||
digitalWrite(LED_PIN, LOW); | ||
bleGamepad.release(BUTTON_1); | ||
} | ||
} | ||
} |