From d37613f54ab505816a4992f42e016528e3de5f0a Mon Sep 17 00:00:00 2001 From: Onyx Date: Fri, 20 Nov 2026 21:21:04 +0100 Subject: [PATCH] chore: use plain hyphens instead of em dashes Replace every em dash in the Bridge sources, helper scripts, workflow and READMEs with a hyphen. Vendored code is untouched. No behavior change. --- .github/workflows/release.yml | 2 +- README.md | 16 ++++++------ native-hid/README.md | 26 +++++++++---------- native-hid/bridge-server.mjs | 4 +-- native-hid/src/apply.mjs | 20 +++++++-------- native-hid/src/brands.mjs | 8 +++--- native-hid/src/button-listener.mjs | 2 +- native-hid/src/hid-device-adapter.mjs | 28 ++++++++++----------- native-hid/src/registry.mjs | 4 +-- src/config.rs | 4 +-- src/drivers/mod.rs | 24 +++++++++--------- src/drivers/native_hid.rs | 14 +++++------ src/drivers/pulsar.rs | 20 +++++++-------- src/drivers/registry.rs | 8 +++--- src/hid.rs | 4 +-- src/platform/windows.rs | 20 +++++++-------- src/service.rs | 36 +++++++++++++-------------- src/tray_battery.rs | 14 +++++------ 18 files changed, 127 insertions(+), 127 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9a423a75..3f813ae8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -71,7 +71,7 @@ jobs: run: | $ErrorActionPreference = "Stop" npm ci --prefix native-hid --omit=dev - # Trim node-hid's other-platform prebuilt bindings — this archive + # Trim node-hid's other-platform prebuilt bindings - this archive # only ever runs on win32-x64. Get-ChildItem native-hid/node_modules/node-hid/prebuilds -Directory | Where-Object { $_.Name -ne "HID-win32-x64" } | diff --git a/README.md b/README.md index 024d0425..d09f028e 100644 --- a/README.md +++ b/README.md @@ -52,24 +52,24 @@ The initial service provides: - a live tray icon that shows the connected mouse's battery, drawn square at the taskbar's real pixel size with either the native Segoe Fluent Icons battery glyph (Segoe MDL2 Assets on Windows 10) or the percentage number in - bold text — a control-panel choice, since the Windows 11 taskbar only - renders square tray icons faithfully — tinted by charge state: green while + bold text - a control-panel choice, since the Windows 11 taskbar only + renders square tray icons faithfully - tinted by charge state: green while charging (the variant with the built-in bolt) or above half, amber through the mid band, alert red at or below the low-battery threshold, gray when - the reading is stale, and a level glyph for every 10% — with a tooltip that - spells everything out — `Device — 87% · Charging · full in 45 m` — + the reading is stale, and a level glyph for every 10% - with a tooltip that + spells everything out - `Device - 87% · Charging · full in 45 m` - including the estimated time remaining from the recent trend; - process-based detection for configured game executables; - startup discovery: Bridge scans the HID bus for mice whose brands it has - drivers for (the same vendor table the native-hid helper drives — Pulsar, + drivers for (the same vendor table the native-hid helper drives - Pulsar, Logitech, Razer, Delux, VGN, and more), so the tray shows the battery from - the first second — no web panel connection and no saved profile required; + the first second - no web panel connection and no saved profile required; - hybrid device mode (toggle in the panel): while the OpenMouse web app is - disconnected, Bridge drives the mouse itself in onboard memory mode — the + disconnected, Bridge drives the mouse itself in onboard memory mode - the active profile's stored DPI, polling rate, and switch mode are pushed natively (switch mode wherever a driver supports it, e.g. Logitech LightForce), and the battery is read directly (including a native Pulsar - battery reader) — and the moment the web app connects, it takes the mouse + battery reader) - and the moment the web app connects, it takes the mouse over live, with Bridge restoring the stored settings and reading the battery again on disconnect; without a saved profile Bridge leaves the mouse's own onboard memory untouched and just monitors it; diff --git a/native-hid/README.md b/native-hid/README.md index d4f1bc65..ea3d1d55 100644 --- a/native-hid/README.md +++ b/native-hid/README.md @@ -7,19 +7,19 @@ battery, without a browser tab open holding a WebHID connection. ## Why Node, in a Rust project Bridge has a dependency-free native Rust driver for the one protocol that's -been hardware-verified in this workspace (Pulsar — see `src/drivers/pulsar.rs` +been hardware-verified in this workspace (Pulsar - see `src/drivers/pulsar.rs` in the parent crate). Every other brand OpenMouse supports is implemented in `@openmouse/protocol` (the sibling `mouse-protocol` repo) as a WebHID driver class, hardware-tested there, not here. Reimplementing all of those in Rust would mean re-deriving and re-verifying ~15,000 lines of vendor-specific wire -protocol with no hardware in hand to test most of it against — real risk of +protocol with no hardware in hand to test most of it against - real risk of silently writing wrong values to someone's mouse. Instead, this package makes those exact same driver classes runnable outside a browser: `hid-device-adapter.mjs` wraps `node-hid` so it satisfies the `HIDDevice` interface the drivers are written against (see `mouse-protocol/src/drivers/webhid.ts`), and `apply.mjs` constructs the -already-verified class for a given brand directly — no protocol code is +already-verified class for a given brand directly - no protocol code is duplicated or reimplemented here. ## How dispatch works @@ -49,8 +49,8 @@ described devices with each request: collection whose descriptor declares it, padded to the declared size as Chrome does (Windows refuses a feature report of any other length), and reads feature reports at their declared size. `client.open()` then - `client.readStatus()` — a cheap, read-only call every `SupportedClient` - implements — probe it before anything is written. When a profile's brand + `client.readStatus()` - a cheap, read-only call every `SupportedClient` + implements - probe it before anything is written. When a profile's brand is not the one the registry files its mouse under (`"Attack Shark"` saved for hardware filed as `"Delux"`), Bridge sends `"matchStatusBrand": true` and every supported device, and the helper keeps the one whose status @@ -89,14 +89,14 @@ on an onboard one, turns the mouse's button events on, and prints stdin stops it: the events go off and the mouse returns to the mode it was in. It needs an `@openmouse/protocol` release that has `startButtonListener`. -## Exit code contract (Bridge depends on this — see `src/drivers/native_hid.rs`) +## Exit code contract (Bridge depends on this - see `src/drivers/native_hid.rs`) -- `0` — a device was found and the requested settings were applied. In +- `0` - a device was found and the requested settings were applied. In status mode (`{"brand": "…", "action": "status"}` on stdin) the device's status was read instead, and its battery is printed on stdout as `{"batteryPercent": 41, "batteryState": "Discharging"}`. -- `3` — no driver is registered for this brand. Not an error. -- `1` — a driver exists for this brand, but no device answered, or applying +- `3` - no driver is registered for this brand. Not an error. +- `1` - a driver exists for this brand, but no device answered, or applying failed. Details on stderr. ## Setup @@ -106,17 +106,17 @@ npm install ``` `@openmouse/protocol` is a normal git dependency pinned to a specific commit -(`package.json`), matching how `openmouse` itself depends on it — not a +(`package.json`), matching how `openmouse` itself depends on it - not a local `file:`/symlink reference to the sibling `../../mouse-protocol` checkout, deliberately: that checkout can have local work in progress (it -did when this package was created — untracked G-Wolves driver files that +did when this package was created - untracked G-Wolves driver files that briefly broke its own build), and a `file:` dependency would rebuild it as a side effect of `npm install` here. Bump the pinned commit by hand when you want a newer `mouse-protocol`. Both dependencies have install scripts (`node-hid` needs to select its prebuilt native binding; `@openmouse/protocol` needs to compile its -TypeScript) — this environment's npm requires approving those explicitly: +TypeScript) - this environment's npm requires approving those explicitly: ```sh npm approve-scripts node-hid "@openmouse/protocol" @@ -127,7 +127,7 @@ npm install # re-run once scripts are approved, so they actually execute Bridge's release packaging (`.github/workflows/release.yml`) bundles this whole directory next to the `openmouse-bridge` executable, plus a -standalone Node.js runtime under `native-hid/node/` — end users don't need +standalone Node.js runtime under `native-hid/node/` - end users don't need Node.js installed. `src/drivers/native_hid.rs` looks for that bundled runtime first and falls back to `node` on `PATH`, so local development (this README's setup above) works without it. diff --git a/native-hid/bridge-server.mjs b/native-hid/bridge-server.mjs index 2b5b669d..90cf40ef 100644 --- a/native-hid/bridge-server.mjs +++ b/native-hid/bridge-server.mjs @@ -146,7 +146,7 @@ class ManagedDevice { this.batteryAt = Date.now(); console.log(`[Bridge] 🔋 Battery update for ${this.productName}: ${pct}%`); // Forward the raw battery input report to all connected WebSocket clients - // using type:'report' — the format bridge-hid.ts's #receive handler + // using type:'report' - the format bridge-hid.ts's #receive handler // already understands and routes to device.deliver() → AttackShark // driver's onInputReport → x11RuntimeStates cache update. // Payload mirrors the real HID packet: [0x55, 0x40, 0x01, pct] @@ -426,7 +426,7 @@ wss.on('connection', (ws) => { dev.adapter.removeEventListener('inputreport', dev._bridgeListener); delete dev._bridgeListener; } - // Do NOT stop the battery monitor — keep it running so the passive + // Do NOT stop the battery monitor - keep it running so the passive // push updates continue for all connected clients. ws.send(JSON.stringify({ id, ok: true })); return; diff --git a/native-hid/src/apply.mjs b/native-hid/src/apply.mjs index d3b2c35c..7050433c 100644 --- a/native-hid/src/apply.mjs +++ b/native-hid/src/apply.mjs @@ -5,7 +5,7 @@ // // Usage: node apply.mjs < request.json // stdin: {"brand": "Razer", "dpi": 800, "pollingRateHz": 1000} -// (dpi / pollingRateHz are each optional — omit to leave that setting alone) +// (dpi / pollingRateHz are each optional - omit to leave that setting alone) // stdin: {"brand": "Razer", "dpi": 800, "settings": {"lightforceSwitchMode": "Optical"}} // (settings carries the panel's stored MouseStatus fields; ones the driver // supports are applied, the rest are reported and skipped) @@ -16,21 +16,21 @@ // "switchMode": "Optical"} (settings fields null when unreadable) // // Exit codes (Bridge's src/drivers/native_hid.rs depends on this contract): -// 0 — a device was found and the requested settings were applied (or, in +// 0 - a device was found and the requested settings were applied (or, in // status mode, its status was read and printed). -// 3 — no native driver is registered for this brand (not an error: most +// 3 - no native driver is registered for this brand (not an error: most // devices are still driven by the OpenMouse web app over WebHID). -// 1 — a driver is registered for this brand, but no matching device +// 1 - a driver is registered for this brand, but no matching device // answered, or applying the settings failed. Details on stderr. // mouse-protocol's driver classes were written for a browser and several of // them (17 of ~18 brands as of this writing) time their HID++/vendor // request-response waits with `window.setTimeout`/`window.clearTimeout`. // `window` doesn't exist in Node, so that throws a ReferenceError inside the -// Promise executor — which JS silently turns into an instant rejection, not +// Promise executor - which JS silently turns into an instant rejection, not // a timeout, before any real reply can arrive. Concretely, this made // LogitechHidppClient misread that instant non-timeout rejection as "the // receiver answered but this slot has no sensor" on every pairing slot, so -// it reported a connected mouse as "not a mouse" — nothing to do with HID +// it reported a connected mouse as "not a mouse" - nothing to do with HID // permissions or the mouse being asleep. `window` aliased to `globalThis` // fixes every driver relying on this pattern at once. Must run before any // `@openmouse/protocol` driver module is imported, including the dynamic @@ -76,7 +76,7 @@ async function probe(device, candidate) { try { await withTimeout(client.open(), PROBE_TIMEOUT_MS, `${candidate.exportName}.open()`); // Every SupportedClient implements readStatus() (mouse-protocol's - // shared client contract) — a cheap, read-only way to confirm this is + // shared client contract) - a cheap, read-only way to confirm this is // really the right class for this interface before writing anything. const status = await withTimeout(client.readStatus(), PROBE_TIMEOUT_MS, `${candidate.exportName}.readStatus()`); if (candidate.requireBrand !== undefined && brandKey(status?.brand ?? "") !== candidate.requireBrand) { @@ -164,7 +164,7 @@ async function main() { JSON.stringify({ batteryPercent: status?.batteryPercent ?? null, batteryState: status?.batteryState ?? null, - // The driver's own model name (MouseStatus.name) — better than the + // The driver's own model name (MouseStatus.name) - better than the // receiver-level name Bridge's discovery gets from the HID // descriptor (a LIGHTSPEED receiver reports "USB Receiver"). deviceName: status?.name ?? null, @@ -182,7 +182,7 @@ async function main() { // ── Wooting 60HE+ ─────────────────────────────────────────────────── // RAM-only switch needs no confirm; flash saves require confirmed: true - // in stdin (headless gate — no modal possible), else exit 1 unsent. + // in stdin (headless gate - no modal possible), else exit 1 unsent. if (input.action === "switch-profile") { if (!Number.isInteger(input.slot)) { console.error("[native-hid] switch-profile needs an integer slot."); @@ -274,7 +274,7 @@ async function main() { } } if (skipped.length > 0) { - console.error(`[native-hid] no native support for: ${skipped.join(", ")} — skipped.`); + console.error(`[native-hid] no native support for: ${skipped.join(", ")} - skipped.`); } } diff --git a/native-hid/src/brands.mjs b/native-hid/src/brands.mjs index 2537980b..ffc03462 100644 --- a/native-hid/src/brands.mjs +++ b/native-hid/src/brands.mjs @@ -1,6 +1,6 @@ // The fallback dispatch table. Bridge normally sends the devices it described // and the protocol package's own registry picks the driver (registry.mjs); this -// table is used only for a request without them — when the registry could not +// table is used only for a request without them - when the registry could not // be loaded, and for Zaunkoenig's acknowledged automation (automation.mjs). // // Maps a MouseStatus `brand` string (mouse-protocol/src/drivers/mouse-types.ts) @@ -8,11 +8,11 @@ // try constructing against each interface found, in the same order // mouse-protocol/src/drivers/registry.ts's DEVICE_DRIVERS lists them for // that brand (first-match-wins there; here, first class whose open() + -// readStatus() probe succeeds wins — see apply.mjs). +// readStatus() probe succeeds wins - see apply.mjs). // // "Pulsar" is left out: Bridge has a dependency-free native Rust driver for it // (src/drivers/pulsar.rs) that claims the brand before this helper is ever -// invoked — see src/drivers/mod.rs. +// invoked - see src/drivers/mod.rs. // // Vendor ids are copied from mouse-protocol/src/drivers/vendors.ts and each // driver's own `isSupported()`; class import paths use the package's @@ -91,7 +91,7 @@ export const BRAND_DRIVERS = { }, ninjutso: { // NINJUTSO_VENDOR_ID (current) and NINJUTSO_LEGACY_VENDOR_ID (shared - // with Orbital) — see mouse-protocol/src/ninjutso/index.ts. + // with Orbital) - see mouse-protocol/src/ninjutso/index.ts. vendorIds: [0x093a, 0x1915], classes: [client("@openmouse/protocol/drivers/ninjutso/hid", "NinjutsoHidClient")], }, diff --git a/native-hid/src/button-listener.mjs b/native-hid/src/button-listener.mjs index c5e763c0..2440774b 100644 --- a/native-hid/src/button-listener.mjs +++ b/native-hid/src/button-listener.mjs @@ -9,7 +9,7 @@ // to the mode it was in, if this helper changed it. // stdout: one JSON object per line. // {"event": "ready", "priorMode": "Onboard", "buttons": [1, 2, 3, 4, 5]} -// {"event": "buttons", "mask": 16} — the buttons held right now +// {"event": "buttons", "mask": 16} - the buttons held right now // {"event": "error", "message": "..."} // {"event": "stopped"} // diff --git a/native-hid/src/hid-device-adapter.mjs b/native-hid/src/hid-device-adapter.mjs index 2d822538..70041170 100644 --- a/native-hid/src/hid-device-adapter.mjs +++ b/native-hid/src/hid-device-adapter.mjs @@ -1,7 +1,7 @@ // Wraps one or more node-hid devices so together they satisfy the WebHID // `HIDDevice` interface mouse-protocol's driver classes are written against // (see mouse-protocol/src/drivers/webhid.ts, an ambient-type declaration -// only — this file is the runtime implementation of that same shape for +// only - this file is the runtime implementation of that same shape for // Node). // // This lets Bridge reuse OpenMouse's actual, hardware-verified driver @@ -10,9 +10,9 @@ // // One WebHID `HIDDevice` == one USB/BT *interface*, which can carry several // top-level HID collections (e.g. a short and a long report variant on the -// same vendor interface — this is exactly Logitech's HID++ receiver shape: +// same vendor interface - this is exactly Logitech's HID++ receiver shape: // report 0x10 in one collection, report 0x11 in another, same interface). -// node-hid enumerates one entry *per collection*, not per interface — on +// node-hid enumerates one entry *per collection*, not per interface - on // macOS in particular, IOHIDManager opens a separate IOHIDDevice service per // top-level collection it finds, each capable of receiving input reports // only for the report ids declared in *its own* collection. Opening only @@ -43,7 +43,7 @@ export class HidDeviceAdapter { this.vendorId = primary.vendorId; this.productId = primary.productId; this.productName = primary.product ?? ""; - // Real report-descriptor parsing isn't implemented here — callers must + // Real report-descriptor parsing isn't implemented here - callers must // not rely on collections-based `isSupported()` gating (see // native-hid/README.md); construct the known-correct driver class // directly instead. @@ -115,7 +115,7 @@ export class HidDeviceAdapter { async sendReport(reportId, data) { this._requireOpen(); const frame = this._frame(reportId, data); - // Any split for this interface can carry the write on real hardware — + // Any split for this interface can carry the write on real hardware - // the split is a macOS/IOHIDManager enumeration artifact per top-level // collection, not a hardware restriction on which handle can transmit // which report id. Writing through all of them costs little (these are @@ -158,16 +158,16 @@ export class HidDeviceAdapter { * from the parsed report descriptor. Drivers here call this with the * length they themselves expect back baked into their own retry/parsing * logic, so a generous fixed buffer (the largest report any known driver - * here uses) is safe — short replies are simply the leading bytes of it. + * here uses) is safe - short replies are simply the leading bytes of it. * * Classic Razer's control protocol is the largest: 90-byte feature reports * on report id 0 (mouse-protocol/src/razer/codec.ts, RAZER_PACKET_LENGTH = - * 90; the Rust transport's per-vendor budget is 91 for it — see + * 90; the Rust transport's per-vendor budget is 91 for it - see * RAZER_FEATURE_BUFFER_LEN in src/hid.rs). Requesting the whole report one * byte at a time would be wrong; request the id byte plus the largest * payload up front: `getFeatureReport` fills its first byte with the * requested report id and returns that id prefix as part of the buffer - * (node-hid's HID.cc passes buf[0] on to hidapi, which counts it — the + * (node-hid's HID.cc passes buf[0] on to hidapi, which counts it - the * exact same shape the Rust transport's receive_feature_report() accounts * for with `data[1..size]`). Strip that id byte so the drivers see the * payload they get from WebHID. Some backends omit the id byte entirely; @@ -224,7 +224,7 @@ export class HidDeviceAdapter { _onData(data) { // Some backends prefix numbered reports with the report id on read, // some don't (mirrors the same ambiguity the Rust Pulsar driver - // handles) — there is no fully reliable way to tell from the bytes + // handles) - there is no fully reliable way to tell from the bytes // alone, so report id 0 is assumed when in doubt; drivers here match // responses by their own payload content, not strictly by report id. const reportId = data.length > 0 ? data[0] : 0; @@ -237,7 +237,7 @@ export class HidDeviceAdapter { /** @param {Error} error */ _onError(error) { // Surfaced to whoever is waiting on a pending exchange via their own - // timeout, matching how a real device disconnect looks over WebHID — + // timeout, matching how a real device disconnect looks over WebHID - // there is no dedicated "error" WebHID event drivers here listen for. // Logged so it's not silently swallowed. console.error(`[native-hid] device error: ${error.message}`); @@ -245,7 +245,7 @@ export class HidDeviceAdapter { } /** - * Lists every HID *interface* for a vendor id, ready to be opened — one + * Lists every HID *interface* for a vendor id, ready to be opened - one * HidDeviceAdapter per interface, merging any node-hid entries that split * off the same interface into separate top-level collections (see module * docs above). @@ -284,7 +284,7 @@ export function candidateDevices(vendorId, hints = {}, list = devices) { const infos = onPage.length > 0 ? onPage : group; // Several node-hid entries for one interface commonly share the same // underlying `path` (one physical device, listed once per top-level - // collection its descriptor declares) — open each distinct path once. + // collection its descriptor declares) - open each distinct path once. const seen = new Set(); const unique = infos.filter((info) => (seen.has(info.path) ? false : seen.add(info.path))); return new HidDeviceAdapter(unique); @@ -307,8 +307,8 @@ function isStandardOnly(path) { /** * One device as Bridge described it (src/hid.rs, `DescribedDevice`): the - * WebHID view the control panel would get — the same grouping and the - * collections parsed from the report descriptors — plus each collection's + * WebHID view the control panel would get - the same grouping and the + * collections parsed from the report descriptors - plus each collection's * path and the payload size of every report it declares. * * Unlike HidDeviceAdapter it sends a report down only the path whose diff --git a/native-hid/src/registry.mjs b/native-hid/src/registry.mjs index 48ef47ca..8aa3381a 100644 --- a/native-hid/src/registry.mjs +++ b/native-hid/src/registry.mjs @@ -4,8 +4,8 @@ // // Bridge only describes devices matching the registry's SUPPORTED_HID_FILTERS // (the filters the panel requests devices with), and a driver is only used on -// a device its own `supports()` accepts — the same product-id and descriptor -// checks as in the browser — so nothing outside what OpenMouse itself would +// a device its own `supports()` accepts - the same product-id and descriptor +// checks as in the browser - so nothing outside what OpenMouse itself would // open is ever written to. // // The modules are imported lazily: loading the registry pulls in every driver, diff --git a/src/config.rs b/src/config.rs index a20715e6..3e0609bf 100644 --- a/src/config.rs +++ b/src/config.rs @@ -34,9 +34,9 @@ pub struct BridgeConfig { #[serde(default = "default_tray_battery_style")] pub tray_battery_style: String, /// Hybrid device mode: while the OpenMouse web panel is disconnected, - /// Bridge drives the mouse itself — the active profile's stored settings + /// Bridge drives the mouse itself - the active profile's stored settings /// (DPI, polling rate, switch mode) go to the onboard memory and the - /// battery is read natively — and hands the mouse over to the panel the + /// battery is read natively - and hands the mouse over to the panel the /// moment it connects, applying the stored settings again on disconnect. #[serde(default = "enabled_by_default")] pub hybrid_mode: bool, diff --git a/src/drivers/mod.rs b/src/drivers/mod.rs index 83bc2b77..9146d505 100644 --- a/src/drivers/mod.rs +++ b/src/drivers/mod.rs @@ -4,7 +4,7 @@ //! //! Each driver is a Rust port of the matching hardware-verified WebHID //! driver in the sibling `mouse-protocol` repo (`@openmouse/protocol`), -//! scoped to DPI/polling-rate only — the only settings Bridge profiles +//! scoped to DPI/polling-rate only - the only settings Bridge profiles //! store. Dispatch matches `ApplicationProfile.device.id`'s `":"` //! prefix, the same convention the OpenMouse web app writes when it saves a //! profile (see `openmouse/src/app/InterfaceSettings.tsx`); brand strings @@ -34,10 +34,10 @@ mod registry; pub use native_hid::{NativeBattery, NativeStatus, spawn_button_listener}; /// A mouse Bridge discovered by itself, by scanning the HID bus for vendor -/// ids its drivers recognize — no saved profile required. +/// ids its drivers recognize - no saved profile required. #[derive(Clone, Debug, Default, PartialEq, Eq)] pub struct DetectedMouse { - /// Stable profile-style id, `":"` — the same + /// Stable profile-style id, `":"` - the same /// `":"` prefix convention the OpenMouse web app writes. pub device_id: String, /// Human-readable product name from the HID descriptor. @@ -53,8 +53,8 @@ pub struct DetectedMouse { /// (the same drivers the web panel drives, and the same normalization /// `apply.mjs` gives `device.id` prefixes: trim + lowercase). When several /// brands share a vendor id, the entry names the brand whose driver class -/// list covers the most sibling hardware — Delux's list includes the Attack -/// Shark and Lamzu clients — or `mouse-protocol`'s registry.ts first match; +/// list covers the most sibling hardware - Delux's list includes the Attack +/// Shark and Lamzu clients - or `mouse-protocol`'s registry.ts first match; /// the loser's devices merely fail their silent battery probe later. const KNOWN_BRANDS: &[(&str, &[u16])] = &[ ("Delux", &[0x1d57, 0x248a, 0x373e]), @@ -92,10 +92,10 @@ pub fn brand_in_name(name: &str) -> Option<&'static str> { /// Logitech is special: every Logitech-branded device (keyboards, headsets) /// shares vendor id 0x046d and the HID++ transport (`mouse-protocol`'s -/// `drivers/logitech/hidpp.ts` has the same limitation — "whether it is a +/// `drivers/logitech/hidpp.ts` has the same limitation - "whether it is a /// *mouse* cannot be told from descriptors"), so discovery keeps the HID++ -/// collections — short/long reports on usage page 0xFF00, Bluetooth on -/// 0xFF43 — and a keyboard merely fails its battery probe silently later. +/// collections - short/long reports on usage page 0xFF00, Bluetooth on +/// 0xFF43 - and a keyboard merely fails its battery probe silently later. const LOGITECH_VENDOR_ID: u16 = 0x046d; const HIDPP_USAGE_PAGE: u16 = 0xff00; const HIDPP_BLUETOOTH_USAGE_PAGE: u16 = 0xff43; @@ -414,7 +414,7 @@ fn write_settings_held( } /// Reads the onboard-memory state of the mouse `device_id` names -/// (`":"`) over native HID — battery, and the current DPI / +/// (`":"`) over native HID - battery, and the current DPI / /// polling rate / switch mode wherever the driver can read them. /// `Ok(None)` means Bridge has no reader for the brand or the mouse reports /// no battery; `Err` means a driver exists but the mouse did not answer @@ -833,7 +833,7 @@ mod tests { } /// Exercises the real Rust -> Node.js round trip, so it needs Node.js on - /// PATH and the native-hid/ checkout present next to Cargo.toml — not + /// PATH and the native-hid/ checkout present next to Cargo.toml - not /// guaranteed in every CI environment, so it's opt-in rather than part /// of the default `cargo test` run. Run explicitly with /// `cargo test -- --ignored native_hid`. @@ -856,7 +856,7 @@ mod tests { /// Discovery must see every vendor id the helper can drive, and every /// brand discovery writes into `device.id` must normalize to a helper - /// brand key — otherwise a mouse is discovered but its battery or + /// brand key - otherwise a mouse is discovered but its battery or /// settings can never be read. Parses `native-hid/src/brands.mjs` (the /// helper's own table) so the two cannot drift apart silently. #[test] @@ -896,7 +896,7 @@ mod tests { } assert!( !helper_vendor_ids.is_empty(), - "parsed no vendor ids — did brands.mjs's format change?" + "parsed no vendor ids - did brands.mjs's format change?" ); let discoverable = |id: u16| { // The special-cased vendor ids in `discovered_brand`: CompX's diff --git a/src/drivers/native_hid.rs b/src/drivers/native_hid.rs index 466d26b0..7148d7fa 100644 --- a/src/drivers/native_hid.rs +++ b/src/drivers/native_hid.rs @@ -2,7 +2,7 @@ //! that doesn't have a dependency-free native Rust driver. The helper reuses //! OpenMouse's own hardware-verified `@openmouse/protocol` WebHID driver //! classes through a small adapter, instead of Bridge reimplementing every -//! vendor's wire protocol from scratch — see `native-hid/README.md`. +//! vendor's wire protocol from scratch - see `native-hid/README.md`. #[cfg(target_os = "windows")] use std::os::windows::process::CommandExt; @@ -93,7 +93,7 @@ struct StatusReply { battery_percent: Option, battery_state: Option, /// The driver's own model name (`MouseStatus.name`), when the driver - /// reports one — better than the receiver-level name discovery gets from + /// reports one - better than the receiver-level name discovery gets from /// the HID descriptor. device_name: Option, /// The settings currently in the device's onboard memory, when the @@ -126,7 +126,7 @@ pub struct NativeStatus { /// `MouseStatus.dpi` is either one number or a per-stage list; the stages /// have no reliable "active" marker, so a list collapses to its first -/// stage — the one most drivers treat as the default. +/// stage - the one most drivers treat as the default. fn coerce_dpi(value: Option<&serde_json::Value>) -> Option { match value? { serde_json::Value::Number(number) => number.as_u64().map(|dpi| dpi as u32), @@ -316,7 +316,7 @@ pub(super) fn run_helper(request: &impl Serialize) -> Result>> { bundled.display() ), None => format!( - "could not start Node.js to run {} — is Node.js installed and on PATH?", + "could not start Node.js to run {} - is Node.js installed and on PATH?", script.display() ), })?; @@ -352,8 +352,8 @@ pub fn spawn_button_listener(brand: &str) -> Result { }) } -/// Finds `native-hid/src/apply.mjs` next to the running executable — how a -/// packaged Bridge release is expected to ship it — falling back to the +/// Finds `native-hid/src/apply.mjs` next to the running executable - how a +/// packaged Bridge release is expected to ship it - falling back to the /// checkout's own source tree so `cargo run`/`cargo test` work without a /// packaging step. fn locate_apply_script() -> Result { @@ -395,7 +395,7 @@ fn runs_inside(checkout: &Path) -> bool { /// Finds the Node.js runtime a packaged Bridge release bundles at /// `native-hid/node/` next to the executable (see `.github/workflows/release.yml`). /// `None` means no bundled runtime was found, so the caller should fall back -/// to `node` on `PATH` — the normal case for `cargo run`/`cargo test`, which +/// to `node` on `PATH` - the normal case for `cargo run`/`cargo test`, which /// don't produce a packaged layout. fn locate_node_binary() -> Option { let dir = installed_native_hid_dir()?.join("node"); diff --git a/src/drivers/pulsar.rs b/src/drivers/pulsar.rs index cae0d37f..cdb826b2 100644 --- a/src/drivers/pulsar.rs +++ b/src/drivers/pulsar.rs @@ -1,5 +1,5 @@ //! Native HID driver for real Pulsar-vendor (0x3710) mice, so Bridge can push -//! DPI and polling-rate changes to the mouse on its own — without a browser +//! DPI and polling-rate changes to the mouse on its own - without a browser //! tab open and holding a WebHID connection. //! //! The wire protocol here is ported byte-for-byte from @@ -19,7 +19,7 @@ use anyhow::{Context, Result, anyhow, bail}; use super::{NativeBattery, NativeStatus}; use crate::config::ApplicationProfile; -/// This driver's slot in `crate::drivers`' brand registry — matches the +/// This driver's slot in `crate::drivers`' brand registry - matches the /// `"Pulsar:"` prefix the OpenMouse web app writes into `device.id`. pub const BRAND: &str = "pulsar"; @@ -60,7 +60,7 @@ fn read_flash_settings(device: &PulsarDevice) -> Result<(Option, Option Result> { /// Real Pulsar-branded mice and dongles. The Pulsar 4K Wireless Receiver /// shares a report-8 16-byte protocol but enumerates under a different, -/// shared vendor id (0x3554) that other brands also use — out of scope here. +/// shared vendor id (0x3554) that other brands also use - out of scope here. pub const VENDOR_ID: u16 = 0x3710; const CONFIG_REPORT_ID: u8 = 0x08; @@ -155,7 +155,7 @@ fn encode_polling_rate(rate_hz: u32) -> Result { /// The 10-step low range plus a dpiEx-flagged high range real Pulsar-vendor /// flash mice (including the X2 CrazyLight, CID 0x57) use. Do not apply this -/// to the Pulsar 4K Wireless Receiver (vendor 0x3554) — it uses a flat +/// to the Pulsar 4K Wireless Receiver (vendor 0x3554) - it uses a flat /// 50-step encoding with no dpiEx branching (`pulsarVgn*` in the TS source). fn decode_dpi(data: &[u8]) -> Option { if data.len() < 4 { @@ -225,7 +225,7 @@ pub struct PulsarDevice { impl PulsarDevice { /// Scans every HID interface reporting Pulsar's vendor id and opens the - /// first one that answers the identification query on report 8 — a mouse + /// first one that answers the identification query on report 8 - a mouse /// exposes several HID interfaces (boot mouse, consumer control, ...) /// sharing the same vendor id, and only one of them is this config /// channel, so wrong interfaces are expected to fail here and are @@ -330,7 +330,7 @@ impl PulsarDevice { } /// Wraps a flash read/write in the receiver's host-control handshake: - /// entered before the operation, always exited afterward (best-effort — + /// entered before the operation, always exited afterward (best-effort - /// leaving the receiver stuck in host-control mode would also break its /// normal button/movement reporting). fn with_device_control(&self, operation: impl FnOnce() -> Result) -> Result { @@ -354,7 +354,7 @@ impl PulsarDevice { assert_accepted(&response, label)?; if response[9] != 1 { if enabled && response[5] != 1 { - bail!("the Pulsar mouse is offline — move it or click a button, then retry"); + bail!("the Pulsar mouse is offline - move it or click a button, then retry"); } return Ok(()); } @@ -444,7 +444,7 @@ impl PulsarDevice { if read == 0 { continue; } - // Some backends prefix the report id, some don't — accept both. + // Some backends prefix the report id, some don't - accept both. let body = if read == buffer.len() && buffer[0] == CONFIG_REPORT_ID { &buffer[1..read] } else { @@ -516,7 +516,7 @@ mod tests { #[test] fn packet_checksum_matches_the_hardware_verified_pulsar_formula() { // 0x55 - (CONFIG_REPORT_ID + sum(bytes[0..14])) & 0xff, over a - // deviceOnline(true) packet — mirrors pulsarPacketChecksum in + // deviceOnline(true) packet - mirrors pulsarPacketChecksum in // mouse-protocol/src/pulsar/index.ts. let mut packet = [0u8; PACKET_LENGTH]; packet[0] = command::DEVICE_ONLINE; diff --git a/src/drivers/registry.rs b/src/drivers/registry.rs index d1df1a87..ce673f78 100644 --- a/src/drivers/registry.rs +++ b/src/drivers/registry.rs @@ -1,6 +1,6 @@ //! Which devices on the bus are mice Bridge can drive, and which brand each -//! is, decided by `@openmouse/protocol`'s own driver registry — the same -//! `supports()` checks the control panel runs in the browser — rather than a +//! is, decided by `@openmouse/protocol`'s own driver registry - the same +//! `supports()` checks the control panel runs in the browser - rather than a //! vendor-id table of Bridge's own. //! //! Bridge describes the bus (`hid::describe_devices`: grouped devices with @@ -168,9 +168,9 @@ fn brands_by_key(reply: IdentifyReply) -> HashMap { } /// The devices a `brand` request may use: those the registry gives that -/// brand. When none has it — a profile saved under the brand the driver +/// brand. When none has it - a profile saved under the brand the driver /// reports (`Attack Shark`) for hardware the registry files under another -/// (`Delux`) — every supported device is offered and the helper keeps the one +/// (`Delux`) - every supported device is offered and the helper keeps the one /// whose own status reports `brand`. `None` when the registry is unavailable. pub(super) fn devices_for(brand: &str) -> Option { let devices = devices()?; diff --git a/src/hid.rs b/src/hid.rs index 73762a8a..23839ef6 100644 --- a/src/hid.rs +++ b/src/hid.rs @@ -109,7 +109,7 @@ fn note_session_ended(session_id: u64) { } /// The devices the control panel currently holds open over native HID, most -/// recently opened first. Empty when no HID session has a device open — e.g. +/// recently opened first. Empty when no HID session has a device open - e.g. /// a wired mouse that was never opened still leaves no trace here, which is /// why callers fall back to the battery list and the active profile. pub fn active_devices() -> Vec { @@ -382,7 +382,7 @@ impl ReaderHandle { // The handle is shared with send_report, and std's Mutex is not // fair: a reader that blocks in read_timeout while holding the // lock, then immediately re-locks, can starve a writer for many - // seconds — and the writer holds the session lock meanwhile, so + // seconds - and the writer holds the session lock meanwhile, so // every other command (even `list`) stalls behind it. Read without // blocking under the lock and idle with it released instead. #[cfg(not(target_os = "windows"))] diff --git a/src/platform/windows.rs b/src/platform/windows.rs index 3b4270ce..1e48394d 100644 --- a/src/platform/windows.rs +++ b/src/platform/windows.rs @@ -84,11 +84,11 @@ pub fn battery_glyph(percent: u8, charging: bool) -> u32 { } /// Renders the tray battery display as a square `size` × `size` RGBA -/// buffer, tinted with `ink` — the Windows 11 taskbar only renders square +/// buffer, tinted with `ink` - the Windows 11 taskbar only renders square /// tray icons faithfully. The `style` picks what fills the square: the /// Segoe Fluent battery glyph for the level (the charging variant with the /// bolt when `charging`), or the percentage number in bold UI text (the -/// `%` is left off — at tray sizes it would shrink the digits to a +/// `%` is left off - at tray sizes it would shrink the digits to a /// squint; the tooltip spells the full `NN%` out). Returns the buffer with /// its width and height. `Segoe Fluent Icons` ships with Windows 11; /// `Segoe MDL2 Assets` carries the same glyphs on Windows 10. @@ -206,7 +206,7 @@ fn compose_battery_display( // Otherwise the digits fill it. if label.is_empty() { // A landscape glyph in a square icon: fitting its width to all but - // 1px of the canvas — the footprint the old square renderer used — + // 1px of the canvas - the footprint the old square renderer used - // is the largest it can be, and the height lands near half. let battery = fit_and_rasterize( dc, @@ -231,7 +231,7 @@ fn compose_battery_display( return Ok((canvas.rgba, height, height)); } - // The digits are drawn as tall as the square allows — a 2px margin — + // The digits are drawn as tall as the square allows - a 2px margin - // and squeezed proportionally when the string is wider than tall // ("100" is, at every size that matters). let mut target = height.saturating_sub(4).max(8); @@ -267,7 +267,7 @@ struct LabelRaster { /// Rasterizes the label into one tight coverage bitmap in a bold UI face, /// sized so a digit stands `target` pixels tall. Characters are placed by -/// the font's own advances and side bearings, top-aligned — digits and +/// the font's own advances and side bearings, top-aligned - digits and /// `%` share the cap height, so the row lines up. fn rasterize_label(dc: HDC, label: &[u16], family: &[u16], target: u32) -> Option { if label.is_empty() { @@ -399,8 +399,8 @@ impl Canvas { } /// Fits the font so the battery glyph's visible bounds span `target` -/// pixels wide — the right fit for a landscape glyph in a square icon (the -/// fit loop accepts within a pixel) — then rasterizes the glyph as an +/// pixels wide - the right fit for a landscape glyph in a square icon (the +/// fit loop accepts within a pixel) - then rasterizes the glyph as an /// 8-bit coverage bitmap. `None` when the font or glyph is missing. fn fit_and_rasterize( dc: HDC, @@ -461,13 +461,13 @@ fn fit_and_rasterize( /// Rasterizes the glyph as an 8-bit grayscale coverage bitmap /// (`GGO_GRAY8_BITMAP`): GDI's own anti-aliased glyph raster, no drawing /// surface involved. GDI writes the bitmap's *actual* bounds back into -/// `metrics` — which can come back a pixel wider than `GGO_METRICS` +/// `metrics` - which can come back a pixel wider than `GGO_METRICS` /// reported (the anti-aliased edge column), so the caller must lay the /// buffer out by the written-back values or every row skews. fn glyph_bitmap(dc: HDC, codepoint: u32, metrics: &mut GLYPHMETRICS) -> Option> { // SAFETY: `dc` is a live DC with a font selected; the metrics and // matrix structs are valid for the call and the buffer is sized to hold - // the reported black box (rows are DWORD-aligned) plus slack — GDI + // the reported black box (rows are DWORD-aligned) plus slack - GDI // rejects an exact-size buffer for some glyphs, asking for a few bytes // more than stride × rows. unsafe { @@ -627,7 +627,7 @@ mod tests { assert_eq!(rgba.len(), (size * size * 4) as usize); let coverage = |x: u32, y: u32| rgba[((y * size + x) * 4 + 3) as usize]; // The glyph's visible bounds fill the canvas: across the - // middle row, the covered span (first to last covered pixel — + // middle row, the covered span (first to last covered pixel - // the battery's body-to-nub gap doesn't count against it) is // at most two blank columns short of the full width. let row = size / 2; diff --git a/src/service.rs b/src/service.rs index 7696300e..0b0716b1 100644 --- a/src/service.rs +++ b/src/service.rs @@ -142,7 +142,7 @@ const BATTERY_TREND_WINDOW: Duration = Duration::from_secs(6 * 60 * 60); const BATTERY_MIN_TREND_SPAN: Duration = Duration::from_secs(30 * 60); /// The smallest drift (percent per minute) that counts as a trend, about 1% -/// per 3 hours — the pace a mouse battery actually moves at. +/// per 3 hours - the pace a mouse battery actually moves at. const BATTERY_TREND_EPSILON: f64 = 0.005; /// Estimates beyond this are noise for a mouse battery, not a plan. @@ -455,13 +455,13 @@ fn switch_message( match outcome { Some(ApplyOutcome::Failed) => { switch.detail = if current.is_none() { - "Couldn't restore original mouse settings — check Bridge status".into() + "Couldn't restore original mouse settings - check Bridge status".into() } else { - "Couldn't reach the mouse — open OpenMouse to apply".into() + "Couldn't reach the mouse - open OpenMouse to apply".into() }; } Some(ApplyOutcome::NoDriver) => { - switch.detail = "Bridge can't drive this mouse — open OpenMouse to apply".into(); + switch.detail = "Bridge can't drive this mouse - open OpenMouse to apply".into(); } _ => {} } @@ -519,7 +519,7 @@ struct BridgeState { active_games: Vec, processes: Vec, applications: Vec, - // Every visible application, registered game or not — what a control + // Every visible application, registered game or not - what a control // panel offers when someone requests a new game or app be added. running_applications: Vec, application_icons: HashMap>>, @@ -573,7 +573,7 @@ pub struct BatteryReading { #[serde(default)] pub charging: bool, /// The settings currently in the mouse's onboard memory, when the - /// reader could see them — native reads report them; a control panel's + /// reader could see them - native reads report them; a control panel's /// `PUT /v1/battery` may not. #[serde(default)] pub dpi: Option, @@ -607,7 +607,7 @@ struct BatteryState { /// Estimates the minutes left until the battery is empty (discharging) or /// full (charging) from the percent history: the level's drift across the /// samples inside the trend window. `None` while there is no confident -/// trend yet — too little history, or the level is holding still. +/// trend yet - too little history, or the level is holding still. fn estimate_minutes_remaining( history: &VecDeque<(Instant, u8)>, percent: u8, @@ -660,8 +660,8 @@ pub struct DeviceBattery { } /// A mouse the control panel currently holds open over native HID, most -/// recently opened first. Unlike the battery list — which accumulates every -/// device that ever reported a charge level — this reflects the live HID +/// recently opened first. Unlike the battery list - which accumulates every +/// device that ever reported a charge level - this reflects the live HID /// session, so the status view can follow device switches (including wired /// mice that never report battery). #[derive(Clone, Debug, Serialize)] @@ -1635,10 +1635,10 @@ impl BridgeService { } match mode { DeviceMode::Live => { - tracing::info!("the web panel connected — it drives the mouse live now"); + tracing::info!("the web panel connected - it drives the mouse live now"); } DeviceMode::Onboard => { - tracing::info!("the web panel disconnected — resuming onboard memory mode"); + tracing::info!("the web panel disconnected - resuming onboard memory mode"); let hybrid = service.inner.read().await.config.hybrid_mode; if !hybrid { continue; @@ -1800,7 +1800,7 @@ impl BridgeService { )> = None; if !state.profile_seeded { // Adopt the initial profile silently so startup is quiet, - // but still push it to the mouse — Bridge should reflect + // but still push it to the mouse - Bridge should reflect // the right settings from a cold start, not only switches. state.active_profile_key = current_key; state.applied_profile = current.clone(); @@ -1862,7 +1862,7 @@ impl BridgeService { /// One battery-polling pass: covers every device named by the saved profiles /// plus every mouse Bridge discovered on the HID bus whose brand no profile /// already names, reads each mouse's battery natively (skipped while the web -/// panel holds the session — it reports the battery itself over +/// panel holds the session - it reports the battery itself over /// `PUT /v1/battery`) and records it. Used by the five-minute monitor and by /// onboard-mode handovers. /// Writes devices.json; a failure is logged and never stops Bridge. @@ -2140,7 +2140,7 @@ fn canonical_battery_identity(device_id: &str, reported_name: &str) -> String { } /// The devices battery polling should cover: the saved profiles' devices plus -/// discovered mice whose brand no profile already names — discovery fills the +/// discovered mice whose brand no profile already names - discovery fills the /// gap before the panel has ever saved a profile, without double-reporting a /// mouse a profile already covers (profile and discovery ids for the same /// physical mouse differ, so brand-level dedup keeps one battery entry). @@ -2163,7 +2163,7 @@ fn merge_detected_mice( } /// Enters onboard memory mode: pushes the stored settings to the mouse's -/// onboard memory (when a default profile exists — without one, the device +/// onboard memory (when a default profile exists - without one, the device /// simply keeps the memory it already has) and reads the battery right away. /// Shared by the startup seed and the panel-disconnect handover. async fn resume_onboard(service: &BridgeService) { @@ -2953,13 +2953,13 @@ mod tests { switch_message(Some(&game), None, None, Some(ApplyOutcome::Failed), false).unwrap(); assert_eq!( notice.detail, - "Couldn't restore original mouse settings — check Bridge status" + "Couldn't restore original mouse settings - check Bridge status" ); let unsupported = switch_message(None, Some(&game), None, Some(ApplyOutcome::NoDriver), false).unwrap(); assert_eq!( unsupported.detail, - "Bridge can't drive this mouse — open OpenMouse to apply" + "Bridge can't drive this mouse - open OpenMouse to apply" ); } @@ -3010,7 +3010,7 @@ mod tests { switch_message(None, Some(&game), None, failed, false) .unwrap() .detail, - "Couldn't reach the mouse — open OpenMouse to apply" + "Couldn't reach the mouse - open OpenMouse to apply" ); assert_eq!( switch_message(None, Some(&game), None, failed, true) diff --git a/src/tray_battery.rs b/src/tray_battery.rs index b477fade..a775cc63 100644 --- a/src/tray_battery.rs +++ b/src/tray_battery.rs @@ -107,7 +107,7 @@ pub fn remaining_text(minutes: u32) -> String { } } -/// `Device — 87% · Charging · full in 45 m`. +/// `Device - 87% · Charging · full in 45 m`. pub fn tooltip(battery: &TrayBattery) -> String { let status = match (battery.charging, battery.stale) { (true, _) => " · Charging", @@ -123,10 +123,10 @@ pub fn tooltip(battery: &TrayBattery) -> String { }); let text = match estimate { Some(estimate) => format!( - "{} — {}%{status} · {estimate}", + "{} - {}%{status} · {estimate}", battery.device_name, battery.percent ), - None => format!("{} — {}%{status}", battery.device_name, battery.percent), + None => format!("{} - {}%{status}", battery.device_name, battery.percent), }; text.chars().take(TOOLTIP_CHARS).collect() } @@ -201,18 +201,18 @@ mod tests { #[test] fn the_tooltip_spells_out_the_state() { - assert_eq!(tooltip(&tray(87, false, false, None)), "Mouse — 87%"); + assert_eq!(tooltip(&tray(87, false, false, None)), "Mouse - 87%"); assert_eq!( tooltip(&tray(87, true, false, Some(45))), - "Mouse — 87% · Charging · full in 45 m" + "Mouse - 87% · Charging · full in 45 m" ); assert_eq!( tooltip(&tray(40, false, false, Some(150))), - "Mouse — 40% · 2 h 30 m left" + "Mouse - 40% · 2 h 30 m left" ); assert_eq!( tooltip(&tray(40, false, true, None)), - "Mouse — 40% · Not updating" + "Mouse - 40% · Not updating" ); }