Skip to content

Commit 284f2d8

Browse files
committed
Set control surface 'get' functions as const
1 parent 5ab63cb commit 284f2d8

2 files changed

Lines changed: 12 additions & 11 deletions

File tree

src/XInput.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,29 +261,29 @@ void XInputGamepad::releaseAll() {
261261
newData = true; // Data changed and is unsent
262262
}
263263

264-
boolean XInputGamepad::getButton(XInputControl button) {
264+
boolean XInputGamepad::getButton(XInputControl button) const {
265265
const XInputMap_Button * buttonData = getButtonFromEnum(button);
266266
if (buttonData == nullptr) return 0; // Not a button
267267
return tx[buttonData->index] & buttonData->mask;
268268
}
269269

270-
boolean XInputGamepad::getDpad(XInputControl dpad) {
270+
boolean XInputGamepad::getDpad(XInputControl dpad) const {
271271
return getButton(dpad);
272272
}
273273

274-
uint8_t XInputGamepad::getTrigger(XInputControl trigger) {
274+
uint8_t XInputGamepad::getTrigger(XInputControl trigger) const {
275275
const XInputMap_Trigger * triggerData = getTriggerFromEnum(trigger);
276276
if (triggerData == nullptr) return 0; // Not a trigger
277277
return tx[triggerData->index];
278278
}
279279

280-
int16_t XInputGamepad::getJoystickX(XInputControl joy) {
280+
int16_t XInputGamepad::getJoystickX(XInputControl joy) const {
281281
const XInputMap_Joystick * joyData = getJoyFromEnum(joy);
282282
if (joyData == nullptr) return 0; // Not a joystick
283283
return (tx[joyData->x_high] << 8) | tx[joyData->x_low];
284284
}
285285

286-
int16_t XInputGamepad::getJoystickY(XInputControl joy) {
286+
int16_t XInputGamepad::getJoystickY(XInputControl joy) const {
287287
const XInputMap_Joystick * joyData = getJoyFromEnum(joy);
288288
if (joyData == nullptr) return 0; // Not a joystick
289289
return (tx[joyData->y_high] << 8) | tx[joyData->y_low];

src/XInput.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class XInputGamepad {
7373
public:
7474
XInputGamepad();
7575

76-
// Control surfaces
76+
// Set Control Surfaces
7777
void press(XInputControl button);
7878
void release(XInputControl button);
7979
void setButton(XInputControl button, boolean state);
@@ -87,11 +87,12 @@ class XInputGamepad {
8787

8888
void releaseAll();
8989

90-
boolean getButton(XInputControl button);
91-
boolean getDpad(XInputControl dpad);
92-
uint8_t getTrigger(XInputControl trigger);
93-
int16_t getJoystickX(XInputControl joy);
94-
int16_t getJoystickY(XInputControl joy);
90+
// Read Control Surfaces
91+
boolean getButton(XInputControl button) const;
92+
boolean getDpad(XInputControl dpad) const;
93+
uint8_t getTrigger(XInputControl trigger) const;
94+
int16_t getJoystickX(XInputControl joy) const;
95+
int16_t getJoystickY(XInputControl joy) const;
9596

9697
// Received Data
9798
uint8_t getPlayer() const; // Player # assigned to the controller (0 is unassigned)

0 commit comments

Comments
 (0)