From b16091659cc9a724a8800f77e631643b4ab089ad Mon Sep 17 00:00:00 2001 From: Ryan Date: Wed, 18 Aug 2021 18:20:25 +1000 Subject: Move USB Host Shield and Arduino core to `lib/` (#13973) --- .../examples/HID/USBHIDBootKbd/USBHIDBootKbd.ino | 129 --------------- .../USBHIDBootKbdAndMouse.ino | 178 --------------------- .../HID/USBHIDBootMouse/USBHIDBootMouse.ino | 83 ---------- .../examples/HID/USBHIDJoystick/USBHIDJoystick.ino | 38 ----- .../HID/USBHIDJoystick/hidjoystickrptparser.cpp | 84 ---------- .../HID/USBHIDJoystick/hidjoystickrptparser.h | 33 ---- .../examples/HID/USBHID_desc/USBHID_desc.ino | 77 --------- .../examples/HID/USBHID_desc/pgmstrings.h | 52 ------ .../examples/HID/le3dp/le3dp.ino | 42 ----- .../examples/HID/le3dp/le3dp_rptparser.cpp | 43 ----- .../examples/HID/le3dp/le3dp_rptparser.h | 42 ----- .../examples/HID/scale/scale.ino | 51 ------ .../examples/HID/scale/scale_rptparser.cpp | 150 ----------------- .../examples/HID/scale/scale_rptparser.h | 55 ------- 14 files changed, 1057 deletions(-) delete mode 100644 tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDBootKbd/USBHIDBootKbd.ino delete mode 100644 tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDBootKbdAndMouse/USBHIDBootKbdAndMouse.ino delete mode 100644 tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDBootMouse/USBHIDBootMouse.ino delete mode 100644 tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDJoystick/USBHIDJoystick.ino delete mode 100644 tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDJoystick/hidjoystickrptparser.cpp delete mode 100644 tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDJoystick/hidjoystickrptparser.h delete mode 100644 tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHID_desc/USBHID_desc.ino delete mode 100644 tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHID_desc/pgmstrings.h delete mode 100644 tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/le3dp/le3dp.ino delete mode 100644 tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/le3dp/le3dp_rptparser.cpp delete mode 100644 tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/le3dp/le3dp_rptparser.h delete mode 100644 tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/scale/scale.ino delete mode 100644 tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/scale/scale_rptparser.cpp delete mode 100644 tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/scale/scale_rptparser.h (limited to 'tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID') diff --git a/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDBootKbd/USBHIDBootKbd.ino b/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDBootKbd/USBHIDBootKbd.ino deleted file mode 100644 index 48b33abfd2..0000000000 --- a/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDBootKbd/USBHIDBootKbd.ino +++ /dev/null @@ -1,129 +0,0 @@ -#include -#include - -// Satisfy the IDE, which needs to see the include statment in the ino too. -#ifdef dobogusinclude -#include -#include -#endif - -class KbdRptParser : public KeyboardReportParser -{ - void PrintKey(uint8_t mod, uint8_t key); - - protected: - void OnControlKeysChanged(uint8_t before, uint8_t after); - - void OnKeyDown (uint8_t mod, uint8_t key); - void OnKeyUp (uint8_t mod, uint8_t key); - void OnKeyPressed(uint8_t key); -}; - -void KbdRptParser::PrintKey(uint8_t m, uint8_t key) -{ - MODIFIERKEYS mod; - *((uint8_t*)&mod) = m; - Serial.print((mod.bmLeftCtrl == 1) ? "C" : " "); - Serial.print((mod.bmLeftShift == 1) ? "S" : " "); - Serial.print((mod.bmLeftAlt == 1) ? "A" : " "); - Serial.print((mod.bmLeftGUI == 1) ? "G" : " "); - - Serial.print(" >"); - PrintHex(key, 0x80); - Serial.print("< "); - - Serial.print((mod.bmRightCtrl == 1) ? "C" : " "); - Serial.print((mod.bmRightShift == 1) ? "S" : " "); - Serial.print((mod.bmRightAlt == 1) ? "A" : " "); - Serial.println((mod.bmRightGUI == 1) ? "G" : " "); -}; - -void KbdRptParser::OnKeyDown(uint8_t mod, uint8_t key) -{ - Serial.print("DN "); - PrintKey(mod, key); - uint8_t c = OemToAscii(mod, key); - - if (c) - OnKeyPressed(c); -} - -void KbdRptParser::OnControlKeysChanged(uint8_t before, uint8_t after) { - - MODIFIERKEYS beforeMod; - *((uint8_t*)&beforeMod) = before; - - MODIFIERKEYS afterMod; - *((uint8_t*)&afterMod) = after; - - if (beforeMod.bmLeftCtrl != afterMod.bmLeftCtrl) { - Serial.println("LeftCtrl changed"); - } - if (beforeMod.bmLeftShift != afterMod.bmLeftShift) { - Serial.println("LeftShift changed"); - } - if (beforeMod.bmLeftAlt != afterMod.bmLeftAlt) { - Serial.println("LeftAlt changed"); - } - if (beforeMod.bmLeftGUI != afterMod.bmLeftGUI) { - Serial.println("LeftGUI changed"); - } - - if (beforeMod.bmRightCtrl != afterMod.bmRightCtrl) { - Serial.println("RightCtrl changed"); - } - if (beforeMod.bmRightShift != afterMod.bmRightShift) { - Serial.println("RightShift changed"); - } - if (beforeMod.bmRightAlt != afterMod.bmRightAlt) { - Serial.println("RightAlt changed"); - } - if (beforeMod.bmRightGUI != afterMod.bmRightGUI) { - Serial.println("RightGUI changed"); - } - -} - -void KbdRptParser::OnKeyUp(uint8_t mod, uint8_t key) -{ - Serial.print("UP "); - PrintKey(mod, key); -} - -void KbdRptParser::OnKeyPressed(uint8_t key) -{ - Serial.print("ASCII: "); - Serial.println((char)key); -}; - -USB Usb; -//USBHub Hub(&Usb); -HIDBoot HidKeyboard(&Usb); - -uint32_t next_time; - -KbdRptParser Prs; - -void setup() -{ - Serial.begin( 115200 ); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - Serial.println("Start"); - - if (Usb.Init() == -1) - Serial.println("OSC did not start."); - - delay( 200 ); - - next_time = millis() + 5000; - - HidKeyboard.SetReportParser(0, (HIDReportParser*)&Prs); -} - -void loop() -{ - Usb.Task(); -} - diff --git a/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDBootKbdAndMouse/USBHIDBootKbdAndMouse.ino b/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDBootKbdAndMouse/USBHIDBootKbdAndMouse.ino deleted file mode 100644 index 5fc8c96fc9..0000000000 --- a/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDBootKbdAndMouse/USBHIDBootKbdAndMouse.ino +++ /dev/null @@ -1,178 +0,0 @@ -#include -#include - -// Satisfy IDE, which only needs to see the include statment in the ino. -#ifdef dobogusinclude -#include -#include -#endif - -class MouseRptParser : public MouseReportParser -{ - protected: - void OnMouseMove(MOUSEINFO *mi); - void OnLeftButtonUp(MOUSEINFO *mi); - void OnLeftButtonDown(MOUSEINFO *mi); - void OnRightButtonUp(MOUSEINFO *mi); - void OnRightButtonDown(MOUSEINFO *mi); - void OnMiddleButtonUp(MOUSEINFO *mi); - void OnMiddleButtonDown(MOUSEINFO *mi); -}; -void MouseRptParser::OnMouseMove(MOUSEINFO *mi) -{ - Serial.print("dx="); - Serial.print(mi->dX, DEC); - Serial.print(" dy="); - Serial.println(mi->dY, DEC); -}; -void MouseRptParser::OnLeftButtonUp (MOUSEINFO *mi) -{ - Serial.println("L Butt Up"); -}; -void MouseRptParser::OnLeftButtonDown (MOUSEINFO *mi) -{ - Serial.println("L Butt Dn"); -}; -void MouseRptParser::OnRightButtonUp (MOUSEINFO *mi) -{ - Serial.println("R Butt Up"); -}; -void MouseRptParser::OnRightButtonDown (MOUSEINFO *mi) -{ - Serial.println("R Butt Dn"); -}; -void MouseRptParser::OnMiddleButtonUp (MOUSEINFO *mi) -{ - Serial.println("M Butt Up"); -}; -void MouseRptParser::OnMiddleButtonDown (MOUSEINFO *mi) -{ - Serial.println("M Butt Dn"); -}; - -class KbdRptParser : public KeyboardReportParser -{ - void PrintKey(uint8_t mod, uint8_t key); - - protected: - void OnControlKeysChanged(uint8_t before, uint8_t after); - void OnKeyDown (uint8_t mod, uint8_t key); - void OnKeyUp (uint8_t mod, uint8_t key); - void OnKeyPressed(uint8_t key); -}; - -void KbdRptParser::PrintKey(uint8_t m, uint8_t key) -{ - MODIFIERKEYS mod; - *((uint8_t*)&mod) = m; - Serial.print((mod.bmLeftCtrl == 1) ? "C" : " "); - Serial.print((mod.bmLeftShift == 1) ? "S" : " "); - Serial.print((mod.bmLeftAlt == 1) ? "A" : " "); - Serial.print((mod.bmLeftGUI == 1) ? "G" : " "); - - Serial.print(" >"); - PrintHex(key, 0x80); - Serial.print("< "); - - Serial.print((mod.bmRightCtrl == 1) ? "C" : " "); - Serial.print((mod.bmRightShift == 1) ? "S" : " "); - Serial.print((mod.bmRightAlt == 1) ? "A" : " "); - Serial.println((mod.bmRightGUI == 1) ? "G" : " "); -}; - -void KbdRptParser::OnKeyDown(uint8_t mod, uint8_t key) -{ - Serial.print("DN "); - PrintKey(mod, key); - uint8_t c = OemToAscii(mod, key); - - if (c) - OnKeyPressed(c); -} - -void KbdRptParser::OnControlKeysChanged(uint8_t before, uint8_t after) { - - MODIFIERKEYS beforeMod; - *((uint8_t*)&beforeMod) = before; - - MODIFIERKEYS afterMod; - *((uint8_t*)&afterMod) = after; - - if (beforeMod.bmLeftCtrl != afterMod.bmLeftCtrl) { - Serial.println("LeftCtrl changed"); - } - if (beforeMod.bmLeftShift != afterMod.bmLeftShift) { - Serial.println("LeftShift changed"); - } - if (beforeMod.bmLeftAlt != afterMod.bmLeftAlt) { - Serial.println("LeftAlt changed"); - } - if (beforeMod.bmLeftGUI != afterMod.bmLeftGUI) { - Serial.println("LeftGUI changed"); - } - - if (beforeMod.bmRightCtrl != afterMod.bmRightCtrl) { - Serial.println("RightCtrl changed"); - } - if (beforeMod.bmRightShift != afterMod.bmRightShift) { - Serial.println("RightShift changed"); - } - if (beforeMod.bmRightAlt != afterMod.bmRightAlt) { - Serial.println("RightAlt changed"); - } - if (beforeMod.bmRightGUI != afterMod.bmRightGUI) { - Serial.println("RightGUI changed"); - } - -} - -void KbdRptParser::OnKeyUp(uint8_t mod, uint8_t key) -{ - Serial.print("UP "); - PrintKey(mod, key); -} - -void KbdRptParser::OnKeyPressed(uint8_t key) -{ - Serial.print("ASCII: "); - Serial.println((char)key); -}; - -USB Usb; -USBHub Hub(&Usb); - -HIDBoot < HID_PROTOCOL_KEYBOARD | HID_PROTOCOL_MOUSE > HidComposite(&Usb); -HIDBoot HidKeyboard(&Usb); -HIDBoot HidMouse(&Usb); - -//uint32_t next_time; - -KbdRptParser KbdPrs; -MouseRptParser MousePrs; - -void setup() -{ - Serial.begin( 115200 ); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - Serial.println("Start"); - - if (Usb.Init() == -1) - Serial.println("OSC did not start."); - - delay( 200 ); - - //next_time = millis() + 5000; - - HidComposite.SetReportParser(0, (HIDReportParser*)&KbdPrs); - HidComposite.SetReportParser(1, (HIDReportParser*)&MousePrs); - HidKeyboard.SetReportParser(0, (HIDReportParser*)&KbdPrs); - HidMouse.SetReportParser(0, (HIDReportParser*)&MousePrs); -} - -void loop() -{ - Usb.Task(); -} - diff --git a/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDBootMouse/USBHIDBootMouse.ino b/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDBootMouse/USBHIDBootMouse.ino deleted file mode 100644 index 53102512bd..0000000000 --- a/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDBootMouse/USBHIDBootMouse.ino +++ /dev/null @@ -1,83 +0,0 @@ -#include -#include - -// Satisfy the IDE, which needs to see the include statment in the ino too. -#ifdef dobogusinclude -#include -#include -#endif - -class MouseRptParser : public MouseReportParser -{ -protected: - void OnMouseMove (MOUSEINFO *mi); - void OnLeftButtonUp (MOUSEINFO *mi); - void OnLeftButtonDown (MOUSEINFO *mi); - void OnRightButtonUp (MOUSEINFO *mi); - void OnRightButtonDown (MOUSEINFO *mi); - void OnMiddleButtonUp (MOUSEINFO *mi); - void OnMiddleButtonDown (MOUSEINFO *mi); -}; -void MouseRptParser::OnMouseMove(MOUSEINFO *mi) -{ - Serial.print("dx="); - Serial.print(mi->dX, DEC); - Serial.print(" dy="); - Serial.println(mi->dY, DEC); -}; -void MouseRptParser::OnLeftButtonUp (MOUSEINFO *mi) -{ - Serial.println("L Butt Up"); -}; -void MouseRptParser::OnLeftButtonDown (MOUSEINFO *mi) -{ - Serial.println("L Butt Dn"); -}; -void MouseRptParser::OnRightButtonUp (MOUSEINFO *mi) -{ - Serial.println("R Butt Up"); -}; -void MouseRptParser::OnRightButtonDown (MOUSEINFO *mi) -{ - Serial.println("R Butt Dn"); -}; -void MouseRptParser::OnMiddleButtonUp (MOUSEINFO *mi) -{ - Serial.println("M Butt Up"); -}; -void MouseRptParser::OnMiddleButtonDown (MOUSEINFO *mi) -{ - Serial.println("M Butt Dn"); -}; - -USB Usb; -USBHub Hub(&Usb); -HIDBoot HidMouse(&Usb); - -uint32_t next_time; - -MouseRptParser Prs; - -void setup() -{ - Serial.begin( 115200 ); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - Serial.println("Start"); - - if (Usb.Init() == -1) - Serial.println("OSC did not start."); - - delay( 200 ); - - next_time = millis() + 5000; - - HidMouse.SetReportParser(0,(HIDReportParser*)&Prs); -} - -void loop() -{ - Usb.Task(); -} - diff --git a/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDJoystick/USBHIDJoystick.ino b/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDJoystick/USBHIDJoystick.ino deleted file mode 100644 index 956441d67a..0000000000 --- a/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDJoystick/USBHIDJoystick.ino +++ /dev/null @@ -1,38 +0,0 @@ -#include -#include -#include - -// Satisfy IDE, which only needs to see the include statment in the ino. -#ifdef dobogusinclude -#include -#include -#endif - -#include "hidjoystickrptparser.h" - -USB Usb; -USBHub Hub(&Usb); -HIDUniversal Hid(&Usb); -JoystickEvents JoyEvents; -JoystickReportParser Joy(&JoyEvents); - -void setup() { - Serial.begin(115200); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - Serial.println("Start"); - - if (Usb.Init() == -1) - Serial.println("OSC did not start."); - - delay(200); - - if (!Hid.SetReportParser(0, &Joy)) - ErrorMessage (PSTR("SetReportParser"), 1); -} - -void loop() { - Usb.Task(); -} - diff --git a/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDJoystick/hidjoystickrptparser.cpp b/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDJoystick/hidjoystickrptparser.cpp deleted file mode 100644 index 083b95cac5..0000000000 --- a/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDJoystick/hidjoystickrptparser.cpp +++ /dev/null @@ -1,84 +0,0 @@ -#include "hidjoystickrptparser.h" - -JoystickReportParser::JoystickReportParser(JoystickEvents *evt) : -joyEvents(evt), -oldHat(0xDE), -oldButtons(0) { - for (uint8_t i = 0; i < RPT_GEMEPAD_LEN; i++) - oldPad[i] = 0xD; -} - -void JoystickReportParser::Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) { - bool match = true; - - // Checking if there are changes in report since the method was last called - for (uint8_t i = 0; i < RPT_GEMEPAD_LEN; i++) - if (buf[i] != oldPad[i]) { - match = false; - break; - } - - // Calling Game Pad event handler - if (!match && joyEvents) { - joyEvents->OnGamePadChanged((const GamePadEventData*)buf); - - for (uint8_t i = 0; i < RPT_GEMEPAD_LEN; i++) oldPad[i] = buf[i]; - } - - uint8_t hat = (buf[5] & 0xF); - - // Calling Hat Switch event handler - if (hat != oldHat && joyEvents) { - joyEvents->OnHatSwitch(hat); - oldHat = hat; - } - - uint16_t buttons = (0x0000 | buf[6]); - buttons <<= 4; - buttons |= (buf[5] >> 4); - uint16_t changes = (buttons ^ oldButtons); - - // Calling Button Event Handler for every button changed - if (changes) { - for (uint8_t i = 0; i < 0x0C; i++) { - uint16_t mask = (0x0001 << i); - - if (((mask & changes) > 0) && joyEvents) - if ((buttons & mask) > 0) - joyEvents->OnButtonDn(i + 1); - else - joyEvents->OnButtonUp(i + 1); - } - oldButtons = buttons; - } -} - -void JoystickEvents::OnGamePadChanged(const GamePadEventData *evt) { - Serial.print("X1: "); - PrintHex (evt->X, 0x80); - Serial.print("\tY1: "); - PrintHex (evt->Y, 0x80); - Serial.print("\tX2: "); - PrintHex (evt->Z1, 0x80); - Serial.print("\tY2: "); - PrintHex (evt->Z2, 0x80); - Serial.print("\tRz: "); - PrintHex (evt->Rz, 0x80); - Serial.println(""); -} - -void JoystickEvents::OnHatSwitch(uint8_t hat) { - Serial.print("Hat Switch: "); - PrintHex (hat, 0x80); - Serial.println(""); -} - -void JoystickEvents::OnButtonUp(uint8_t but_id) { - Serial.print("Up: "); - Serial.println(but_id, DEC); -} - -void JoystickEvents::OnButtonDn(uint8_t but_id) { - Serial.print("Dn: "); - Serial.println(but_id, DEC); -} diff --git a/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDJoystick/hidjoystickrptparser.h b/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDJoystick/hidjoystickrptparser.h deleted file mode 100644 index 733b8f8da8..0000000000 --- a/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDJoystick/hidjoystickrptparser.h +++ /dev/null @@ -1,33 +0,0 @@ -#if !defined(__HIDJOYSTICKRPTPARSER_H__) -#define __HIDJOYSTICKRPTPARSER_H__ - -#include - -struct GamePadEventData { - uint8_t X, Y, Z1, Z2, Rz; -}; - -class JoystickEvents { -public: - virtual void OnGamePadChanged(const GamePadEventData *evt); - virtual void OnHatSwitch(uint8_t hat); - virtual void OnButtonUp(uint8_t but_id); - virtual void OnButtonDn(uint8_t but_id); -}; - -#define RPT_GEMEPAD_LEN 5 - -class JoystickReportParser : public HIDReportParser { - JoystickEvents *joyEvents; - - uint8_t oldPad[RPT_GEMEPAD_LEN]; - uint8_t oldHat; - uint16_t oldButtons; - -public: - JoystickReportParser(JoystickEvents *evt); - - virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf); -}; - -#endif // __HIDJOYSTICKRPTPARSER_H__ diff --git a/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHID_desc/USBHID_desc.ino b/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHID_desc/USBHID_desc.ino deleted file mode 100644 index 85cfc19a2e..0000000000 --- a/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHID_desc/USBHID_desc.ino +++ /dev/null @@ -1,77 +0,0 @@ -#include -#include -#include -#include -#include "pgmstrings.h" - -// Satisfy the IDE, which needs to see the include statment in the ino too. -#ifdef dobogusinclude -#include -#include -#endif - -class HIDUniversal2 : public HIDUniversal -{ -public: - HIDUniversal2(USB *usb) : HIDUniversal(usb) {}; - -protected: - uint8_t OnInitSuccessful(); -}; - -uint8_t HIDUniversal2::OnInitSuccessful() -{ - uint8_t rcode; - - HexDumper Hex; - ReportDescParser Rpt; - - if ((rcode = GetReportDescr(0, &Hex))) - goto FailGetReportDescr1; - - if ((rcode = GetReportDescr(0, &Rpt))) - goto FailGetReportDescr2; - - return 0; - -FailGetReportDescr1: - USBTRACE("GetReportDescr1:"); - goto Fail; - -FailGetReportDescr2: - USBTRACE("GetReportDescr2:"); - goto Fail; - -Fail: - Serial.println(rcode, HEX); - Release(); - return rcode; -} - -USB Usb; -//USBHub Hub(&Usb); -HIDUniversal2 Hid(&Usb); -UniversalReportParser Uni; - -void setup() -{ - Serial.begin( 115200 ); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - Serial.println("Start"); - - if (Usb.Init() == -1) - Serial.println("OSC did not start."); - - delay( 200 ); - - if (!Hid.SetReportParser(0, &Uni)) - ErrorMessage(PSTR("SetReportParser"), 1 ); -} - -void loop() -{ - Usb.Task(); -} - diff --git a/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHID_desc/pgmstrings.h b/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHID_desc/pgmstrings.h deleted file mode 100644 index bdb0077ecc..0000000000 --- a/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHID_desc/pgmstrings.h +++ /dev/null @@ -1,52 +0,0 @@ -#if !defined(__PGMSTRINGS_H__) -#define __PGMSTRINGS_H__ - -#define LOBYTE(x) ((char*)(&(x)))[0] -#define HIBYTE(x) ((char*)(&(x)))[1] -#define BUFSIZE 256 //buffer size - - -/* Print strings in Program Memory */ -const char Gen_Error_str[] PROGMEM = "\r\nRequest error. Error code:\t"; -const char Dev_Header_str[] PROGMEM ="\r\nDevice descriptor: "; -const char Dev_Length_str[] PROGMEM ="\r\nDescriptor Length:\t"; -const char Dev_Type_str[] PROGMEM ="\r\nDescriptor type:\t"; -const char Dev_Version_str[] PROGMEM ="\r\nUSB version:\t\t"; -const char Dev_Class_str[] PROGMEM ="\r\nDevice class:\t\t"; -const char Dev_Subclass_str[] PROGMEM ="\r\nDevice Subclass:\t"; -const char Dev_Protocol_str[] PROGMEM ="\r\nDevice Protocol:\t"; -const char Dev_Pktsize_str[] PROGMEM ="\r\nMax.packet size:\t"; -const char Dev_Vendor_str[] PROGMEM ="\r\nVendor ID:\t\t"; -const char Dev_Product_str[] PROGMEM ="\r\nProduct ID:\t\t"; -const char Dev_Revision_str[] PROGMEM ="\r\nRevision ID:\t\t"; -const char Dev_Mfg_str[] PROGMEM ="\r\nMfg.string index:\t"; -const char Dev_Prod_str[] PROGMEM ="\r\nProd.string index:\t"; -const char Dev_Serial_str[] PROGMEM ="\r\nSerial number index:\t"; -const char Dev_Nconf_str[] PROGMEM ="\r\nNumber of conf.:\t"; -const char Conf_Trunc_str[] PROGMEM ="Total length truncated to 256 bytes"; -const char Conf_Header_str[] PROGMEM ="\r\nConfiguration descriptor:"; -const char Conf_Totlen_str[] PROGMEM ="\r\nTotal length:\t\t"; -const char Conf_Nint_str[] PROGMEM ="\r\nNum.intf:\t\t"; -const char Conf_Value_str[] PROGMEM ="\r\nConf.value:\t\t"; -const char Conf_String_str[] PROGMEM ="\r\nConf.string:\t\t"; -const char Conf_Attr_str[] PROGMEM ="\r\nAttr.:\t\t\t"; -const char Conf_Pwr_str[] PROGMEM ="\r\nMax.pwr:\t\t"; -const char Int_Header_str[] PROGMEM ="\r\n\r\nInterface descriptor:"; -const char Int_Number_str[] PROGMEM ="\r\nIntf.number:\t\t"; -const char Int_Alt_str[] PROGMEM ="\r\nAlt.:\t\t\t"; -const char Int_Endpoints_str[] PROGMEM ="\r\nEndpoints:\t\t"; -const char Int_Class_str[] PROGMEM ="\r\nIntf. Class:\t\t"; -const char Int_Subclass_str[] PROGMEM ="\r\nIntf. Subclass:\t\t"; -const char Int_Protocol_str[] PROGMEM ="\r\nIntf. Protocol:\t\t"; -const char Int_String_str[] PROGMEM ="\r\nIntf.string:\t\t"; -const char End_Header_str[] PROGMEM ="\r\n\r\nEndpoint descriptor:"; -const char End_Address_str[] PROGMEM ="\r\nEndpoint address:\t"; -const char End_Attr_str[] PROGMEM ="\r\nAttr.:\t\t\t"; -const char End_Pktsize_str[] PROGMEM ="\r\nMax.pkt size:\t\t"; -const char End_Interval_str[] PROGMEM ="\r\nPolling interval:\t"; -const char Unk_Header_str[] PROGMEM = "\r\nUnknown descriptor:"; -const char Unk_Length_str[] PROGMEM ="\r\nLength:\t\t"; -const char Unk_Type_str[] PROGMEM ="\r\nType:\t\t"; -const char Unk_Contents_str[] PROGMEM ="\r\nContents:\t"; - -#endif // __PGMSTRINGS_H__ \ No newline at end of file diff --git a/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/le3dp/le3dp.ino b/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/le3dp/le3dp.ino deleted file mode 100644 index 837d7f5a70..0000000000 --- a/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/le3dp/le3dp.ino +++ /dev/null @@ -1,42 +0,0 @@ -/* Simplified Logitech Extreme 3D Pro Joystick Report Parser */ - -#include -#include -#include - -#include "le3dp_rptparser.h" - -// Satisfy the IDE, which needs to see the include statment in the ino too. -#ifdef dobogusinclude -#include -#include -#endif - -USB Usb; -USBHub Hub(&Usb); -HIDUniversal Hid(&Usb); -JoystickEvents JoyEvents; -JoystickReportParser Joy(&JoyEvents); - -void setup() -{ - Serial.begin( 115200 ); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - Serial.println("Start"); - - if (Usb.Init() == -1) - Serial.println("OSC did not start."); - - delay( 200 ); - - if (!Hid.SetReportParser(0, &Joy)) - ErrorMessage(PSTR("SetReportParser"), 1 ); -} - -void loop() -{ - Usb.Task(); -} - diff --git a/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/le3dp/le3dp_rptparser.cpp b/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/le3dp/le3dp_rptparser.cpp deleted file mode 100644 index baece13b2c..0000000000 --- a/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/le3dp/le3dp_rptparser.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include "le3dp_rptparser.h" - -JoystickReportParser::JoystickReportParser(JoystickEvents *evt) : - joyEvents(evt) -{} - -void JoystickReportParser::Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) -{ - bool match = true; - - // Checking if there are changes in report since the method was last called - for (uint8_t i=0; iOnGamePadChanged((const GamePadEventData*)buf); - - for (uint8_t i=0; i(evt->x, 0x80); - Serial.print(" Y: "); - PrintHex(evt->y, 0x80); - Serial.print(" Hat Switch: "); - PrintHex(evt->hat, 0x80); - Serial.print(" Twist: "); - PrintHex(evt->twist, 0x80); - Serial.print(" Slider: "); - PrintHex(evt->slider, 0x80); - Serial.print(" Buttons A: "); - PrintHex(evt->buttons_a, 0x80); - Serial.print(" Buttons B: "); - PrintHex(evt->buttons_b, 0x80); - Serial.println(""); -} diff --git a/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/le3dp/le3dp_rptparser.h b/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/le3dp/le3dp_rptparser.h deleted file mode 100644 index 2400364e65..0000000000 --- a/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/le3dp/le3dp_rptparser.h +++ /dev/null @@ -1,42 +0,0 @@ -#if !defined(__HIDJOYSTICKRPTPARSER_H__) -#define __HIDJOYSTICKRPTPARSER_H__ - -#include - -struct GamePadEventData -{ - union { //axes and hut switch - uint32_t axes; - struct { - uint32_t x : 10; - uint32_t y : 10; - uint32_t hat : 4; - uint32_t twist : 8; - }; - }; - uint8_t buttons_a; - uint8_t slider; - uint8_t buttons_b; -}; - -class JoystickEvents -{ -public: - virtual void OnGamePadChanged(const GamePadEventData *evt); -}; - -#define RPT_GAMEPAD_LEN sizeof(GamePadEventData)/sizeof(uint8_t) - -class JoystickReportParser : public HIDReportParser -{ - JoystickEvents *joyEvents; - - uint8_t oldPad[RPT_GAMEPAD_LEN]; - -public: - JoystickReportParser(JoystickEvents *evt); - - virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf); -}; - -#endif // __HIDJOYSTICKRPTPARSER_H__ diff --git a/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/scale/scale.ino b/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/scale/scale.ino deleted file mode 100644 index f26ff964da..0000000000 --- a/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/scale/scale.ino +++ /dev/null @@ -1,51 +0,0 @@ -/* Digital Scale Output. Written for Stamps.com Model 510 */ -/* 5lb Digital Scale; any HID scale with Usage page 0x8d should work */ - -#include -#include -#include - -#include "scale_rptparser.h" - -// Satisfy the IDE, which needs to see the include statment in the ino too. -#ifdef dobogusinclude -#include -#include -#endif - -USB Usb; -USBHub Hub(&Usb); -HIDUniversal Hid(&Usb); -Max_LCD LCD(&Usb); -ScaleEvents ScaleEvents(&LCD); -ScaleReportParser Scale(&ScaleEvents); - -void setup() -{ - Serial.begin( 115200 ); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - Serial.println("Start"); - - if (Usb.Init() == -1) - Serial.println("OSC did not start."); - - // set up the LCD's number of rows and columns: - LCD.begin(16, 2); - LCD.clear(); - LCD.home(); - LCD.setCursor(0,0); - LCD.write('R'); - - delay( 200 ); - - if (!Hid.SetReportParser(0, &Scale)) - ErrorMessage(PSTR("SetReportParser"), 1 ); -} - -void loop() -{ - Usb.Task(); -} - diff --git a/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/scale/scale_rptparser.cpp b/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/scale/scale_rptparser.cpp deleted file mode 100644 index 01ed980cfb..0000000000 --- a/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/scale/scale_rptparser.cpp +++ /dev/null @@ -1,150 +0,0 @@ -/* Parser for standard HID scale (usage page 0x8d) data input report (ID 3) */ -#include "scale_rptparser.h" - -const char* UNITS[13] = { - "units", // unknown unit - "mg", // milligram - "g", // gram - "kg", // kilogram - "cd", // carat - "taels", // lian - "gr", // grain - "dwt", // pennyweight - "tonnes", // metric tons - "tons", // avoir ton - "ozt", // troy ounce - "oz", // ounce - "lbs" // pound -}; - -ScaleReportParser::ScaleReportParser(ScaleEvents *evt) : - scaleEvents(evt) -{} - -void ScaleReportParser::Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) -{ - bool match = true; - - // Checking if there are changes in report since the method was last called - for (uint8_t i=0; iOnScaleChanged((const ScaleEventData*)buf); - - for (uint8_t i=0; iwrite( *str++ ); - - } -} - -void ScaleEvents::OnScaleChanged(const ScaleEventData *evt) -{ - - pLcd->clear(); - pLcd->home(); - pLcd->setCursor(0,0); - - if( evt->reportID != 3 ) { - - const char inv_report[]="Invalid report!"; - - Serial.println(inv_report); - LcdPrint(inv_report); - - return; - - }//if( evt->reportID != 3... - - switch( evt->status ) { - - case REPORT_FAULT: - Serial.println(F("Report fault")); - break; - - case ZEROED: - Serial.println(F("Scale zero set")); - break; - - case WEIGHING: { - - const char progress[] = "Weighing..."; - Serial.println(progress); - LcdPrint(progress); - break; - } - - case WEIGHT_VALID: { - - char buf[10]; - double weight = evt->weight * pow( 10, evt->exp ); - - - - Serial.print(F("Weight: ")); - Serial.print( weight ); - Serial.print(F(" ")); - Serial.println( UNITS[ evt->unit ]); - - LcdPrint("Weight: "); - dtostrf( weight, 4, 2, buf ); - LcdPrint( buf ); - LcdPrint( UNITS[ evt->unit ]); - - break; - - }//case WEIGHT_VALID... - - case WEIGHT_NEGATIVE: { - - const char negweight[] = "Negative weight"; - Serial.println(negweight); - LcdPrint(negweight); - break; - } - - case OVERWEIGHT: { - - const char overweight[] = "Max.weight reached"; - Serial.println(overweight); - LcdPrint( overweight ); - break; - } - - case CALIBRATE_ME: - - Serial.println(F("Scale calibration required")); - break; - - case ZERO_ME: - - Serial.println(F("Scale zeroing required")); - break; - - default: - - Serial.print(F("Undefined status code: ")); - Serial.println( evt->status ); - break; - - }//switch( evt->status... - -} diff --git a/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/scale/scale_rptparser.h b/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/scale/scale_rptparser.h deleted file mode 100644 index 57fbb033bf..0000000000 --- a/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/scale/scale_rptparser.h +++ /dev/null @@ -1,55 +0,0 @@ -#if !defined(__SCALERPTPARSER_H__) -#define __SCALERPTPARSER_H__ - -#include -#include - -/* Scale status constants */ -#define REPORT_FAULT 0x01 -#define ZEROED 0x02 -#define WEIGHING 0x03 -#define WEIGHT_VALID 0x04 -#define WEIGHT_NEGATIVE 0x05 -#define OVERWEIGHT 0x06 -#define CALIBRATE_ME 0x07 -#define ZERO_ME 0x08 - -/* input data report */ -struct ScaleEventData -{ - uint8_t reportID; //must be 3 - uint8_t status; - uint8_t unit; - int8_t exp; //scale factor for the weight - uint16_t weight; // -}; - -class ScaleEvents -{ - - Max_LCD* pLcd; - - void LcdPrint( const char* str ); - -public: - - ScaleEvents( Max_LCD* pLCD ); - - virtual void OnScaleChanged(const ScaleEventData *evt); -}; - -#define RPT_SCALE_LEN sizeof(ScaleEventData)/sizeof(uint8_t) - -class ScaleReportParser : public HIDReportParser -{ - ScaleEvents *scaleEvents; - - uint8_t oldScale[RPT_SCALE_LEN]; - -public: - ScaleReportParser(ScaleEvents *evt); - - virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf); -}; - -#endif // __SCALERPTPARSER_H__ -- cgit v1.2.3