@openmouse/protocol 0.21.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,125 @@
1
+ import type { MouseLighting, MouseStatus } from "../mouse-types.ts";
2
+ import { type KeychronLauncherMouse } from "@openmouse/protocol/keychron";
3
+ /**
4
+ * The parts of Keychron Launcher's "8k" and "1k" mouse protocols that are the
5
+ * same in both: the first 18 bytes of the status report, the DPI, sensor and
6
+ * debounce packets, and the button and lighting codes. Decoded from Launcher
7
+ * (main.be11320b2a72b61b.js, webpack modules 20706, 75994 and 8596).
8
+ */
9
+ export declare const KEYCHRON_DPI_STAGE_COUNT = 5;
10
+ /** Launcher's POLLING_RATE_VALUE_SCALE; polling tables hold indexes into it. */
11
+ export declare const KEYCHRON_POLLING_RATES: readonly [125, 500, 1000, 2000, 4000, 8000];
12
+ /** Ranges Launcher's descriptors give: debounce 0-20 ms, sleep 1-240 minutes. */
13
+ export declare const KEYCHRON_DEBOUNCE_MAX_MS = 20;
14
+ export declare const KEYCHRON_SLEEP_MINUTES: readonly [1, 3, 5, 10, 15, 30, 60, 120, 240];
15
+ export declare const KEYCHRON_DPI_STEP = 50;
16
+ /** The M6's range, for a mouse missing from the model table. */
17
+ export declare const KEYCHRON_DEFAULT_DPI: readonly [number, number];
18
+ /** Command bytes the two protocols share; each sends them on its own reports. */
19
+ export declare const KEYCHRON_SET: {
20
+ readonly receiverState: 3;
21
+ readonly firmware: 4;
22
+ readonly dpi: 64;
23
+ readonly polling: 65;
24
+ readonly sensor: 66;
25
+ readonly debounce: 67;
26
+ readonly readButton: 98;
27
+ readonly writeButton: 82;
28
+ };
29
+ type LiftOff = NonNullable<MouseStatus["liftOffDistance"]>;
30
+ export declare function keychronLauncherMouse(productId: number | null | undefined): KeychronLauncherMouse | undefined;
31
+ /** Status bytes 1-17, laid out the same in the "8k" 0x06 and the "1k" 0x07 report. */
32
+ export type KeychronSettings = {
33
+ /** Active onboard profile, zero-based. */
34
+ profile: number;
35
+ /** For USB, 2.4 GHz and Bluetooth: DPI stage in the low nibble, polling gear in the high nibble. */
36
+ levels: number[];
37
+ /** All five hardware slots; only the first `stageCount` are in use. */
38
+ dpiStages: number[];
39
+ stageCount: number;
40
+ /** Bits 0-1 of byte 15: the lift-off code. */
41
+ lod: number;
42
+ rippleControl: boolean;
43
+ angleSnapping: boolean;
44
+ motionSync: boolean;
45
+ scrollReversed: boolean;
46
+ debounceMs: number;
47
+ };
48
+ export declare function keychronDecodeSettings(bytes: Uint8Array): KeychronSettings;
49
+ /** The DPI stage of a connection (0 USB, 1 2.4 GHz, 2 Bluetooth), kept inside the stage count. */
50
+ export declare function keychronActiveStage(settings: KeychronSettings, workMode: number): number;
51
+ /** The polling gear of a connection. */
52
+ export declare function keychronActiveGear(settings: KeychronSettings, workMode: number): number;
53
+ /**
54
+ * 0x40: the DPI part of the status layout shifted down a byte. The stage goes
55
+ * to all three connections, as Launcher sends it.
56
+ */
57
+ export declare function keychronEncodeDpi(activeStage: number, dpiStages: readonly number[], stageCount: number): Uint8Array;
58
+ export type KeychronSensorWrite = {
59
+ /** 2-bit lift-off code, or 0 to leave it (Launcher's choice when it writes the level byte). */
60
+ lod: number;
61
+ rippleControl: boolean;
62
+ angleSnapping: boolean;
63
+ motionSync: boolean;
64
+ scrollReversed: boolean;
65
+ /** "8k" only: the 20K FPS switch. */
66
+ maxSpeed?: boolean;
67
+ /** "8k" only: the lift-off level byte, on firmware that flags it. */
68
+ lodLevel?: number;
69
+ };
70
+ /** 0x42: every sensor option at once. Toggles are 1 = on, 2 = off; 0 would leave one alone. */
71
+ export declare function keychronEncodeSensor(sensor: KeychronSensorWrite): Uint8Array;
72
+ /** 0x42 in its angle form: byte 9 = 2 enables tuning, byte 10 is the signed angle. */
73
+ export declare function keychronEncodeAngle(degrees: number): Uint8Array;
74
+ export declare function keychronEncodeDebounce(debounceMs: number): Uint8Array;
75
+ /** Launcher's 0x03 answer: [1] count, then vendor ID, product ID (both little-endian) and state (1 = connected) per mouse. */
76
+ export declare function keychronDecodeConnectedMouse(bytes: Uint8Array): number | null;
77
+ /** 0x04 answer: [1] is the length of the ASCII version that starts at [2]. */
78
+ export declare function keychronLauncherFirmware(bytes: Uint8Array): string | null;
79
+ export type KeychronProtocol = "8k" | "1k";
80
+ export declare function keychronButtonOptions(protocol: KeychronProtocol): string[];
81
+ /**
82
+ * Bytes 3 onward of a 0x52 write: the type, then the data the way Launcher
83
+ * packs it (mouse codes three bytes high to low, media codes low byte first,
84
+ * the DPI key as one byte).
85
+ */
86
+ export declare function keychronEncodeButton(label: string, protocol: KeychronProtocol): number[] | null;
87
+ /**
88
+ * Reads a 0x62 answer from byte 3. Null means the button runs its default
89
+ * function (type 0, which is all Launcher's own reads return until something
90
+ * is remapped); "Macro" and "Custom" cover codes the remapper cannot offer.
91
+ */
92
+ export declare function keychronDecodeButton(bytes: Uint8Array, protocol: KeychronProtocol): string | null;
93
+ export type KeychronButton = {
94
+ name: string;
95
+ index: number;
96
+ defaultAction: string;
97
+ };
98
+ /** A model's buttons named after their default function; repeats get a number ("Forward 2"). */
99
+ export declare function keychronButtons(model: KeychronLauncherMouse | undefined): KeychronButton[];
100
+ /** Firmware codes on the PAW3950/3395 family: 1 = 1 mm, 2 = 2 mm, 3 = 0.7 mm. */
101
+ export declare const KEYCHRON_STANDARD_LOD: ReadonlyArray<readonly [number, number]>;
102
+ export type KeychronLiftOff = Pick<MouseStatus, "liftOffDistance" | "supportedLiftOffDistances" | "liftOffScale"> & {
103
+ note?: string;
104
+ };
105
+ /**
106
+ * Up to three choices become the Low/Medium/High stops (two become Low and
107
+ * High); more become the lift-off slider, whose labels assume even steps.
108
+ */
109
+ export declare function keychronLiftOff(choices: ReadonlyArray<readonly [number, number]>, current: number): KeychronLiftOff;
110
+ /** [stop, code, millimetres] for three or fewer choices, lowest first. */
111
+ export declare function keychronLiftOffStops(choices: ReadonlyArray<readonly [number, number]>): Array<[LiftOff, number, number]>;
112
+ export type KeychronLight = {
113
+ mode: number;
114
+ brightness: number;
115
+ speed: number;
116
+ rgb: [number, number, number];
117
+ };
118
+ /** The panel's view of a light state; Launcher's sliders run 0-255 for brightness and speed. */
119
+ export declare function keychronLighting(light: KeychronLight, offered: readonly number[]): MouseLighting;
120
+ /** The panel's lighting as the mouse's codes. */
121
+ export declare function keychronEncodeLighting(lighting: MouseLighting, offered: readonly number[]): KeychronLight;
122
+ export declare function readU16(bytes: Uint8Array, offset: number): number;
123
+ export declare function writeU16(bytes: Uint8Array, offset: number, value: number): void;
124
+ export {};
125
+ //# sourceMappingURL=launcher-mouse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"launcher-mouse.d.ts","sourceRoot":"","sources":["../../../src/drivers/keychron/launcher-mouse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAqB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACvF,OAAO,EAGL,KAAK,qBAAqB,EAC3B,MAAM,8BAA8B,CAAC;AAEtC;;;;;GAKG;AAEH,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAC1C,gFAAgF;AAChF,eAAO,MAAM,sBAAsB,6CAA8C,CAAC;AAClF,iFAAiF;AACjF,eAAO,MAAM,wBAAwB,KAAK,CAAC;AAC3C,eAAO,MAAM,sBAAsB,8CAA+C,CAAC;AACnF,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,gEAAgE;AAChE,eAAO,MAAM,oBAAoB,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAiB,CAAC;AAE7E,iFAAiF;AACjF,eAAO,MAAM,YAAY;;;;;;;;;CASf,CAAC;AAEX,KAAK,OAAO,GAAG,WAAW,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC,CAAC;AAE3D,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,qBAAqB,GAAG,SAAS,CAE7G;AAED,sFAAsF;AACtF,MAAM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AAC,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,eAAe,CA2BnH;AAED,0EAA0E;AAC1E,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAIxH;AAeD,MAAM,MAAM,aAAa,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CAAC;AAE/G,gGAAgG;AAChG,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,aAAa,CAiBhG;AAED,iDAAiD;AACjD,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,aAAa,EAAE,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,aAAa,CAUzG;AAMD,wBAAgB,OAAO,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAEjE;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAG/E"}
@@ -0,0 +1,342 @@
1
+ import { KEYCHRON_LAUNCHER_MICE, } from "@openmouse/protocol/keychron";
2
+ /**
3
+ * The parts of Keychron Launcher's "8k" and "1k" mouse protocols that are the
4
+ * same in both: the first 18 bytes of the status report, the DPI, sensor and
5
+ * debounce packets, and the button and lighting codes. Decoded from Launcher
6
+ * (main.be11320b2a72b61b.js, webpack modules 20706, 75994 and 8596).
7
+ */
8
+ export const KEYCHRON_DPI_STAGE_COUNT = 5;
9
+ /** Launcher's POLLING_RATE_VALUE_SCALE; polling tables hold indexes into it. */
10
+ export const KEYCHRON_POLLING_RATES = [125, 500, 1000, 2000, 4000, 8000];
11
+ /** Ranges Launcher's descriptors give: debounce 0-20 ms, sleep 1-240 minutes. */
12
+ export const KEYCHRON_DEBOUNCE_MAX_MS = 20;
13
+ export const KEYCHRON_SLEEP_MINUTES = [1, 3, 5, 10, 15, 30, 60, 120, 240];
14
+ export const KEYCHRON_DPI_STEP = 50;
15
+ /** The M6's range, for a mouse missing from the model table. */
16
+ export const KEYCHRON_DEFAULT_DPI = [100, 26_000];
17
+ /** Command bytes the two protocols share; each sends them on its own reports. */
18
+ export const KEYCHRON_SET = {
19
+ receiverState: 0x03,
20
+ firmware: 0x04,
21
+ dpi: 0x40,
22
+ polling: 0x41,
23
+ sensor: 0x42,
24
+ debounce: 0x43,
25
+ readButton: 0x62,
26
+ writeButton: 0x52,
27
+ };
28
+ export function keychronLauncherMouse(productId) {
29
+ return KEYCHRON_LAUNCHER_MICE.find((mouse) => mouse.productId === productId);
30
+ }
31
+ export function keychronDecodeSettings(bytes) {
32
+ const flags = bytes[15] ?? 0;
33
+ const stageCount = Math.min(bytes[16] || KEYCHRON_DPI_STAGE_COUNT, KEYCHRON_DPI_STAGE_COUNT);
34
+ return {
35
+ profile: bytes[1] ?? 0,
36
+ levels: [bytes[2] ?? 0, bytes[3] ?? 0, bytes[4] ?? 0],
37
+ dpiStages: Array.from({ length: KEYCHRON_DPI_STAGE_COUNT }, (_, stage) => readU16(bytes, 5 + stage * 2)),
38
+ stageCount,
39
+ lod: flags & 0x03,
40
+ rippleControl: (flags & 0x04) !== 0,
41
+ angleSnapping: (flags & 0x08) !== 0,
42
+ motionSync: (flags & 0x10) !== 0,
43
+ scrollReversed: (flags & 0x40) !== 0,
44
+ debounceMs: bytes[17] ?? 0,
45
+ };
46
+ }
47
+ /** The DPI stage of a connection (0 USB, 1 2.4 GHz, 2 Bluetooth), kept inside the stage count. */
48
+ export function keychronActiveStage(settings, workMode) {
49
+ return Math.min((settings.levels[Math.min(workMode, 2)] ?? 0) & 0x0f, settings.stageCount - 1);
50
+ }
51
+ /** The polling gear of a connection. */
52
+ export function keychronActiveGear(settings, workMode) {
53
+ return ((settings.levels[Math.min(workMode, 2)] ?? 0) >> 4) & 0x0f;
54
+ }
55
+ /**
56
+ * 0x40: the DPI part of the status layout shifted down a byte. The stage goes
57
+ * to all three connections, as Launcher sends it.
58
+ */
59
+ export function keychronEncodeDpi(activeStage, dpiStages, stageCount) {
60
+ const packet = new Uint8Array(20);
61
+ packet[0] = KEYCHRON_SET.dpi;
62
+ packet.fill(activeStage, 1, 4);
63
+ dpiStages.slice(0, KEYCHRON_DPI_STAGE_COUNT).forEach((dpi, stage) => writeU16(packet, 4 + stage * 2, dpi));
64
+ packet[14] = stageCount;
65
+ return packet;
66
+ }
67
+ /** 0x42: every sensor option at once. Toggles are 1 = on, 2 = off; 0 would leave one alone. */
68
+ export function keychronEncodeSensor(sensor) {
69
+ const packet = new Uint8Array(20);
70
+ packet[0] = KEYCHRON_SET.sensor;
71
+ packet[1] = sensor.lod;
72
+ packet[2] = sensor.rippleControl ? 1 : 2;
73
+ packet[3] = sensor.angleSnapping ? 1 : 2;
74
+ packet[4] = sensor.motionSync ? 1 : 2;
75
+ packet[6] = sensor.scrollReversed ? 2 : 1;
76
+ if (sensor.maxSpeed !== undefined)
77
+ packet[8] = sensor.maxSpeed ? 2 : 1;
78
+ if (sensor.lodLevel !== undefined)
79
+ packet[11] = sensor.lodLevel;
80
+ return packet;
81
+ }
82
+ /** 0x42 in its angle form: byte 9 = 2 enables tuning, byte 10 is the signed angle. */
83
+ export function keychronEncodeAngle(degrees) {
84
+ const packet = new Uint8Array(20);
85
+ packet[0] = KEYCHRON_SET.sensor;
86
+ packet[9] = 2;
87
+ packet[10] = degrees & 0xff;
88
+ return packet;
89
+ }
90
+ export function keychronEncodeDebounce(debounceMs) {
91
+ const packet = new Uint8Array(20);
92
+ packet[0] = KEYCHRON_SET.debounce;
93
+ packet[1] = debounceMs;
94
+ return packet;
95
+ }
96
+ /** Launcher's 0x03 answer: [1] count, then vendor ID, product ID (both little-endian) and state (1 = connected) per mouse. */
97
+ export function keychronDecodeConnectedMouse(bytes) {
98
+ const count = Math.min(bytes[1] ?? 0, Math.floor((bytes.length - 2) / 5));
99
+ for (let entry = 0; entry < count; entry += 1) {
100
+ const offset = 2 + entry * 5;
101
+ if (bytes[offset + 4] === 1)
102
+ return readU16(bytes, offset + 2);
103
+ }
104
+ return null;
105
+ }
106
+ /** 0x04 answer: [1] is the length of the ASCII version that starts at [2]. */
107
+ export function keychronLauncherFirmware(bytes) {
108
+ const length = Math.min(bytes[1] ?? 0, bytes.length - 2);
109
+ const text = Array.from(bytes.slice(2, 2 + length))
110
+ .filter((byte) => byte >= 0x20 && byte < 0x7f)
111
+ .map((byte) => String.fromCharCode(byte))
112
+ .join("")
113
+ .trim();
114
+ if (!text)
115
+ return null;
116
+ return text.startsWith("v") ? text : `v${text}`;
117
+ }
118
+ // Buttons ───────────────────────────────────────────────────────────────
119
+ /** Launcher's EFunKey: byte 3 of a button record. */
120
+ const BUTTON_TYPE = { default: 0, mouse: 1, media: 3, macro: 4, dpi: 5, disabled: 9 };
121
+ /**
122
+ * Launcher's EBasicKey, written as three bytes high to low. The "1k" enum
123
+ * (module 8596) is the "8k" one (module 75994) with Back and Forward swapped.
124
+ */
125
+ const MOUSE_CODE = {
126
+ left: 0x010000,
127
+ right: 0x020000,
128
+ middle: 0x040000,
129
+ back8k: 0x080000,
130
+ forward8k: 0x100000,
131
+ doubleClick: 0x800000,
132
+ scrollUp: 0x000200,
133
+ scrollDown: 0x00fe00,
134
+ scrollLeft: 0x0000fe,
135
+ scrollRight: 0x000002,
136
+ };
137
+ /** Every action the remapper offers, in display order. Media codes are HID consumer usages. */
138
+ function buttonActions(protocol) {
139
+ const [back, forward] = protocol === "8k"
140
+ ? [MOUSE_CODE.back8k, MOUSE_CODE.forward8k]
141
+ : [MOUSE_CODE.forward8k, MOUSE_CODE.back8k];
142
+ return [
143
+ { label: "Left Click", type: BUTTON_TYPE.mouse, value: MOUSE_CODE.left },
144
+ { label: "Right Click", type: BUTTON_TYPE.mouse, value: MOUSE_CODE.right },
145
+ { label: "Middle Click", type: BUTTON_TYPE.mouse, value: MOUSE_CODE.middle },
146
+ { label: "Back", type: BUTTON_TYPE.mouse, value: back },
147
+ { label: "Forward", type: BUTTON_TYPE.mouse, value: forward },
148
+ { label: "Double Click", type: BUTTON_TYPE.mouse, value: MOUSE_CODE.doubleClick },
149
+ { label: "Scroll Up", type: BUTTON_TYPE.mouse, value: MOUSE_CODE.scrollUp },
150
+ { label: "Scroll Down", type: BUTTON_TYPE.mouse, value: MOUSE_CODE.scrollDown },
151
+ { label: "Scroll Left", type: BUTTON_TYPE.mouse, value: MOUSE_CODE.scrollLeft },
152
+ { label: "Scroll Right", type: BUTTON_TYPE.mouse, value: MOUSE_CODE.scrollRight },
153
+ { label: "DPI Loop", type: BUTTON_TYPE.dpi, value: 1 },
154
+ { label: "DPI +", type: BUTTON_TYPE.dpi, value: 2 },
155
+ { label: "DPI -", type: BUTTON_TYPE.dpi, value: 3 },
156
+ { label: "Volume Up", type: BUTTON_TYPE.media, value: 0xe9 },
157
+ { label: "Volume Down", type: BUTTON_TYPE.media, value: 0xea },
158
+ { label: "Mute", type: BUTTON_TYPE.media, value: 0xe2 },
159
+ { label: "Play/Pause", type: BUTTON_TYPE.media, value: 0xcd },
160
+ { label: "Next Track", type: BUTTON_TYPE.media, value: 0xb5 },
161
+ { label: "Previous Track", type: BUTTON_TYPE.media, value: 0xb6 },
162
+ { label: "Disabled", type: BUTTON_TYPE.disabled, value: 0 },
163
+ // Launcher's "restore": the firmware's own function for that button.
164
+ { label: "Default", type: BUTTON_TYPE.default, value: 0 },
165
+ ];
166
+ }
167
+ export function keychronButtonOptions(protocol) {
168
+ return buttonActions(protocol).map(({ label }) => label);
169
+ }
170
+ /**
171
+ * Bytes 3 onward of a 0x52 write: the type, then the data the way Launcher
172
+ * packs it (mouse codes three bytes high to low, media codes low byte first,
173
+ * the DPI key as one byte).
174
+ */
175
+ export function keychronEncodeButton(label, protocol) {
176
+ const action = buttonActions(protocol).find((entry) => entry.label === label);
177
+ if (!action)
178
+ return null;
179
+ switch (action.type) {
180
+ case BUTTON_TYPE.mouse:
181
+ return [action.type, (action.value >> 16) & 0xff, (action.value >> 8) & 0xff, action.value & 0xff];
182
+ case BUTTON_TYPE.media:
183
+ return [action.type, action.value & 0xff, (action.value >> 8) & 0xff];
184
+ case BUTTON_TYPE.dpi:
185
+ return [action.type, action.value];
186
+ default:
187
+ return [action.type];
188
+ }
189
+ }
190
+ /**
191
+ * Reads a 0x62 answer from byte 3. Null means the button runs its default
192
+ * function (type 0, which is all Launcher's own reads return until something
193
+ * is remapped); "Macro" and "Custom" cover codes the remapper cannot offer.
194
+ */
195
+ export function keychronDecodeButton(bytes, protocol) {
196
+ const type = bytes[3] ?? 0;
197
+ if (type === BUTTON_TYPE.default)
198
+ return null;
199
+ if (type === BUTTON_TYPE.macro)
200
+ return "Macro";
201
+ const value = type === BUTTON_TYPE.mouse ? ((bytes[4] ?? 0) << 16) | ((bytes[5] ?? 0) << 8) | (bytes[6] ?? 0)
202
+ : type === BUTTON_TYPE.media ? (bytes[4] ?? 0) | ((bytes[5] ?? 0) << 8)
203
+ : type === BUTTON_TYPE.dpi ? (bytes[4] ?? 0)
204
+ : 0;
205
+ return buttonActions(protocol).find((action) => action.type === type && action.value === value)?.label ?? "Custom";
206
+ }
207
+ const BUTTON_NAME = {
208
+ left: "Left",
209
+ right: "Right",
210
+ middle: "Middle",
211
+ backward: "Back",
212
+ forward: "Forward",
213
+ leftTilt: "Tilt Left",
214
+ rightTilt: "Tilt Right",
215
+ upScroll: "Scroll Up",
216
+ downScroll: "Scroll Down",
217
+ leftScroll: "Scroll Left",
218
+ rightScroll: "Scroll Right",
219
+ dpiLoop: "DPI",
220
+ pageUp: "Page Up",
221
+ pageDown: "Page Down",
222
+ swichLight: "Lighting",
223
+ };
224
+ /** What a button does before it is remapped, as a remapper label. */
225
+ const DEFAULT_ACTION = {
226
+ left: "Left Click",
227
+ right: "Right Click",
228
+ middle: "Middle Click",
229
+ backward: "Back",
230
+ forward: "Forward",
231
+ upScroll: "Scroll Up",
232
+ downScroll: "Scroll Down",
233
+ leftScroll: "Scroll Left",
234
+ rightScroll: "Scroll Right",
235
+ dpiLoop: "DPI Loop",
236
+ };
237
+ /** A model's buttons named after their default function; repeats get a number ("Forward 2"). */
238
+ export function keychronButtons(model) {
239
+ const seen = new Map();
240
+ return (model?.buttons ?? []).map(([index, id]) => {
241
+ const base = BUTTON_NAME[id];
242
+ const count = (seen.get(base) ?? 0) + 1;
243
+ seen.set(base, count);
244
+ return { name: count > 1 ? `${base} ${count}` : base, index, defaultAction: DEFAULT_ACTION[id] ?? "Default" };
245
+ });
246
+ }
247
+ // Lift-off ──────────────────────────────────────────────────────────────
248
+ /** Firmware codes on the PAW3950/3395 family: 1 = 1 mm, 2 = 2 mm, 3 = 0.7 mm. */
249
+ export const KEYCHRON_STANDARD_LOD = [[3, 0.7], [1, 1], [2, 2]];
250
+ /**
251
+ * Up to three choices become the Low/Medium/High stops (two become Low and
252
+ * High); more become the lift-off slider, whose labels assume even steps.
253
+ */
254
+ export function keychronLiftOff(choices, current) {
255
+ const sorted = [...choices].sort((a, b) => a[1] - b[1]);
256
+ if (!sorted.length)
257
+ return { liftOffDistance: null };
258
+ if (sorted.length > 3) {
259
+ const byLevel = [...choices].sort((a, b) => a[0] - b[0]);
260
+ const first = byLevel[0];
261
+ const last = byLevel[byLevel.length - 1];
262
+ const value = choices.find(([code]) => code === current) ?? first;
263
+ return {
264
+ liftOffDistance: null,
265
+ liftOffScale: {
266
+ value: value[0],
267
+ min: first[0],
268
+ max: last[0],
269
+ millimetres: value[1],
270
+ minMillimetres: first[1],
271
+ maxMillimetres: last[1],
272
+ },
273
+ };
274
+ }
275
+ const stops = keychronLiftOffStops(sorted);
276
+ const level = stops.find(([, code]) => code === current)?.[0] ?? null;
277
+ return {
278
+ liftOffDistance: level,
279
+ supportedLiftOffDistances: stops.map(([name]) => name),
280
+ note: `Lift-off: ${stops.map(([name, , mm]) => `${name} is ${mm} mm`).join(", ")}.`,
281
+ };
282
+ }
283
+ /** [stop, code, millimetres] for three or fewer choices, lowest first. */
284
+ export function keychronLiftOffStops(choices) {
285
+ const sorted = [...choices].sort((a, b) => a[1] - b[1]);
286
+ const names = sorted.length === 3 ? ["Low", "Medium", "High"] : sorted.length === 2 ? ["Low", "High"] : ["Medium"];
287
+ return sorted.map(([code, mm], index) => [names[index], code, mm]);
288
+ }
289
+ // Lighting ──────────────────────────────────────────────────────────────
290
+ /** Launcher's light effects (json.light); 5 (one-colour flow) and 6 (flash) have no panel equivalent. */
291
+ const LIGHT_MODE = [
292
+ [0, "Off"],
293
+ [1, "Static"],
294
+ [2, "Breathing single"],
295
+ [3, "Spectrum"],
296
+ [4, "Wave"],
297
+ ];
298
+ const LIGHT_BRIGHTNESS = [25, 50, 75, 100];
299
+ const LIGHT_SPEEDS = [1, 2, 3, 4, 5];
300
+ /** The panel's view of a light state; Launcher's sliders run 0-255 for brightness and speed. */
301
+ export function keychronLighting(light, offered) {
302
+ const modes = LIGHT_MODE.filter(([code]) => code === 0 || offered.includes(code)).map(([, mode]) => mode);
303
+ const mode = LIGHT_MODE.find(([code]) => code === light.mode)?.[1] ?? null;
304
+ return {
305
+ zone: "Mouse",
306
+ modes,
307
+ mode,
308
+ color: `#${light.rgb.map((value) => value.toString(16).padStart(2, "0")).join("")}`,
309
+ color2: null,
310
+ colorModes: modes.filter((entry) => entry === "Static" || entry === "Breathing single"),
311
+ dualColorModes: [],
312
+ reactiveModes: modes.filter((entry) => entry !== "Off" && entry !== "Static"),
313
+ speeds: [...LIGHT_SPEEDS],
314
+ speed: Math.max(1, Math.round((light.speed * LIGHT_SPEEDS.length) / 255)),
315
+ brightness: nearest(LIGHT_BRIGHTNESS, Math.round((light.brightness * 100) / 255)),
316
+ brightnessLevels: [...LIGHT_BRIGHTNESS],
317
+ };
318
+ }
319
+ /** The panel's lighting as the mouse's codes. */
320
+ export function keychronEncodeLighting(lighting, offered) {
321
+ const mode = LIGHT_MODE.find(([code, name]) => name === lighting.mode && (code === 0 || offered.includes(code)))?.[0];
322
+ if (mode === undefined)
323
+ throw new Error(`This Keychron mouse has no ${lighting.mode ?? "unknown"} lighting effect.`);
324
+ const hex = /^#([0-9a-f]{6})$/i.exec(lighting.color ?? "")?.[1] ?? "ffffff";
325
+ return {
326
+ mode,
327
+ brightness: Math.round(((lighting.brightness ?? 100) * 255) / 100),
328
+ speed: Math.round(((lighting.speed ?? LIGHT_SPEEDS.length) * 255) / LIGHT_SPEEDS.length),
329
+ rgb: [0, 2, 4].map((offset) => Number.parseInt(hex.slice(offset, offset + 2), 16)),
330
+ };
331
+ }
332
+ function nearest(values, target) {
333
+ return values.reduce((best, value) => (Math.abs(value - target) < Math.abs(best - target) ? value : best), values[0]);
334
+ }
335
+ export function readU16(bytes, offset) {
336
+ return (bytes[offset] ?? 0) | ((bytes[offset + 1] ?? 0) << 8);
337
+ }
338
+ export function writeU16(bytes, offset, value) {
339
+ bytes[offset] = value & 0xff;
340
+ bytes[offset + 1] = (value >> 8) & 0xff;
341
+ }
342
+ //# sourceMappingURL=launcher-mouse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"launcher-mouse.js","sourceRoot":"","sources":["../../../src/drivers/keychron/launcher-mouse.ts"],"names":[],"mappings":"AACA,OAAO,EACL,sBAAsB,GAGvB,MAAM,8BAA8B,CAAC;AAEtC;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAC1C,gFAAgF;AAChF,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAU,CAAC;AAClF,iFAAiF;AACjF,MAAM,CAAC,MA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,0 +1,78 @@
1
+ import type { MouseLighting, MouseStatus } from "../mouse-types.ts";
2
+ type LiftOff = NonNullable<MouseStatus["liftOffDistance"]>;
3
+ /**
4
+ * Keychron Launcher's "1k" mouse protocol on usage page 0x8c: the "8k"
5
+ * command set in 20-byte feature reports on 0x51 (answers fetched with a
6
+ * feature read of the same report), with buttons on 64-byte feature report
7
+ * 0x52. It has no sleep, profile, angle or 20K FPS commands and a fixed
8
+ * 125/500/1000 Hz table. Decoded from Launcher (main.be11320b2a72b61b.js,
9
+ * webpack modules 20706, 61892 and 8596), not yet confirmed on hardware, and
10
+ * Launcher does not say which models use it.
11
+ *
12
+ * 0x06 identity: [1..2] protocol version, [3..4] vendor ID, [5..6] product
13
+ * ID, [7..8] firmware, [9] low 3 bits connection, [10] battery percent,
14
+ * [11] bits 0-1 power state. 0x07 status: bytes 1-17 of the "8k" status
15
+ * report. 0x03 through a receiver lists the paired mice.
16
+ */
17
+ export declare class Keychron1kHidClient {
18
+ readonly device: HIDDevice;
19
+ private identity;
20
+ private model;
21
+ /** Feature writes and reads come in pairs, so they run one at a time. */
22
+ private queue;
23
+ constructor(device: HIDDevice);
24
+ /** Launcher uses this collection only when the device has no 0xffc1 one. */
25
+ static isSupported(device: HIDDevice): boolean;
26
+ open(): Promise<void>;
27
+ close(): Promise<void>;
28
+ getDpiOptions(): number[];
29
+ getDebounceOptions(): number[];
30
+ /** Falls back to the name alone when the mouse does not answer, e.g. asleep behind its receiver. */
31
+ readStatus(): Promise<MouseStatus>;
32
+ setDpi(dpi: number): Promise<number>;
33
+ setDpiStageValue(stage: number, dpi: number): Promise<number>;
34
+ setActiveDpiStage(stage: number): Promise<number>;
35
+ setDpiStageCount(count: number): Promise<number>;
36
+ /** 0x41: the gear for both connection slots, then Launcher's table. */
37
+ setPollingRate(rateHz: number): Promise<number>;
38
+ setLiftOffDistance(lod: LiftOff): Promise<LiftOff>;
39
+ setMotionSync(enabled: boolean): Promise<boolean>;
40
+ setAngleSnapping(enabled: boolean): Promise<boolean>;
41
+ setRippleControl(enabled: boolean): Promise<boolean>;
42
+ setDebounceTime(debounceMs: number): Promise<number>;
43
+ /** 0x52 on feature report 0x52: [1] button index, [3] type, then the type's data. */
44
+ setButtonMapping(button: string, action: string): Promise<void>;
45
+ /** Launcher writes the effect, then its brightness, speed and colour one command at a time. */
46
+ setLighting(lighting: MouseLighting): Promise<MouseLighting>;
47
+ private get label();
48
+ private get receiver();
49
+ private pollingRate;
50
+ private lodChoices;
51
+ private writeSensorFlag;
52
+ /** 0x42 with every option resent; "1k" firmware has no 20K FPS or lift-off level bytes. */
53
+ private writeSensor;
54
+ private unreachableStatus;
55
+ private requireDpi;
56
+ private requireStage;
57
+ private readSettings;
58
+ /** Read once per connection; a failed read leaves the mode the product ID implies. */
59
+ private readIdentity;
60
+ /** 0x06 again: the battery sits in the identity answer, which is otherwise read once. */
61
+ private readPower;
62
+ /** By USB product ID, then the identity's, then the connected mouse in a receiver's 0x03 list. */
63
+ private readModel;
64
+ private readButtons;
65
+ private readButton;
66
+ /** 0x12 names the active effect ([3]); 0x18 then gives its RGB ([2..4]), brightness ([5]) and speed ([6]). */
67
+ private readLight;
68
+ /** A write's answer carries nothing Launcher checks, so it is only drained; the re-read confirms. */
69
+ private write;
70
+ /**
71
+ * Sends a feature report, then reads the same report back until the answer
72
+ * matches, as Launcher's feature transceivers do (behind a receiver it waits
73
+ * first). The answer starts with the report ID, which is dropped.
74
+ */
75
+ private request;
76
+ }
77
+ export {};
78
+ //# sourceMappingURL=mouse-1k-hid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mouse-1k-hid.d.ts","sourceRoot":"","sources":["../../../src/drivers/keychron/mouse-1k-hid.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAoEpE,KAAK,OAAO,GAAG,WAAW,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC,CAAC;AAa3D;;;;;;;;;;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