@openmouse/protocol 0.48.1 → 0.50.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 (96) hide show
  1. package/README.md +1 -0
  2. package/dist/drivers/atk/hid.d.ts.map +1 -1
  3. package/dist/drivers/atk/hid.js +2 -2
  4. package/dist/drivers/atk/hid.js.map +1 -1
  5. package/dist/drivers/atk/products.d.ts +7 -0
  6. package/dist/drivers/atk/products.d.ts.map +1 -1
  7. package/dist/drivers/atk/products.js +19 -2
  8. package/dist/drivers/atk/products.js.map +1 -1
  9. package/dist/drivers/glorious/sinowealth-hid.d.ts +71 -0
  10. package/dist/drivers/glorious/sinowealth-hid.d.ts.map +1 -0
  11. package/dist/drivers/glorious/sinowealth-hid.js +388 -0
  12. package/dist/drivers/glorious/sinowealth-hid.js.map +1 -0
  13. package/dist/drivers/gwolves/products.d.ts +5 -0
  14. package/dist/drivers/gwolves/products.d.ts.map +1 -1
  15. package/dist/drivers/gwolves/products.js +14 -10
  16. package/dist/drivers/gwolves/products.js.map +1 -1
  17. package/dist/drivers/gwolves/xvi-hid.d.ts +1 -0
  18. package/dist/drivers/gwolves/xvi-hid.d.ts.map +1 -1
  19. package/dist/drivers/gwolves/xvi-hid.js +14 -7
  20. package/dist/drivers/gwolves/xvi-hid.js.map +1 -1
  21. package/dist/drivers/hitscan/xvi-hid.d.ts +110 -0
  22. package/dist/drivers/hitscan/xvi-hid.d.ts.map +1 -0
  23. package/dist/drivers/hitscan/xvi-hid.js +803 -0
  24. package/dist/drivers/hitscan/xvi-hid.js.map +1 -0
  25. package/dist/drivers/motospeed/hid.js +1 -1
  26. package/dist/drivers/motospeed/hid.js.map +1 -1
  27. package/dist/drivers/mouse-types.d.ts +16 -0
  28. package/dist/drivers/mouse-types.d.ts.map +1 -1
  29. package/dist/drivers/razer/hid.d.ts +0 -1
  30. package/dist/drivers/razer/hid.d.ts.map +1 -1
  31. package/dist/drivers/razer/hid.js +14 -9
  32. package/dist/drivers/razer/hid.js.map +1 -1
  33. package/dist/drivers/redragon/hid.d.ts +44 -63
  34. package/dist/drivers/redragon/hid.d.ts.map +1 -1
  35. package/dist/drivers/redragon/hid.js +207 -270
  36. package/dist/drivers/redragon/hid.js.map +1 -1
  37. package/dist/drivers/registry.d.ts +2 -1
  38. package/dist/drivers/registry.d.ts.map +1 -1
  39. package/dist/drivers/registry.js +10 -1
  40. package/dist/drivers/registry.js.map +1 -1
  41. package/dist/drivers/vendors.d.ts +8 -1
  42. package/dist/drivers/vendors.d.ts.map +1 -1
  43. package/dist/drivers/vendors.js +18 -4
  44. package/dist/drivers/vendors.js.map +1 -1
  45. package/dist/gearhub/index.d.ts +8 -0
  46. package/dist/gearhub/index.d.ts.map +1 -1
  47. package/dist/gearhub/index.js +18 -0
  48. package/dist/gearhub/index.js.map +1 -1
  49. package/dist/glorious-sinowealth/index.d.ts +165 -0
  50. package/dist/glorious-sinowealth/index.d.ts.map +1 -0
  51. package/dist/glorious-sinowealth/index.js +345 -0
  52. package/dist/glorious-sinowealth/index.js.map +1 -0
  53. package/dist/hitscan/index.d.ts +2 -0
  54. package/dist/hitscan/index.d.ts.map +1 -1
  55. package/dist/hitscan/index.js +2 -0
  56. package/dist/hitscan/index.js.map +1 -1
  57. package/dist/hitscan/xvi-inputs.d.ts +81 -0
  58. package/dist/hitscan/xvi-inputs.d.ts.map +1 -0
  59. package/dist/hitscan/xvi-inputs.js +393 -0
  60. package/dist/hitscan/xvi-inputs.js.map +1 -0
  61. package/dist/hitscan/xvi.d.ts +278 -0
  62. package/dist/hitscan/xvi.d.ts.map +1 -0
  63. package/dist/hitscan/xvi.js +773 -0
  64. package/dist/hitscan/xvi.js.map +1 -0
  65. package/dist/index.d.ts +1 -0
  66. package/dist/index.d.ts.map +1 -1
  67. package/dist/index.js +1 -0
  68. package/dist/index.js.map +1 -1
  69. package/dist/keychron/index.d.ts.map +1 -1
  70. package/dist/keychron/index.js +4 -0
  71. package/dist/keychron/index.js.map +1 -1
  72. package/dist/razer/codec.d.ts +3 -2
  73. package/dist/razer/codec.d.ts.map +1 -1
  74. package/dist/razer/codec.js +5 -4
  75. package/dist/razer/codec.js.map +1 -1
  76. package/dist/redragon/deprecated.d.ts +24 -0
  77. package/dist/redragon/deprecated.d.ts.map +1 -0
  78. package/dist/redragon/deprecated.js +54 -0
  79. package/dist/redragon/deprecated.js.map +1 -0
  80. package/dist/redragon/holtek.d.ts +127 -0
  81. package/dist/redragon/holtek.d.ts.map +1 -0
  82. package/dist/redragon/holtek.js +232 -0
  83. package/dist/redragon/holtek.js.map +1 -0
  84. package/dist/redragon/index.d.ts +9 -203
  85. package/dist/redragon/index.d.ts.map +1 -1
  86. package/dist/redragon/index.js +11 -430
  87. package/dist/redragon/index.js.map +1 -1
  88. package/dist/redragon/m612.d.ts +82 -0
  89. package/dist/redragon/m612.d.ts.map +1 -0
  90. package/dist/redragon/m612.js +166 -0
  91. package/dist/redragon/m612.js.map +1 -0
  92. package/dist/redragon/m724.d.ts +47 -0
  93. package/dist/redragon/m724.d.ts.map +1 -0
  94. package/dist/redragon/m724.js +107 -0
  95. package/dist/redragon/m724.js.map +1 -0
  96. package/package.json +5 -1
