@openmouse/protocol 0.20.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.
Files changed (68) hide show
  1. package/README.md +1 -0
  2. package/dist/drivers/keychron/launcher-mouse.d.ts +125 -0
  3. package/dist/drivers/keychron/launcher-mouse.d.ts.map +1 -0
  4. package/dist/drivers/keychron/launcher-mouse.js +342 -0
  5. package/dist/drivers/keychron/launcher-mouse.js.map +1 -0
  6. package/dist/drivers/keychron/mouse-1k-hid.d.ts +78 -0
  7. package/dist/drivers/keychron/mouse-1k-hid.d.ts.map +1 -0
  8. package/dist/drivers/keychron/mouse-1k-hid.js +403 -0
  9. package/dist/drivers/keychron/mouse-1k-hid.js.map +1 -0
  10. package/dist/drivers/keychron/mouse-4k-hid.d.ts +5 -1
  11. package/dist/drivers/keychron/mouse-4k-hid.d.ts.map +1 -1
  12. package/dist/drivers/keychron/mouse-4k-hid.js +8 -3
  13. package/dist/drivers/keychron/mouse-4k-hid.js.map +1 -1
  14. package/dist/drivers/keychron/mouse-8k-hid.d.ts +136 -0
  15. package/dist/drivers/keychron/mouse-8k-hid.d.ts.map +1 -0
  16. package/dist/drivers/keychron/mouse-8k-hid.js +754 -0
  17. package/dist/drivers/keychron/mouse-8k-hid.js.map +1 -0
  18. package/dist/drivers/keychron/mouse-8k-nordic-hid.d.ts +145 -0
  19. package/dist/drivers/keychron/mouse-8k-nordic-hid.d.ts.map +1 -0
  20. package/dist/drivers/keychron/mouse-8k-nordic-hid.js +639 -0
  21. package/dist/drivers/keychron/mouse-8k-nordic-hid.js.map +1 -0
  22. package/dist/drivers/ksnake/hid.d.ts +43 -10
  23. package/dist/drivers/ksnake/hid.d.ts.map +1 -1
  24. package/dist/drivers/ksnake/hid.js +223 -48
  25. package/dist/drivers/ksnake/hid.js.map +1 -1
  26. package/dist/drivers/mouse-types.d.ts +4 -2
  27. package/dist/drivers/mouse-types.d.ts.map +1 -1
  28. package/dist/drivers/rapoo/hid.d.ts +72 -0
  29. package/dist/drivers/rapoo/hid.d.ts.map +1 -0
  30. package/dist/drivers/rapoo/hid.js +389 -0
  31. package/dist/drivers/rapoo/hid.js.map +1 -0
  32. package/dist/drivers/redragon/hid.d.ts +56 -5
  33. package/dist/drivers/redragon/hid.d.ts.map +1 -1
  34. package/dist/drivers/redragon/hid.js +309 -1
  35. package/dist/drivers/redragon/hid.js.map +1 -1
  36. package/dist/drivers/registry.d.ts +5 -2
  37. package/dist/drivers/registry.d.ts.map +1 -1
  38. package/dist/drivers/registry.js +15 -2
  39. package/dist/drivers/registry.js.map +1 -1
  40. package/dist/drivers/vendors.d.ts +3 -1
  41. package/dist/drivers/vendors.d.ts.map +1 -1
  42. package/dist/drivers/vendors.js +17 -4
  43. package/dist/drivers/vendors.js.map +1 -1
  44. package/dist/index.d.ts +1 -0
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +1 -0
  47. package/dist/index.js.map +1 -1
  48. package/dist/keychron/index.d.ts +63 -0
  49. package/dist/keychron/index.d.ts.map +1 -1
  50. package/dist/keychron/index.js +103 -0
  51. package/dist/keychron/index.js.map +1 -1
  52. package/dist/ksnake/index.d.ts +88 -15
  53. package/dist/ksnake/index.d.ts.map +1 -1
  54. package/dist/ksnake/index.js +323 -26
  55. package/dist/ksnake/index.js.map +1 -1
  56. package/dist/rapoo/index.d.ts +278 -0
  57. package/dist/rapoo/index.d.ts.map +1 -0
  58. package/dist/rapoo/index.js +363 -0
  59. package/dist/rapoo/index.js.map +1 -0
  60. package/dist/redragon/index.d.ts +122 -0
  61. package/dist/redragon/index.d.ts.map +1 -1
  62. package/dist/redragon/index.js +322 -0
  63. package/dist/redragon/index.js.map +1 -1
  64. package/package.json +5 -1
  65. package/dist/drivers/keychron/m6-hid.d.ts +0 -81
  66. package/dist/drivers/keychron/m6-hid.d.ts.map +0 -1
  67. package/dist/drivers/keychron/m6-hid.js +0 -486
  68. package/dist/drivers/keychron/m6-hid.js.map +0 -1
