Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <usbhid.h>
- #include <hiduniversal.h>
- #include <Usb.h>
- #include <usbhub.h>
- #include <hidboot.h>
- USB Usb;
- USBHub Hub(&Usb);
- HIDUniversal Hid(&Usb);
- class KbdRptParser : public KeyboardReportParser {
- void PrintKey(uint8_t mod, uint8_t key);
- protected:
- virtual void OnKeyDown (uint8_t mod, uint8_t key);
- virtual void OnKeyPressed(uint8_t key);
- };
- void KbdRptParser::OnKeyDown(uint8_t mod, uint8_t key)
- {
- uint8_t c = OemToAscii(mod, key);
- if (c)
- OnKeyPressed(c);
- }
- void KbdRptParser::OnKeyPressed(uint8_t key)
- {
- Serial.print((char) key );
- };
- KbdRptParser Prs;
- void setup()
- {
- Serial.begin( 115200 );
- Serial.println("Start");
- if (Usb.Init() == -1) {
- Serial.println("OSC did not start.");
- }
- delay( 200 );
- Hid.SetReportParser(0, (HIDReportParser*)&Prs);
- }
- void loop()
- {
- Usb.Task();
- }
Advertisement
Add Comment
Please, Sign In to add comment