@openmouse/protocol 0.19.0 → 0.21.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 (58) hide show
  1. package/README.md +1 -0
  2. package/dist/drivers/keychron/mouse-4k-hid.d.ts +5 -1
  3. package/dist/drivers/keychron/mouse-4k-hid.d.ts.map +1 -1
  4. package/dist/drivers/keychron/mouse-4k-hid.js +8 -3
  5. package/dist/drivers/keychron/mouse-4k-hid.js.map +1 -1
  6. package/dist/drivers/keychron/mouse-8k-nordic-hid.d.ts +145 -0
  7. package/dist/drivers/keychron/mouse-8k-nordic-hid.d.ts.map +1 -0
  8. package/dist/drivers/keychron/mouse-8k-nordic-hid.js +639 -0
  9. package/dist/drivers/keychron/mouse-8k-nordic-hid.js.map +1 -0
  10. package/dist/drivers/ksnake/hid.d.ts +43 -10
  11. package/dist/drivers/ksnake/hid.d.ts.map +1 -1
  12. package/dist/drivers/ksnake/hid.js +223 -48
  13. package/dist/drivers/ksnake/hid.js.map +1 -1
  14. package/dist/drivers/mouse-types.d.ts +4 -2
  15. package/dist/drivers/mouse-types.d.ts.map +1 -1
  16. package/dist/drivers/pulsar/pulsar-xs1-hid.d.ts.map +1 -1
  17. package/dist/drivers/pulsar/pulsar-xs1-hid.js +4 -1
  18. package/dist/drivers/pulsar/pulsar-xs1-hid.js.map +1 -1
  19. package/dist/drivers/rapoo/hid.d.ts +72 -0
  20. package/dist/drivers/rapoo/hid.d.ts.map +1 -0
  21. package/dist/drivers/rapoo/hid.js +389 -0
  22. package/dist/drivers/rapoo/hid.js.map +1 -0
  23. package/dist/drivers/redragon/hid.d.ts +56 -5
  24. package/dist/drivers/redragon/hid.d.ts.map +1 -1
  25. package/dist/drivers/redragon/hid.js +309 -1
  26. package/dist/drivers/redragon/hid.js.map +1 -1
  27. package/dist/drivers/registry.d.ts +3 -1
  28. package/dist/drivers/registry.d.ts.map +1 -1
  29. package/dist/drivers/registry.js +10 -0
  30. package/dist/drivers/registry.js.map +1 -1
  31. package/dist/drivers/vendors.d.ts +2 -0
  32. package/dist/drivers/vendors.d.ts.map +1 -1
  33. package/dist/drivers/vendors.js +11 -0
  34. package/dist/drivers/vendors.js.map +1 -1
  35. package/dist/index.d.ts +1 -0
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +1 -0
  38. package/dist/index.js.map +1 -1
  39. package/dist/keychron/index.d.ts +19 -0
  40. package/dist/keychron/index.d.ts.map +1 -1
  41. package/dist/keychron/index.js +21 -0
  42. package/dist/keychron/index.js.map +1 -1
  43. package/dist/ksnake/index.d.ts +88 -15
  44. package/dist/ksnake/index.d.ts.map +1 -1
  45. package/dist/ksnake/index.js +323 -26
  46. package/dist/ksnake/index.js.map +1 -1
  47. package/dist/pulsar/index.d.ts.map +1 -1
  48. package/dist/pulsar/index.js +1 -1
  49. package/dist/pulsar/index.js.map +1 -1
  50. package/dist/rapoo/index.d.ts +278 -0
  51. package/dist/rapoo/index.d.ts.map +1 -0
  52. package/dist/rapoo/index.js +363 -0
  53. package/dist/rapoo/index.js.map +1 -0
  54. package/dist/redragon/index.d.ts +122 -0
  55. package/dist/redragon/index.d.ts.map +1 -1
  56. package/dist/redragon/index.js +322 -0
  57. package/dist/redragon/index.js.map +1 -1
  58. package/package.json +5 -1
