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
6 changes: 5 additions & 1 deletion src/device/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ const needsOpenClasses = (): Array<ClientClass<SupportedClient> | undefined> =>
CM()?.WallhackKeyboardHidClient, CM()?.GloriousHidClient, CM()?.GloriousClassicHidClient, CM()?.GloriousCore2HidClient,
CM()?.MchoseHidClient, CM()?.MchoseDockHidClient, CM()?.MchoseA5ProMaxHidClient, CM()?.MchoseV3HidClient,
CM()?.MicrosoftHidClient, CM()?.DareuHidClient, CM()?.IncottHidClient, CM()?.BytechHidClient, CM()?.RapooHidClient,
CM()?.FaterHidClient, CM()?.CoolerMasterHidClient, CM()?.RedragonM690ProHidClient, CM()?.RedragonM719ProHidClient, CM()?.AjazzHidClient,
CM()?.FaterHidClient, CM()?.CoolerMasterHidClient, CM()?.RedragonM690ProHidClient, CM()?.RedragonM719ProHidClient, CM()?.RedgearX13HidClient, CM()?.AjazzHidClient,
CM()?.HitscanHidClient, CM()?.XiaomiHidClient,
];
const pulsarClasses = (): Array<ClientClass<PulsarClient> | undefined> =>
Expand Down Expand Up @@ -4954,6 +4954,10 @@ export function applyDpiStageValue(stage: number, rawDpi: number): void {
applyDpiStageAxes(stage, { x: rawDpi });
return;
}
// A mouse that reports its stages but cannot rewrite them (fixed stages, as
// on the Redgear X13 Pro) skips the value: a game profile or profile key
// then still applies the rest instead of failing at flash time.
if (!clientHasMethod("setDpiStageValue")) return;
const stagedStatus = latestDeviceStatus ? withPendingChanges(latestDeviceStatus) : null;
const stages = stagedStatus?.dpiStages ?? latestDeviceStatus?.dpiStages;
if (!stages || !Number.isInteger(stage) || stage < 0 || stage >= stages.length) return;
Expand Down
42 changes: 42 additions & 0 deletions src/device/dpi-stage-writable.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import assert from "node:assert/strict";
import test from "node:test";
import { readFileSync } from "node:fs";
import vm from "node:vm";
import ts from "typescript";
import * as pending from "./pending-changes.ts";
import * as snapshots from "./game-profile-snapshot.ts";

function harness() {
pending.clearPendingChanges();
const exports: any = {};
const mocks = new Map();
const source = readFileSync(new URL("./controller.ts", import.meta.url), "utf8").replaceAll("import.meta.env", "({ DEV: false })") + `
export function testSelect(client) { clearActiveClients(); clearPendingChanges(); active = client; activeDevice = client.device; latestDeviceStatus = { name: "Fixed stages", dpi: 800, dpiStages: [400, 800, 1600], pollingRateHz: 1000, ui: { dpiStageEditor: { maxStages: 3 } } }; dpiOptions = [400, 800, 1200, 1600, 3200]; }
`;
const code = ts.transpileModule(source, { compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2022 } }).outputText;
const localStorage = { getItem: () => null };
const context = { exports, structuredClone, __BUILD_CHANNEL__: "stable", __BUILD_ID__: "test", __APP_VERSION__: "test", localStorage, window: { localStorage, setTimeout: () => 1, clearTimeout() {} }, setTimeout, clearTimeout, console, require: (name: string) => {
if (name.endsWith("pending-changes")) return pending;
if (name.endsWith("game-profile-snapshot")) return snapshots;
if (name.endsWith("interface-preferences")) return { loadInterfacePreferences: () => ({ locale: "en", reducedMotion: false }) };
if (name.endsWith("i18n/index")) return { t: (_locale: string, key: string) => key, tp: (_locale: string, key: string) => key };
if (!mocks.has(name)) mocks.set(name, new Proxy({}, { get: (target: any, key) => target[key] ??= function () {} }));
return mocks.get(name);
} };
vm.runInNewContext(code, context);
return exports;
}

test("a mouse with fixed DPI stages gets no stage-value write", () => {
const control = harness();
control.testSelect({ device: {} });
control.applyDpiStageValue(1, 1200);
assert.deepEqual(pending.pendingChanges().map((change) => change.key), []);
});

test("a mouse that can rewrite a stage still gets the write", () => {
const control = harness();
control.testSelect({ device: {}, async setDpiStageValue() {} });
control.applyDpiStageValue(1, 1200);
assert.deepEqual(pending.pendingChanges().map((change) => change.key), ["dpi-stage-1"]);
});
2 changes: 2 additions & 0 deletions src/device/driver-classes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export type DriverModules = typeof import("@openmouse/protocol/drivers/endgame/e
& typeof import("@openmouse/protocol/drivers/ajazz/hid")
& typeof import("@openmouse/protocol/drivers/redragon/m690-pro-hid")
& typeof import("@openmouse/protocol/drivers/redragon/m719-pro-hid")
& typeof import("@openmouse/protocol/drivers/redgear/hid")
& typeof import("@openmouse/protocol/drivers/hitscan/hid")
& typeof import("@openmouse/protocol/drivers/xiaomi/hid");

Expand Down Expand Up @@ -145,6 +146,7 @@ export function ensureDriverModules(): Promise<DriverModules> {
import("@openmouse/protocol/drivers/ajazz/hid"),
import("@openmouse/protocol/drivers/redragon/m690-pro-hid"),
import("@openmouse/protocol/drivers/redragon/m719-pro-hid"),
import("@openmouse/protocol/drivers/redgear/hid"),
import("@openmouse/protocol/drivers/hitscan/hid"),
import("@openmouse/protocol/drivers/xiaomi/hid"),
]).then((mods) => (loaded = Object.assign({}, ...mods) as DriverModules));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ test("Delux M800 Mini still resolves to its supported row on the shared PIDs", (
assert.equal(m719.status, "supported");
assert.equal(m719.pageModel, "M719 Invader Pro");
}
const x13 = crosscheckSupportedDevices(
device({ brand: "Redgear", name: "Redgear X13 Pro", vendorId: 0x1b80, productId: 0xb412 }),
"pass",
);
assert.equal(x13.listed, true);
assert.equal(x13.matchedBy, "pid");
assert.equal(x13.status, "supported");
assert.equal(x13.pageModel, "X13 Pro");
});

test("M2-NEX resolves by product name since its row pins no PIDs", () => {
Expand Down
1 change: 1 addition & 0 deletions src/features/hardware-test/supported-devices-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,7 @@ export const SUPPORTED_DEVICES: readonly SupportedDeviceEntry[] = [
{ brand: "Razer", model: "DeathAdder Essential (2021)", status: "pending" },
{ brand: "Razer", model: "RC30-030501", status: "pending" },
{ brand: "Razer", model: "RZ01-0385", status: "pending" },
{ brand: "Redgear", model: "X13 Pro", status: "supported", pids: [0xb412] },
{ brand: "Redgear", model: "A10", status: "pending" },
{ brand: "Redgear", model: "X12 V2", status: "pending" },
{ brand: "Redgear", model: "A20", status: "pending" },
Expand Down