@openmouse/protocol 0.57.0 → 0.59.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/dist/aula/index.d.ts +20 -0
- package/dist/aula/index.d.ts.map +1 -0
- package/dist/aula/index.js +83 -0
- package/dist/aula/index.js.map +1 -0
- package/dist/drivers/aula/hid.d.ts +25 -0
- package/dist/drivers/aula/hid.d.ts.map +1 -0
- package/dist/drivers/aula/hid.js +153 -0
- package/dist/drivers/aula/hid.js.map +1 -0
- package/dist/drivers/incott/hid.d.ts +25 -6
- package/dist/drivers/incott/hid.d.ts.map +1 -1
- package/dist/drivers/incott/hid.js +62 -13
- package/dist/drivers/incott/hid.js.map +1 -1
- package/dist/drivers/mouse-types.d.ts +1 -1
- package/dist/drivers/mouse-types.d.ts.map +1 -1
- package/dist/drivers/registry.d.ts +2 -1
- package/dist/drivers/registry.d.ts.map +1 -1
- package/dist/drivers/registry.js +2 -0
- package/dist/drivers/registry.js.map +1 -1
- package/dist/drivers/thermaltake/hid.d.ts +20 -0
- package/dist/drivers/thermaltake/hid.d.ts.map +1 -1
- package/dist/drivers/thermaltake/hid.js +74 -6
- package/dist/drivers/thermaltake/hid.js.map +1 -1
- package/dist/drivers/vendors.d.ts.map +1 -1
- package/dist/drivers/vendors.js +7 -0
- package/dist/drivers/vendors.js.map +1 -1
- package/dist/incott/index.d.ts +86 -7
- package/dist/incott/index.d.ts.map +1 -1
- package/dist/incott/index.js +103 -6
- package/dist/incott/index.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/package.json +5 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare const SC380_PRO_VENDOR_ID = 9610;
|
|
2
|
+
export declare const SC380_PRO_RECEIVER_ID = 312;
|
|
3
|
+
export declare const SC380_PRO_USAGE_PAGE = 65282;
|
|
4
|
+
export declare const SC380_PRO_USAGE = 2;
|
|
5
|
+
export declare const SC380_PRO_REPORT_ID = 9;
|
|
6
|
+
export declare const SC380_PRO_READ_SETTINGS = 68;
|
|
7
|
+
export declare const SC380_PRO_SETTINGS_LENGTH = 400;
|
|
8
|
+
export declare const SC380_PRO_POLLING_RATES: readonly [125, 250, 500, 1000];
|
|
9
|
+
export declare const SC380_PRO_DPI_STEP = 100;
|
|
10
|
+
export declare const SC380_PRO_MAX_DPI = 12000;
|
|
11
|
+
export declare function encodeSc380ProReport(command: number, argument: number, length: number, data?: Uint8Array): Uint8Array<ArrayBuffer>;
|
|
12
|
+
export declare function decodeSc380ProReply(reply: Uint8Array, command: number, argument: number, length: number): Uint8Array;
|
|
13
|
+
export declare function decodeSc380ProSettings(block: Uint8Array): {
|
|
14
|
+
active: number;
|
|
15
|
+
polling: 250 | 500 | 1000 | 125;
|
|
16
|
+
x: number[];
|
|
17
|
+
y: number[];
|
|
18
|
+
};
|
|
19
|
+
export declare function setSc380ProStageDpi(block: Uint8Array, stage: number, x: number, y: number): void;
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/aula/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,OAAS,CAAC;AAC1C,eAAO,MAAM,qBAAqB,MAAS,CAAC;AAC5C,eAAO,MAAM,oBAAoB,QAAS,CAAC;AAC3C,eAAO,MAAM,eAAe,IAAO,CAAC;AACpC,eAAO,MAAM,mBAAmB,IAAO,CAAC;AAExC,eAAO,MAAM,uBAAuB,KAAO,CAAC;AAC5C,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAC7C,eAAO,MAAM,uBAAuB,gCAAiC,CAAC;AACtE,eAAO,MAAM,kBAAkB,MAAM,CAAC;AACtC,eAAO,MAAM,iBAAiB,QAAQ,CAAC;AASvC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC,WAAW,CAAC,CAYlI;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,CAkBpH;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,UAAU;;;;;EAmBvD;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAYhG"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export const SC380_PRO_VENDOR_ID = 0x258a;
|
|
2
|
+
export const SC380_PRO_RECEIVER_ID = 0x0138;
|
|
3
|
+
export const SC380_PRO_USAGE_PAGE = 0xff02;
|
|
4
|
+
export const SC380_PRO_USAGE = 0x02;
|
|
5
|
+
export const SC380_PRO_REPORT_ID = 0x09;
|
|
6
|
+
export const SC380_PRO_READ_SETTINGS = 0x44;
|
|
7
|
+
export const SC380_PRO_SETTINGS_LENGTH = 400;
|
|
8
|
+
export const SC380_PRO_POLLING_RATES = [125, 250, 500, 1000];
|
|
9
|
+
export const SC380_PRO_DPI_STEP = 100;
|
|
10
|
+
export const SC380_PRO_MAX_DPI = 12000;
|
|
11
|
+
const REPORT_LENGTH = 520;
|
|
12
|
+
const HEADER_LENGTH = 8;
|
|
13
|
+
const SETTINGS_MARKER = 0x64;
|
|
14
|
+
const PAW3311_CODE = 0x18;
|
|
15
|
+
const DPI_X_OFFSET = 7;
|
|
16
|
+
const DPI_Y_OFFSET = 27;
|
|
17
|
+
export function encodeSc380ProReport(command, argument, length, data) {
|
|
18
|
+
if (!Number.isInteger(length) || length < 0 || length > REPORT_LENGTH - HEADER_LENGTH
|
|
19
|
+
|| (data && data.length !== length)) {
|
|
20
|
+
throw new Error("Invalid AULA SC380 Pro report length.");
|
|
21
|
+
}
|
|
22
|
+
// WebHID supplies the report ID separately.
|
|
23
|
+
const payload = new Uint8Array(REPORT_LENGTH - 1);
|
|
24
|
+
payload.set([command, argument, 1, 0, length & 0xff, length >> 8], 1);
|
|
25
|
+
if (data)
|
|
26
|
+
payload.set(data, HEADER_LENGTH - 1);
|
|
27
|
+
payload[0] = payload.reduce((sum, byte) => sum + byte, 0) & 0xff;
|
|
28
|
+
return payload;
|
|
29
|
+
}
|
|
30
|
+
export function decodeSc380ProReply(reply, command, argument, length) {
|
|
31
|
+
// Some WebHID transports include the report ID in the DataView.
|
|
32
|
+
for (const offset of reply[0] === SC380_PRO_REPORT_ID ? [1, 0] : [0]) {
|
|
33
|
+
const start = offset + HEADER_LENGTH - 1;
|
|
34
|
+
if (reply.length >= start + length && reply[offset + 1] === command
|
|
35
|
+
&& reply[offset + 2] === argument && reply[offset + 3] === 1 && reply[offset + 4] === 0
|
|
36
|
+
&& reply[offset + 5] === (length & 0xff) && reply[offset + 6] === (length >> 8)) {
|
|
37
|
+
if (command === SC380_PRO_READ_SETTINGS) {
|
|
38
|
+
const checksum = reply.subarray(offset + 1, start + length).reduce((sum, byte) => sum + byte, 0) & 0xff;
|
|
39
|
+
if (reply[offset] !== checksum) {
|
|
40
|
+
if (offset === 1)
|
|
41
|
+
continue;
|
|
42
|
+
throw new Error("Invalid AULA SC380 Pro settings checksum.");
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return reply.slice(start, start + length);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
throw new Error("Unexpected AULA SC380 Pro reply.");
|
|
49
|
+
}
|
|
50
|
+
export function decodeSc380ProSettings(block) {
|
|
51
|
+
if (block.length !== SC380_PRO_SETTINGS_LENGTH)
|
|
52
|
+
throw new Error("Unexpected AULA SC380 Pro settings block.");
|
|
53
|
+
const count = block[3] & 0x0f;
|
|
54
|
+
const active = (block[3] >> 4) - 1;
|
|
55
|
+
const polling = SC380_PRO_POLLING_RATES[(block[2] & 0x0f) - 1];
|
|
56
|
+
if (block[0] !== SETTINGS_MARKER
|
|
57
|
+
|| (block[1] & 0x1f) !== PAW3311_CODE || count < 1 || count > 6
|
|
58
|
+
|| active < 0 || active >= count || polling === undefined) {
|
|
59
|
+
throw new Error("Unexpected AULA SC380 Pro settings block.");
|
|
60
|
+
}
|
|
61
|
+
const view = new DataView(block.buffer, block.byteOffset, block.byteLength);
|
|
62
|
+
const readStages = (start) => Array.from({ length: count }, (_, stage) => (view.getUint16(start + 2 * stage, true) + 1) * SC380_PRO_DPI_STEP);
|
|
63
|
+
const x = readStages(DPI_X_OFFSET);
|
|
64
|
+
const y = readStages(DPI_Y_OFFSET);
|
|
65
|
+
if ([...x, ...y].some((dpi) => dpi > SC380_PRO_MAX_DPI)) {
|
|
66
|
+
throw new Error("Unexpected AULA SC380 Pro DPI value.");
|
|
67
|
+
}
|
|
68
|
+
return { active, polling, x, y };
|
|
69
|
+
}
|
|
70
|
+
export function setSc380ProStageDpi(block, stage, x, y) {
|
|
71
|
+
const { x: stages } = decodeSc380ProSettings(block);
|
|
72
|
+
if (!Number.isInteger(stage) || stage < 0 || stage >= stages.length) {
|
|
73
|
+
throw new Error("Invalid AULA SC380 Pro DPI stage.");
|
|
74
|
+
}
|
|
75
|
+
if ([x, y].some((dpi) => !Number.isInteger(dpi) || dpi < SC380_PRO_DPI_STEP
|
|
76
|
+
|| dpi > SC380_PRO_MAX_DPI || dpi % SC380_PRO_DPI_STEP !== 0)) {
|
|
77
|
+
throw new Error("Invalid AULA SC380 Pro DPI value.");
|
|
78
|
+
}
|
|
79
|
+
const view = new DataView(block.buffer, block.byteOffset, block.byteLength);
|
|
80
|
+
view.setUint16(DPI_X_OFFSET + 2 * stage, x / SC380_PRO_DPI_STEP - 1, true);
|
|
81
|
+
view.setUint16(DPI_Y_OFFSET + 2 * stage, y / SC380_PRO_DPI_STEP - 1, true);
|
|
82
|
+
}
|
|
83
|
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AAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACvD,CAAC;IACD,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,kBAAkB;WACpE,GAAG,GAAG,iBAAiB,IAAI,GAAG,GAAG,kBAAkB,KAAK,CAAC,CAAC,EAAE,CAAC;QAClE,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACvD,CAAC;IACD,MAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IAC5E,IAAI,CAAC,SAAS,CAAC,YAAY,GAAG,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,kBAAkB,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;IAC3E,IAAI,CAAC,SAAS,CAAC,YAAY,GAAG,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,kBAAkB,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;AAC7E,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { MouseStatus } from "../mouse-types.ts";
|
|
2
|
+
export declare class AulaSc380ProHidClient {
|
|
3
|
+
readonly device: HIDDevice;
|
|
4
|
+
private queue;
|
|
5
|
+
readonly pollIntervalMs = 0;
|
|
6
|
+
constructor(device: HIDDevice);
|
|
7
|
+
static isSupported(device: HIDDevice): boolean;
|
|
8
|
+
get supportedPollingRates(): number[];
|
|
9
|
+
getDpiOptions(): number[];
|
|
10
|
+
open(): Promise<void>;
|
|
11
|
+
close(): Promise<void>;
|
|
12
|
+
readStatus(): Promise<MouseStatus>;
|
|
13
|
+
setPollingRate(hz: number): Promise<void>;
|
|
14
|
+
setActiveDpiStage(stage: number): Promise<void>;
|
|
15
|
+
setDpiStageValue(stage: number, dpi: number): Promise<void>;
|
|
16
|
+
setDpiStageAxes(stage: number, x: number, y: number): Promise<void>;
|
|
17
|
+
setDpi(dpi: number): Promise<void>;
|
|
18
|
+
private identify;
|
|
19
|
+
private isLinked;
|
|
20
|
+
private readSettings;
|
|
21
|
+
private read;
|
|
22
|
+
private update;
|
|
23
|
+
private run;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=hid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hid.d.ts","sourceRoot":"","sources":["../../../src/drivers/aula/hid.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAiBrD,qBAAa,qBAAqB;IAIpB,QAAQ,CAAC,MAAM,EAAE,SAAS;IAHtC,OAAO,CAAC,KAAK,CAAuC;IACpD,QAAQ,CAAC,cAAc,KAAK;gBAEP,MAAM,EAAE,SAAS;IAEtC,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO;IAK9C,IAAI,qBAAqB,IAAI,MAAM,EAAE,CAEpC;IAED,aAAa,IAAI,MAAM,EAAE;IAKnB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAIrB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAMtB,UAAU,IAAI,OAAO,CAAC,WAAW,CAAC;IA+ClC,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAO/C,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAS/C,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI3D,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKnE,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YAQpB,QAAQ;YAOR,QAAQ;IAItB,OAAO,CAAC,YAAY;YAIN,IAAI;IAOlB,OAAO,CAAC,MAAM;IAgBd,OAAO,CAAC,GAAG;CAKZ"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { SC380_PRO_DPI_STEP, SC380_PRO_MAX_DPI, SC380_PRO_POLLING_RATES, SC380_PRO_READ_SETTINGS, SC380_PRO_RECEIVER_ID, SC380_PRO_REPORT_ID, SC380_PRO_SETTINGS_LENGTH, SC380_PRO_USAGE, SC380_PRO_USAGE_PAGE, SC380_PRO_VENDOR_ID, decodeSc380ProReply, decodeSc380ProSettings, encodeSc380ProReport, setSc380ProStageDpi, } from "../../aula/index.js";
|
|
2
|
+
const NAME = "AULA SC380 Pro";
|
|
3
|
+
const MODEL_SIGNATURE = [0x04, 0, 0, 0, 0, 0x2e];
|
|
4
|
+
const WRITE_SETTINGS = 0x04;
|
|
5
|
+
const READ_IDENTITY = 0x05;
|
|
6
|
+
const READ_LINK = 0x07;
|
|
7
|
+
const READ_BATTERY = 0x09;
|
|
8
|
+
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
9
|
+
function hasSettingsReport(collection) {
|
|
10
|
+
return (collection.usagePage === SC380_PRO_USAGE_PAGE && collection.usage === SC380_PRO_USAGE
|
|
11
|
+
&& collection.featureReports.some((report) => report.reportId === SC380_PRO_REPORT_ID))
|
|
12
|
+
|| collection.children.some(hasSettingsReport);
|
|
13
|
+
}
|
|
14
|
+
export class AulaSc380ProHidClient {
|
|
15
|
+
device;
|
|
16
|
+
queue = Promise.resolve();
|
|
17
|
+
pollIntervalMs = 0;
|
|
18
|
+
constructor(device) {
|
|
19
|
+
this.device = device;
|
|
20
|
+
}
|
|
21
|
+
static isSupported(device) {
|
|
22
|
+
return device.vendorId === SC380_PRO_VENDOR_ID && device.productId === SC380_PRO_RECEIVER_ID
|
|
23
|
+
&& device.collections.some(hasSettingsReport);
|
|
24
|
+
}
|
|
25
|
+
get supportedPollingRates() {
|
|
26
|
+
return [...SC380_PRO_POLLING_RATES];
|
|
27
|
+
}
|
|
28
|
+
getDpiOptions() {
|
|
29
|
+
return Array.from({ length: SC380_PRO_MAX_DPI / SC380_PRO_DPI_STEP }, (_, index) => (index + 1) * SC380_PRO_DPI_STEP);
|
|
30
|
+
}
|
|
31
|
+
async open() {
|
|
32
|
+
if (!this.device.opened)
|
|
33
|
+
await this.device.open();
|
|
34
|
+
}
|
|
35
|
+
async close() {
|
|
36
|
+
await this.run(async () => {
|
|
37
|
+
if (this.device.opened)
|
|
38
|
+
await this.device.close();
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
async readStatus() {
|
|
42
|
+
return this.run(async () => {
|
|
43
|
+
await this.open();
|
|
44
|
+
await this.identify();
|
|
45
|
+
const linked = await this.isLinked();
|
|
46
|
+
const settings = linked ? decodeSc380ProSettings(await this.readSettings()) : null;
|
|
47
|
+
const battery = linked ? (await this.read(READ_BATTERY, 1, 1).catch(() => null))?.[0] : undefined;
|
|
48
|
+
return {
|
|
49
|
+
brand: "AULA",
|
|
50
|
+
name: NAME,
|
|
51
|
+
ui: {
|
|
52
|
+
family: "aula-sc380-pro",
|
|
53
|
+
defaultDisplayName: NAME,
|
|
54
|
+
settingsReady: settings !== null,
|
|
55
|
+
hideUnsupportedPollingRates: true,
|
|
56
|
+
hideProcessingCard: true,
|
|
57
|
+
hideSleepCard: true,
|
|
58
|
+
hideSignalCard: true,
|
|
59
|
+
...(settings ? {
|
|
60
|
+
dpiStageEditor: {
|
|
61
|
+
maxStages: settings.x.length,
|
|
62
|
+
countEditable: false,
|
|
63
|
+
minDpi: SC380_PRO_DPI_STEP,
|
|
64
|
+
maxDpi: SC380_PRO_MAX_DPI,
|
|
65
|
+
stepDpi: SC380_PRO_DPI_STEP,
|
|
66
|
+
},
|
|
67
|
+
} : { statusNote: "Wake the mouse to read its settings." }),
|
|
68
|
+
},
|
|
69
|
+
dpi: settings?.x[settings.active] ?? 0,
|
|
70
|
+
dpiY: settings?.y[settings.active],
|
|
71
|
+
dpiStages: settings?.x,
|
|
72
|
+
dpiStagesY: settings?.y,
|
|
73
|
+
activeDpiStage: settings?.active,
|
|
74
|
+
supportsSeparateDpiAxes: settings !== null,
|
|
75
|
+
pollingRateHz: settings?.polling ?? 0,
|
|
76
|
+
supportedPollingRates: this.supportedPollingRates,
|
|
77
|
+
batteryPercent: battery !== undefined && battery <= 100 ? battery : null,
|
|
78
|
+
batteryState: "Unknown",
|
|
79
|
+
activeProfile: null,
|
|
80
|
+
connectionType: "Wireless",
|
|
81
|
+
connectionDetail: "2.4 GHz receiver",
|
|
82
|
+
liftOffDistance: null,
|
|
83
|
+
firmware: [],
|
|
84
|
+
};
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
async setPollingRate(hz) {
|
|
88
|
+
const code = this.supportedPollingRates.indexOf(hz) + 1;
|
|
89
|
+
if (code === 0)
|
|
90
|
+
throw new Error("Unsupported AULA SC380 Pro polling rate.");
|
|
91
|
+
return this.update((block) => { block[2] = (block[2] & 0xf0) | code; }, (actual) => actual.polling === hz);
|
|
92
|
+
}
|
|
93
|
+
setActiveDpiStage(stage) {
|
|
94
|
+
return this.update((block, current) => {
|
|
95
|
+
if (!Number.isInteger(stage) || stage < 0 || stage >= current.x.length) {
|
|
96
|
+
throw new Error("Invalid AULA SC380 Pro DPI stage.");
|
|
97
|
+
}
|
|
98
|
+
block[3] = ((stage + 1) << 4) | (block[3] & 0x0f);
|
|
99
|
+
}, (actual) => actual.active === stage);
|
|
100
|
+
}
|
|
101
|
+
setDpiStageValue(stage, dpi) {
|
|
102
|
+
return this.setDpiStageAxes(stage, dpi, dpi);
|
|
103
|
+
}
|
|
104
|
+
setDpiStageAxes(stage, x, y) {
|
|
105
|
+
return this.update((block) => setSc380ProStageDpi(block, stage, x, y), (actual) => actual.x[stage] === x && actual.y[stage] === y);
|
|
106
|
+
}
|
|
107
|
+
setDpi(dpi) {
|
|
108
|
+
let stage = 0;
|
|
109
|
+
return this.update((block, current) => {
|
|
110
|
+
stage = current.active;
|
|
111
|
+
setSc380ProStageDpi(block, stage, dpi, dpi);
|
|
112
|
+
}, (actual) => actual.x[stage] === dpi && actual.y[stage] === dpi);
|
|
113
|
+
}
|
|
114
|
+
async identify() {
|
|
115
|
+
const signature = await this.read(READ_IDENTITY, 1, MODEL_SIGNATURE.length);
|
|
116
|
+
if (!MODEL_SIGNATURE.every((byte, index) => signature[index] === byte)) {
|
|
117
|
+
throw new Error("This receiver did not identify as an AULA SC380 Pro.");
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
async isLinked() {
|
|
121
|
+
return (await this.read(READ_LINK, 0, 1))[0] === 1;
|
|
122
|
+
}
|
|
123
|
+
readSettings() {
|
|
124
|
+
return this.read(SC380_PRO_READ_SETTINGS, 0, SC380_PRO_SETTINGS_LENGTH);
|
|
125
|
+
}
|
|
126
|
+
async read(command, argument, length) {
|
|
127
|
+
await this.device.sendFeatureReport(SC380_PRO_REPORT_ID, encodeSc380ProReport(command, argument, length));
|
|
128
|
+
await delay(30);
|
|
129
|
+
const view = await this.device.receiveFeatureReport(SC380_PRO_REPORT_ID);
|
|
130
|
+
return decodeSc380ProReply(new Uint8Array(view.buffer, view.byteOffset, view.byteLength), command, argument, length);
|
|
131
|
+
}
|
|
132
|
+
update(edit, verify) {
|
|
133
|
+
return this.run(async () => {
|
|
134
|
+
await this.open();
|
|
135
|
+
await this.identify();
|
|
136
|
+
if (!await this.isLinked())
|
|
137
|
+
throw new Error("Wake the AULA SC380 Pro before changing settings.");
|
|
138
|
+
const block = await this.readSettings();
|
|
139
|
+
edit(block, decodeSc380ProSettings(block));
|
|
140
|
+
await this.device.sendFeatureReport(SC380_PRO_REPORT_ID, encodeSc380ProReport(WRITE_SETTINGS, 0, block.length, block));
|
|
141
|
+
await delay(250);
|
|
142
|
+
if (!verify(decodeSc380ProSettings(await this.readSettings()))) {
|
|
143
|
+
throw new Error("The AULA SC380 Pro did not keep the requested setting.");
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
run(operation) {
|
|
148
|
+
const result = this.queue.then(operation);
|
|
149
|
+
this.queue = result.then(() => undefined, () => undefined);
|
|
150
|
+
return result;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=hid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hid.js","sourceRoot":"","sources":["../../../src/drivers/aula/hid.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,uBAAuB,EACvB,uBAAuB,EACvB,qBAAqB,EACrB,mBAAmB,EACnB,yBAAyB,EACzB,eAAe,EACf,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAG7B,MAAM,IAAI,GAAG,gBAAgB,CAAC;AAC9B,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;AACjD,MAAM,cAAc,GAAG,IAAI,CAAC;AAC5B,MAAM,aAAa,GAAG,IAAI,CAAC;AAC3B,MAAM,SAAS,GAAG,IAAI,CAAC;AACvB,MAAM,YAAY,GAAG,IAAI,CAAC;AAC1B,MAAM,KAAK,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAGtF,SAAS,iBAAiB,CAAC,UAA6B;IACtD,OAAO,CAAC,UAAU,CAAC,SAAS,KAAK,oBAAoB,IAAI,UAAU,CAAC,KAAK,KAAK,eAAe;WACxF,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,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;YAClB,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;YACtB,IAAI,CAAC,MAAM,IAAI,CAAC,QAAQ,EAAE;gBAAE,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;YACjG,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;YACxC,IAAI,CAAC,KAAK,EAAE,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAC;YAC3C,MAAM,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,mBAAmB,EACrD,oBAAoB,CAAC,cAAc,EAAE,CAAC,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;YAChE,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;YACjB,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,EAAE,CAAC;gBAC/D,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;YAC5E,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,GAAG,CAAI,SAA2B;QACxC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC1C,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC3D,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -57,12 +57,19 @@ export declare class IncottTransactionQueue {
|
|
|
57
57
|
*/
|
|
58
58
|
send(payload: Uint8Array): Promise<void>;
|
|
59
59
|
/**
|
|
60
|
-
* Sends
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
60
|
+
* Sends one macro chunk: the 8-byte feature report announcing it, the gap
|
|
61
|
+
* the device needs to get ready, then the 32-byte OUTPUT report carrying
|
|
62
|
+
* it — as ONE queue entry.
|
|
63
|
+
*
|
|
64
|
+
* The two halves must be one entry, not two. Queueing them separately looks
|
|
65
|
+
* ordered and is not: `await`ing the header hands control back to the event
|
|
66
|
+
* loop, so anything queued meanwhile — a status refresh, a battery read,
|
|
67
|
+
* any of the app's background polling — runs between a header and the chunk
|
|
68
|
+
* it announced. The device is waiting for an output report at that point
|
|
69
|
+
* and gets a feature query instead. Nothing acknowledges a chunk, so the
|
|
70
|
+
* damage is silent.
|
|
64
71
|
*/
|
|
65
|
-
|
|
72
|
+
sendChunk(header: Uint8Array, reportId: number, chunk: Uint8Array, settleMs?: number): Promise<void>;
|
|
66
73
|
private exchange;
|
|
67
74
|
private read;
|
|
68
75
|
}
|
|
@@ -355,7 +362,19 @@ export declare class IncottHidClient {
|
|
|
355
362
|
* The device does not acknowledge any of it, so unlike every other setter
|
|
356
363
|
* here there is nothing to verify against: there is no macro read command.
|
|
357
364
|
* Bind a button to `Macro <n>` and press it — that is the only confirmation
|
|
358
|
-
* available.
|
|
365
|
+
* available. That makes both halves of `sendChunk` load-bearing: a chunk
|
|
366
|
+
* sent too early, or after something else has been allowed in between, is
|
|
367
|
+
* dropped in silence and the buffer keeps whatever that region held before
|
|
368
|
+
* — so a short macro can replay the tail of a longer one it replaced, or a
|
|
369
|
+
* setting can survive the upload meant to change it.
|
|
370
|
+
*
|
|
371
|
+
* Re-bind the button AFTER every upload, even when it is already on
|
|
372
|
+
* `Macro`: `setButtonMapping(button, "Macro")`. HARDWARE-CONFIRMED
|
|
373
|
+
* 2026-11-06: the loop mode and repeat count take effect when the binding is
|
|
374
|
+
* written, not when the buffer is. Uploading alone replaced the steps but
|
|
375
|
+
* kept the old loop mode, so a macro set to repeat ran only while held. The
|
|
376
|
+
* vendor writes the binding after the buffer on every save, which is why
|
|
377
|
+
* its own captures never show the problem.
|
|
359
378
|
*/
|
|
360
379
|
uploadMacro(macro: IncottMacro): Promise<void>;
|
|
361
380
|
/** Reads the DPI cycle (stage count + active stage) in one query. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hid.d.ts","sourceRoot":"","sources":["../../../src/drivers/incott/hid.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAgB,MAAM,mBAAmB,CAAC;AACnE,OAAO,
|
|
1
|
+
{"version":3,"file":"hid.d.ts","sourceRoot":"","sources":["../../../src/drivers/incott/hid.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAgB,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAmFL,KAAK,aAAa,EAElB,KAAK,aAAa,EAElB,KAAK,WAAW,EACjB,MAAM,uBAAuB,CAAC;AAE/B,KAAK,YAAY,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE9C;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvE,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC1D;;;;;OAKG;IACH,UAAU,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAClE;AAED,MAAM,WAAW,wBAAwB;IACvC,gEAAgE;IAChE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kDAAkD;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACvC;AAKD;;;;;;;;;;;;GAYG;AACH,qBAAa,sBAAsB;IACjC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAmB;IAC7C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAA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,CAAC;IAIlD;;;;;;OAMG;IACH,aAAa,IAAI,MAAM,EAAE;IAIzB;;;;;;;;;;;;;;;;OAgBG;IACG,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAe/C,gFAAgF;YAClE,KAAK;IAKnB;;;;;OAKG;YACW,YAAY;IAU1B,4EAA4E;IACtE,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAOlF;;;;;;OAMG;IACG,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC;YAezE,KAAK;CAGpB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { incottButtonActionCode, incottDecodeButtonBinding, incottDecodeDebounce, incottDecodeDpiStage, incottDecodeDpiStageAxis, incottDecodeDpiCycle, incottDecodeFireKey, incottDecodeIdentity, incottDpiMaxForSensor, incottDecodeInputStatus, incottDecodeLiftOffDirect, incottDecodePerformanceMode, incottDecodePollingRate, incottDecodeReceiverLed, incottDecodeSleep, incottDecodeToggle, incottEncodeMacroBuffer, incottEncodeMacroChunkHeader, incottEncodeQuery, incottEncodeQueryDpiAxis, incottEncodeSetButtonBinding, incottEncodeSetDebounce, incottEncodeSetDpi, incottEncodeSetDpiCycle, incottEncodeSetFireKey, incottEncodeSetLiftOff, incottEncodeSetPerformanceMode, incottEncodeSetPollingRate, incottEncodeSetReceiverLed, incottEncodeSetSleep, incottEncodeSetToggle, incottFrameMatches, incottIsWiredProduct, incottMacroChunks, incottLiftOffLabel, incottLiftOffStepsForSensor, incottLiftOffTenths, incottNormalizeProductName, incottPerformanceModeFromWire, incottPerformanceModeToWire, incottValidateDpi, INCOTT_BUTTON_ACTIONS, INCOTT_BUTTON_NAMES, INCOTT_BUTTON_WIRE_INDEX, INCOTT_CMD_QUERY_BUTTON, INCOTT_CMD_QUERY_DPI_STAGE, INCOTT_CMD_QUERY_DPI_STAGE_VALUE, INCOTT_CMD_QUERY_IDENTITY, INCOTT_CMD_QUERY_POLLING, INCOTT_CMD_QUERY_RECEIVER_LED, INCOTT_CMD_QUERY_SENSOR, INCOTT_CMD_QUERY_TIMING, INCOTT_DEBOUNCE_MAX_MS, INCOTT_DPI_AXIS, INCOTT_DPI_DEFAULT_STAGE_PRESETS, INCOTT_DPI_MAX, INCOTT_DPI_MIN, INCOTT_DPI_STAGE_COUNT, INCOTT_DPI_STEP, INCOTT_INPUT_REPORT_ID, INCOTT_PERFORMANCE_MODE_NAMES, INCOTT_POLLING_STEPS_HZ, INCOTT_POLLING_STEPS_HZ_WIRED, INCOTT_PRODUCT_IDS, INCOTT_SLEEP_OPTIONS, INCOTT_REPORT_ID, INCOTT_RESPONSE_LENGTH, INCOTT_SUB_ANGLE_SNAP, INCOTT_SUB_DEBOUNCE, INCOTT_SUB_FIRE_KEY, INCOTT_SUB_LOD, INCOTT_SUB_MOTION_SYNC, INCOTT_SUB_NONE, INCOTT_SUB_PERFORMANCE, INCOTT_SUB_RIPPLE, INCOTT_SUB_SLEEP, INCOTT_USAGE_PAGE, INCOTT_VENDOR_ID, } from "../../incott/index.js";
|
|
1
|
+
import { incottButtonActionCode, incottMacroBindingForButton, incottMacroSlotFromBinding, incottDecodeButtonBinding, incottDecodeDebounce, incottDecodeDpiStage, incottDecodeDpiStageAxis, incottDecodeDpiCycle, incottDecodeFireKey, incottDecodeIdentity, incottDpiMaxForSensor, incottDecodeInputStatus, incottDecodeLiftOffDirect, incottDecodePerformanceMode, incottDecodePollingRate, incottDecodeReceiverLed, incottDecodeSleep, incottDecodeToggle, incottEncodeMacroBuffer, incottEncodeMacroChunkHeader, incottEncodeQuery, incottEncodeQueryDpiAxis, incottEncodeSetButtonBinding, incottEncodeSetDebounce, incottEncodeSetDpi, incottEncodeSetDpiCycle, incottEncodeSetFireKey, incottEncodeSetLiftOff, incottEncodeSetPerformanceMode, incottEncodeSetPollingRate, incottEncodeSetReceiverLed, incottEncodeSetSleep, incottEncodeSetToggle, incottFrameMatches, incottIsWiredProduct, incottMacroChunks, incottLiftOffLabel, incottLiftOffStepsForSensor, incottLiftOffTenths, incottNormalizeProductName, incottPerformanceModeFromWire, incottPerformanceModeToWire, incottValidateDpi, INCOTT_BUTTON_ACTIONS, INCOTT_MACRO_ACTION_LABEL, INCOTT_BUTTON_NAMES, INCOTT_BUTTON_WIRE_INDEX, INCOTT_CMD_QUERY_BUTTON, INCOTT_CMD_QUERY_DPI_STAGE, INCOTT_CMD_QUERY_DPI_STAGE_VALUE, INCOTT_CMD_QUERY_IDENTITY, INCOTT_CMD_QUERY_POLLING, INCOTT_CMD_QUERY_RECEIVER_LED, INCOTT_CMD_QUERY_SENSOR, INCOTT_CMD_QUERY_TIMING, INCOTT_DEBOUNCE_MAX_MS, INCOTT_DPI_AXIS, INCOTT_DPI_DEFAULT_STAGE_PRESETS, INCOTT_DPI_MAX, INCOTT_DPI_MIN, INCOTT_DPI_STAGE_COUNT, INCOTT_DPI_STEP, INCOTT_INPUT_REPORT_ID, INCOTT_MACRO_CHUNK_SETTLE_MS, INCOTT_PERFORMANCE_MODE_NAMES, INCOTT_POLLING_STEPS_HZ, INCOTT_POLLING_STEPS_HZ_WIRED, INCOTT_PRODUCT_IDS, INCOTT_SLEEP_OPTIONS, INCOTT_REPORT_ID, INCOTT_RESPONSE_LENGTH, INCOTT_SUB_ANGLE_SNAP, INCOTT_SUB_DEBOUNCE, INCOTT_SUB_FIRE_KEY, INCOTT_SUB_LOD, INCOTT_SUB_MOTION_SYNC, INCOTT_SUB_NONE, INCOTT_SUB_PERFORMANCE, INCOTT_SUB_RIPPLE, INCOTT_SUB_SLEEP, INCOTT_USAGE_PAGE, INCOTT_VENDOR_ID, } from "../../incott/index.js";
|
|
2
2
|
const defaultSleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
3
3
|
/**
|
|
4
4
|
* Serializes feature-report request/response pairs for the Incott protocol.
|
|
@@ -54,18 +54,29 @@ export class IncottTransactionQueue {
|
|
|
54
54
|
return run;
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
|
-
* Sends
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
57
|
+
* Sends one macro chunk: the 8-byte feature report announcing it, the gap
|
|
58
|
+
* the device needs to get ready, then the 32-byte OUTPUT report carrying
|
|
59
|
+
* it — as ONE queue entry.
|
|
60
|
+
*
|
|
61
|
+
* The two halves must be one entry, not two. Queueing them separately looks
|
|
62
|
+
* ordered and is not: `await`ing the header hands control back to the event
|
|
63
|
+
* loop, so anything queued meanwhile — a status refresh, a battery read,
|
|
64
|
+
* any of the app's background polling — runs between a header and the chunk
|
|
65
|
+
* it announced. The device is waiting for an output report at that point
|
|
66
|
+
* and gets a feature query instead. Nothing acknowledges a chunk, so the
|
|
67
|
+
* damage is silent.
|
|
61
68
|
*/
|
|
62
|
-
|
|
69
|
+
sendChunk(header, reportId, chunk, settleMs = this.settleMs) {
|
|
63
70
|
const run = this.tail.then(async () => {
|
|
64
71
|
if (!this.transport.sendReport) {
|
|
65
72
|
throw new Error("This transport cannot send output reports, which the macro upload needs.");
|
|
66
73
|
}
|
|
67
|
-
await this.transport.
|
|
68
|
-
|
|
74
|
+
await this.transport.sendFeatureReport(INCOTT_REPORT_ID, toArrayBuffer(header));
|
|
75
|
+
// The settle happens BETWEEN the header and the chunk. The vendor waits
|
|
76
|
+
// there — not after — which reads as the device needing that gap to get
|
|
77
|
+
// ready for the output report.
|
|
78
|
+
await this.sleep(settleMs);
|
|
79
|
+
await this.transport.sendReport(reportId, toArrayBuffer(chunk));
|
|
69
80
|
});
|
|
70
81
|
this.tail = run.catch(() => undefined);
|
|
71
82
|
return run;
|
|
@@ -751,7 +762,19 @@ export class IncottHidClient {
|
|
|
751
762
|
// when it has the current assignments AND the list of actions it may
|
|
752
763
|
// write back.
|
|
753
764
|
...(buttonMappings !== null
|
|
754
|
-
? {
|
|
765
|
+
? {
|
|
766
|
+
buttonMappings,
|
|
767
|
+
// One "Macro" entry, not ten numbered slots: a button can only
|
|
768
|
+
// run the buffer carrying its own index, so offering a choice of
|
|
769
|
+
// slot would list combinations the device ignores. Nothing can
|
|
770
|
+
// ask which buffers hold a macro, so the option is always
|
|
771
|
+
// present; choosing it on a button with no macro uploaded is
|
|
772
|
+
// accepted and does nothing, as in the vendor tool.
|
|
773
|
+
buttonOptions: [
|
|
774
|
+
...INCOTT_BUTTON_ACTIONS.map(([label]) => label),
|
|
775
|
+
INCOTT_MACRO_ACTION_LABEL,
|
|
776
|
+
],
|
|
777
|
+
}
|
|
755
778
|
: {}),
|
|
756
779
|
motionSync,
|
|
757
780
|
rippleControl,
|
|
@@ -821,13 +844,24 @@ export class IncottHidClient {
|
|
|
821
844
|
* The device does not acknowledge any of it, so unlike every other setter
|
|
822
845
|
* here there is nothing to verify against: there is no macro read command.
|
|
823
846
|
* Bind a button to `Macro <n>` and press it — that is the only confirmation
|
|
824
|
-
* available.
|
|
847
|
+
* available. That makes both halves of `sendChunk` load-bearing: a chunk
|
|
848
|
+
* sent too early, or after something else has been allowed in between, is
|
|
849
|
+
* dropped in silence and the buffer keeps whatever that region held before
|
|
850
|
+
* — so a short macro can replay the tail of a longer one it replaced, or a
|
|
851
|
+
* setting can survive the upload meant to change it.
|
|
852
|
+
*
|
|
853
|
+
* Re-bind the button AFTER every upload, even when it is already on
|
|
854
|
+
* `Macro`: `setButtonMapping(button, "Macro")`. HARDWARE-CONFIRMED
|
|
855
|
+
* 2026-11-06: the loop mode and repeat count take effect when the binding is
|
|
856
|
+
* written, not when the buffer is. Uploading alone replaced the steps but
|
|
857
|
+
* kept the old loop mode, so a macro set to repeat ran only while held. The
|
|
858
|
+
* vendor writes the binding after the buffer on every save, which is why
|
|
859
|
+
* its own captures never show the problem.
|
|
825
860
|
*/
|
|
826
861
|
async uploadMacro(macro) {
|
|
827
862
|
const chunks = incottMacroChunks(incottEncodeMacroBuffer(macro));
|
|
828
863
|
for (const [index, chunk] of chunks.entries()) {
|
|
829
|
-
await this.
|
|
830
|
-
await this.queue.sendOutput(INCOTT_REPORT_ID, chunk);
|
|
864
|
+
await this.queue.sendChunk(incottEncodeMacroChunkHeader(index, macro.bufferId), INCOTT_REPORT_ID, chunk, INCOTT_MACRO_CHUNK_SETTLE_MS);
|
|
831
865
|
}
|
|
832
866
|
}
|
|
833
867
|
/** Reads the DPI cycle (stage count + active stage) in one query. */
|
|
@@ -994,6 +1028,17 @@ export class IncottHidClient {
|
|
|
994
1028
|
const binding = incottDecodeButtonBinding(await this.query(INCOTT_CMD_QUERY_BUTTON, index), index);
|
|
995
1029
|
if (binding === null)
|
|
996
1030
|
return null;
|
|
1031
|
+
// A macro binding is only meaningful against the button it was read
|
|
1032
|
+
// from: the slot it names should be that button's own index. One
|
|
1033
|
+
// pointing elsewhere was written by something that had the model wrong,
|
|
1034
|
+
// so report it rather than showing it as a working macro.
|
|
1035
|
+
const macroSlot = incottMacroSlotFromBinding(binding.code);
|
|
1036
|
+
if (macroSlot !== null) {
|
|
1037
|
+
mappings[name] = macroSlot === INCOTT_BUTTON_NAMES.indexOf(name)
|
|
1038
|
+
? INCOTT_MACRO_ACTION_LABEL
|
|
1039
|
+
: `Macro (buffer ${macroSlot})`;
|
|
1040
|
+
continue;
|
|
1041
|
+
}
|
|
997
1042
|
mappings[name] = binding.label ?? `Unknown (0x${binding.code.toString(16).padStart(8, "0")})`;
|
|
998
1043
|
}
|
|
999
1044
|
return mappings;
|
|
@@ -1011,7 +1056,11 @@ export class IncottHidClient {
|
|
|
1011
1056
|
const name = INCOTT_BUTTON_NAMES.find((candidate) => candidate === button);
|
|
1012
1057
|
if (name === undefined)
|
|
1013
1058
|
throw new Error(`This mouse has no "${button}" button.`);
|
|
1014
|
-
|
|
1059
|
+
// "Macro" resolves per button: the buffer a button runs is its own
|
|
1060
|
+
// display index, so the binding cannot be looked up from the label alone.
|
|
1061
|
+
const code = actionLabel === INCOTT_MACRO_ACTION_LABEL
|
|
1062
|
+
? incottMacroBindingForButton(name)
|
|
1063
|
+
: incottButtonActionCode(actionLabel);
|
|
1015
1064
|
if (code === null)
|
|
1016
1065
|
throw new Error(`Unknown button action "${actionLabel}".`);
|
|
1017
1066
|
const index = INCOTT_BUTTON_WIRE_INDEX[name];
|