Repository navigation
Conversation
A receiver that is plugged back in (its Thunderbolt dock was reconnected) answers within seconds, but the keyboard or mouse behind it stays silent until its next key press. A device arrival got one rescan 1.5 s later and no retries, so the device stayed under "Connected, not controllable yet" until Rescan was clicked in the editor. - A Razer arrival now starts the same retries as tray start and wake (4 s, 15 s, 45 s, then once a minute for half an hour while a known wireless device is asleep). - While such a device is asleep, the tray registers raw input for its kind (keyboards and keypads, or mice) and reads only which device sent it. Input from the sleeping device starts the retries again, however long it slept; at most 5 times until it answers. Nothing is registered otherwise. - The retry counter is no longer part of `App`, so an arrival that comes in while `App` is borrowed still starts the retries over, and a retry that comes in at such a moment is tried again instead of dropped. - The editor's server tells the tray when it rescanned by itself, and an open editor shows a device the tray found or lost without a click on Rescan (a list counter in /api/live and in the state). An open editor panel is left alone and the change shown once it is closed. - Log: "gone: <names>", "not answering: <names> (asleep?), looking again at its next key press or movement", "input from <name>: looking for it again". Tested on a DeathStalker V2 Pro (Wireless, 0290) whose receiver sits on a Thunderbolt dock: found 2 s after the first key press that reached Windows.
|
This fixes a real gap, and the logs from your dock test are exactly what was needed. It can't merge as is, though. It's built on 0.5.1, and 0.6.0 changed There's also one clash that matters. In 0.6.0, RGB Studio's Reactive and Ripple effects already register raw input for keyboards and mice on the tray window (
Could you open a new PR against the latest main (0.6.0)? One owner for raw input would solve it: One smaller thing while you're in there: every Razer arrival now adds three extra rescans, and a rescan reopens the device handles, which can make a running Studio animation stutter. Starting the retries only when a known wireless device is still asleep after the first look would avoid that. The rest looks good: the input cache and flood cut-off, the 5-wake limit, the retry counter moved out of |
|
Replaced by #92: the same fix rebuilt on main (0.6.0), with one owner for raw input and the retries only while a device is asleep. |
#92) A receiver that is plugged back in (its Thunderbolt dock was reconnected) answers within seconds, but the keyboard or mouse behind it stays silent until its next key press. A device arrival got one rescan 1.5 s later and no retries, so the device stayed under "Connected, not controllable yet" until Rescan was clicked in the editor. This is #84 rebuilt on 0.6.0, with the two changes asked for there. - Raw input has one owner, `input.rs`. It registers keyboards and mice while the Studio (Reactive, Ripple) or the watch for a device that is asleep needs them, one kind at a time, so one of the two stopping never drops what the other uses. One `WM_INPUT` handler gives each input to both: the press to the Studio, the sender to the watch. - While a known wireless device is asleep, the watch asks for input of its kind (keyboards and keypads, or mice). Only which device sent it is read while the Studio doesn't listen. Input from the sleeping device starts a look for it, however long it slept; at most 5 times until it answers. - A Razer arrival, or input from a sleeping device, is followed by one look. The retries (4 s, 15 s, 45 s, then once a minute for half an hour) start only if that look still finds a known wireless device asleep, and end as soon as none is. With nothing asleep an arrival costs the one rescan it cost before. The retries after tray start and wake are as they were. - The retry counter is no longer part of `App`, so a wake that comes in while `App` is borrowed still starts the retries over, and a retry that comes in at such a moment is tried again instead of dropped. - `Input` notes a registration as changed only when Windows accepted the call, so a refused removal is asked for again. - The editor's server tells the tray when it rescanned by itself, and an open editor shows a device the tray found or lost without a click on Rescan (a list counter in /api/live and in the state). An open editor panel and the Settings page are left alone and the change is shown once they are closed. - Log: "gone: <names>", "not answering: <names> (asleep?), looking again at its next key press or movement", "input from <name>: looking for it again". Tested on a DeathStalker V2 Pro (Wireless, 0290) whose receiver sits on a Thunderbolt dock: found 1 s after the first key press that reached Windows.
Found a new failure mode - unplugging/replugging the laptop dock stops secbird control of the keyboard and its Editor reports "Connected, not controllable yet". Text below and fix is by Fable 5.2 reviewed by GPT-6 Astra. Deployment tested working by me.
Problem
A wireless keyboard whose receiver sits on a Thunderbolt dock stops being managed after the dock is unplugged and plugged back in. The receiver is back within seconds, but the keyboard behind it doesn't answer until its next key press. The tray looks once, 1.5 s after the arrival (
schedule_rescan), finds the keyboard silent, and never looks again: the retries (start_retries) only run at tray start and after a wake. The editor then lists the keyboard under "Connected, not controllable yet" with "Asleep? Press a key or move it", and pressing a key changes nothing until Rescan is clicked.Nothing is logged when this happens. On my machine there were 12 receiver removals in the last month (Windows event 1010 in Kernel-PnP "Device Management"). Two were followed by a
found:line within seconds. After the other ten none came for hours, and in eight of them not before the tray was started again.It is the keyboard that is silent, not the tray that is early: 7 s after the receiver came back, and before any key was pressed,
secbird infosaiderror: not found: no matching Razer device. After the key press it answered.Fix
RegisterRawInputDevices,RIDEV_INPUTSINK, on the tray's hidden window). OnWM_INPUTit reads the header only (RID_HEADER), asks for the sending device's path and looks forVID_1532&PID_<product id of the sleeping device>. A match drops the registration and starts a rescan plus the retries. So a device that slept for hours is found at its first key press that reaches Windows, without polling.INPUT_WAKES) until the device answers or is unplugged. A device that types but never answers isn't looked for on every key.App.WM_DEVICECHANGEis a sent message, so it can come in whileAppis borrowed (inside a shell call).start_retriesthen set its timer but could not resetretry_step, and a chain that had run out before ended after one more retry. The counter is a static now (RETRY_STEP, withRETRY_CHAINcounting restarts so a retry that was in its rescan when the chain was restarted leaves the new timer alone). ATIMER_RETRYthat findsAppborrowed is set again afterSETTLE_MS, asTIMER_RESCANalready was./api/liveand the state carry a counter (list) that grows when a rescan changes what the editor lists (keys, names, reasons). The page reloads the state when it changes, so a device the tray found by itself shows up without a click on Rescan. An open editor panel is left alone and the change is shown once it is closed; a request that fails is silent and tried again on the next tick./api/rescan, and the rescan-and-retry inpost), so the tray keeps following a device the editor dropped.Not changed: the retry delays and the half-hour cap, and what the editor's own Rescan does (a device it finds still gets no profile and no
found:line).Tested
x86_64-pc-windows-gnu(rustc 1.100.0, mingw-w64). Onlysecbird-tray.exewas replaced.input fromis the second press.found:the tray used 0.000 s of processor time over 30 s, andsecbird infostill showssleeping off.cargo clippy --release --target x86_64-pc-windows-gnu --all-targets -- -D warningsis clean. Unit tests: 104 (core) and 3 (tray) pass on Windows, 97 and 1 pass on Linux. The page's refresh logic passes 24 checks against a fake tray API in Node (a small script outside this change; I can add it if it is wanted).