@openmouse/protocol 0.56.0 → 0.57.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,97 @@
1
+ /**
2
+ * X13 Pro identity and raw status framing. Evidence: docs/redgear-x13-pro-testing.md.
3
+ * DPI/rate mappings come from intercepted original vendor calls (writes blocked).
4
+ * Hardware acceptance remains separate from encoding evidence.
5
+ */
6
+ export const REDGEAR_X13_VENDOR_ID = 0x1b80;
7
+ export const REDGEAR_X13_PRODUCT_ID = 0xb412;
8
+ export const REDGEAR_X13_USAGE_PAGE = 0xff00;
9
+ export const REDGEAR_X13_USAGE = 1;
10
+ export const REDGEAR_X13_STATUS_REPORT_ID = 3;
11
+ export const REDGEAR_X13_STATUS_BYTES = 40;
12
+ export const REDGEAR_X13_SUPPORT = {
13
+ name: "Redgear X13 Pro",
14
+ verified: false,
15
+ nativeStatusReadTested: true,
16
+ bridgeStatusReadTested: true,
17
+ dpiWriteReadBackTested: true,
18
+ pollingWriteReadBackTested: true,
19
+ staticColorChannelsTested: true,
20
+ standardButtonWriteReadBackTested: true,
21
+ settingsReady: true,
22
+ };
23
+ /** Accept a complete native Windows feature buffer, including its report ID. */
24
+ export function redgearDecodeRawStatus(report) {
25
+ if (report.length !== REDGEAR_X13_STATUS_BYTES) {
26
+ throw new RangeError(`X13 Pro status must be ${REDGEAR_X13_STATUS_BYTES} bytes including its report ID`);
27
+ }
28
+ if (report[0] !== REDGEAR_X13_STATUS_REPORT_ID) {
29
+ throw new Error("Unexpected X13 Pro status report ID");
30
+ }
31
+ // Ownership is separate from the input buffer; framing does not interpret fields.
32
+ return { payload: report.slice(1) };
33
+ }
34
+ /** WebHID/Bridge return feature data without the separately requested report ID. */
35
+ export function redgearDecodeStatusPayload(payload) {
36
+ if (payload.length !== REDGEAR_X13_STATUS_BYTES - 1) {
37
+ throw new RangeError("X13 Pro status payload must be 39 bytes without its report ID");
38
+ }
39
+ return { payload: payload.slice() };
40
+ }
41
+ export const REDGEAR_X13_DPI = [
42
+ 400, 800, 1200, 2400, 3200, 4000, 4800,
43
+ ];
44
+ export const REDGEAR_X13_RATES = [125, 250, 500, 1000];
45
+ export function redgearDecodeSettings(payload) {
46
+ redgearDecodeStatusPayload(payload);
47
+ const dpi = REDGEAR_X13_DPI[payload[0]];
48
+ const pollingRateHz = REDGEAR_X13_RATES[payload[1]];
49
+ if (dpi === undefined || pollingRateHz === undefined)
50
+ throw new RangeError("Unknown X13 Pro DPI/rate code");
51
+ return { dpi, pollingRateHz };
52
+ }
53
+ /** Mutate exactly one proven byte in a fresh status payload. Never use cached vendor defaults. */
54
+ export function redgearEncodeDpi(payload, dpi) {
55
+ redgearDecodeSettings(payload);
56
+ const index = REDGEAR_X13_DPI.indexOf(dpi);
57
+ if (index < 0)
58
+ throw new RangeError("Unsupported X13 Pro DPI");
59
+ const result = payload.slice();
60
+ result[0] = index;
61
+ return result;
62
+ }
63
+ export function redgearEncodePollingRate(payload, rate) {
64
+ redgearDecodeSettings(payload);
65
+ const index = REDGEAR_X13_RATES.indexOf(rate);
66
+ if (index < 0)
67
+ throw new RangeError("Unsupported X13 Pro polling rate");
68
+ const result = payload.slice();
69
+ result[1] = index;
70
+ return result;
71
+ }
72
+ /** Original vendor UI encoding. Kept distinct from the corrected physical channel order. */
73
+ export function redgearEncodeVendorStaticColor(payload, color) {
74
+ redgearDecodeSettings(payload);
75
+ if (!/^#[0-9a-f]{6}$/i.test(color))
76
+ throw new RangeError("Expected #rrggbb colour");
77
+ const result = payload.slice();
78
+ // High nibble: mode 0 (Lock Single-Color). Bit 0: automatic colour cycle off.
79
+ // Preserve the other low-nibble flags, DPI/rate, speed, bindings and stage colours.
80
+ result[2] = result[2] & 0x0e;
81
+ for (let channel = 0; channel < 3; channel++)
82
+ result[4 + channel] = parseInt(color.slice(1 + channel * 2, 3 + channel * 2), 16);
83
+ return result;
84
+ }
85
+ /** Tested hardware order is R,B,G; the vendor UI mistakenly sends R,G,B. */
86
+ export function redgearEncodeStaticColor(payload, color) {
87
+ if (!/^#[0-9a-f]{6}$/i.test(color))
88
+ throw new RangeError("Expected #rrggbb colour");
89
+ return redgearEncodeVendorStaticColor(payload, `#${color.slice(1, 3)}${color.slice(5, 7)}${color.slice(3, 5)}`);
90
+ }
91
+ export function redgearDecodeStaticColor(payload) {
92
+ redgearDecodeSettings(payload);
93
+ const color = `#${[payload[4], payload[6], payload[5]].map((byte) => byte.toString(16).padStart(2, "0")).join("")}`;
94
+ return { mode: (payload[2] & 0xf1) === 0 ? "Static" : null, color };
95
+ }
96
+ export { redgearDecodeButtons, redgearEncodeButton, X13_BUTTON_NAMES, X13_BUTTON_ACTIONS, } from "./buttons.js";
97
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/redgear/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC;AAC5C,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC;AAC7C,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC;AAC7C,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC;AACnC,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC;AAC9C,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAE3C,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,IAAI,EAAE,iBAAiB;IACvB,QAAQ,EAAE,KAAK;IACf,sBAAsB,EAAE,IAAI;IAC5B,sBAAsB,EAAE,IAAI;IAC5B,sBAAsB,EAAE,IAAI;IAC5B,0BAA0B,EAAE,IAAI;IAChC,yBAAyB,EAAE,IAAI;IAC/B,iCAAiC,EAAE,IAAI;IACvC,aAAa,EAAE,IAAI;CACX,CAAC;AAEX,gFAAgF;AAChF,MAAM,UAAU,sBAAsB,CAAC,MAAkB;IAGvD,IAAI,MA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BAAgB,EAChB,kBAAkB,GACnB,MAAM,cAAc,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmouse/protocol",
3
- "version": "0.56.0",
3
+ "version": "0.57.0",
4
4
  "description": "Gaming mouse protocol codecs and WebHID drivers used by OpenMouse.",
5
5
  "license": "AGPL-3.0-or-later",
6
6
  "type": "module",
@@ -18,6 +18,10 @@
18
18
  "CONTRIBUTING.md"
19
19
  ],
20
20
  "exports": {
21
+ "./redgear": {
22
+ "types": "./dist/redgear/index.d.ts",
23
+ "import": "./dist/redgear/index.js"
24
+ },
21
25
  ".": {
22
26
  "types": "./dist/index.d.ts",
23
27
  "import": "./dist/index.js"