| 219 | } |
| 220 | |
| 221 | void XInputController::setButton(uint8_t button, boolean state) { |
| 222 | const XInputMap_Button * buttonData = getButtonFromEnum((XInputControl) button); |
| 223 | if (buttonData != nullptr) { |
| 224 | if (getButton(button) == state) return; // Button hasn't changed |
| 225 | |
| 226 | if (state) { tx[buttonData->index] |= buttonData->mask; } // Press |
| 227 | else { tx[buttonData->index] &= ~(buttonData->mask); } // Release |
| 228 | newData = true; |
| 229 | autosend(); |
| 230 | } |
| 231 | else { |
| 232 | Range * triggerRange = getRangeFromEnum((XInputControl) button); |
| 233 | if (triggerRange == nullptr) return; // Not a trigger (or joystick, but the trigger function will ignore that) |
| 234 | setTrigger((XInputControl) button, state ? triggerRange->max : triggerRange->min); // Treat trigger like a button |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | void XInputController::setDpad(XInputControl pad, boolean state) { |
| 239 | setButton(pad, state); |
nothing calls this directly
no test coverage detected