Skip to content

Commit 981b4f7

Browse files
committed
Add begin function
Unused for now, although it matches the other HID libraries that use a 'begin' function, and it's quite useful to have an initialization function ready if we ever need it.
1 parent b1e3330 commit 981b4f7

8 files changed

Lines changed: 20 additions & 5 deletions

File tree

examples/Blink/Blink.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include <XInput.h>
3232

3333
void setup() {
34-
34+
XInput.begin();
3535
}
3636

3737
void loop() {

examples/GamepadPins/GamepadPins.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,10 @@ void setup() {
114114
pinMode(Pin_DpadLeft, INPUT_PULLUP);
115115
pinMode(Pin_DpadRight, INPUT_PULLUP);
116116

117-
// Set joystick range to the ADC max
118-
XInput.setJoystickRange(0, ADC_Max);
119-
117+
XInput.setJoystickRange(0, ADC_Max); // Set joystick range to the ADC
120118
XInput.setAutoSend(false); // Wait for all controls before sending
119+
120+
XInput.begin();
121121
}
122122

123123
void loop() {

examples/ReceiveCallback/ReceiveCallback.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ void setup() {
4444
// Set callback function. Function must have a 'void' return type
4545
// and take a single uint8_t as an argument
4646
XInput.setReceiveCallback(rumbleCallback);
47+
48+
XInput.begin();
4749
}
4850

4951
void loop() {

examples/SimulateAll/SimulateAll.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ double angle = 0.0;
7575
void setup() {
7676
pinMode(SafetyPin, INPUT_PULLUP);
7777
XInput.setAutoSend(false); // Wait for all controls before sending
78+
79+
XInput.begin();
7880
}
7981

8082
void loop() {

examples/WiiClassicController/WiiClassicController.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ void setup() {
4343

4444
XInput.setAutoSend(false); // Wait for all controls before sending
4545

46+
XInput.begin();
47+
4648
while (!classic.connect()) {
4749
delay(1000); // Controller not connected
4850
}

keywords.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ XInputLEDPattern KEYWORD1
2121
# Methods and Functions (KEYWORD2)
2222
#######################################
2323

24+
# Setup
25+
begin KEYWORD2
26+
reset KEYWORD2
27+
2428
# Set Control Data
2529
press KEYWORD2
2630
release KEYWORD2
@@ -61,7 +65,6 @@ setJoystickRange KEYWORD2
6165
setRange KEYWORD2
6266

6367
# Other
64-
reset KEYWORD2
6568
printDebug KEYWORD2
6669

6770
#######################################

src/XInput.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@ XInputGamepad::XInputGamepad() :
203203
#endif
204204
}
205205

206+
void XInputGamepad::begin() {
207+
// Empty for now
208+
}
209+
206210
void XInputGamepad::press(uint8_t button) {
207211
setButton(button, true);
208212
}

src/XInput.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ class XInputGamepad {
7878
public:
7979
XInputGamepad();
8080

81+
void begin();
82+
8183
// Set Control Surfaces
8284
void press(uint8_t button);
8385
void release(uint8_t button);

0 commit comments

Comments
 (0)