USB Wake Feature (port from DS5Dongle) - #93
Open
515orestis wants to merge 7 commits into
Open
Conversation
…tons
Ports the wake feature from awalol/DS5Dongle into the DS5 Bridge companion
firmware. When built with ENABLE_WAKE_HID (default ON), the config descriptor
advertises USB REMOTE_WAKEUP (bmAttributes 0xE0) and a controller button press
during host suspend taps F15 on the existing HID keyboard interface to wake the PC.
- src/wake.{h,cpp}: wake FSM (button/reconnect detection -> tud_remote_wakeup ->
F15 keystroke via HID instance 1), stripped of awalol's config/ps_shortcut and
controller power-off (DS5 Bridge already power-manages in usb_pm_poll()).
- usb_descriptors.c: 0xE0 REMOTE_WAKEUP when ENABLE_WAKE_HID.
- usb.cpp: wake_note_suspend/resume() in the suspend/resume/mount callbacks.
- bt.cpp: wake_on_bt_connect() on HID interrupt channel open (pad reconnect).
- main.cpp: wake_on_bt_input() per BT report; wake_init()/wake_task() in main loop.
- CMakeLists.txt: build src/wake.cpp, add ENABLE_WAKE_HID option (default ON).
Firmware: add a runtime wake enable/disable flag gated in the wake FSM, exposed
via a new companion command CommandSetWakeEnabled (0x34). Default enabled.
- wake.{h,cpp}: wake_set_enabled()/wake_is_enabled(); request_host_wake() no-ops
when disabled (still advertises remote-wakeup, just never wakes the host).
- companion.cpp: CommandSetWakeEnabled handler (mirrors SetSleepKeybindEnabled).
Companion app: 'Wake PC on PS Button' toggle in the device settings
'Power & Controller' section, wired end-to-end and re-applied on connect.
- protocol.ts: SET_WAKE_ENABLED (0x34) + wakeEnabled setting.
- types.ts / settings-store.ts: wakeEnabled setting (default true) + persistence.
- preload.ts / main.ts: setWakeEnabled IPC.
- bridge-service.ts: setWakeEnabled() + apply on connect.
- App.tsx: the toggle row + settings mapping.
Typecheck passes (tsc main+renderer); firmware builds clean (Pico SDK 2.2.0).
…umerate) Previously the toggle only gated the firmware's wake action while the descriptor statically advertised remote-wakeup, so Windows always saw the device as a wake source. Now mirror awalol/DS5Dongle: - usb_descriptors.c: bmAttributes REMOTE_WAKEUP bit (0xE0/0xC0) is set at runtime in tud_descriptor_configuration_cb from the wake flag (via C-linkage wake_remote_wakeup_enabled()); static image carries 0xC0. Keyboard interface stays present regardless (shared with shortcuts), unlike awalol which drops it. - companion.cpp: CommandSetWakeEnabled calls usb_request_reconnect() so Windows re-reads the descriptor and adds/removes the device from its wake sources -- but only when the value actually changes, else the app's connect-time settings re-apply would loop the reconnect. - wake.cpp: wake_remote_wakeup_enabled() C accessor for the C-compiled descriptor. Not persisted to flash (DS5 Bridge has no on-dongle config store; the companion app re-applies on connect, like its other settings).
The reapply routine now sends SET_WAKE_ENABLED (0x34) during a full settings re-apply, but the test's expected command-order constant was not updated, failing the two reapply-order assertions. Insert the command at the same position as in bridge-service.ts (after SET_SLEEP_KEYBIND_ENABLED).
# Conflicts: # CMakeLists.txt # src/bt.cpp # src/main.cpp
The merge from up/main brought upstream's flash-nuke hash constant, but our bundled pico-universal-flash-nuke.uf2 is built locally and differs byte-for-byte. Rebuilt the flash-nuke and regenerated the constant so the bundled binary matches the hash the companion verifies at runtime.
Owner
|
Thanks for updating the PR. I'll be testing it later today. |
Author
|
it was based on 1.6.3 .i have updated from 1.6.4 but not tested , it has multiple changes from 1.6.3 ->1.6.4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.