MCPcopy Create free account
hub / github.com/dmadison/ArduinoXInput / XInputController

Class XInputController

src/XInput.h:77–166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75
76
77class XInputController {
78public:
79 XInputController();
80
81 void begin();
82
83 // Set Control Surfaces
84 void press(uint8_t button);
85 void release(uint8_t button);
86 void setButton(uint8_t button, boolean state);
87
88 void setDpad(XInputControl pad, boolean state);
89 void setDpad(boolean up, boolean down, boolean left, boolean right, boolean useSOCD=true);
90
91 void setTrigger(XInputControl trigger, int32_t val);
92
93 void setJoystick(XInputControl joy, int32_t x, int32_t y);
94 void setJoystick(XInputControl joy, boolean up, boolean down, boolean left, boolean right, boolean useSOCD=true);
95 void setJoystickX(XInputControl joy, int32_t x, boolean invert=false);
96 void setJoystickY(XInputControl joy, int32_t y, boolean invert=false);
97
98 void releaseAll();
99
100 // Auto-Send Data
101 void setAutoSend(boolean a);
102
103 // Read Control Surfaces
104 boolean getButton(uint8_t button) const;
105 boolean getDpad(XInputControl dpad) const;
106 uint8_t getTrigger(XInputControl trigger) const;
107 int16_t getJoystickX(XInputControl joy) const;
108 int16_t getJoystickY(XInputControl joy) const;
109
110 // Received Data
111 uint8_t getPlayer() const; // Player # assigned to the controller (0 is unassigned)
112
113 uint16_t getRumble() const; // Rumble motors. MSB is large weight, LSB is small
114 uint8_t getRumbleLeft() const; // Large rumble motor, left grip
115 uint8_t getRumbleRight() const; // Small rumble motor, right grip
116
117 XInputLEDPattern getLEDPattern() const; // Returns LED pattern type
118
119 // Received Data Callback
120 using RecvCallbackType = void(*)(uint8_t packetType);
121 void setReceiveCallback(RecvCallbackType);
122
123 // USB IO
124 boolean connected();
125 int send();
126 int receive();
127
128 // Control Input Ranges
129 struct Range { int32_t min; int32_t max; };
130
131 void setTriggerRange(int32_t rangeMin, int32_t rangeMax);
132 void setJoystickRange(int32_t rangeMin, int32_t rangeMax);
133 void setRange(XInputControl ctrl, int32_t rangeMin, int32_t rangeMax);
134

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected