@@ -311,6 +311,9 @@ void XInputGamepad::send() {
311311 if (!newData) return ; // TX data hasn't changed
312312 XInputUSB.send (tx, USB_Timeout);
313313 newData = false ;
314+ #else
315+ #warning "Using debug output for XInput send()"
316+ printDebug ();
314317#endif
315318}
316319
@@ -419,4 +422,60 @@ void XInputGamepad::reset() {
419422 setJoystickRange (XInputMap_Joystick::range.min , XInputMap_Joystick::range.max );
420423}
421424
425+ void XInputGamepad::printDebug (Print &output) const {
426+ const char fillCharacter = ' _' ;
427+
428+ char buffer[80 ];
429+
430+ // Buttons
431+ const char dpadLPrint = getButton (DPAD_LEFT) ? ' <' : fillCharacter;
432+ const char dpadUPrint = getButton (DPAD_UP) ? ' ^' : fillCharacter;
433+ const char dpadDPrint = getButton (DPAD_DOWN) ? ' v' : fillCharacter;
434+ const char dpadRPrint = getButton (DPAD_RIGHT) ? ' >' : fillCharacter;
435+
436+ const char aButtonPrint = getButton (BUTTON_A) ? ' A' : fillCharacter;
437+ const char bButtonPrint = getButton (BUTTON_B) ? ' B' : fillCharacter;
438+ const char xButtonPrint = getButton (BUTTON_X) ? ' X' : fillCharacter;
439+ const char yButtonPrint = getButton (BUTTON_Y) ? ' Y' : fillCharacter;
440+
441+ const char startPrint = getButton (BUTTON_START) ? ' >' : fillCharacter;
442+ const char backPrint = getButton (BUTTON_BACK) ? ' <' : fillCharacter;
443+
444+ const char logoPrint = getButton (BUTTON_LOGO) ? ' X' : fillCharacter;
445+
446+ // Bumpers
447+ char leftBumper[3 ] = " LB" ;
448+ char rightBumper[3 ] = " RB" ;
449+
450+ if (!getButton (BUTTON_LB)) {
451+ leftBumper[0 ] = fillCharacter;
452+ leftBumper[1 ] = fillCharacter;
453+ }
454+ if (!getButton (BUTTON_RB)) {
455+ rightBumper[0 ] = fillCharacter;
456+ rightBumper[1 ] = fillCharacter;
457+ }
458+
459+ output.print (" XInput Debug: " );
460+ sprintf (buffer,
461+ " LT: %3u %s L:(%6d, %6d) %c%c%c%c | %c%c%c | %c%c%c%c R:(%6d, %6d) %s RT: %3u" ,
462+
463+ // Left side controls
464+ getTrigger (TRIGGER_LEFT),
465+ leftBumper,
466+ getJoystickX (JOY_LEFT), getJoystickY (JOY_LEFT),
467+
468+ // Buttons
469+ dpadLPrint, dpadUPrint, dpadDPrint, dpadRPrint,
470+ backPrint, logoPrint, startPrint,
471+ aButtonPrint, bButtonPrint, xButtonPrint, yButtonPrint,
472+
473+ // Right side controls
474+ getJoystickX (JOY_RIGHT), getJoystickY (JOY_RIGHT),
475+ rightBumper,
476+ getTrigger (TRIGGER_RIGHT)
477+ );
478+ output.println (buffer);
479+ }
480+
422481XInputGamepad XInput;
0 commit comments