]> git.gir.st - tmk_keyboard.git/blob - tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/BTHID/BTHID.ino
core: Fix Logical Maximum in report descriptor
[tmk_keyboard.git] / tmk_core / protocol / usb_hid / USB_Host_Shield_2.0 / examples / Bluetooth / BTHID / BTHID.ino
1 /*
2 Example sketch for the HID Bluetooth library - developed by Kristian Lauszus
3 For more information visit my blog: http://blog.tkjelectronics.dk/ or
4 send me an e-mail: kristianl@tkjelectronics.com
5 */
6
7 #include <BTHID.h>
8 #include <usbhub.h>
9 #include "KeyboardParser.h"
10 #include "MouseParser.h"
11
12 // Satisfy the IDE, which needs to see the include statment in the ino too.
13 #ifdef dobogusinclude
14 #include <spi4teensy3.h>
15 #include <SPI.h>
16 #endif
17
18 USB Usb;
19 //USBHub Hub1(&Usb); // Some dongles have a hub inside
20 BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so
21
22 /* You can create the instance of the class in two ways */
23 // This will start an inquiry and then pair with your device - you only have to do this once
24 // If you are using a Bluetooth keyboard, then you should type in the password on the keypad and then press enter
25 BTHID bthid(&Btd, PAIR, "0000");
26
27 // After that you can simply create the instance like so and then press any button on the device
28 //BTHID hid(&Btd);
29
30 KbdRptParser keyboardPrs;
31 MouseRptParser mousePrs;
32
33 void setup() {
34 Serial.begin(115200);
35 #if !defined(__MIPSEL__)
36 while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
37 #endif
38 if (Usb.Init() == -1) {
39 Serial.print(F("\r\nOSC did not start"));
40 while (1); // Halt
41 }
42
43 bthid.SetReportParser(KEYBOARD_PARSER_ID, (HIDReportParser*)&keyboardPrs);
44 bthid.SetReportParser(MOUSE_PARSER_ID, (HIDReportParser*)&mousePrs);
45
46 // If "Boot Protocol Mode" does not work, then try "Report Protocol Mode"
47 // If that does not work either, then uncomment PRINTREPORT in BTHID.cpp to see the raw report
48 bthid.setProtocolMode(HID_BOOT_PROTOCOL); // Boot Protocol Mode
49 //bthid.setProtocolMode(HID_RPT_PROTOCOL); // Report Protocol Mode
50
51 Serial.print(F("\r\nHID Bluetooth Library Started"));
52 }
53 void loop() {
54 Usb.Task();
55 }
Imprint / Impressum