@@ -0,0 +1,136 @@
1
+ import type { MouseLighting, MouseStatus } from "../mouse-types.ts";
2
+ type LiftOff = NonNullable<MouseStatus["liftOffDistance"]>;
3
+ /**
4
+ * Keychron Launcher's "8k" mouse protocol on the 0xffc1 collection (63-byte
5
+ * 0xb3/0xb4 reads, 20-byte 0xb5/0xb6 writes), which the M6 and most other
6
+ * Keychron mice speak. Not the VIA raw-HID protocol the Nape Pro speaks.
7
+ * Decoded from Launcher (main.be11320b2a72b61b.js, webpack module 20706);
8
+ * the M6 (firmware 1.0.3, USB and Link-KM) confirmed every field it reads and
9
+ * every write except angle tuning, buttons, lighting and the flagged paths.
10
+ *
11
+ * Status report (0x06) layout:
12
+ * [1] active onboard profile, zero-based; [50] profile count
13
+ * [2..4] per connection (USB, 2.4 GHz, Bluetooth): DPI stage in the low
14
+ * nibble, polling gear in the high nibble
15
+ * [5..14] five DPI slots, little-endian 16-bit
16
+ * [15] bits 0-1 lift-off code, bit 2 ripple control, bit 3 angle
17
+ * snapping, bit 4 motion sync, bit 6 reversed scroll
18
+ * [16] DPI stages in use (1-5); unused tail slots keep stale values
19
+ * [17] debounce in ms; [18] sleep timeout in minutes
20
+ * [19] battery percent, bit 7 = charging
21
+ * [26] [53] [60] feature flags before protocol 6 (from 6, 0x02 bytes 11-13 and 15)
22
+ * [40..41] DPI ceiling; [42] DPI step (when flagged)
23
+ * [43..48] polling gears as indexes into POLLING_RATES; [49] gears in use
24
+ * [52] bit 0 20K FPS; [55] sensor angle, signed
25
+ * [61] lift-off level in the low nibble, level count in the high nibble
26
+ * Settings writes are acknowledged with [0xe4, code, command]; code 0 is
27
+ * success and 7 means the command is not supported on this connection.
28
+ * The 0x40 write packet is the DPI part of this layout shifted one byte down
29
+ * (stage at [1..3], slots at [4..13], stage count at [14]).
30
+ */
31
+ export declare class Keychron8kHidClient {
32
+ readonly device: HIDDevice;
33
+ private openedListener;
34
+ private identity;
35
+ private model;
36
+ /** Floor, ceiling and step from the last status report, for getDpiOptions(). */
37
+ private dpiLimits;
38
+ private responseWaiter;
39
+ private readonly onInputReport;
40
+ constructor(device: HIDDevice);
41
+ /** Launcher treats any Keychron device with this collection as an "8k" mouse, so this does too. */
42
+ static isSupported(device: HIDDevice): boolean;
43
+ open(): Promise<void>;
44
+ close(): Promise<void>;
45
+ getDpiOptions(): number[];
46
+ getSleepOptions(): number[];
47
+ getDebounceOptions(): number[];
48
+ readonly canDisableSleep = false;
49
+ /** Falls back to the name alone when the mouse does not answer, e.g. asleep behind its receiver. */
50
+ readStatus(): Promise<MouseStatus>;
51
+ setDpi(dpi: number): Promise<number>;
52
+ setDpiStageValue(stage: number, dpi: number): Promise<number>;
53
+ setActiveDpiStage(stage: number): Promise<number>;
54
+ setDpiStageCount(count: number): Promise<number>;
55
+ /**
56
+ * Picks the gear that already holds the rate. Firmware that flags editable
57
+ * gears gets the rate written into the active gear instead, when the model
58
+ * offers it.
59
+ */
60
+ setPollingRate(rateHz: number): Promise<number>;
61
+ setLiftOffDistance(lod: LiftOff): Promise<LiftOff>;
62
+ /** Lift-off on models with more than three heights; the code is the level Launcher's config lists. */
63
+ setLiftOffScale(code: number): Promise<number>;
64
+ setMotionSync(enabled: boolean): Promise<boolean>;
65
+ setAngleSnapping(enabled: boolean): Promise<boolean>;
66
+ setRippleControl(enabled: boolean): Promise<boolean>;
67
+ /** Launcher's "20K FPS" switch, on firmware that flags it. */
68
+ setPerformanceMode(enabled: boolean): Promise<boolean>;
69
+ setAngleTuning(degrees: number): Promise<number>;
70
+ setDebounceTime(debounceMs: number): Promise<number>;
71
+ setSleepTimeout(seconds: number): Promise<number>;
72
+ /** Switch the onboard profile (1-based, as the panel numbers them). */
73
+ setProfile(profile: number): Promise<number>;
74
+ /** 0x52 on the 63-byte report: [1] button index, [3] type, then the type's data. */
75
+ setButtonMapping(button: string, action: string): Promise<void>;
76
+ setLighting(lighting: MouseLighting): Promise<MouseLighting>;
77
+ private get label();
78
+ private writeSensorFlag;
79
+ /**
80
+ * The 0x42 packet carries every sensor option at once, so resend the
81
+ * current state with the requested change applied. Lift-off goes in the
82
+ * code or the level byte, whichever the firmware uses, with the other one
83
+ * 0 the way Launcher sends it.
84
+ */
85
+ private writeSensor;
86
+ private writeLiftOff;
87
+ /**
88
+ * The 2-bit codes, or on firmware that flags lift-off levels the level byte,
89
+ * which Launcher fills from the same config list sorted by index and cut to
90
+ * the count the mouse reports.
91
+ */
92
+ private liftOffChoices;
93
+ /** The model's rates when the gears can be rewritten, otherwise the rates the gears hold. */
94
+ private supportedRates;
95
+ private connectionDetail;
96
+ private unreachableStatus;
97
+ private requireDpi;
98
+ private requireStage;
99
+ /** The model's floor, and the mouse's own ceiling and step when it flags them. */
100
+ private modelDpiLimits;
101
+ private readSettings;
102
+ /**
103
+ * Firmware string (0x04 on 0xb3) and connection mode (0x02 on 0xb5) never
104
+ * change while connected, so they are read once. Either failing leaves the
105
+ * mouse usable: the mode falls back to what the product ID implies.
106
+ */
107
+ private readIdentity;
108
+ /**
109
+ * The model table row: by USB product ID, then by the ID in the 0x02
110
+ * answer, then, behind a receiver, by the connected mouse in its 0x03 list.
111
+ */
112
+ private readModel;
113
+ private parseStatus;
114
+ /** Stages from the status report, or from 0x49 on firmware that keeps X and Y apart. */
115
+ private readDpi;
116
+ /**
117
+ * 0x40, or 0x48 when X and Y are kept apart. The panel edits one axis, so
118
+ * a changed stage gets X = Y; the other stages keep their pairs.
119
+ */
120
+ private writeDpi;
121
+ /** The gear set of this connection: the status table, or 0x4b's USB and 2.4 GHz sets. */
122
+ private readPolling;
123
+ /** 0x41 carries this connection's gears; 0x4a carries both sets. */
124
+ private pollingPacket;
125
+ private readButtons;
126
+ /** 0x62 answers [0x62, index, 0, type, data...]. */
127
+ private readButton;
128
+ /** 0x23 answers on 0x21: mode, brightness, speed, then RGB. */
129
+ private readLight;
130
+ private queryStatus;
131
+ private querySettings;
132
+ private writeSettings;
133
+ private query;
134
+ }
135
+ export {};
136
+ //# sourceMappingURL=mouse-8k-hid.d.ts.map
@@ -0,0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