]> git.gir.st - tmk_keyboard.git/blob - tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDJoystick/USBHIDJoystick.ino
Merge branch 'master' into chibios
[tmk_keyboard.git] / tmk_core / protocol / usb_hid / USB_Host_Shield_2.0 / examples / HID / USBHIDJoystick / USBHIDJoystick.ino
1 #include <hid.h>
2 #include <hiduniversal.h>
3 #include <usbhub.h>
4
5 // Satisfy IDE, which only needs to see the include statment in the ino.
6 #ifdef dobogusinclude
7 #include <spi4teensy3.h>
8 #include <SPI.h>
9 #endif
10
11 #include "hidjoystickrptparser.h"
12
13 USB Usb;
14 USBHub Hub(&Usb);
15 HIDUniversal Hid(&Usb);
16 JoystickEvents JoyEvents;
17 JoystickReportParser Joy(&JoyEvents);
18
19 void setup() {
20 Serial.begin(115200);
21 #if !defined(__MIPSEL__)
22 while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
23 #endif
24 Serial.println("Start");
25
26 if (Usb.Init() == -1)
27 Serial.println("OSC did not start.");
28
29 delay(200);
30
31 if (!Hid.SetReportParser(0, &Joy))
32 ErrorMessage<uint8_t > (PSTR("SetReportParser"), 1);
33 }
34
35 void loop() {
36 Usb.Task();
37 }
38
Imprint / Impressum