Skip to content

Commit 4038334

Browse files
authored
Merge pull request #10 from dmadison/development
Press by Numbers
2 parents 296da4c + d80e09e commit 4038334

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

examples/GamepadPins/GamepadPins.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@
4242
#include <XInput.h>
4343

4444
// Setup
45-
const boolean UseLeftJoystick = true; // set to false to disable left joystick
45+
const boolean UseLeftJoystick = false; // set to true to enable left joystick
4646
const boolean InvertLeftYAxis = false; // set to true to use inverted left joy Y
4747

48-
const boolean UseRightJoystick = true; // set to false to disable right joystick
48+
const boolean UseRightJoystick = false; // set to true to enable right joystick
4949
const boolean InvertRightYAxis = false; // set to true to use inverted right joy Y
5050

5151
const boolean UseTriggerButtons = true; // set to false if using analog triggers

src/XInput.cpp

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

206-
void XInputGamepad::press(XInputControl button) {
206+
void XInputGamepad::press(uint8_t button) {
207207
setButton(button, true);
208208
}
209209

210-
void XInputGamepad::release(XInputControl button) {
210+
void XInputGamepad::release(uint8_t button) {
211211
setButton(button, false);
212212
}
213213

214-
void XInputGamepad::setButton(XInputControl button, boolean state) {
215-
const XInputMap_Button * buttonData = getButtonFromEnum(button);
214+
void XInputGamepad::setButton(uint8_t button, boolean state) {
215+
const XInputMap_Button * buttonData = getButtonFromEnum((XInputControl) button);
216216
if (buttonData != nullptr) {
217217
if (getButton(button) == state) return; // Button hasn't changed
218218

@@ -222,9 +222,9 @@ void XInputGamepad::setButton(XInputControl button, boolean state) {
222222
autosend();
223223
}
224224
else {
225-
Range * triggerRange = getRangeFromEnum(button);
225+
Range * triggerRange = getRangeFromEnum((XInputControl) button);
226226
if (triggerRange == nullptr) return; // Not a trigger (or joystick, but the trigger function will ignore that)
227-
setTrigger(button, state ? triggerRange->max : triggerRange->min); // Treat trigger like a button
227+
setTrigger((XInputControl) button, state ? triggerRange->max : triggerRange->min); // Treat trigger like a button
228228
}
229229
}
230230

@@ -291,8 +291,8 @@ void XInputGamepad::setAutoSend(boolean a) {
291291
autoSendOption = a;
292292
}
293293

294-
boolean XInputGamepad::getButton(XInputControl button) const {
295-
const XInputMap_Button * buttonData = getButtonFromEnum(button);
294+
boolean XInputGamepad::getButton(uint8_t button) const {
295+
const XInputMap_Button * buttonData = getButtonFromEnum((XInputControl) button);
296296
if (buttonData == nullptr) return 0; // Not a button
297297
return tx[buttonData->index] & buttonData->mask;
298298
}

src/XInput.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ class XInputGamepad {
7979
XInputGamepad();
8080

8181
// Set Control Surfaces
82-
void press(XInputControl button);
83-
void release(XInputControl button);
84-
void setButton(XInputControl button, boolean state);
82+
void press(uint8_t button);
83+
void release(uint8_t button);
84+
void setButton(uint8_t button, boolean state);
8585

8686
void setDpad(XInputControl pad, boolean state);
8787
void setDpad(boolean up, boolean down, boolean left, boolean right);
@@ -96,7 +96,7 @@ class XInputGamepad {
9696
void setAutoSend(boolean a);
9797

9898
// Read Control Surfaces
99-
boolean getButton(XInputControl button) const;
99+
boolean getButton(uint8_t button) const;
100100
boolean getDpad(XInputControl dpad) const;
101101
uint8_t getTrigger(XInputControl trigger) const;
102102
int16_t getJoystickX(XInputControl joy) const;

0 commit comments

Comments
 (0)