wake_hid.cpp 910 B

1234567891011121314151617
  1. #include "wake_hid.h"
  2. #include <Adafruit_TinyUSB.h>
  3. // A bog-standard boot MOUSE descriptor -- the same shape Xbox mode's right-pad mouse uses, which is proven to
  4. // enumerate and wake Windows. We never send a report on it; it exists purely so the host enumerates a
  5. // "HID-compliant mouse" child and grants the device wake-from-sleep privileges. (A boot keyboard was tried
  6. // first and was worse: it didn't enumerate on Windows and suppressed the wake that the mouse class provides.)
  7. static const uint8_t WAKE_HID_DESC[] = { TUD_HID_REPORT_DESC_MOUSE() };
  8. static Adafruit_USBD_HID g_wakeHid;
  9. void wakeHidBegin(){
  10. g_wakeHid.setBootProtocol(HID_ITF_PROTOCOL_MOUSE); // boot mouse = a wake device class honored by Windows + Linux
  11. g_wakeHid.setStringDescriptor("OpenPuck Wake");
  12. g_wakeHid.setReportDescriptor(WAKE_HID_DESC, sizeof WAKE_HID_DESC);
  13. g_wakeHid.setPollInterval(10);
  14. g_wakeHid.begin();
  15. }