Repository navigation
Spectrum wake sync (experimental, off by default): keep devices cycling in step after a wake - #70
Open
lukethehawk wants to merge 4 commits into
Open
lukethehawk wants to merge 4 commits into
lukethehawk wants to merge 4 commits into
Conversation
…nfinityInfinite#48, infinityInfinite#52) A device can miss the write that dims or turns off its lights, and then stays lit the whole time away: a Basilisk V4 HyperSpeed missed it 3 times out of 5 right as the screen went off, and took it a second later. Retry those on the existing 3 s lights beat for 30 s, the way the lights coming back are already retried for 2 minutes. The log now names the devices that missed a write, and says when one answered on a retry or was given up on. A device that left the list is no longer counted as relit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r a wake Each device runs Spectrum on its own clock, so a keyboard and mouse that both cycle drift apart as soon as one sleeps and wakes. With the new setting on, the tray restarts Spectrum on the awake devices together when one of them wakes, whichever wakes first and however long apart. Wakes are seen through Windows Raw Input (RIDEV_INPUTSINK, event headers only): nothing is sent to a device to find out whether it is awake, so sleep is unaffected. A wireless device's first input after a gap as long as its sleep timer is a wake; one quiet for longer may be asleep and is not written to, and its own wake syncs everything again. If a device that woke had been dropped from the list while asleep, one rescan brings it back first. If it doesn't take the write, the others aren't restarted out of step with it: two more tries, then wait for the next wake. A profile the tray sends a device by itself (back in a rescan, or relit after the lights came back) syncs too. The logic is in wake_sync.rs, free of Win32 and tested without devices: both orders, wakes 10 s and 90 s apart, a device that sleeps again before the other wakes, one that dropped from the list, steady input, retries. Each attempt is logged with the result and time of every write. Settings also gets a "Re-sync now" button. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lukethehawk
added a commit
to lukethehawk/secbird
that referenced
this pull request
Oct 29, 2026
…Infinite#70 opened [skip ci] Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
0.5.1 already has the Lights when away retry (infinityInfinite#68) this branch was built on, so the only conflicts were in engine.rs and win.rs, where this branch has that same code plus the wake sync. Kept this branch's side there; the diff to main is now the wake sync alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lukethehawk
added a commit
to lukethehawk/secbird
that referenced
this pull request
Oct 30, 2026
infinityInfinite#71; infinityInfinite#70 merged with main [skip ci] Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflicts in engine.rs (imports) and win.rs (timers, App fields, WM_INPUT). Both 0.6's Reactive/Ripple key presses and the wake sync use Raw Input on the tray window, so: - one WM_INPUT arm feeds both (the first arm would have hidden the other); - Input::want takes `kept`: while the wake sync keeps mouse and keyboard registered (INPUTSINK | DEVNOTIFY), it only starts or stops reading, since registering again would drop DEVNOTIFY and RIDEV_REMOVE would end the wake sync's registration. With the wake sync off nothing changes; - the wake sync's timer moves to 9; Studio keeps 8. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lukethehawk
added a commit
to lukethehawk/secbird
that referenced
this pull request
Nov 15, 2026
…d with Studio's key presses [skip ci] Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Problem
Each device runs Spectrum cycling on its own clock. A keyboard and mouse set to Spectrum (for example with Sync all) start in step. They drift apart as soon as one of them sleeps and wakes, because the device that wakes restarts its cycle alone. Today the only fix is to sync again by hand every time.
What this adds
This adds two things under Settings → Startup and games. It is opt-in and off by default.
Nothing changes for anyone who leaves the setting off, or for any effect other than Spectrum.
How it works
Seeing wakes without traffic
RIDEV_INPUTSINK | RIDEV_DEVNOTIFYfor mouse and keyboard (usages 01:02 and 01:06).VID_1532&PID_xxxx).What counts as awake
The sync itself
When a device isn't ready
retry_lights_back). It doesn't happen after an apply to every device (start, resume, back from away), where they all restart together anyway.Where it lives
Code
wake_sync.rsholds the logic, kept free of Win32 and tested without devices (20 tests):engine.rsaddsspectrum_pids,restart_spectrumandwake_peers.win.rshandles Raw Input, the timer and the hooks after a rescan and afterretry_lights_back.Log
Every attempt is logged with the result and time of each write, without serial numbers:
Builds on the Lights when away retry PR
This branch includes the commit from #68 ("Lights when away: retry devices that miss the write"). The sync uses what that retry returns. The diff here will shrink to one commit once #68 is merged.
Tested
Setup
devices.jsonentry for 00EA lists logo and scroll LEDs; the mouse has one underglow LED (id 10).Results
WM_INPUT_DEVICE_CHANGEremovals appeared while the devices slept, so the Raw Input handles stay stable.CI
cargo clippy --release --all-targets -- -D warningsandcargo test --releasepass on Windows and Linux (https://github.com/lukethehawk/secbird/actions/runs/40859512622).Not tested
Known limits
🤖 Generated with Claude Code