From 3a62864a41ae8f9d7af3df68c67e1ad0cdb1af71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thea=20Sch=C3=B6bl?= Date: Thu, 7 Dec 2023 21:29:26 +0100 Subject: [PATCH] feat: ccx key count --- src/lib/serial/device.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/lib/serial/device.ts b/src/lib/serial/device.ts index 3e9dd08a..eddea6e9 100644 --- a/src/lib/serial/device.ts +++ b/src/lib/serial/device.ts @@ -12,6 +12,12 @@ const PORT_FILTERS: Map = new Map([ ["X", {usbProductId: 33163, usbVendorId: 12346}], ]) +const KEY_COUNTS = { + ONE: 90, + LITE: 67, + X: 255, +} + if (browser && navigator.serial === undefined && import.meta.env.TAURI_FAMILY !== undefined) { await import("./tauri-serial") } @@ -47,9 +53,9 @@ export class CharaDevice { version!: SemVer company!: "CHARACHORDER" - device!: "ONE" | "LITE" + device!: "ONE" | "LITE" | "X" chipset!: "M0" | "S2" - keyCount!: 90 | 67 + keyCount!: 90 | 67 | 255 constructor(private readonly baudRate = 115200) {} @@ -77,9 +83,9 @@ export class CharaDevice { this.version = new SemVer(await this.send("VERSION").then(([version]) => version)) const [company, device, chipset] = await this.send("ID") this.company = company as "CHARACHORDER" - this.device = device as "ONE" | "LITE" + this.device = device as "ONE" | "LITE" | "X" this.chipset = chipset as "M0" | "S2" - this.keyCount = this.device === "ONE" ? 90 : 67 + this.keyCount = KEY_COUNTS[this.device] } catch (e) { alert(e) console.error(e)