Skip to content

Commit fe251a2

Browse files
committed
Use different USB warnings for separate board types
This also throws an #error if using an unknown board where USB_XINPUT (the USB API) isn't defined. The library would still print debug info, mind you, but this way it's very explicit to the novice: "THIS WON'T WORK DON'T EVEN TRY".
1 parent cfb534f commit fe251a2

1 file changed

Lines changed: 23 additions & 10 deletions

File tree

src/XInput.cpp

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,33 @@
2626

2727
#include "XInput.h"
2828

29-
#ifndef USB_XINPUT
30-
#warning "USB type is not set to XInput in boards menu! Using debug print - board will not behave as an XInput device"
31-
#endif
32-
33-
#if defined(TEENSYDUINO)
29+
// AVR Board with USB support
30+
#if defined(USBCON)
31+
#ifndef USB_XINPUT
32+
#warning "Non-XInput version selected in boards menu! Using debug print - board will not behave as an XInput device"
33+
#endif
34+
35+
// Teensy 3 Boards
36+
#elif defined(TEENSYDUINO)
3437
// Teensy 3.1-3.2: __MK20DX256__
3538
// Teensy LC: __MKL26Z64__
3639
// Teensy 3.5: __MK64FX512__
3740
// Teensy 3.6: __MK66FX1M0__
38-
#if !defined(__MK20DX256__) && !defined(__MKL26Z64__) && \
39-
!defined(__MK64FX512__) && !defined(__MK66FX1M0__)
40-
#warning "Not a supported board! Must use Teensy 3.1/3.2, LC, 3.5, or 3.6"
41-
#endif /* if supported Teensy board */
42-
#endif /* if defined(TEENSYDUINO) */
41+
#if !defined(__MK20DX256__) && !defined(__MKL26Z64__) && \
42+
!defined(__MK64FX512__) && !defined(__MK66FX1M0__)
43+
#warning "Not a supported board! Must use Teensy 3.1/3.2, LC, 3.5, or 3.6"
44+
#elif !defined(USB_XINPUT)
45+
#warning "USB type is not set to XInput in boards menu! Using debug print - board will not behave as an XInput device"
46+
#endif /* if supported Teensy board */
47+
48+
// Everything else
49+
#else
50+
#ifdef USB_XINPUT
51+
#warning "Unknown board. XInput may not work properly."
52+
#else
53+
#error "This board does not support XInput!"
54+
#endif
55+
#endif /* if supported board */
4356

4457
// --------------------------------------------------------
4558
// XInput Button Maps |

0 commit comments

Comments
 (0)