Sfoglia il codice sorgente

Try mouse child devices for wake

Jariullah Safi 4 mesi fa
parent
commit
9b1ef70bfc
4 ha cambiato i file con 15 aggiunte e 11 eliminazioni
  1. 4 3
      ARCHITECTURE.md
  2. 1 1
      OpenPuck/OpenPuck.ino
  3. 6 4
      OpenPuck/wake_hid.cpp
  4. 4 3
      OpenPuck/wake_hid.h

+ 4 - 3
ARCHITECTURE.md

@@ -85,7 +85,7 @@ just points at the `OpenPuck` directory). Modules are layered low → high:
 | `rf_diag.{h,cpp}` | RF reverse-engineering / calibration tooling: raw capture, CRC-validating config sweeps, frame replay, address listen, scan-then-respond, live-session sniffer. Not used in normal operation. |
 | `webusb_config.{h,cpp}` | The WebUSB binary config channel for the browser panel. |
 | `serial_console.{h,cpp}` | The CDC single-letter debug command line. |
-| `wake_hid.{h,cpp}` | A boot-keyboard HID interface added to the clean controller modes so the host honors USB remote-wakeup (see "Wake from sleep"). |
+| `wake_hid.{h,cpp}` | A boot-mouse HID interface added to the clean controller modes so the host honors USB remote-wakeup (see "Wake from sleep"). |
 
 ## The controller abstraction
 
@@ -213,8 +213,9 @@ only *honors* a resume signal from an allow-listed input device class (HID keybo
 gamepad/vendor/composite presentation gets armed but ignored (notably Windows under Modern Standby). That's
 why Xbox mode (which exposes a boot mouse) woke Windows while the gamepad/puck modes didn't.
 
-The fix: `wake_hid.cpp` registers a do-nothing **boot keyboard** interface so each mode is classified as a
-wake-capable input device. It's added in `setup()` for every **clean** mode. It is **not** added in puck mode,
+The fix: `wake_hid.cpp` registers a do-nothing **boot mouse** interface (the same shape Xbox mode already uses
+to wake Windows) so each mode is classified as a wake-capable input device. It's added in `setup()` for every
+**clean** mode. It is **not** added in puck mode,
 which is already at the nRF52840's 7-data-IN-endpoint limit (CDC + 4 puck HID + WebUSB) — adding it there would
 require freeing an endpoint (dropping CDC or WebUSB, or a bond slot). Puck mode already wakes on Linux/Steam
 Deck; making it wake Windows is the one case this doesn't cover without that tradeoff.

+ 1 - 1
OpenPuck/OpenPuck.ino

@@ -66,7 +66,7 @@ void setup() {
 
   g_active->begin();   // register this mode's USB interface(s) + set VID/PID/strings
 
-  // Boot-keyboard wake interface so the host honors USBDevice.remoteWakeup() in this mode (see wake_hid.h).
+  // Boot-mouse wake interface so the host honors USBDevice.remoteWakeup() in this mode (see wake_hid.h).
   // Skipped in puck mode: its CDC + 4 HID + WebUSB composite already uses all 7 data IN endpoints.
   if (!puckMode) wakeHidBegin();
 

+ 6 - 4
OpenPuck/wake_hid.cpp

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

+ 4 - 3
OpenPuck/wake_hid.h

@@ -5,9 +5,10 @@
 // TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP), so the device is *armed* to wake the host. But hosts only *honor* a
 // remote-wakeup resume signal from an allow-listed input device class -- a HID keyboard/mouse. Windows
 // (especially under Modern Standby) ignores the wake from a bare gamepad / vendor / composite presentation
-// even though it's armed. Exposing a boot keyboard interface puts the device in that allow-list. It never
-// sends reports -- the actual wake is the device-level USBDevice.remoteWakeup() resume signal driven from
-// rf_link.cpp; this interface only changes how the host classifies us.
+// even though it's armed. Exposing a boot MOUSE interface (the same shape Xbox mode already uses to wake
+// Windows) puts the device in that allow-list. It never sends reports -- the actual wake is the device-level
+// USBDevice.remoteWakeup() resume signal driven from rf_link.cpp; this interface only changes how the host
+// classifies us. (A boot keyboard was tried and was worse -- it didn't enumerate on Windows.)
 //
 // NOT used in puck (Steam) mode: that composite (CDC + 4 puck HID + WebUSB) already consumes all 7 of the
 // nRF52840's data IN endpoints, leaving no room for another interface. (Puck mode already wakes on Linux/Deck;