diff --git a/src/drivers/via/hid.test.ts b/src/drivers/via/hid.test.ts index 93af6d4..2d93b33 100644 --- a/src/drivers/via/hid.test.ts +++ b/src/drivers/via/hid.test.ts @@ -111,6 +111,18 @@ test("readStatus reports identity and leaves unsupported values null", async () macroBufferSize: 16, }); assert.deepEqual(status.firmware, ["VIA protocol 9", "Firmware 258"]); + assert.equal(status.connectionType, "Wired"); +}); + +test("a receiver is reported as wireless from its product name", async () => { + for (const productName of ["2.4G Receiver", "Keyboard Dongle", "Keychron Link", "Wireless Board"]) { + const board = new FakeViaBoard(); + board.productName = productName; + assert.equal((await client(board).readStatus()).connectionType, "Wireless", productName); + } + const board = new FakeViaBoard(); + board.productName = "Linkin Board"; + assert.equal((await client(board).readStatus()).connectionType, "Wired"); }); test("a firmware version of 0 means the maker never set one and is reported as unknown", async () => { diff --git a/src/drivers/via/hid.ts b/src/drivers/via/hid.ts index da5474a..eb3792f 100644 --- a/src/drivers/via/hid.ts +++ b/src/drivers/via/hid.ts @@ -65,6 +65,8 @@ export interface ViaMacros { macros: number[][]; } +const VIA_RECEIVER_NAME = /receiver|dongle|2\.4 ?g|wireless|\blink\b/i; + /** * Any board running VIA/QMK raw HID (usage page 0xFF60, usage 0x61). Key * layout and custom-menu meaning come from a VIA definition, not the board, so @@ -223,11 +225,12 @@ export class ViaHidClient { protocolVersion, layerCount, firmwareVersion, keycodesVersion, layoutOptions, uptimeMs, macroCount, macroBufferSize, }; const name = this.device.productName || "VIA keyboard"; + const wireless = VIA_RECEIVER_NAME.test(name); return { brand: "VIA", name, - connectionType: "Unknown", - connectionDetail: "VIA raw HID", + connectionType: wireless ? "Wireless" : "Wired", + connectionDetail: wireless ? "2.4 GHz receiver" : "USB", firmware: [`VIA protocol ${protocolVersion}`, ...(firmwareVersion ? [`Firmware ${firmwareVersion}`] : [])], firmwareVersion: firmwareVersion ? String(firmwareVersion) : null, layout: null,