Skip to content

Commit 222bdd3

Browse files
authored
Update HIDGamepad.ino
1 parent 67f94ca commit 222bdd3

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

libraries/USB/examples/HIDGamepad/HIDGamepad.ino

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,29 @@ int8_t readAxis(uint8_t pin) {
187187
return (int8_t)mapped;
188188
};
189189

190+
// REPORT BREAKDOWN
191+
void printReport(const GamepadReport &r) {
192+
Serial.print("Axes: ");
193+
for (int i = 0; i < 6; i++) {
194+
Serial.print(r.axis[i]);
195+
Serial.print(" ");
196+
}
197+
198+
Serial.print("| Hat: ");
199+
Serial.print(r.hat);
200+
201+
Serial.print(" | Buttons: ");
202+
for (int i = 0; i < 3; i++) {
203+
Serial.print("0b");
204+
for (int b = 7; b >= 0; b--) {
205+
Serial.print((r.buttons[i] >> b) & 0x01);
206+
}
207+
Serial.print(" ");
208+
}
209+
210+
Serial.println();
211+
}
212+
190213
void setup() {
191214
Serial.begin(115200);
192215
Serial.setDebugOutput(true);
@@ -235,6 +258,9 @@ void loop() {
235258
report.padding = 0;
236259
memcpy(report.buttons, buttons, 3);
237260

261+
// debug and test line
262+
printReport(report);
263+
238264
// Send to host
239265
if (HID.ready()) {
240266
Device.send(report);

0 commit comments

Comments
 (0)