Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ checklist.
| SteelSeries Rival 3 (Gen 1) | `@openmouse/protocol/steelseries` |
| Teevolution | `@openmouse/protocol/teevolution` |
| VGN | `@openmouse/protocol/vgn` |
| VAXEE / ZYGEN | `@openmouse/protocol/vaxee` |
| WALLHACK | `@openmouse/protocol/wallhack` |
| WLMouse | `@openmouse/protocol/wlmouse` |
| Wooting | `@openmouse/protocol/wooting` |
Expand Down
42 changes: 39 additions & 3 deletions docs/vaxee-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,44 @@

Source: the public [VAXEE Control Center](https://vcc.vaxee.cn/index.php), version 3.6, specifically its `api/api_core.js`, `api/api.js`, and `api/paramter.js` modules. The global site has the same page but currently serves a browser challenge to automated requests. The code in this repository is an independent implementation of the commands exposed by those modules.

The site advertises USB VID `3057`, the `FF05:0001` control collection, feature report `0E`, and the product IDs in `src/vaxee/index.ts`. Requests are 63 data bytes after the report ID. The panel sends a request, waits 100 ms, then reads feature report `0E`. Reply data begins at byte 5. The battery value is in 5% steps, which the panel multiplies by five.
The site advertises USB VID `3057`, the `FF05:0001` control collection, feature report `0E`, and the product IDs in `src/vaxee/index.ts`. Requests are 63 data bytes after the report ID. The panel sends a request, waits 100 ms, then reads feature report `0E`. On Windows the WebHID `DataView` includes the report ID at byte 0, so payload data begins at byte 5; implementations must also tolerate platforms that strip the prefix. Read replies carry `A5 <command> 01 <length> <data...>` and write acknowledgements carry `A5 <command> 03 01 01 ...`. The battery value is in 5% steps, which the panel multiplies by five.

OpenMouse currently exposes the active DPI stage, polling rate, battery, and lift-off distance. DPI, polling, and LOD writes are followed by a read-back. The driver limits DPI writes to the common 100–26,000 range in steps of 50 and limits the polling choices to rates the current wired or receiver path can safely use. VAXEE's newer 3954 models expose additional DPI and 8 kHz options, while the Control Center also supports tracking modes, trajectory, click latency, profiles, and key remapping. Those need model-specific verification before they are exposed here.
A receiver can answer the previous request when another application is polling the same collection. The Control Center retries a failed read; the driver does the same with a short pause before resending.

No model or connection path has been exercised on physical hardware yet. To validate one, record the mouse and receiver USB IDs, firmware versions, control-collection descriptor, and sanitized replies for commands `01`, `02`, `04`, `07`, `09`, `0A`, `0B`, and `10`. Test read-back after each setting change and note which writes persist after reconnection. The receiver may report a mouse PID distinct from its own USB PID. Avoid sharing device serial numbers or raw captures with personal data.
OpenMouse exposes all four DPI stages, the active stage, polling rate, battery, and lift-off distance. DPI stage values, the active stage, polling, and LOD writes are followed by a read-back. The driver limits DPI writes to the common 100–26,000 range in steps of 50 and limits the polling choices to rates the current wired or receiver path can safely use. VAXEE's newer 3954 models expose additional DPI and 8 kHz options, while the Control Center also supports tracking modes, trajectory, click latency, profiles, and key remapping. Those need model-specific verification before they are exposed here.

No model or connection path had been exercised on physical hardware when the driver was added. To validate one, record the mouse and receiver USB IDs, firmware versions, control-collection descriptor, and sanitized replies for commands `01`, `02`, `04`, `07`, `09`, `0A`, `0B`, and `10`. Test read-back after each setting change and note which writes persist after reconnection. The receiver may report a mouse PID distinct from its own USB PID. Avoid sharing device serial numbers or raw captures with personal data.

## Hardware verification

A VAXEE E1 Wireless (mouse PID `0x1010`) behind the VXD02 4K receiver
(`3057:2001`, product string `VAXEE 4K Wireless 1.0`) was tested on Windows
WebHID. The official Control Center and the driver both report four enabled
stages: 400 / 800 / 800 / 3,200 DPI, with stage 3 active at 800 DPI and
1,000 Hz polling. The mouse reported firmware `0x0059`, low LOD, tracking mode
1, and a battery level of 7 steps (35%) while discharging.

Measured replies (report ID included):

```text
mouse PID 0E A5 0A 01 02 10 10
DPI stage 0E A5 02 01 01 03
DPI enabled 0E A5 03 01 04 01 01 01 01
DPI stage 1 0E A5 04 01 03 01 90 01 (400 DPI)
DPI stage 2 0E A5 04 01 03 02 20 03 (800 DPI)
DPI stage 3 0E A5 04 01 03 03 20 03 (800 DPI)
DPI stage 4 0E A5 04 01 03 04 80 0C (3,200 DPI)
polling 0E A5 07 01 01 02
LOD 0E A5 09 01 01 01
battery 0E A5 0B 01 01 07
charging 0E A5 10 01 01 00
firmware 0E A5 01 01 02 59 00
```

A stage write is acknowledged with `0E A5 04 03 01 01` and read back as
`0E A5 04 01 03 <stage> <DpiLow> <DpiHigh>`. When the edited stage is the
active one, the driver selects that stage again with a `0x02` write so the
firmware applies the new DPI to the sensor; the Control Center does the same.
Stage 3 was written to 800 DPI and read back as
`0E A5 04 01 03 03 20 03`; polling and LOD writes were also acknowledged and
read back. Persistence across a power cycle has not been tested.
125 changes: 116 additions & 9 deletions src/drivers/vaxee/hid.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ import test from "node:test";
import { VaxeeHidClient } from "./hid.ts";
import { VAXEE_COMMAND, VAXEE_REPORT_ID } from "@openmouse/protocol/vaxee";

function device(productId = 0x2002, options: { ignoreWrites?: boolean; standardMode?: boolean } = {}) {
let dpi = 800;
function device(productId = 0x2002, options: { ignoreWrites?: boolean; standardMode?: boolean; mousePid?: number; batterySteps?: number; dpiStages?: number[]; activeStage?: number; staleDpiStageOnce?: number } = {}) {
let rateCode = 2;
let lod = 1;
const targetPid = options.mousePid ?? 0x1011;
const batterySteps = options.batterySteps ?? 13;
const dpiStages = [...(options.dpiStages ?? [800, 800, 800, 800])];
let activeStage = options.activeStage ?? 0;
let pending: Uint8Array | null = null;
let staleDpiStage = options.staleDpiStageOnce ?? null;
const writes: Uint8Array[] = [];
const hid = {
vendorId: 0x3057,
Expand All @@ -25,7 +29,11 @@ function device(productId = 0x2002, options: { ignoreWrites?: boolean; standardM
pending = new Uint8Array(buffer as ArrayBuffer);
writes.push(pending);
if (pending[2] === 2 && !options.ignoreWrites) {
if (pending[1] === VAXEE_COMMAND.dpiValue) dpi = pending[5]! | (pending[6]! << 8);
if (pending[1] === VAXEE_COMMAND.dpiStage) activeStage = pending[4]! - 1;
if (pending[1] === VAXEE_COMMAND.dpiValue) {
const stage = pending[4]! - 1;
dpiStages[stage] = pending[5]! | (pending[6]! << 8);
}
if (pending[1] === VAXEE_COMMAND.polling) rateCode = pending[4]!;
if (pending[1] === VAXEE_COMMAND.lod) lod = pending[4]!;
}
Expand All @@ -34,17 +42,27 @@ function device(productId = 0x2002, options: { ignoreWrites?: boolean; standardM
assert.equal(reportId, VAXEE_REPORT_ID);
assert.ok(pending);
const command = pending[1]!;
const reply = new Uint8Array(63);
const data = command === VAXEE_COMMAND.mousePid ? [0x11, 0x10]
: command === VAXEE_COMMAND.dpiStage ? [1]
: command === VAXEE_COMMAND.dpiValue ? [1, dpi & 255, dpi >> 8]
const reply = new Uint8Array(64);
const requestedStage = pending[4]!;
const stageDpi = dpiStages[requestedStage - 1] ?? 800;
const data = command === VAXEE_COMMAND.mousePid ? [targetPid & 0xff, targetPid >> 8]
: command === VAXEE_COMMAND.dpiStage ? [activeStage + 1]
: command === VAXEE_COMMAND.dpiEnabled ? [1, 1, 1, 1]
: command === VAXEE_COMMAND.dpiValue ? [requestedStage, stageDpi & 255, stageDpi >> 8]
: command === VAXEE_COMMAND.polling ? [rateCode]
: command === VAXEE_COMMAND.tracking ? [options.standardMode ? 0 : 1]
: command === VAXEE_COMMAND.lod ? [lod]
: command === VAXEE_COMMAND.battery ? [13]
: command === VAXEE_COMMAND.battery ? [batterySteps]
: command === VAXEE_COMMAND.charging ? [0]
: command === VAXEE_COMMAND.firmware ? [1, 2] : [1];
reply.set([0xa5, command, 3, 1, data.length, ...data]);
if (command === VAXEE_COMMAND.dpiValue && requestedStage === staleDpiStage) {
staleDpiStage = null;
data[0] = requestedStage - 1;
}
// Windows WebHID keeps the report ID at byte 0. Read replies carry type
// 0x01 followed by the payload length; write acks carry 0x03 0x01 0x01.
if (pending[2] === 1) reply.set([0x0e, 0xa5, command, 1, data.length, ...data]);
else reply.set([0x0e, 0xa5, command, 3, 1, 1]);
return new DataView(reply.buffer);
},
} as unknown as HIDDevice;
Expand Down Expand Up @@ -81,3 +99,92 @@ test("VAXEE status decodes battery steps and writes verify against read-back", a
await assert.rejects(() => client.setDpi(1651), RangeError);
await assert.rejects(() => client.setPollingRate(125), RangeError);
});

test("VAXEE retries a reply that answers another command", async () => {
const { hid } = device();
const receive = hid.receiveFeatureReport.bind(hid);
let first = true;
hid.receiveFeatureReport = async (reportId: number) => {
if (first) {
first = false;
const reply = new Uint8Array(64);
reply.set([0x0e, 0xa5, VAXEE_COMMAND.polling, 1, 1, 2]);
return new DataView(reply.buffer);
}
return receive(reportId);
};
const status = await new VaxeeHidClient(hid).readStatus();
assert.equal(first, false);
assert.equal(status.name, "VAXEE NP-01S V2 Wireless");
assert.equal(status.dpi, 800);
});

test("VAXEE retries a DPI reply that answers the previous stage", async () => {
const { hid } = device(0x2001, {
mousePid: 0x1010,
dpiStages: [400, 800, 1600, 3200], activeStage: 2,
staleDpiStageOnce: 2,
});
const status = await new VaxeeHidClient(hid).readStatus();
assert.deepEqual(status.dpiStages, [400, 800, 1600, 3200]);
assert.equal(status.dpi, 1600);
assert.equal(status.activeDpiStage, 2);
});

test("VAXEE retries a stale DPI read-back after a stage write", async () => {
const { hid } = device(0x2001, {
mousePid: 0x1010,
dpiStages: [400, 800, 1600, 3200], activeStage: 2,
staleDpiStageOnce: 3,
});
const client = new VaxeeHidClient(hid);
assert.equal(await client.setDpiStageValue(2, 2000), 2000);
});

test("VAXEE reselects the active stage after a DPI write", async () => {
const { hid, writes } = device(0x2001, {
mousePid: 0x1010,
dpiStages: [400, 800, 1600, 3200], activeStage: 2,
});
const client = new VaxeeHidClient(hid);
writes.length = 0;
await client.setDpiStageValue(1, 900);
assert.equal(writes.some((report) => report[1] === VAXEE_COMMAND.dpiStage && report[2] === 2), false);
writes.length = 0;
await client.setDpiStageValue(2, 2000);
assert.ok(writes.some((report) => report[1] === VAXEE_COMMAND.dpiStage && report[2] === 2 && report[4] === 3));
assert.equal((await client.readStatus()).dpi, 2000);
});

test("VAXEE exposes the four DPI stages and writes them", async () => {
const { hid } = device(0x2001, {
mousePid: 0x1010, batterySteps: 7,
dpiStages: [400, 800, 800, 3200], activeStage: 2,
});
const client = new VaxeeHidClient(hid);
const status = await client.readStatus();
assert.equal(status.name, "VAXEE E1 Wireless");
assert.equal(status.batteryPercent, 35);
assert.equal(status.batteryState, "Discharging");
assert.equal(status.connectionType, "Wireless");
assert.equal(status.connectionDetail, "2.4 GHz receiver");
assert.deepEqual(status.supportedPollingRates, [500, 1000, 2000, 4000]);
assert.deepEqual(status.dpiStages, [400, 800, 800, 3200]);
assert.equal(status.activeDpiStage, 2);
assert.equal(status.dpi, 800);
assert.deepEqual(status.ui?.dpiStageEditor, {
maxStages: 4, countEditable: false, minDpi: 100, maxDpi: 26000, stepDpi: 50,
});

assert.equal(await client.setDpiStageValue(0, 1600), 1600);
assert.equal(await client.setActiveDpiStage(0), 0);
const afterStageWrite = await client.readStatus();
assert.deepEqual(afterStageWrite.dpiStages, [1600, 800, 800, 3200]);
assert.equal(afterStageWrite.activeDpiStage, 0);
assert.equal(afterStageWrite.dpi, 1600);

assert.equal(await client.setDpi(1200), 1200);
assert.equal((await client.readStatus()).dpi, 1200);
await assert.rejects(() => client.setDpiStageValue(4, 800), /between 0 and 3/);
await assert.rejects(() => client.setActiveDpiStage(-1), /between 0 and 3/);
});
Loading