@@ -0,0 +1,278 @@
1
+ /**
2
+ * Rapoo's vendor configuration channel (VT9 Pro and its family).
3
+ *
4
+ * Two independent sources pin the layout down, and they agree byte for byte:
5
+ *
6
+ * - a capture from a real VT9 Pro on 2026-09-29 (receiver 0x24AE:0x1205,
7
+ * cable 0x24AE:0x4405) reading every register below twice, on both links;
8
+ * - mousectl's `rapoo_vt3pro` driver, reverse engineered from Rapoo's own
9
+ * `RapooGameDevDriver` 1.6.29, which documents the same frame and the same
10
+ * addresses for the VT3 PRO.
11
+ *
12
+ * The request is 31 bytes of output report 0xBA on the 0xFF00:0x000E
13
+ * interface: one connection byte, then 30 payload bytes.
14
+ *
15
+ * [0] connection byte [1] command
16
+ * [2] payload length [3..6] address, u32 little endian
17
+ * [7..] data
18
+ *
19
+ * Those 31 bytes are the *report data*: the report id goes to the transport
20
+ * separately, the way WebHID's `sendReport` and OpenMouse Bridge take it.
21
+ * Windows reports the same report as 32 bytes because `HidP_GetCaps` counts
22
+ * the id, and hidraw wants it prepended - both of those are this 31 plus one
23
+ * byte. Sending 32 bytes of data instead is refused before it reaches the
24
+ * mouse (measured in the browser: `Failed to write the report`).
25
+ *
26
+ * The answer travels back through GET_REPORT(Input) rather than as an
27
+ * interrupt-IN report, which is why WebHID cannot see it: the browser has no
28
+ * equivalent call. Transports that can issue it (Windows `HidD_GetInputReport`,
29
+ * Linux `HIDIOCGINPUT`, OpenMouse Bridge's `receiveInputReport`) deliver the
30
+ * report id stripped, leaving the status byte first:
31
+ *
32
+ * [0] status, 0x01 when the frame was answered
33
+ * [1] 0 for every block answer, non-zero on a battery answer
34
+ * [2] battery percentage on a battery answer
35
+ * [4..] payload
36
+ *
37
+ * Two measured properties of the link shape every caller, so they belong here
38
+ * rather than in a driver:
39
+ *
40
+ * - **the channel is lossy.** About 40% of frames are dropped without the
41
+ * device ever going busy (busy is a status byte other than 0x01). An OK that
42
+ * was not preceded by a busy is the *previous* command's answer, so a read
43
+ * has to be retried, and "no answer" never means "no such register";
44
+ * - **the connection byte is not validated.** 0xFF and 0xA5 both answered, as
45
+ * did 0x00, 0x01 and 0x5A. A dropped frame must therefore never be read as
46
+ * "wrong connection type".
47
+ *
48
+ * Everything in this module is transport independent: it encodes frames,
49
+ * decodes answers, and turns register blocks into protocol values. Retries,
50
+ * sleeps and the read-modify-write of a live device belong to the driver.
51
+ */
52
+ export declare const RAPOO_VENDOR_ID = 9390;
53
+ /** The 2.4 GHz receiver's configuration interface. */
54
+ export declare const RAPOO_WIRELESS_PRODUCT_ID = 4613;
55
+ /** The same mouse reached over its cable. */
56
+ export declare const RAPOO_WIRED_PRODUCT_ID = 17413;
57
+ export declare const RAPOO_PRODUCT_IDS: ReadonlySet<number>;
58
+ export declare const RAPOO_CONFIG_USAGE_PAGE = 65280;
59
+ export declare const RAPOO_CONFIG_USAGE = 14;
60
+ /** Report data length of the command channel, in both directions. */
61
+ export declare const RAPOO_CONFIG_REPORT_ID = 186;
62
+ /** The unsolicited status report; see {@link decodeRapooNotification}. */
63
+ export declare const RAPOO_NOTIFY_REPORT_ID = 187;
64
+ /**
65
+ * A separate interface (0xFF0B:0x0104) that answers a GET_REPORT(Feature) with
66
+ * a status block. It is the only Rapoo read WebHID can perform, because
67
+ * `receiveFeatureReport` exists in the browser and `GET_REPORT(Input)` does
68
+ * not.
69
+ */
70
+ export declare const RAPOO_STATUS_USAGE_PAGE = 65291;
71
+ export declare const RAPOO_STATUS_USAGE = 260;
72
+ export declare const RAPOO_STATUS_REPORT_ID = 42;
73
+ export declare const RAPOO_FRAME_LENGTH = 31;
74
+ export declare const RAPOO_CMD_READ = 164;
75
+ export declare const RAPOO_CMD_WRITE = 165;
76
+ export declare const RAPOO_CMD_BATTERY = 170;
77
+ /** The status byte of an answered frame. Anything else means "not ready". */
78
+ export declare const RAPOO_STATUS_OK = 1;
79
+ /**
80
+ * What mousectl's driver sends, and the values that were measured answering.
81
+ * Nothing validates this byte on the VT9 Pro - see the module comment.
82
+ */
83
+ export declare const RAPOO_CONNECTION_WIRED = 255;
84
+ export declare const RAPOO_CONNECTION_RECEIVER = 165;
85
+ /**
86
+ * EEPROM addresses: profile 0's base of 0x600 plus the offsets the Windows
87
+ * driver uses. The VT9 Pro and the VT3 PRO agree on all of them.
88
+ */
89
+ export declare const RAPOO_ADDRESS: {
90
+ /** [0] polling rate on 2.4 GHz, [2] the same on the cable. */
91
+ readonly performance: 2176;
92
+ /** [0] lift-off index, [1] motion sync. */
93
+ readonly sensor: 2180;
94
+ /** 7 little-endian u16 DPI values, [14] the stage count byte. */
95
+ readonly dpiX: 2184;
96
+ /** [0] the active stage index, 0 based. */
97
+ readonly activeStage: 2200;
98
+ /** [0] press debounce, [1] release debounce, [2] sleep minutes, [3] flags. */
99
+ readonly timing: 2240;
100
+ /** [0] sensor angle in degrees. */
101
+ readonly angle: 2244;
102
+ /** Same layout as {@link RAPOO_ADDRESS.dpiX}. */
103
+ readonly dpiY: 2248;
104
+ };
105
+ /**
106
+ * The block length the Windows driver reads for each address. A read has to
107
+ * ask for the same length the vendor tool does: the device answers with the
108
+ * block it has, not with what was asked for.
109
+ */
110
+ export declare const RAPOO_BLOCK_LENGTH: Readonly<Record<number, number>>;
111
+ /** Polling-rate byte to Hz, straight from the vendor driver's switch table. */
112
+ export declare const RAPOO_POLLING_RATES: Readonly<Record<number, number>>;
113
+ export declare function rapooPollingRateHz(code: number): number | null;
114
+ /** Debounce values the vendor driver's table indexes, in milliseconds. */
115
+ export declare const RAPOO_DEBOUNCE_MS: readonly number[];
116
+ /** How many DPI stages the table holds. */
117
+ export declare const RAPOO_DPI_STAGES = 7;
118
+ /**
119
+ * Bit 0 of {@link RAPOO_ADDRESS.timing}'s flag byte means "angle snap is off",
120
+ * bit 1 means "ripple control is off" - the vendor driver stores *disable*
121
+ * flags here, so a set bit is a feature the user turned off.
122
+ */
123
+ export declare const RAPOO_FLAG_ANGLE_SNAP_OFF = 1;
124
+ export declare const RAPOO_FLAG_RIPPLE_OFF = 2;
125
+ export interface RapooFrameOptions {
126
+ /** Defaults to {@link RAPOO_CONNECTION_RECEIVER}. */
127
+ connection?: number;
128
+ data?: readonly number[];
129
+ /** Overrides the length byte; the data still has to be passed separately. */
130
+ length?: number;
131
+ }
132
+ /**
133
+ * Build one command frame: the whole report data of 0xBA, 31 bytes.
134
+ *
135
+ * The frame is zero padded, so a write of fewer bytes than the block length
136
+ * still sends the whole block - which is what the vendor driver does, and what
137
+ * the device expects.
138
+ */
139
+ export declare function encodeRapooFrame(command: number, address: number, options?: RapooFrameOptions): Uint8Array;
140
+ export declare function encodeRapooRead(address: number, length: number, connection?: number): Uint8Array;
141
+ export declare function encodeRapooWrite(address: number, data: readonly number[], connection?: number): Uint8Array;
142
+ /**
143
+ * The battery query. Unlike a block read it carries address 0 and length 0, and
144
+ * its answer does not follow the busy -> OK handshake: the value is already in
145
+ * the device's input buffer, so callers have to look for the marker byte.
146
+ */
147
+ export declare function encodeRapooBatteryQuery(connection?: number): Uint8Array;
148
+ /**
149
+ * Index of the status byte in a raw GET_REPORT(Input) buffer.
150
+ *
151
+ * Windows strips the report id and Linux hidraw may keep it, so both layouts
152
+ * occur in the wild; mousectl accepts either and so does this. The status byte
153
+ * is 0x01 when answered and something else while busy, so a 0xBA in front of
154
+ * the buffer is unambiguous.
155
+ */
156
+ export declare function rapooAnswerOffset(bytes: Uint8Array): 0 | 1;
157
+ export interface RapooAnswer {
158
+ /** Byte 0: {@link RAPOO_STATUS_OK} when this frame was answered. */
159
+ status: number;
160
+ ok: boolean;
161
+ /**
162
+ * True while the device is still working on the frame before this one. It is
163
+ * the expected first state of an exchange, not an error.
164
+ */
165
+ busy: boolean;
166
+ /** Byte 1: 0 on a block answer, non-zero on a battery answer. */
167
+ marker: number;
168
+ /** Everything from byte 4 on, i.e. the block a read asked for. */
169
+ payload: Uint8Array;
170
+ /** The answer with any leading report id removed. */
171
+ data: Uint8Array;
172
+ }
173
+ /**
174
+ * Classify one raw answer. Returns null for a buffer too short to carry a
175
+ * status byte, so a transport can treat a non-answer as a non-answer rather
176
+ * than as a device that said 0x00.
177
+ */
178
+ export declare function decodeRapooAnswer(bytes: Uint8Array): RapooAnswer | null;
179
+ /** The block of `length` bytes an answered read carries, or null. */
180
+ export declare function rapooAnswerBlock(answer: RapooAnswer, length: number): Uint8Array | null;
181
+ export interface RapooPerformance {
182
+ /** Polling rate while the mouse talks to its receiver. */
183
+ receiverHz: number | null;
184
+ /** Polling rate while it is on the cable. */
185
+ wiredHz: number | null;
186
+ /** Bytes 1 and 3, whose meaning is not established. Preserved unread. */
187
+ reserved: readonly [number, number];
188
+ }
189
+ /** {@link RAPOO_ADDRESS.performance}: `82 00 82 ff` on a 4000 Hz VT9 Pro. */
190
+ export declare function decodeRapooPerformance(block: Uint8Array): RapooPerformance | null;
191
+ export interface RapooSensor {
192
+ /**
193
+ * Raw lift-off selector. The scale it indexes is not established for this
194
+ * mouse (the vendor bundle carries both a 1.0-2.0 mm and a 0.7-1.7 mm
195
+ * ladder), so it is exposed as the raw code rather than as millimetres.
196
+ */
197
+ liftOffIndex: number;
198
+ motionSync: boolean;
199
+ }
200
+ /** {@link RAPOO_ADDRESS.sensor}: `01 01 01 00` = index 1, motion sync on. */
201
+ export declare function decodeRapooSensor(block: Uint8Array): RapooSensor | null;
202
+ export interface RapooDpiTable {
203
+ /** Every stored stage, in device order, as the mouse stores it. */
204
+ stages: number[];
205
+ /**
206
+ * How many stages are switched on. The mouse stores that count byte as one
207
+ * less than the number of active stages: a byte of 2 means three stages.
208
+ */
209
+ enabledStages: number;
210
+ /** The stored byte, for callers that would rather not work from the count. */
211
+ countByte: number;
212
+ }
213
+ /** {@link RAPOO_ADDRESS.dpiX} and {@link RAPOO_ADDRESS.dpiY}. */
214
+ export declare function decodeRapooDpiTable(block: Uint8Array): RapooDpiTable | null;
215
+ /** {@link RAPOO_ADDRESS.activeStage}: `01 00 02 01` = the second stage. */
216
+ export declare function decodeRapooActiveStage(block: Uint8Array): number | null;
217
+ export interface RapooTiming {
218
+ /** Debounce in milliseconds, or null when the stored index is unknown. */
219
+ pressDebounceMs: number | null;
220
+ releaseDebounceMs: number | null;
221
+ sleepMinutes: number;
222
+ angleSnapOff: boolean;
223
+ rippleOff: boolean;
224
+ /** The raw flag byte, so a caller can preserve what it does not understand. */
225
+ flags: number;
226
+ }
227
+ /** {@link RAPOO_ADDRESS.timing}: `04 04 78 03` = 16/16 ms, 120 min. */
228
+ export declare function decodeRapooTiming(block: Uint8Array): RapooTiming | null;
229
+ /** {@link RAPOO_ADDRESS.angle}: `00 00 01 00` = 0 degrees. */
230
+ export declare function decodeRapooAngle(block: Uint8Array): number | null;
231
+ export interface RapooBattery {
232
+ percent: number;
233
+ charging: boolean;
234
+ }
235
+ /**
236
+ * The `0xAA` answer, which is the only place the charge state is readable.
237
+ *
238
+ * Returns null when the byte is 0 (that is a block answer, not a battery one)
239
+ * or when the marker is a value neither the vendor driver's table nor this
240
+ * capture explains.
241
+ */
242
+ export declare function decodeRapooBatteryAnswer(answer: RapooAnswer): RapooBattery | null;
243
+ export interface RapooNotification {
244
+ /** The link byte, `0x01` on the receiver in every capture so far. */
245
+ linkCode: number;
246
+ batteryPercent: number | null;
247
+ }
248
+ /**
249
+ * Input report 0xBB, which the mouse sends unprompted roughly every three
250
+ * seconds: `b0 51 20 03 01 62` at 98% on the receiver.
251
+ *
252
+ * The header is checked rather than assumed, so an unrelated report that
253
+ * happens to carry id 0xBB is rejected. Bytes 2 and 3 have been 0x20 and 0x03
254
+ * in every observation but are not understood.
255
+ */
256
+ export declare function decodeRapooNotification(bytes: Uint8Array): RapooNotification | null;
257
+ /**
258
+ * The link byte of {@link decodeRapooNotification}.
259
+ *
260
+ * `0x01` was measured on the receiver. `0x02` as the cable is a hypothesis -
261
+ * it was never seen, because every capture had the receiver attached - so a
262
+ * caller that needs the connection for certain should fall back to the product
263
+ * id instead.
264
+ */
265
+ export declare function rapooLinkConnection(linkCode: number): "Wireless" | "Wired" | null;
266
+ /**
267
+ * Battery percentage out of the `0x2A` feature block on 0xFF0B:0x0104, which
268
+ * is the one Rapoo read a browser can perform.
269
+ *
270
+ * Observed with the two links differing at byte 5 of the report data:
271
+ * `2a 01 00 00 04 21 50 00 00 62` on the cable and `... 11 20 ...` on the
272
+ * receiver. Windows' GET_REPORT keeps the report id in front of the data and
273
+ * WebHID's `receiveFeatureReport` may not, so the reading is taken relative to
274
+ * the report data rather than at a fixed offset. Only the percentage is
275
+ * understood; the rest of the block is not.
276
+ */
277
+ export declare function rapooStatusBatteryPercent(bytes: Uint8Array): number | null;
278
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rapoo/index.ts"],"names":[],"mappings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W,WAAW;IAC1B,0EAA0E;IAC1E,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,OAAO,CAAC;IACtB,SAAS,EAAE,OAAO,CAAC;IACnB,+EAA+E;IAC/E,KAAK,EAAE,MAAM,CAAC;CACf;AAED,uEAAuE;AACvE,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,UAAU,GAAG,WAAW,GAAG,IAAI,CAYvE;AAED,8DAA8D;AAC9D,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,CAGjE;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,WAAW,GAAG,YAAY,GAAG,IAAI,CAQjF;AAED,MAAM,WAAW,iBAAiB;IAChC,qEAAqE;IACrE,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,UAAU,GAAG,iBAAiB,GAAG,IAAI,CASnF;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,GAAG,IAAI,CAIjF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,CAK1E"}
@@ -0,0 +1,363 @@
1
+ /**
2
+ * Rapoo's vendor configuration channel (VT9 Pro and its family).
3
+ *
4
+ * Two independent sources pin the layout down, and they agree byte for byte:
5
+ *
6
+ * - a capture from a real VT9 Pro on 2026-09-29 (receiver 0x24AE:0x1205,
7
+ * cable 0x24AE:0x4405) reading every register below twice, on both links;
8
+ * - mousectl's `rapoo_vt3pro` driver, reverse engineered from Rapoo's own
9
+ * `RapooGameDevDriver` 1.6.29, which documents the same frame and the same
10
+ * addresses for the VT3 PRO.
11
+ *
12
+ * The request is 31 bytes of output report 0xBA on the 0xFF00:0x000E
13
+ * interface: one connection byte, then 30 payload bytes.
14
+ *
15
+ * [0] connection byte [1] command
16
+ * [2] payload length [3..6] address, u32 little endian
17
+ * [7..] data
18
+ *
19
+ * Those 31 bytes are the *report data*: the report id goes to the transport
20
+ * separately, the way WebHID's `sendReport` and OpenMouse Bridge take it.
21
+ * Windows reports the same report as 32 bytes because `HidP_GetCaps` counts
22
+ * the id, and hidraw wants it prepended - both of those are this 31 plus one
23
+ * byte. Sending 32 bytes of data instead is refused before it reaches the
24
+ * mouse (measured in the browser: `Failed to write the report`).
25
+ *
26
+ * The answer travels back through GET_REPORT(Input) rather than as an
27
+ * interrupt-IN report, which is why WebHID cannot see it: the browser has no
28
+ * equivalent call. Transports that can issue it (Windows `HidD_GetInputReport`,
29
+ * Linux `HIDIOCGINPUT`, OpenMouse Bridge's `receiveInputReport`) deliver the
30
+ * report id stripped, leaving the status byte first:
31
+ *
32
+ * [0] status, 0x01 when the frame was answered
33
+ * [1] 0 for every block answer, non-zero on a battery answer
34
+ * [2] battery percentage on a battery answer
35
+ * [4..] payload
36
+ *
37
+ * Two measured properties of the link shape every caller, so they belong here
38
+ * rather than in a driver:
39
+ *
40
+ * - **the channel is lossy.** About 40% of frames are dropped without the
41
+ * device ever going busy (busy is a status byte other than 0x01). An OK that
42
+ * was not preceded by a busy is the *previous* command's answer, so a read
43
+ * has to be retried, and "no answer" never means "no such register";
44
+ * - **the connection byte is not validated.** 0xFF and 0xA5 both answered, as
45
+ * did 0x00, 0x01 and 0x5A. A dropped frame must therefore never be read as
46
+ * "wrong connection type".
47
+ *
48
+ * Everything in this module is transport independent: it encodes frames,
49
+ * decodes answers, and turns register blocks into protocol values. Retries,
50
+ * sleeps and the read-modify-write of a live device belong to the driver.
51
+ */
52
+ export const RAPOO_VENDOR_ID = 0x24ae;
53
+ /** The 2.4 GHz receiver's configuration interface. */
54
+ export const RAPOO_WIRELESS_PRODUCT_ID = 0x1205;
55
+ /** The same mouse reached over its cable. */
56
+ export const RAPOO_WIRED_PRODUCT_ID = 0x4405;
57
+ export const RAPOO_PRODUCT_IDS = new Set([
58
+ RAPOO_WIRELESS_PRODUCT_ID,
59
+ RAPOO_WIRED_PRODUCT_ID,
60
+ ]);
61
+ export const RAPOO_CONFIG_USAGE_PAGE = 0xff00;
62
+ export const RAPOO_CONFIG_USAGE = 0x000e;
63
+ /** Report data length of the command channel, in both directions. */
64
+ export const RAPOO_CONFIG_REPORT_ID = 0xba;
65
+ /** The unsolicited status report; see {@link decodeRapooNotification}. */
66
+ export const RAPOO_NOTIFY_REPORT_ID = 0xbb;
67
+ /**
68
+ * A separate interface (0xFF0B:0x0104) that answers a GET_REPORT(Feature) with
69
+ * a status block. It is the only Rapoo read WebHID can perform, because
70
+ * `receiveFeatureReport` exists in the browser and `GET_REPORT(Input)` does
71
+ * not.
72
+ */
73
+ export const RAPOO_STATUS_USAGE_PAGE = 0xff0b;
74
+ export const RAPOO_STATUS_USAGE = 0x0104;
75
+ export const RAPOO_STATUS_REPORT_ID = 0x2a;
76
+ export const RAPOO_FRAME_LENGTH = 31;
77
+ export const RAPOO_CMD_READ = 0xa4;
78
+ export const RAPOO_CMD_WRITE = 0xa5;
79
+ export const RAPOO_CMD_BATTERY = 0xaa;
80
+ /** The status byte of an answered frame. Anything else means "not ready". */
81
+ export const RAPOO_STATUS_OK = 0x01;
82
+ /**
83
+ * What mousectl's driver sends, and the values that were measured answering.
84
+ * Nothing validates this byte on the VT9 Pro - see the module comment.
85
+ */
86
+ export const RAPOO_CONNECTION_WIRED = 0xff;
87
+ export const RAPOO_CONNECTION_RECEIVER = 0xa5;
88
+ /**
89
+ * EEPROM addresses: profile 0's base of 0x600 plus the offsets the Windows
90
+ * driver uses. The VT9 Pro and the VT3 PRO agree on all of them.
91
+ */
92
+ export const RAPOO_ADDRESS = {
93
+ /** [0] polling rate on 2.4 GHz, [2] the same on the cable. */
94
+ performance: 0x880,
95
+ /** [0] lift-off index, [1] motion sync. */
96
+ sensor: 0x884,
97
+ /** 7 little-endian u16 DPI values, [14] the stage count byte. */
98
+ dpiX: 0x888,
99
+ /** [0] the active stage index, 0 based. */
100
+ activeStage: 0x898,
101
+ /** [0] press debounce, [1] release debounce, [2] sleep minutes, [3] flags. */
102
+ timing: 0x8c0,
103
+ /** [0] sensor angle in degrees. */
104
+ angle: 0x8c4,
105
+ /** Same layout as {@link RAPOO_ADDRESS.dpiX}. */
106
+ dpiY: 0x8c8,
107
+ };
108
+ /**
109
+ * The block length the Windows driver reads for each address. A read has to
110
+ * ask for the same length the vendor tool does: the device answers with the
111
+ * block it has, not with what was asked for.
112
+ */
113
+ export const RAPOO_BLOCK_LENGTH = {
114
+ [RAPOO_ADDRESS.performance]: 4,
115
+ [RAPOO_ADDRESS.sensor]: 4,
116
+ [RAPOO_ADDRESS.dpiX]: 16,
117
+ [RAPOO_ADDRESS.activeStage]: 4,
118
+ [RAPOO_ADDRESS.timing]: 4,
119
+ [RAPOO_ADDRESS.angle]: 4,
120
+ [RAPOO_ADDRESS.dpiY]: 16,
121
+ };
122
+ /** Polling-rate byte to Hz, straight from the vendor driver's switch table. */
123
+ export const RAPOO_POLLING_RATES = {
124
+ 0x08: 125,
125
+ 0x04: 250,
126
+ 0x02: 500,
127
+ 0x01: 1000,
128
+ 0x84: 2000,
129
+ 0x82: 4000,
130
+ // Decoded so an 8K model reads correctly, but deliberately not offered as an
131
+ // option anywhere: the VT3 PRO profile has support8k = false and the VT9 Pro
132
+ // has never been seen on 8000 Hz.
133
+ 0x81: 8000,
134
+ };
135
+ export function rapooPollingRateHz(code) {
136
+ return RAPOO_POLLING_RATES[code] ?? null;
137
+ }
138
+ /** Debounce values the vendor driver's table indexes, in milliseconds. */
139
+ export const RAPOO_DEBOUNCE_MS = [1, 2, 4, 8, 16, 24, 32];
140
+ /** How many DPI stages the table holds. */
141
+ export const RAPOO_DPI_STAGES = 7;
142
+ /**
143
+ * Bit 0 of {@link RAPOO_ADDRESS.timing}'s flag byte means "angle snap is off",
144
+ * bit 1 means "ripple control is off" - the vendor driver stores *disable*
145
+ * flags here, so a set bit is a feature the user turned off.
146
+ */
147
+ export const RAPOO_FLAG_ANGLE_SNAP_OFF = 0x01;
148
+ export const RAPOO_FLAG_RIPPLE_OFF = 0x02;
149
+ /**
150
+ * Build one command frame: the whole report data of 0xBA, 31 bytes.
151
+ *
152
+ * The frame is zero padded, so a write of fewer bytes than the block length
153
+ * still sends the whole block - which is what the vendor driver does, and what
154
+ * the device expects.
155
+ */
156
+ export function encodeRapooFrame(command, address, options = {}) {
157
+ if (!Number.isInteger(address) || address < 0 || address > 0xffffffff) {
158
+ throw new RangeError(`Rapoo address out of range: ${address}`);
159
+ }
160
+ if (!Number.isInteger(command) || command < 0 || command > 0xff) {
161
+ throw new RangeError(`Rapoo command out of range: ${command}`);
162
+ }
163
+ const data = options.data ?? [];
164
+ const capacity = RAPOO_FRAME_LENGTH - 7;
165
+ if (data.length > capacity) {
166
+ throw new RangeError(`Rapoo frame holds ${capacity} data bytes, got ${data.length}`);
167
+ }
168
+ const frame = new Uint8Array(RAPOO_FRAME_LENGTH);
169
+ frame[0] = options.connection ?? RAPOO_CONNECTION_RECEIVER;
170
+ frame[1] = command;
171
+ frame[2] = options.length ?? data.length;
172
+ frame[3] = address & 0xff;
173
+ frame[4] = (address >>> 8) & 0xff;
174
+ frame[5] = (address >>> 16) & 0xff;
175
+ frame[6] = (address >>> 24) & 0xff;
176
+ for (let index = 0; index < data.length; index += 1)
177
+ frame[7 + index] = data[index];
178
+ return frame;
179
+ }
180
+ export function encodeRapooRead(address, length, connection = RAPOO_CONNECTION_RECEIVER) {
181
+ return encodeRapooFrame(RAPOO_CMD_READ, address, { connection, length });
182
+ }
183
+ export function encodeRapooWrite(address, data, connection = RAPOO_CONNECTION_RECEIVER) {
184
+ return encodeRapooFrame(RAPOO_CMD_WRITE, address, { connection, data });
185
+ }
186
+ /**
187
+ * The battery query. Unlike a block read it carries address 0 and length 0, and
188
+ * its answer does not follow the busy -> OK handshake: the value is already in
189
+ * the device's input buffer, so callers have to look for the marker byte.
190
+ */
191
+ export function encodeRapooBatteryQuery(connection = RAPOO_CONNECTION_RECEIVER) {
192
+ return encodeRapooFrame(RAPOO_CMD_BATTERY, 0, { connection, length: 0 });
193
+ }
194
+ /**
195
+ * Index of the status byte in a raw GET_REPORT(Input) buffer.
196
+ *
197
+ * Windows strips the report id and Linux hidraw may keep it, so both layouts
198
+ * occur in the wild; mousectl accepts either and so does this. The status byte
199
+ * is 0x01 when answered and something else while busy, so a 0xBA in front of
200
+ * the buffer is unambiguous.
201
+ */
202
+ export function rapooAnswerOffset(bytes) {
203
+ return bytes[0] === RAPOO_CONFIG_REPORT_ID ? 1 : 0;
204
+ }
205
+ /**
206
+ * Classify one raw answer. Returns null for a buffer too short to carry a
207
+ * status byte, so a transport can treat a non-answer as a non-answer rather
208
+ * than as a device that said 0x00.
209
+ */
210
+ export function decodeRapooAnswer(bytes) {
211
+ const offset = rapooAnswerOffset(bytes);
212
+ const data = bytes.subarray(offset);
213
+ if (data.length < 4)
214
+ return null;
215
+ const status = data[0];
216
+ return {
217
+ status,
218
+ ok: status === RAPOO_STATUS_OK,
219
+ busy: status !== RAPOO_STATUS_OK,
220
+ marker: data[1],
221
+ payload: data.subarray(4),
222
+ data,
223
+ };
224
+ }
225
+ /** The block of `length` bytes an answered read carries, or null. */
226
+ export function rapooAnswerBlock(answer, length) {
227
+ if (!answer.ok || answer.payload.length < length)
228
+ return null;
229
+ return answer.payload.subarray(0, length);
230
+ }
231
+ function readUint16(bytes, offset) {
232
+ return bytes[offset] | (bytes[offset + 1] << 8);
233
+ }
234
+ /** {@link RAPOO_ADDRESS.performance}: `82 00 82 ff` on a 4000 Hz VT9 Pro. */
235
+ export function decodeRapooPerformance(block) {
236
+ if (block.length < 4)
237
+ return null;
238
+ return {
239
+ receiverHz: rapooPollingRateHz(block[0]),
240
+ wiredHz: rapooPollingRateHz(block[2]),
241
+ reserved: [block[1], block[3]],
242
+ };
243
+ }
244
+ /** {@link RAPOO_ADDRESS.sensor}: `01 01 01 00` = index 1, motion sync on. */
245
+ export function decodeRapooSensor(block) {
246
+ if (block.length < 2)
247
+ return null;
248
+ return { liftOffIndex: block[0], motionSync: block[1] === 1 };
249
+ }
250
+ /** {@link RAPOO_ADDRESS.dpiX} and {@link RAPOO_ADDRESS.dpiY}. */
251
+ export function decodeRapooDpiTable(block) {
252
+ const countOffset = RAPOO_DPI_STAGES * 2;
253
+ if (block.length < countOffset + 1)
254
+ return null;
255
+ const stages = [];
256
+ for (let index = 0; index < RAPOO_DPI_STAGES; index += 1) {
257
+ stages.push(readUint16(block, index * 2));
258
+ }
259
+ const countByte = block[countOffset];
260
+ return {
261
+ stages,
262
+ enabledStages: Math.min(countByte + 1, RAPOO_DPI_STAGES),
263
+ countByte,
264
+ };
265
+ }
266
+ /** {@link RAPOO_ADDRESS.activeStage}: `01 00 02 01` = the second stage. */
267
+ export function decodeRapooActiveStage(block) {
268
+ if (block.length < 1)
269
+ return null;
270
+ const index = block[0];
271
+ return index < RAPOO_DPI_STAGES ? index : null;
272
+ }
273
+ /** {@link RAPOO_ADDRESS.timing}: `04 04 78 03` = 16/16 ms, 120 min. */
274
+ export function decodeRapooTiming(block) {
275
+ if (block.length < 4)
276
+ return null;
277
+ const flags = block[3];
278
+ return {
279
+ pressDebounceMs: RAPOO_DEBOUNCE_MS[block[0]] ?? null,
280
+ releaseDebounceMs: RAPOO_DEBOUNCE_MS[block[1]] ?? null,
281
+ sleepMinutes: block[2],
282
+ angleSnapOff: (flags & RAPOO_FLAG_ANGLE_SNAP_OFF) !== 0,
283
+ rippleOff: (flags & RAPOO_FLAG_RIPPLE_OFF) !== 0,
284
+ flags,
285
+ };
286
+ }
287
+ /** {@link RAPOO_ADDRESS.angle}: `00 00 01 00` = 0 degrees. */
288
+ export function decodeRapooAngle(block) {
289
+ if (block.length < 1)
290
+ return null;
291
+ return block[0];
292
+ }
293
+ /**
294
+ * The `0xAA` answer, which is the only place the charge state is readable.
295
+ *
296
+ * Returns null when the byte is 0 (that is a block answer, not a battery one)
297
+ * or when the marker is a value neither the vendor driver's table nor this
298
+ * capture explains.
299
+ */
300
+ export function decodeRapooBatteryAnswer(answer) {
301
+ if (answer.data.length < 3)
302
+ return null;
303
+ const marker = answer.data[1];
304
+ if (marker !== 1 && marker !== 2)
305
+ return null;
306
+ const percent = answer.data[2];
307
+ if (percent > 100)
308
+ return null;
309
+ return { percent, charging: marker === 2 };
310
+ }
311
+ /**
312
+ * Input report 0xBB, which the mouse sends unprompted roughly every three
313
+ * seconds: `b0 51 20 03 01 62` at 98% on the receiver.
314
+ *
315
+ * The header is checked rather than assumed, so an unrelated report that
316
+ * happens to carry id 0xBB is rejected. Bytes 2 and 3 have been 0x20 and 0x03
317
+ * in every observation but are not understood.
318
+ */
319
+ export function decodeRapooNotification(bytes) {
320
+ if (bytes.length < 6)
321
+ return null;
322
+ if (bytes[0] !== 0xb0 || bytes[1] !== 0x51)
323
+ return null;
324
+ const percent = bytes[5];
325
+ return {
326
+ linkCode: bytes[4],
327
+ batteryPercent: percent <= 100 ? percent : null,
328
+ };
329
+ }
330
+ /**
331
+ * The link byte of {@link decodeRapooNotification}.
332
+ *
333
+ * `0x01` was measured on the receiver. `0x02` as the cable is a hypothesis -
334
+ * it was never seen, because every capture had the receiver attached - so a
335
+ * caller that needs the connection for certain should fall back to the product
336
+ * id instead.
337
+ */
338
+ export function rapooLinkConnection(linkCode) {
339
+ if (linkCode === 0x01)
340
+ return "Wireless";
341
+ if (linkCode === 0x02)
342
+ return "Wired";
343
+ return null;
344
+ }
345
+ /**
346
+ * Battery percentage out of the `0x2A` feature block on 0xFF0B:0x0104, which
347
+ * is the one Rapoo read a browser can perform.
348
+ *
349
+ * Observed with the two links differing at byte 5 of the report data:
350
+ * `2a 01 00 00 04 21 50 00 00 62` on the cable and `... 11 20 ...` on the
351
+ * receiver. Windows' GET_REPORT keeps the report id in front of the data and
352
+ * WebHID's `receiveFeatureReport` may not, so the reading is taken relative to
353
+ * the report data rather than at a fixed offset. Only the percentage is
354
+ * understood; the rest of the block is not.
355
+ */
356
+ export function rapooStatusBatteryPercent(bytes) {
357
+ const offset = bytes[0] === RAPOO_STATUS_REPORT_ID ? 1 : 0;
358
+ if (bytes.length < offset + 9)
359
+ return null;
360
+ const percent = bytes[offset + 8];
361
+ return percent <= 100 ? percent : null;
362
+ }
363
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/rapoo/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AAEH,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC;AAEtC,sDAAsD;AACtD,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC;AAEhD,6CAA6C;AAC7C,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC;AAE7C,MAAM,CAAC,MAAM,iBAAiB,GAAwB,IAAI,GAAG,CAAC;IAC5D,yBAAyB;IACzB,sBAAsB;CACvB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC;AAC9C,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAEzC,qEAAqE;AACrE,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,CAAC;AAE3C,0EAA0E;AAC1E,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC;AAC9C,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC;AACzC,MA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