wake_hid.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // wake_hid.h -- a minimal boot-protocol HID interface whose ONLY job is to make the device a host-recognized
  2. // USB wake source.
  3. //
  4. // Every mode already advertises remote-wakeup in its config descriptor, so the device is *armed* to wake the
  5. // host. But hosts only *honor* a resume signal from an allow-listed input device class -- a HID keyboard/mouse.
  6. // Windows (especially Modern Standby) ignores the wake from a bare gamepad / vendor / composite presentation
  7. // even though it's armed. Exposing a boot MOUSE interface puts the device in that allow-list. It never sends
  8. // reports -- the actual wake is the device-level USBDevice.remoteWakeup() resume signal driven from
  9. // rf_link.cpp; this interface only changes how the host classifies us. (A boot keyboard didn't enumerate on
  10. // Windows.)
  11. //
  12. // Added for every clean mode AND for puck mode on a normal boot: puck mode drops its CDC serial console by
  13. // default (freeing the endpoint this interface needs) so it too can wake Windows. The one-shot debug boot keeps
  14. // CDC and skips this interface (no endpoint room for both) -- see config.h (g_debugCdcThisBoot).
  15. #pragma once
  16. #include <stdint.h>
  17. // register the boot-mouse wake interface (call from setup() for clean modes + normal puck boot). Locks its
  18. // TinyUSB HID instance index -- for dynamic-mount modes call this BEFORE the slot pool so it is HID instance 0.
  19. void wakeHidBegin();
  20. // Re-add the (already-begun) wake-mouse interface to a freshly-cleared config descriptor, for a dynamic
  21. // re-enumeration that doesn't reboot. begin() is once-only; this re-emits the interface descriptor.
  22. void wakeHidAddInterface();
  23. // true once wakeHidBegin() has registered the boot mouse this boot (false on the debug-CDC boot, which omits it)
  24. bool wakeHidPresent();
  25. // boot mouse enumerated and ready to accept a report (false while the bus is suspended/unconfigured)
  26. bool wakeHidReady();
  27. // send one boot-mouse movement report (buttons=0). This is the input that actually wakes the host: it rides the
  28. // interface Windows armed as the wake source, unlike a gamepad-slot report. Returns false if not ready.
  29. bool wakeHidMove(int8_t dx, int8_t dy);