@@ -0,0 +1,54 @@
1
+ /*
2
+ * The first M724 driver's frame builders, kept so existing imports keep
3
+ * working. They read `[F3 sub profile section]` where the bytes are really
4
+ * `[F3 addrLo addrHi len]` (see `holtek.ts`); each still returns the frame
5
+ * it always did. New code uses `redragonEncodeWrite` and the model codecs.
6
+ */
7
+ import { REDRAGON_POLLING_CODES, REDRAGON_POLLING_RATES, redragonEncodeWrite, redragonSession } from "./holtek.js";
8
+ /** @deprecated The "section" byte is the write length; use `redragonEncodeWrite`. */
9
+ export const REDRAGON_DPI_SECTION = 0x05;
10
+ /** @deprecated The "section" byte is the write length; use `redragonEncodeWrite`. */
11
+ export const REDRAGON_POLL_SECTION = 0x06;
12
+ /** @deprecated The polling "subcommand" is address `0x32`; use `redragonPollAddress`. */
13
+ export const REDRAGON_POLL_SUB = 0x32;
14
+ /** @deprecated The "profile" byte is the address high byte; use `redragonSlotAddress`. */
15
+ export const REDRAGON_PROFILE0 = 0x00;
16
+ /** @deprecated Profile 1's stage slot addresses; use `redragonSlotAddress(0, stage)`. */
17
+ export const REDRAGON_PROFILE0_DPI_SUBCMDS = [0x44, 0x4a, 0x50, 0x56, 0x5c];
18
+ /** @deprecated Approximates RDCfg's table; use `redragonM724EncodeDpi`. */
19
+ export function redragonEncodeDpiValue(dpi) {
20
+ if (!Number.isInteger(dpi) || dpi < 50 || dpi > 12400) {
21
+ throw new Error(`Redragon DPI ${dpi} is outside the observed 50-12400 range.`);
22
+ }
23
+ const code = Math.round((dpi * 9) / 400);
24
+ return code <= 255 ? { value: code, range: 0 } : { value: Math.round(code / 2), range: 1 };
25
+ }
26
+ /** @deprecated Approximates RDCfg's table; use `redragonM724DecodeDpi`. */
27
+ export function redragonDecodeDpiValue(value, range) {
28
+ return Math.round(value * (range === 1 ? 2 : 1) * (400 / 9));
29
+ }
30
+ /** @deprecated Profile 1 only; use `redragonEncodeWrite(redragonSlotAddress(...), ...)`. */
31
+ export function redragonEncodeDpiSlot(profile, level, dpiX, dpiY = dpiX) {
32
+ if (profile !== REDRAGON_PROFILE0) {
33
+ throw new Error(`Redragon profile ${profile} subcommands are not decoded yet (only profile 1).`);
34
+ }
35
+ const address = REDRAGON_PROFILE0_DPI_SUBCMDS[level];
36
+ if (!Number.isInteger(level) || address === undefined)
37
+ throw new Error(`Redragon DPI level ${level} is out of range 0-4.`);
38
+ const x = redragonEncodeDpiValue(dpiX);
39
+ const y = redragonEncodeDpiValue(dpiY);
40
+ return redragonEncodeWrite(address, [0x01, x.value, x.range, y.value, y.range]);
41
+ }
42
+ /** @deprecated Also sets profiles 2-3 to 1000 Hz; use `redragonPollAddress`. */
43
+ export function redragonEncodePollingRate(hz) {
44
+ const code = REDRAGON_POLLING_CODES[hz];
45
+ if (code === undefined) {
46
+ throw new Error(`Redragon polling rate ${hz} Hz was never observed; supported: ${REDRAGON_POLLING_RATES.join(", ")}.`);
47
+ }
48
+ return redragonEncodeWrite(REDRAGON_POLL_SUB, [code, 0x00, 0x01, 0x00, 0x01, 0x00]);
49
+ }
50
+ /** @deprecated Use `redragonSession(true)`. */
51
+ export function redragonHello() {
52
+ return redragonSession(true);
53
+ }
54
+ //# sourceMappingURL=deprecated.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deprecated.js","sourceRoot":"","sources":["../../src/redragon/deprecated.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnH,qFAAqF;AACrF,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAC;AACzC,qFAAqF;AACrF,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAC1C,yFAAyF;AACzF,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC;AACtC,0FAA0F;AAC1F,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC;AACtC,yFAAyF;AACzF,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAU,CAAC;AAErF,2EAA2E;AAC3E,MAAM,UAAU,sBAAsB,CAAC,GAAW;IAChD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,EAAE,IAAI,GAAG,GAAG,KAAK,EAAE,CAAC;QACtD,MAAM,IAAI,KAAK,CAAC,gBAAgB,GAAG,0CAA0C,CAAC,CAAC;IACjF,CAAC;IACD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;IACzC,OAAO,IAAI,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAA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C,CAAC;IACxC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,yBAAyB,EAAE,sCAAsC,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzH,CAAC;IACD,OAAO,mBAAmB,CAAC,iBAAiB,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AACtF,CAAC;AAED,+CAA+C;AAC/C,MAAM,UAAU,aAAa;IAC3B,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,127 @@
1
+ export declare const REDRAGON_VENDOR_ID = 1241;
2
+ export declare const REDRAGON_CONFIG_USAGE_PAGE = 65440;
3
+ export declare const REDRAGON_CONFIG_USAGE = 1;
4
+ export declare const REDRAGON_REPORT_ID = 2;
5
+ export declare const REDRAGON_REPORT_SIZE = 16;
6
+ /** First payload byte of a config write (report id excluded). */
7
+ export declare const REDRAGON_CMD_WRITE = 243;
8
+ /** First payload byte of a settings read (report id excluded). */
9
+ export declare const REDRAGON_CMD_READ = 242;
10
+ /** First payload byte of the session bracket (report id excluded). */
11
+ export declare const REDRAGON_CMD_HELLO = 245;
12
+ /** First payload byte of a commit write (report id excluded). */
13
+ export declare const REDRAGON_CMD_COMMIT = 241;
14
+ /** First payload byte of every GET_FEATURE answer (report id excluded). */
15
+ export declare const REDRAGON_REPLY_TAG = 8;
16
+ /** Length of the answer header before the data bytes (report id excluded). */
17
+ export declare const REDRAGON_REPLY_HEADER = 7;
18
+ /** Most data bytes one read or write frame carries. */
19
+ export declare const REDRAGON_MAX_TRANSFER = 8;
20
+ /** Write section of the commit block. */
21
+ export declare const REDRAGON_COMMIT_SECTION = 2;
22
+ /**
23
+ * Commit codes RDCfg sends after a button write (`SendButtonRefesh`), in
24
+ * order. Each reloads one area (01 profile, 02 DPI, 04 lighting, 08 polling
25
+ * and lift-off); a write without its commit is stored but only takes effect
26
+ * at boot. The whole block is sent after every write.
27
+ */
28
+ export declare const REDRAGON_COMMIT_CODES: readonly [4, 1, 2, 8, 16];
29
+ export declare const REDRAGON_POLLING_RATES: readonly [125, 250, 500, 1000];
30
+ /** Polling code per rate: code = 1000 / Hz. */
31
+ export declare const REDRAGON_POLLING_CODES: Readonly<Record<number, number>>;
32
+ /** `[02 F3 addrLo addrHi len 00 00 00 data...]` (full frame, report id included). */
33
+ export declare function redragonEncodeWrite(address: number, data: ArrayLike<number>): Uint8Array;
34
+ /** `[02 F2 addrLo addrHi len ...]` (full frame, report id included). */
35
+ export declare function redragonEncodeRead(address: number, length: number): Uint8Array;
36
+ /**
37
+ * Validates the GET_FEATURE answer to `redragonEncodeRead(address, length)`
38
+ * and returns its data bytes. Accepts the answer with or without the leading
39
+ * report id, since WebHID and hidraw differ there.
40
+ */
41
+ export declare function redragonDecodeRead(answer: Uint8Array, address: number, length: number): Uint8Array;
42
+ /** Session bracket frame: `[02 F5 00]` opens, `[02 F5 01]` closes. */
43
+ export declare function redragonSession(begin: boolean): Uint8Array;
44
+ /** One commit write `[02 F1 02 code]` (full frame, report id included). */
45
+ export declare function redragonEncodeCommit(code: number): Uint8Array;
46
+ export declare const REDRAGON_PROFILE_COUNT = 5;
47
+ /** Active onboard profile `[profile, 00]`, 0-4. */
48
+ export declare const REDRAGON_ACTIVE_PROFILE_ADDRESS = 44;
49
+ /** Extra commit RDCfg's MODE select sends before the commit block. */
50
+ export declare const REDRAGON_PROFILE_SELECT_CODE = 1;
51
+ /** Polling code of profile p at `0x32 + 2p`, `[1000 / Hz, 00]`. */
52
+ export declare const REDRAGON_POLL_ADDRESS = 50;
53
+ /**
54
+ * Per-profile block bases. `base + 0` is the active DPI stage (0-4); stage
55
+ * slot `n` is the 5 bytes at `base + 2 + 6n`: `[enabled, x, xRange, y, yRange]`.
56
+ */
57
+ export declare const REDRAGON_PROFILE_BASES: readonly [66, 258, 434, 610, 786];
58
+ export declare const REDRAGON_STAGE_COUNT = 5;
59
+ export declare const REDRAGON_SLOT_LENGTH = 5;
60
+ /** Button slot `s` of profile p is the 4 bytes at `button base + 4s`. */
61
+ export declare const REDRAGON_BUTTON_BASES: readonly [130, 322, 498, 674, 850];
62
+ export declare const REDRAGON_BUTTON_LENGTH = 4;
63
+ export declare function redragonPollAddress(profile: number): number;
64
+ /** Address of one DPI stage slot. */
65
+ export declare function redragonSlotAddress(profile: number, stage: number): number;
66
+ export interface RedragonDpiCode {
67
+ value: number;
68
+ range: 0 | 1;
69
+ }
70
+ /** Slider position whose label is nearest to `dpi` (ties go to the lower one). */
71
+ export declare function redragonNearestDpiPosition(labels: readonly number[], dpi: number, model: string): number;
72
+ /**
73
+ * Keyboard assignments are `[8F, modifiers, usage]` with the HID keyboard
74
+ * modifier bits (1 Ctrl, 2 Shift, 4 Alt, 8 Win) and usage IDs (RDCfg's
75
+ * COMBO KEY and shortcut menus).
76
+ */
77
+ export declare const REDRAGON_KEY_ACTION = 143;
78
+ /** RDCfg's SINGLE KEY writes `[90 00 usage 00]` instead (action table `DAT_0049f280`). */
79
+ export declare const REDRAGON_SINGLE_KEY_ACTION = 144;
80
+ export interface RedragonButtonCodec {
81
+ /** Every action name `encode` accepts, in display order. */
82
+ options: readonly string[];
83
+ /** Four-byte slot value for an action name from `options`. */
84
+ encode(action: string): number[];
85
+ /**
86
+ * Names a slot value: an offered action where the bytes match one exactly,
87
+ * any other keyboard combination by its keys, and anything else (macros,
88
+ * RDCfg's advanced actions) as its raw bytes.
89
+ */
90
+ decode(value: ArrayLike<number>): string;
91
+ }
92
+ /**
93
+ * Button codec over a model's single-action list plus the shared shortcuts
94
+ * and keys; `keyPrefix` is what a plain "Key X" writes before the usage.
95
+ */
96
+ export declare function redragonButtonCodec(model: string, actions: ReadonlyArray<readonly [string, readonly number[]]>, keyPrefix?: readonly number[]): RedragonButtonCodec;
97
+ /** What differs between the Holtek models; the memory layout above is shared. */
98
+ export interface RedragonModel {
99
+ /** Catalog model, e.g. "M724". */
100
+ model: string;
101
+ productId: number;
102
+ dpi: {
103
+ /** RDCfg slider labels, ascending. */
104
+ labels: readonly number[];
105
+ /** Step the DPI editor offers. */
106
+ step: number;
107
+ /** Snaps to the nearest label and returns it with its wire code. */
108
+ encode(dpi: number): RedragonDpiCode & {
109
+ dpi: number;
110
+ };
111
+ decode(value: number, range: number): number;
112
+ };
113
+ /** Button names and slot offsets from the profile's button base, in slot order. */
114
+ buttons: {
115
+ names: readonly string[];
116
+ offsets: readonly number[];
117
+ } & RedragonButtonCodec;
118
+ /**
119
+ * `effect`: one global effect selector plus a parameter block per effect
120
+ * (M612, RDCfg's `PRODUCT/Light=4` path). `profile`: one block per
121
+ * profile at `0x448 + 8p` (M724, `PRODUCT/Light=0`).
122
+ */
123
+ lighting: "effect" | "profile";
124
+ /** Lift-off `[level, 00]` (0 low, 1 medium, 2 high), where the mouse honours it. */
125
+ liftOffAddress?: number;
126
+ }
127
+ //# sourceMappingURL=holtek.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"holtek.d.ts","sourceRoot":"","sources":["../../src/redragon/holtek.ts"],"names":[],"mappings":"AAkBA,eAAO,MAAM,kBAAkB,OAAS,CAAC;AACzC,eAAO,MAAM,0BAA0B,QAAS,CAAC;AACjD,eAAO,MAAM,qBAAqB,IAAO,CAAC;AAC1C,eAAO,MAAM,kBAAkB,IAAI,CAAC;AACpC,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC,iEAAiE;AACjE,eAAO,MAAM,kBAAkB,MAAO,CAAC;AACvC,kEAAkE;AAClE,eAAO,MAAM,iBAAiB,MAAO,CAAC;AACtC,sEAAsE;AACtE,eAAO,MAAM,kBAAkB,MAAO,CAAC;AACvC,iEAAiE;AACjE,eAAO,MAAM,mBAAmB,MAAO,CAAC;AACxC,2EAA2E;AAC3E,eAAO,MAAM,kBAAkB,IAAO,CAAC;AACvC,8EAA8E;AAC9E,eAAO,MAAM,qBAAqB,IAAI,CAA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,oEAAoE;QACpE,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,GAAG;YAAE,GAAG,EAAE,MAAM,CAAA;SAAE,CAAC;QACvD,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;KAC9C,CAAC;IACF,mFAAmF;IACnF,OAAO,EAAE;QAAE,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;QAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE,GAAG,mBAAmB,CAAC;IACxF;;;;OAIG;IACH,QAAQ,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC/B,oFAAoF;IACpF,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB"}
@@ -0,0 +1,232 @@
1
+ /*
2
+ * Holtek transport shared by the Redragon M724 and M612, decoded from
3
+ * RDCfg.exe (sha256 ddfab882...7294) and confirmed on both mice: the
4
+ * settings are one flat memory behind 16-byte feature report 2 on the
5
+ * `0xFFA0:0x01` collection (USB interface 2).
6
+ *
7
+ * write [02 F3 addrLo addrHi len 00 00 00 data...] (len <= 8)
8
+ * read [02 F2 addrLo addrHi len ...], then GET_FEATURE
9
+ * -> [02 08 addrLo 32+addrHi len 00 FA FA data...]
10
+ * commit [02 F1 02 code]
11
+ * bracket [02 F5 00] ... [02 F5 01] around a write session
12
+ *
13
+ * There is no checksum. Malformed frames STALL, and a session left open
14
+ * hangs the interface until replug.
15
+ */
16
+ import { KEY_USAGES, SHORTCUTS, keyName } from "./keys.js";
17
+ export const REDRAGON_VENDOR_ID = 0x04d9; // Holtek Semiconductor
18
+ export const REDRAGON_CONFIG_USAGE_PAGE = 0xffa0;
19
+ export const REDRAGON_CONFIG_USAGE = 0x01;
20
+ export const REDRAGON_REPORT_ID = 2;
21
+ export const REDRAGON_REPORT_SIZE = 16;
22
+ /** First payload byte of a config write (report id excluded). */
23
+ export const REDRAGON_CMD_WRITE = 0xf3;
24
+ /** First payload byte of a settings read (report id excluded). */
25
+ export const REDRAGON_CMD_READ = 0xf2;
26
+ /** First payload byte of the session bracket (report id excluded). */
27
+ export const REDRAGON_CMD_HELLO = 0xf5;
28
+ /** First payload byte of a commit write (report id excluded). */
29
+ export const REDRAGON_CMD_COMMIT = 0xf1;
30
+ /** First payload byte of every GET_FEATURE answer (report id excluded). */
31
+ export const REDRAGON_REPLY_TAG = 0x08;
32
+ /** Length of the answer header before the data bytes (report id excluded). */
33
+ export const REDRAGON_REPLY_HEADER = 7;
34
+ /** Most data bytes one read or write frame carries. */
35
+ export const REDRAGON_MAX_TRANSFER = 8;
36
+ /** Write section of the commit block. */
37
+ export const REDRAGON_COMMIT_SECTION = 0x02;
38
+ /**
39
+ * Commit codes RDCfg sends after a button write (`SendButtonRefesh`), in
40
+ * order. Each reloads one area (01 profile, 02 DPI, 04 lighting, 08 polling
41
+ * and lift-off); a write without its commit is stored but only takes effect
42
+ * at boot. The whole block is sent after every write.
43
+ */
44
+ export const REDRAGON_COMMIT_CODES = [0x04, 0x01, 0x02, 0x08, 0x10];
45
+ export const REDRAGON_POLLING_RATES = [125, 250, 500, 1000];
46
+ /** Polling code per rate: code = 1000 / Hz. */
47
+ export const REDRAGON_POLLING_CODES = {
48
+ 1000: 0x01,
49
+ 500: 0x02,
50
+ 250: 0x04,
51
+ 125: 0x08,
52
+ };
53
+ /** Rejects addresses outside 16 bits and lengths a single frame cannot carry. */
54
+ function checkTransfer(address, length) {
55
+ if (!Number.isInteger(address) || address < 0 || address > 0xffff) {
56
+ throw new Error(`Redragon address ${address} is outside 0x0000-0xffff.`);
57
+ }
58
+ if (!Number.isInteger(length) || length < 1 || length > REDRAGON_MAX_TRANSFER) {
59
+ throw new Error(`Redragon transfer length ${length} is outside 1-${REDRAGON_MAX_TRANSFER}.`);
60
+ }
61
+ }
62
+ /** `[02 F3 addrLo addrHi len 00 00 00 data...]` (full frame, report id included). */
63
+ export function redragonEncodeWrite(address, data) {
64
+ checkTransfer(address, data.length);
65
+ const frame = new Uint8Array(REDRAGON_REPORT_SIZE);
66
+ frame[0] = REDRAGON_REPORT_ID;
67
+ frame[1] = REDRAGON_CMD_WRITE;
68
+ frame[2] = address & 0xff;
69
+ frame[3] = address >> 8;
70
+ frame[4] = data.length;
71
+ for (let index = 0; index < data.length; index++) {
72
+ const byte = data[index];
73
+ if (!Number.isInteger(byte) || byte < 0 || byte > 0xff)
74
+ throw new Error(`Redragon data byte ${byte} is not a byte.`);
75
+ frame[8 + index] = byte;
76
+ }
77
+ return frame;
78
+ }
79
+ /** `[02 F2 addrLo addrHi len ...]` (full frame, report id included). */
80
+ export function redragonEncodeRead(address, length) {
81
+ checkTransfer(address, length);
82
+ const frame = new Uint8Array(REDRAGON_REPORT_SIZE);
83
+ frame[0] = REDRAGON_REPORT_ID;
84
+ frame[1] = REDRAGON_CMD_READ;
85
+ frame[2] = address & 0xff;
86
+ frame[3] = address >> 8;
87
+ frame[4] = length;
88
+ return frame;
89
+ }
90
+ /**
91
+ * Validates the GET_FEATURE answer to `redragonEncodeRead(address, length)`
92
+ * and returns its data bytes. Accepts the answer with or without the leading
93
+ * report id, since WebHID and hidraw differ there.
94
+ */
95
+ export function redragonDecodeRead(answer, address, length) {
96
+ checkTransfer(address, length);
97
+ const body = answer[0] === REDRAGON_REPORT_ID && answer[1] === REDRAGON_REPLY_TAG ? answer.subarray(1) : answer;
98
+ const hex = [...answer].map((byte) => byte.toString(16).padStart(2, "0")).join(" ");
99
+ if (body.length < REDRAGON_REPLY_HEADER + length ||
100
+ body[0] !== REDRAGON_REPLY_TAG ||
101
+ body[1] !== (address & 0xff) ||
102
+ body[2] !== 0x32 + (address >> 8) ||
103
+ body[3] !== length ||
104
+ body[5] !== 0xfa ||
105
+ body[6] !== 0xfa) {
106
+ throw new Error(`Redragon read of ${length} bytes at 0x${address.toString(16).padStart(4, "0")} got an unexpected answer: ${hex}.`);
107
+ }
108
+ return body.slice(REDRAGON_REPLY_HEADER, REDRAGON_REPLY_HEADER + length);
109
+ }
110
+ /** Session bracket frame: `[02 F5 00]` opens, `[02 F5 01]` closes. */
111
+ export function redragonSession(begin) {
112
+ const frame = new Uint8Array(REDRAGON_REPORT_SIZE);
113
+ frame[0] = REDRAGON_REPORT_ID;
114
+ frame[1] = REDRAGON_CMD_HELLO;
115
+ frame[2] = begin ? 0x00 : 0x01;
116
+ return frame;
117
+ }
118
+ /** One commit write `[02 F1 02 code]` (full frame, report id included). */
119
+ export function redragonEncodeCommit(code) {
120
+ const frame = new Uint8Array(REDRAGON_REPORT_SIZE);
121
+ frame[0] = REDRAGON_REPORT_ID;
122
+ frame[1] = REDRAGON_CMD_COMMIT;
123
+ frame[2] = REDRAGON_COMMIT_SECTION;
124
+ frame[3] = code;
125
+ return frame;
126
+ }
127
+ /*
128
+ * Settings memory layout, identical on the M724 and M612 (RDCfg's
129
+ * `SendPollRate`, `SendLedState`, profile select, DPI and button writers
130
+ * are model-independent; only the codecs below differ).
131
+ */
132
+ export const REDRAGON_PROFILE_COUNT = 5;
133
+ /** Active onboard profile `[profile, 00]`, 0-4. */
134
+ export const REDRAGON_ACTIVE_PROFILE_ADDRESS = 0x002c;
135
+ /** Extra commit RDCfg's MODE select sends before the commit block. */
136
+ export const REDRAGON_PROFILE_SELECT_CODE = 0x01;
137
+ /** Polling code of profile p at `0x32 + 2p`, `[1000 / Hz, 00]`. */
138
+ export const REDRAGON_POLL_ADDRESS = 0x0032;
139
+ /**
140
+ * Per-profile block bases. `base + 0` is the active DPI stage (0-4); stage
141
+ * slot `n` is the 5 bytes at `base + 2 + 6n`: `[enabled, x, xRange, y, yRange]`.
142
+ */
143
+ export const REDRAGON_PROFILE_BASES = [0x0042, 0x0102, 0x01b2, 0x0262, 0x0312];
144
+ export const REDRAGON_STAGE_COUNT = 5;
145
+ export const REDRAGON_SLOT_LENGTH = 5;
146
+ /** Button slot `s` of profile p is the 4 bytes at `button base + 4s`. */
147
+ export const REDRAGON_BUTTON_BASES = [0x0082, 0x0142, 0x01f2, 0x02a2, 0x0352];
148
+ export const REDRAGON_BUTTON_LENGTH = 4;
149
+ export function redragonPollAddress(profile) {
150
+ checkProfile(profile);
151
+ return REDRAGON_POLL_ADDRESS + 2 * profile;
152
+ }
153
+ /** Address of one DPI stage slot. */
154
+ export function redragonSlotAddress(profile, stage) {
155
+ checkProfile(profile);
156
+ if (!Number.isInteger(stage) || stage < 0 || stage >= REDRAGON_STAGE_COUNT) {
157
+ throw new Error(`Redragon DPI stage ${stage} is outside 0-${REDRAGON_STAGE_COUNT - 1}.`);
158
+ }
159
+ return REDRAGON_PROFILE_BASES[profile] + 2 + 6 * stage;
160
+ }
161
+ /** Rejects profile indexes outside 0-4. */
162
+ function checkProfile(profile) {
163
+ if (!Number.isInteger(profile) || profile < 0 || profile >= REDRAGON_PROFILE_COUNT) {
164
+ throw new Error(`Redragon profile ${profile} is outside 0-${REDRAGON_PROFILE_COUNT - 1}.`);
165
+ }
166
+ }
167
+ /** Slider position whose label is nearest to `dpi` (ties go to the lower one). */
168
+ export function redragonNearestDpiPosition(labels, dpi, model) {
169
+ if (!Number.isInteger(dpi) || dpi < labels[0] || dpi > labels[labels.length - 1]) {
170
+ throw new Error(`Redragon ${model} DPI ${dpi} is outside ${labels[0]}-${labels[labels.length - 1]}.`);
171
+ }
172
+ let best = 0;
173
+ for (let position = 1; position < labels.length; position++) {
174
+ if (Math.abs(labels[position] - dpi) < Math.abs(labels[best] - dpi))
175
+ best = position;
176
+ }
177
+ return best;
178
+ }
179
+ /**
180
+ * Keyboard assignments are `[8F, modifiers, usage]` with the HID keyboard
181
+ * modifier bits (1 Ctrl, 2 Shift, 4 Alt, 8 Win) and usage IDs (RDCfg's
182
+ * COMBO KEY and shortcut menus).
183
+ */
184
+ export const REDRAGON_KEY_ACTION = 0x8f;
185
+ /** RDCfg's SINGLE KEY writes `[90 00 usage 00]` instead (action table `DAT_0049f280`). */
186
+ export const REDRAGON_SINGLE_KEY_ACTION = 0x90;
187
+ /**
188
+ * Button codec over a model's single-action list plus the shared shortcuts
189
+ * and keys; `keyPrefix` is what a plain "Key X" writes before the usage.
190
+ */
191
+ export function redragonButtonCodec(model, actions, keyPrefix = [REDRAGON_KEY_ACTION, 0x00]) {
192
+ const usage = (key) => KEY_USAGES.find(([name]) => name === key)[1];
193
+ const shortcutName = ([name, modifiers, key]) => `${name} (${keyName(modifiers, usage(key))})`;
194
+ const options = [
195
+ ...actions.map(([name]) => name),
196
+ ...SHORTCUTS.map(shortcutName),
197
+ ...KEY_USAGES.map(([name]) => `Key ${name}`),
198
+ ];
199
+ const pad = (bytes) => [...bytes, 0, 0, 0, 0].slice(0, REDRAGON_BUTTON_LENGTH);
200
+ const encode = (action) => {
201
+ const fixed = actions.find(([name]) => name === action);
202
+ if (fixed)
203
+ return pad(fixed[1]);
204
+ const shortcut = SHORTCUTS.find((entry) => shortcutName(entry) === action);
205
+ if (shortcut)
206
+ return pad([REDRAGON_KEY_ACTION, shortcut[1], usage(shortcut[2])]);
207
+ const key = action.startsWith("Key ") ? KEY_USAGES.find(([name]) => name === action.slice(4)) : undefined;
208
+ if (key)
209
+ return pad([...keyPrefix, key[1]]);
210
+ throw new Error(`Redragon ${model} button action "${action}" is not offered.`);
211
+ };
212
+ const decode = (value) => {
213
+ const bytes = Array.from(value).slice(0, REDRAGON_BUTTON_LENGTH);
214
+ const same = (encoded) => encoded.every((byte, index) => byte === (bytes[index] ?? 0));
215
+ const named = options.find((option) => same(encode(option)));
216
+ if (named)
217
+ return named;
218
+ if (bytes[0] === REDRAGON_KEY_ACTION && (bytes[3] ?? 0) === 0) {
219
+ const combination = keyName(bytes[1] ?? 0, bytes[2] ?? 0);
220
+ if (combination)
221
+ return `Keys ${combination}`;
222
+ }
223
+ if (bytes[0] === REDRAGON_SINGLE_KEY_ACTION && (bytes[1] ?? 0) === 0 && (bytes[3] ?? 0) === 0) {
224
+ const key = KEY_USAGES.find(([, code]) => code === bytes[2]);
225
+ if (key)
226
+ return `Key ${key[0]}`;
227
+ }
228
+ return `Vendor action (${bytes.map((byte) => byte.toString(16).padStart(2, "0")).join(" ")})`;
229
+ };
230
+ return { options, encode, decode };
231
+ }
232
+ //# sourceMappingURL=holtek.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"holtek.js","sourceRoot":"","sources":["../../src/redragon/holtek.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE3D,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,CAAC,uBAAuB;AACjE,MAAM,CAAC,MAAM,0BAA0B,GAAG,MAAM,CAAC;AACjD,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAC1C,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AACpC,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAEvC,iEAAiE;AACjE,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC;AACvC,kEAAkE;AAClE,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC;AACtC,sEAAsE;AACtE,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC;AACvC,iEAAiE;AACjE,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC;AACxC,2EAA2E;AAC3E,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC;AACvC,8EAA8E;AAC9E,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AACvC,uDAAuD;AACvD,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEvC,yCAAyC;AACzC,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,CAAC;AAC5C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAU,CAAC;AAE7E,MAAM,CAAC,MAAM,sBAAsB,G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