diff --git a/gpui/js/controls.ts b/gpui/js/controls.ts index 2edf8a9..c9b82db 100644 --- a/gpui/js/controls.ts +++ b/gpui/js/controls.ts @@ -244,9 +244,124 @@ function advanced(s: any, brand: string): Section[] { } /** Brand-specific extras that were reported by drivers but had no control yet. */ -function extras(s: any): Section[] { +export function extras(s: any): Section[] { const out: Section[] = []; + if (s.wlmouse && typeof s.wlmouse === "object") { + const wl = s.wlmouse; + const sensorControls: Control[] = []; + if (wl.lodMode != null) { + sensorControls.push({ + id: "wl.lodMode", + label: "Lift-off precision", + kind: "choice", + options: [{ value: "standard", label: "Standard" }, { value: "precise", label: "Precise" }], + current: wl.lodMode, + }); + } + if (typeof s.supportsSeparateDpiAxes === "boolean") { + sensorControls.push({ + id: "wl.separateAxes", + label: "Independent X/Y DPI", + kind: "toggle", + current: s.supportsSeparateDpiAxes, + }); + } + if (wl.sensorPosition) { + sensorControls.push({ + id: "wl.sensorX", + label: "Sensor position X", + kind: "number", + min: -5, + max: 5, + step: 1, + current: wl.sensorPosition.x, + }); + sensorControls.push({ + id: "wl.sensorY", + label: "Sensor position Y", + kind: "number", + min: -5, + max: 5, + step: 1, + current: wl.sensorPosition.y, + }); + } + if (wl.bhopWheel) { + sensorControls.push({ + id: "wl.bhop", + label: "BHop wheel", + kind: "toggle", + current: Boolean(wl.bhopWheel.enabled), + }); + if (wl.bhopWheel.enabled) { + sensorControls.push({ + id: "wl.bhopDir", + label: "BHop filter direction", + kind: "choice", + options: [ + { value: "both", label: "Both" }, + { value: "up", label: "Up" }, + { value: "down", label: "Down" }, + ], + current: wl.bhopWheel.direction, + }); + sensorControls.push({ + id: "wl.bhopWindow", + label: "BHop filter window", + kind: "number", + min: 0, + max: 750, + step: 10, + unit: "ms", + current: wl.bhopWheel.windowMs, + }); + } + } + if (wl.dynamicDpi) { + sensorControls.push({ + id: "wl.dynDpi", + label: "Dynamic DPI", + kind: "toggle", + current: Boolean(wl.dynamicDpi.enabled), + }); + } + if (sensorControls.length) out.push({ title: "WLMouse · Sensor & scroll", controls: sensorControls }); + + if (wl.dongleScreen) { + const lcd = wl.dongleScreen; + out.push({ + title: "WLMouse · Dongle screen", + controls: [ + { + id: "wl.lcdEnabled", + label: "Screen effect", + kind: "toggle", + current: Boolean(lcd.enabled), + }, + { + id: "wl.lcdDefaultScreen", + label: "Default screen", + kind: "choice", + options: [ + { value: "mouse-stats", label: "Mouse stats" }, + { value: "usb-monitor", label: "USB monitor" }, + { value: "media", label: "Media" }, + ], + current: lcd.defaultScreen, + }, + { + id: "wl.lcdDoubleTap", + label: "Double-tap link", + description: "Double-tap the receiver touchscreen to open the configurator.", + kind: "toggle", + current: Boolean(lcd.doubleTapEnabled), + }, + ], + }); + } + } + if (s.finalmouseIsSlx === true) { const mode = [{ value: 0, label: "Mechanical" }, { value: 1, label: "TMR analog" }]; const rel = [{ value: 0, label: "Normal" }, { value: 1, label: "Early" }, { value: 2, label: "Late" }]; @@ -781,6 +896,56 @@ export async function writeControl(info: HidInterfaceInfo, status: any, id: stri case "dongle.led": return callClientMethod(info, "setDongleLed", Boolean(value)); case "dongle.incott": return callClientMethod(info, "setReceiverLed", Number(value)); case "dongle.atk": return callClientMethod(info, "setDongleLight", Number(value)); + case "wl.lodMode": { + const mode = value === "precise" ? "precise" : "standard"; + const currentMm = status.wlmouse?.lodMm ?? 1; + const mm = mode === "standard" && ![0.7, 1, 2].includes(currentMm) ? 1 : currentMm; + await callClientMethod(info, "setLiftOffHeight", mm, mode); + if (status.wlmouse) { status.wlmouse.lodMode = mode; status.wlmouse.lodMm = mm; } + return; + } + case "wl.separateAxes": + await callClientMethod(info, "setSeparateDpiAxes", Boolean(value)); + status.supportsSeparateDpiAxes = Boolean(value); + return; + case "wl.sensorX": case "wl.sensorY": { + const cur = status.wlmouse?.sensorPosition ?? { x: 0, y: 0 }; + const x = id === "wl.sensorX" ? Math.round(Number(value)) : cur.x; + const y = id === "wl.sensorY" ? Math.round(Number(value)) : cur.y; + await callClientMethod(info, "setSensorPosition", x, y); + if (status.wlmouse) status.wlmouse.sensorPosition = { x, y }; + return; + } + case "wl.bhop": case "wl.bhopDir": case "wl.bhopWindow": { + const cur = status.wlmouse?.bhopWheel ?? { enabled: false, direction: "both", windowMs: 200 }; + const next = { + enabled: id === "wl.bhop" ? Boolean(value) : cur.enabled, + direction: id === "wl.bhopDir" ? String(value) : cur.direction, + windowMs: id === "wl.bhopWindow" ? Math.round(Number(value)) : cur.windowMs, + }; + await callClientMethod(info, "setBhopWheel", next); + if (status.wlmouse) status.wlmouse.bhopWheel = next; + return; + } + case "wl.dynDpi": { + const cur = status.wlmouse?.dynamicDpi ?? { enabled: false, points: [{ speed: 0, ratio: 1 }, { speed: 20, ratio: 2.62 }, { speed: 40, ratio: 4.8 }] }; + const next = { ...cur, enabled: Boolean(value) }; + await callClientMethod(info, "setDynamicDpi", next); + if (status.wlmouse) status.wlmouse.dynamicDpi = next; + return; + } + case "wl.lcdEnabled": + await callClientMethod(info, "setDongleScreenEnabled", Boolean(value)); + if (status.wlmouse?.dongleScreen) status.wlmouse.dongleScreen.enabled = Boolean(value); + return; + case "wl.lcdDefaultScreen": + await callClientMethod(info, "setDongleDefaultScreen", String(value)); + if (status.wlmouse?.dongleScreen) status.wlmouse.dongleScreen.defaultScreen = String(value); + return; + case "wl.lcdDoubleTap": + await callClientMethod(info, "setDongleDoubleTap", Boolean(value)); + if (status.wlmouse?.dongleScreen) status.wlmouse.dongleScreen.doubleTapEnabled = Boolean(value); + return; case "gen.profile": return w.setProfile(info, Number(value)); case "gen.powerMode": return callClientMethod(info, "setPowerMode", value); case "perf.sleep": return w.setSleepTimeout(info, Number(value)); diff --git a/package-lock.json b/package-lock.json index 2b3c7ef..c7b1751 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "AGPL-3.0-or-later", "dependencies": { "@openmouse/keyboard-protocol": "1.10.0", - "@openmouse/protocol": "0.67.0" + "@openmouse/protocol": "0.68.0" }, "devDependencies": { "esbuild": "^0.25.12" @@ -468,9 +468,9 @@ } }, "node_modules/@openmouse/protocol": { - "version": "0.67.0", - "resolved": "https://registry.npmjs.org/@openmouse/protocol/-/protocol-0.67.0.tgz", - "integrity": "sha512-IoXXYvsaMd1Cg9+PBrDJO9NIdchLPMOI+EmHN6eMpad/rHP89NQu6NhCExXYa/iFBar2qdO5SPy5+FiqGiL5Ig==", + "version": "0.68.0", + "resolved": "https://registry.npmjs.org/@openmouse/protocol/-/protocol-0.68.0.tgz", + "integrity": "sha512-0uj07ePYkftS+7LbI1D/wGU9usqWvPC3ExZZZzL6fkwZ1XU3G8Lm4PCjLKZaFdS2kOUeRrrRMQcsHasdv2ch+Q==", "license": "AGPL-3.0-or-later", "engines": { "node": ">=20" diff --git a/package.json b/package.json index dfc08a4..c093f1c 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "description": "Build tooling for the native GPUI app: gpui/build.rs bundles the protocol drivers with esbuild.", "dependencies": { "@openmouse/keyboard-protocol": "1.10.0", - "@openmouse/protocol": "0.67.0" + "@openmouse/protocol": "0.68.0" }, "devDependencies": { "esbuild": "^0.25.12"