@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.
- package/README.md +1 -0
- package/dist/drivers/keychron/launcher-mouse.d.ts +125 -0
- package/dist/drivers/keychron/launcher-mouse.d.ts.map +1 -0
- package/dist/drivers/keychron/launcher-mouse.js +342 -0
- package/dist/drivers/keychron/launcher-mouse.js.map +1 -0
- package/dist/drivers/keychron/mouse-1k-hid.d.ts +78 -0
- package/dist/drivers/keychron/mouse-1k-hid.d.ts.map +1 -0
- package/dist/drivers/keychron/mouse-1k-hid.js +403 -0
- package/dist/drivers/keychron/mouse-1k-hid.js.map +1 -0
- package/dist/drivers/keychron/mouse-4k-hid.d.ts +5 -1
- package/dist/drivers/keychron/mouse-4k-hid.d.ts.map +1 -1
- package/dist/drivers/keychron/mouse-4k-hid.js +8 -3
- package/dist/drivers/keychron/mouse-4k-hid.js.map +1 -1
- package/dist/drivers/keychron/mouse-8k-hid.d.ts +136 -0
- package/dist/drivers/keychron/mouse-8k-hid.d.ts.map +1 -0
- package/dist/drivers/keychron/mouse-8k-hid.js +754 -0
- package/dist/drivers/keychron/mouse-8k-hid.js.map +1 -0
- package/dist/drivers/keychron/mouse-8k-nordic-hid.d.ts +145 -0
- package/dist/drivers/keychron/mouse-8k-nordic-hid.d.ts.map +1 -0
- package/dist/drivers/keychron/mouse-8k-nordic-hid.js +639 -0
- package/dist/drivers/keychron/mouse-8k-nordic-hid.js.map +1 -0
- package/dist/drivers/ksnake/hid.d.ts +43 -10
- package/dist/drivers/ksnake/hid.d.ts.map +1 -1
- package/dist/drivers/ksnake/hid.js +223 -48
- package/dist/drivers/ksnake/hid.js.map +1 -1
- package/dist/drivers/mouse-types.d.ts +4 -2
- package/dist/drivers/mouse-types.d.ts.map +1 -1
- package/dist/drivers/rapoo/hid.d.ts +72 -0
- package/dist/drivers/rapoo/hid.d.ts.map +1 -0
- package/dist/drivers/rapoo/hid.js +389 -0
- package/dist/drivers/rapoo/hid.js.map +1 -0
- package/dist/drivers/redragon/hid.d.ts +56 -5
- package/dist/drivers/redragon/hid.d.ts.map +1 -1
- package/dist/drivers/redragon/hid.js +309 -1
- package/dist/drivers/redragon/hid.js.map +1 -1
- package/dist/drivers/registry.d.ts +5 -2
- package/dist/drivers/registry.d.ts.map +1 -1
- package/dist/drivers/registry.js +15 -2
- package/dist/drivers/registry.js.map +1 -1
- package/dist/drivers/vendors.d.ts +3 -1
- package/dist/drivers/vendors.d.ts.map +1 -1
- package/dist/drivers/vendors.js +17 -4
- package/dist/drivers/vendors.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/keychron/index.d.ts +63 -0
- package/dist/keychron/index.d.ts.map +1 -1
- package/dist/keychron/index.js +103 -0
- package/dist/keychron/index.js.map +1 -1
- package/dist/ksnake/index.d.ts +88 -15
- package/dist/ksnake/index.d.ts.map +1 -1
- package/dist/ksnake/index.js +323 -26
- package/dist/ksnake/index.js.map +1 -1
- package/dist/rapoo/index.d.ts +278 -0
- package/dist/rapoo/index.d.ts.map +1 -0
- package/dist/rapoo/index.js +363 -0
- package/dist/rapoo/index.js.map +1 -0
- package/dist/redragon/index.d.ts +122 -0
- package/dist/redragon/index.d.ts.map +1 -1
- package/dist/redragon/index.js +322 -0
- package/dist/redragon/index.js.map +1 -1
- package/package.json +5 -1
- package/dist/drivers/keychron/m6-hid.d.ts +0 -81
- package/dist/drivers/keychron/m6-hid.d.ts.map +0 -1
- package/dist/drivers/keychron/m6-hid.js +0 -486
- package/dist/drivers/keychron/m6-hid.js.map +0 -1
|
@@ -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,0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AAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,yBAAyB,CAAC,KAAiB;IACzD,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3D,IAAI,KAAK,CAAC,MAAM,GAAG,MAAM,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAC3C,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAClC,OAAO,OAAO,IAAI,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;AACzC,CAAC"}
|
package/dist/redragon/index.d.ts
CHANGED
|
@@ -90,4 +90,126 @@ export declare function redragonEncodeCommit(code: number): Uint8Array;
|
|
|
90
90
|
* 1000->0x01, 500->0x02, 250->0x04, 125->0x08).
|
|
91
91
|
*/
|
|
92
92
|
export declare function redragonEncodePollingRate(hz: number): Uint8Array;
|
|
93
|
+
export declare const REDRAGON_M612_PRODUCT_ID = 64609;
|
|
94
|
+
/** First payload byte of a settings read (report id excluded). */
|
|
95
|
+
export declare const REDRAGON_CMD_READ = 242;
|
|
96
|
+
/** First payload byte of every GET_FEATURE answer (report id excluded). */
|
|
97
|
+
export declare const REDRAGON_REPLY_TAG = 8;
|
|
98
|
+
/** Length of the answer header before the data bytes (report id excluded). */
|
|
99
|
+
export declare const REDRAGON_REPLY_HEADER = 7;
|
|
100
|
+
/** Most data bytes one read or write frame carries. */
|
|
101
|
+
export declare const REDRAGON_MAX_TRANSFER = 8;
|
|
102
|
+
/** Active onboard profile, 0-4. */
|
|
103
|
+
export declare const REDRAGON_M612_ACTIVE_PROFILE_ADDRESS = 44;
|
|
104
|
+
/** Polling block: `[1000 / Hz, 00, 02, 00, 02, 00]` (last four constant). */
|
|
105
|
+
export declare const REDRAGON_M612_POLL_ADDRESS = 50;
|
|
106
|
+
export declare const REDRAGON_M612_POLL_LENGTH = 6;
|
|
107
|
+
/**
|
|
108
|
+
* Per-profile block bases. `base + 0` is the active DPI stage (0-4, moved
|
|
109
|
+
* by the DPI button); stage slot `n` is the 5 bytes at `base + 2 + 6n`:
|
|
110
|
+
* `[enabled, x, xRange, y, yRange]`.
|
|
111
|
+
*/
|
|
112
|
+
export declare const REDRAGON_M612_PROFILE_BASES: readonly [66, 258, 434, 610, 786];
|
|
113
|
+
export declare const REDRAGON_M612_STAGE_COUNT = 5;
|
|
114
|
+
export declare const REDRAGON_M612_SLOT_LENGTH = 5;
|
|
115
|
+
/**
|
|
116
|
+
* DPI labels RDCfg shows for each position of its DPI slider, read from the
|
|
117
|
+
* running vendor app and cross-checked by matching its bitmap-font glyphs.
|
|
118
|
+
* Position `p` 0-92 writes `value = 14 + p, range 0`; 93-145 write
|
|
119
|
+
* `value = p - 39, range 1` (range 1 doubles the step). The rule was
|
|
120
|
+
* confirmed by Apply captures at positions 0-6, 93, 94, 120, 144, and 145,
|
|
121
|
+
* and by the factory push (13, 39, 65, 92). The labels are the vendor's
|
|
122
|
+
* rounded values, so they are the DPI OpenMouse shows for the same bytes.
|
|
123
|
+
*/
|
|
124
|
+
export declare const REDRAGON_M612_DPI_LABELS: readonly number[];
|
|
125
|
+
export interface RedragonDpiCode {
|
|
126
|
+
value: number;
|
|
127
|
+
range: 0 | 1;
|
|
128
|
+
}
|
|
129
|
+
/** Wire code for one RDCfg slider position. */
|
|
130
|
+
export declare function redragonM612DpiCodeAt(position: number): RedragonDpiCode;
|
|
131
|
+
/**
|
|
132
|
+
* Snaps a requested DPI to the nearest RDCfg slider label (ties go to the
|
|
133
|
+
* lower one) and returns that label with its wire code.
|
|
134
|
+
*/
|
|
135
|
+
export declare function redragonM612EncodeDpi(dpi: number): RedragonDpiCode & {
|
|
136
|
+
dpi: number;
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* DPI for a wire code. Codes RDCfg can write map to its label; anything else
|
|
140
|
+
* (another tool's write) falls back to the linear sensor scale the labels
|
|
141
|
+
* approximate, 4000 DPI per 106 counts, rounded to 10.
|
|
142
|
+
*/
|
|
143
|
+
export declare function redragonM612DecodeDpi(value: number, range: number): number;
|
|
144
|
+
/** `[02 F3 addrLo addrHi len 00 00 00 data...]` (full frame, report id included). */
|
|
145
|
+
export declare function redragonEncodeWrite(address: number, data: ArrayLike<number>): Uint8Array;
|
|
146
|
+
/** `[02 F2 addrLo addrHi len ...]` (full frame, report id included). */
|
|
147
|
+
export declare function redragonEncodeRead(address: number, length: number): Uint8Array;
|
|
148
|
+
/**
|
|
149
|
+
* Validates the GET_FEATURE answer to `redragonEncodeRead(address, length)`
|
|
150
|
+
* and returns its data bytes. Accepts the answer with or without the leading
|
|
151
|
+
* report id, since WebHID and hidraw differ there.
|
|
152
|
+
*/
|
|
153
|
+
export declare function redragonDecodeRead(answer: Uint8Array, address: number, length: number): Uint8Array;
|
|
154
|
+
/** Address of one M612 DPI stage slot. */
|
|
155
|
+
export declare function redragonM612SlotAddress(profile: number, stage: number): number;
|
|
156
|
+
export declare const REDRAGON_M612_PROFILE_COUNT = 5;
|
|
157
|
+
/**
|
|
158
|
+
* RDCfg's MODE select, byte-for-byte: write `[profile, 00]` at `0x2c`
|
|
159
|
+
* (outside any `F5` bracket), then `F1 02 01`, then the commit block.
|
|
160
|
+
*/
|
|
161
|
+
export declare const REDRAGON_M612_PROFILE_SELECT_CODE = 1;
|
|
162
|
+
/** Lighting effect selector: one bit per effect, `[bit, 00]`. Global, not per profile. */
|
|
163
|
+
export declare const REDRAGON_M612_LIGHTING_EFFECT_ADDRESS = 1094;
|
|
164
|
+
export type RedragonM612Effect = "wave" | "spectrumBreathing" | "breathing" | "flash" | "static" | "off";
|
|
165
|
+
export interface RedragonM612EffectInfo {
|
|
166
|
+
effect: RedragonM612Effect;
|
|
167
|
+
/** Value at `0x446`. */
|
|
168
|
+
bit: number;
|
|
169
|
+
/** 8-byte parameter block `[flag, R, G, B, kind, speed, ?, brightness]`, or null for off. */
|
|
170
|
+
block: number | null;
|
|
171
|
+
color: boolean;
|
|
172
|
+
speed: boolean;
|
|
173
|
+
}
|
|
174
|
+
/** RDCfg effects, from Apply captures of each one. */
|
|
175
|
+
export declare const REDRAGON_M612_EFFECTS: readonly RedragonM612EffectInfo[];
|
|
176
|
+
export declare const REDRAGON_M612_LIGHTING_BLOCK_LENGTH = 8;
|
|
177
|
+
/** Speed byte: 8 is RDCfg's slowest slider position, 1 its fastest. */
|
|
178
|
+
export declare const REDRAGON_M612_LIGHTING_SPEEDS = 8;
|
|
179
|
+
/** Brightness byte: RDCfg's slider has three positions, 1-3. */
|
|
180
|
+
export declare const REDRAGON_M612_LIGHTING_BRIGHTNESS_LEVELS = 3;
|
|
181
|
+
export declare function redragonM612EffectForBit(bit: number): RedragonM612EffectInfo | undefined;
|
|
182
|
+
/**
|
|
183
|
+
* Button slots per profile, in RDCfg's numbering: 1 left, 2 right,
|
|
184
|
+
* 3 middle, 4 rapid fire, 5-6 side, 7-8 DPI, 9 LED, then wheel up/down.
|
|
185
|
+
* Four bytes each; there is no slot at `base + 0x24`.
|
|
186
|
+
*/
|
|
187
|
+
export declare const REDRAGON_M612_BUTTON_BASES: readonly [130, 322, 498, 674, 850];
|
|
188
|
+
export declare const REDRAGON_M612_BUTTON_OFFSETS: readonly [0, 4, 8, 12, 16, 20, 24, 28, 32, 40, 44];
|
|
189
|
+
export declare const REDRAGON_M612_BUTTON_LENGTH = 4;
|
|
190
|
+
export declare function redragonM612ButtonAddress(profile: number, slot: number): number;
|
|
191
|
+
/**
|
|
192
|
+
* Single-byte actions captured from RDCfg (the value is padded to four bytes
|
|
193
|
+
* with zeros). "Rapid fire" is button 4's factory value; its speed and count
|
|
194
|
+
* bytes are kept exactly as shipped.
|
|
195
|
+
*/
|
|
196
|
+
export declare const REDRAGON_M612_BUTTON_ACTIONS: ReadonlyArray<readonly [string, readonly number[]]>;
|
|
197
|
+
/**
|
|
198
|
+
* Keyboard assignments are `[8F, modifiers, usage]` with the HID keyboard
|
|
199
|
+
* modifier bits (1 Ctrl, 2 Shift, 4 Alt, 8 Win) and usage IDs. Captured from
|
|
200
|
+
* RDCfg's shortcut menus: Ctrl+V `8f 01 19`, Ctrl+A `8f 01 04`, Ctrl+F
|
|
201
|
+
* `8f 01 09`, Ctrl+N `8f 01 11`, Alt+Tab `8f 04 2b`, Alt+F4 `8f 04 3d`,
|
|
202
|
+
* Win+E `8f 08 08`, Win+R `8f 08 15`, Win+D `8f 08 07`, Win+L `8f 08 0f`.
|
|
203
|
+
*/
|
|
204
|
+
export declare const REDRAGON_M612_KEY_ACTION = 143;
|
|
205
|
+
/** Every action name `redragonM612EncodeButtonAction` accepts, in display order. */
|
|
206
|
+
export declare const REDRAGON_M612_BUTTON_OPTIONS: readonly string[];
|
|
207
|
+
/** Four-byte slot value for an action name from `REDRAGON_M612_BUTTON_OPTIONS`. */
|
|
208
|
+
export declare function redragonM612EncodeButtonAction(action: string): number[];
|
|
209
|
+
/**
|
|
210
|
+
* Names a slot value: an offered action where the bytes match one exactly,
|
|
211
|
+
* any other keyboard combination by its keys, and anything else (macros,
|
|
212
|
+
* RDCfg's advanced actions) as its raw bytes.
|
|
213
|
+
*/
|
|
214
|
+
export declare function redragonM612DecodeButtonAction(value: ArrayLike<number>): string;
|
|
93
215
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/redragon/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;IACnB,yEAAyE;IACzE,QAAQ,EAAE,OAAO,CAAC;IAClB,sEAAsE;IACtE,MAAM,EAAE,MAAM,CAAC;IACf,+DAA+D;IAC/D,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,kBAAkB,OAAS,CAAC;AACzC,eAAO,MAAM,0B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