Repository navigation
feat: add VIA keyboard support - #8
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
| if (ids.length < 2 || ids.some((id) => !Number.isInteger(id) || id < 0 || id > 0xff)) return null; | ||
| const control = toControl(entry); | ||
| if (!control) return null; | ||
| const bytes = typeof entry.bytes === "number" && entry.bytes >= 1 && entry.bytes <= 4 ? Math.floor(entry.bytes) : 1; |
There was a problem hiding this comment.
🟠 High via/index.ts:780
Controls without an explicit bytes field are always parsed as one-byte values, so valid 16-bit ranges and buttons are truncated on reads and values above 255 are rejected by viaNumberToBytes; color controls also need two bytes for hue and saturation. Infer the width from the parsed control when bytes is absent.
- const bytes = typeof entry.bytes === "number" && entry.bytes >= 1 && entry.bytes <= 4 ? Math.floor(entry.bytes) : 1;
+ const bytes = typeof entry.bytes === "number" && entry.bytes >= 1 && entry.bytes <= 4 ? Math.floor(entry.bytes) : control.type === "color" ? 2 : control.type === "range" ? (control.max > 255 ? 2 : 1) : control.type === "button" ? (control.value > 255 ? 2 : 1) : 1;🤖 Copy this AI Prompt to have your agent fix this:
In file @src/via/index.ts around line 780:
Controls without an explicit `bytes` field are always parsed as one-byte values, so valid 16-bit ranges and buttons are truncated on reads and values above 255 are rejected by `viaNumberToBytes`; color controls also need two bytes for hue and saturation. Infer the width from the parsed control when `bytes` is absent.
ApprovabilityVerdict: Needs Human Approval Macroscope's review found this PR requires human approval — Adds VIA keyboard configuration support while preserving existing brand-driver precedence. Unresolved review concerns about custom-control widths and toggle payloads need reconciliation because they affect values written to keyboard settings. Notes:
You can add or adjust custom eligibility rules. Learn more. |
42aa21c to
7bdc067
Compare
7bdc067 to
8b1cc3b
Compare
8b1cc3b to
4d52a6f
Compare
4d52a6f to
6b317c7
Compare
6b317c7 to
ac80d2b
Compare
ac80d2b to
731d9ca
Compare
Generic driver for boards running VIA/QMK firmware, found by the raw HID collection (usage page 0xFF60, usage 0x61) instead of a vendor list. Driver (drivers/via): protocol version, firmware and keycodes version, keymap read/write by buffer (protocol 8+) or single key, layer count, encoders, macro memory, custom-menu values, and layout options. Writes are read back and the board's reply is returned, since boards clamp or round custom values. Codec (src/via): 32-byte command frames, served v3 definition parser with layout-option decoding, keycode names for both QMK numbering generations, a macro action codec that keeps bytes it does not understand, VIA's macro text syntax with QMK key names, and a parser that turns a definition's menus into range, toggle, dropdown, colour and button controls with their showIf conditions. EEPROM reset, bootloader jump and macro reset are never sent. Exercised on one board (Anvil Native, protocol 11); see docs/via-support.md.
|
🎉 This PR is included in version 1.6.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
What
Adds a driver for keyboards running VIA firmware (QMK/VIA). It is exported as
@openmouse/keyboard-protocol/viaand registered in the driver registry.VIA boards from any vendor use the same raw HID collection (0xFF60:0x61), so the driver matches on that collection alone. It sits last in the registry, so brand drivers (Wooting, Keychron, Arbiter and so on) still win.
Included
.layout.json, and a browser key-code to QMK keycode table.docs/via-support.mdwith the support ledger.Not included
EEPROM reset, bootloader jump and macro reset commands are deliberately never sent. Wilba Tech
wt_*lighting is not modelled.Testing
npm run checkpasses (384 tests), including a fake-board test of the HID client.Note: a Keychron board that is not a catalogued Hall-effect model now falls through to the VIA driver. The registry test was updated to expect that.
Note
Add VIA keyboard support with HID client, protocol codecs, and driver registration
ViaHidClientin hid.ts, a Web HID client that talks the VIA raw-HID protocol: status reads, keymap read/write with read-back verification, single keycodes, encoders, switch-matrix reads, macros, custom-menu values, and layout options. Commands time out after 1500 ms and a failed transaction faults the session.showIfcondition evaluation.0xFF60, usage0x61) matches. Uncatalogued Keychron products now match VIA instead of being unsupported../viaand a rootvianamespace export, plus a new support guide in via-support.md.Macroscope summarized 731d9ca.