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
7 changes: 5 additions & 2 deletions build/check-bundle-size.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@ import { join } from "node:path";
// measured in the Update Mouse Protocol workflow); main grew 27.7 kB to
// 1,413,917 bytes, below its cap. 3.95 MB leaves room for one more release.
export const BUDGET_BYTES: Record<string, number> = {
".css": 170_000,
".js": 3_950_000,
// G6 HE/receiver panels, travel charts, battery tooltips and OLED theme,
// with protocol 0.60.0: measured 177,450 bytes CSS and 3,992,589 bytes JS.
// Main stays at 1,459,853 bytes, below its existing separate cap.
".css": 178_000,
".js": 4_000_000,
};

// main-*.js measured 1,511,619 bytes right after the split (posthog ~377 kB
Expand Down
37 changes: 19 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@
},
"dependencies": {
"@openmouse/keyboard-protocol": "1.6.1",
"@openmouse/protocol": "0.59.0",
"@openmouse/protocol": "0.60.0",
"lucide-react": "^1.43.0",
"posthog-js": "^1.438.17",
"preact": "^10.29.8"
},
"devDependencies": {
"picomatch": "file:vendor/picomatch-safe",
"typescript": "^5.8.3",
"vite": "^6.3.5"
},
"overrides": {
"picomatch": "$picomatch"
}
}
5 changes: 5 additions & 0 deletions public/devices/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ image file — it has nowhere to go. Instead:

## Maintainer upload steps

For the G6 HE use `keychron-g6-he.png`; for a separate TurboLink receiver render
use `keychron-turbolink-8k.png`. Upload at the bucket root. Both name mappings are
in `src/shared/device-images.ts`; the G6 mapping precedes the generic HE keyboard
fallback. These mappings are ready for upload and do not imply the files exist.

1. Save a **transparent** PNG or WebP named after the model in kebab-case,
e.g. `razer-viper-v3-pro.png`. The panel sits on a dark background, so an
image with a white backdrop shows as a white block.
Expand Down
86 changes: 85 additions & 1 deletion src/device/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4754,6 +4754,7 @@ function stageMagneticButton(
const name = `${MAGNETIC_SIDE[button]} click ${label}`;
stageChange({
key: `magnetic-${setting}-${button}`,
priority: latestDeviceStatus?.brand === "Keychron" && setting === "trigger" ? -1 : 0,
label: name,
command: `Set the ${name.toLowerCase()}`,
progress: `Setting the ${name.toLowerCase()}…`,
Expand Down Expand Up @@ -4815,7 +4816,19 @@ export function applyMagneticSwitchType(button: 0 | 1, type: "magnetic" | "optic
}

export function subscribeButtonDepth(listener: (left: number, right: number) => void): () => void {
return magneticClient()?.onButtonDepth?.(listener) ?? (() => {});
let current: MagneticButtonClient | null = null;
let stop = () => {};
const bind = () => {
const next = magneticClient();
if (next === current) return;
stop();
current = next;
listener(NaN, NaN);
stop = next?.onButtonDepth?.(listener) ?? (() => {});
};
bind();
const unsubscribe = subscribe(bind);
return () => { unsubscribe(); stop(); };
}

export async function startMagneticCalibration(): Promise<void> {
Expand Down Expand Up @@ -6246,6 +6259,70 @@ export function toggleSleep(enabled: boolean): void {
applyPulsarValue("sleep", enabled ? lastSleepSeconds : WLMOUSE_SLEEP_NEVER);
}

export function applyKeychronDynamicDpi(value: NonNullable<NonNullable<MouseStatus["keychronMouse"]>["dynamicDpi"]>): void {
if (!latestDeviceStatus?.keychronMouse?.dynamicDpi) return;
const next = structuredClone(value);
stageChange({ key: "keychron-dynamic-dpi", label: t(interfacePreferences.locale, "perf.dynSens"),
command: "Set Keychron dynamic DPI", progress: "Setting Keychron dynamic DPI...",
preview: status => { if (status.keychronMouse) status.keychronMouse.dynamicDpi = structuredClone(next); },
apply: () => callClientMethod("setKeychronDynamicDpi", "dynamic DPI", next),
});
}

export function applyKeychronReceiverButton(button: string, action: string): void {
if (!latestDeviceStatus?.keychronReceiver) return;
stageChange({ key: `keychron-receiver-${button}`, label: `${button}: ${action}`,
command: `Set receiver ${button}`, progress: `Setting receiver ${button}...`,
preview: status => { if (status.keychronReceiver) status.keychronReceiver.buttonMappings[button] = action; },
apply: () => callClientMethod("setKeychronReceiverButton", "receiver button", { button, action }),
});
}

export async function refreshKeychronReceiver(): Promise<void> {
await waitForControllerIdle();
const client = keychron8kClient();
if (!client || refreshInProgress || settingInProgress || activationInProgress) return;
const device = activeDevice;
refreshInProgress = true;
try {
const status = await client.readStatus();
if (activeSettingsClient() !== client || activeDevice !== device) return;
applyStatus(status);
}
catch (error) {
if (activeSettingsClient() === client && activeDevice === device) toastForError("Receiver", error);
}
finally { refreshInProgress = false; }
}

export function applyKeychronReceiverLighting(value: MouseLighting): void {
if (!latestDeviceStatus?.keychronReceiver) return;
const next = structuredClone(value);
stageChange({ key: "keychron-receiver-lighting", label: t(interfacePreferences.locale, "light.receiverTitle"),
command: "Set receiver lighting", progress: "Setting receiver lighting...",
preview: status => { if (status.keychronReceiver) status.keychronReceiver.lighting = structuredClone(next); },
apply: () => callClientMethod("setKeychronReceiverLighting", "receiver lighting", next),
});
}

export function applyKeychronPairing(value: NonNullable<NonNullable<MouseStatus["keychronMouse"]>["pairing"]>): void {
if (!latestDeviceStatus?.keychronMouse?.pairing) return;
stageChange({ key: "keychron-pairing", label: t(interfacePreferences.locale, "magnetic.pairing"),
command: "Set Keychron pairing shortcut", progress: "Setting Keychron pairing shortcut...",
preview: status => { if (status.keychronMouse) status.keychronMouse.pairing = { ...value }; },
apply: () => callClientMethod("setKeychronPairingShortcut", "pairing shortcut", value),
});
}

export function stageKeychronReset(): void {
if (!latestDeviceStatus?.keychronMouse?.factoryReset) return;
if (!window.confirm(t(interfacePreferences.locale, "magnetic.factoryHint"))) return;
stageChange({ key: "keychron-reset", label: t(interfacePreferences.locale, "magnetic.factoryReset"),
command: "Reset Keychron mouse", progress: "Resetting Keychron mouse...",
apply: async () => { await requireClientMethod("resetKeychronMouse", "factory reset").resetKeychronMouse(); },
});
}

export function applyKsnakeScrollDirection(
direction: NonNullable<MouseStatus["scrollDirection"]>,
): void {
Expand Down Expand Up @@ -7397,6 +7474,13 @@ function magneticPreviewClient(initial: MouseStatus): SupportedClient {
open: async () => undefined,
close: async () => undefined,
readStatus: async () => structuredClone(status),
setScrollDirection: async (direction: "Forward" | "Reverse") => { status.scrollDirection = direction; },
setKeychronReceiverButton: async ({ button, action }: { button: string; action: string }) => { if (status.keychronReceiver) status.keychronReceiver.buttonMappings[button] = action; },
setKeychronReceiverLighting: async (value: MouseLighting) => { if (status.keychronReceiver) status.keychronReceiver.lighting = structuredClone(value); },
setKeychronPairingShortcut: async (value: { mask: number; holdTime: number }) => { if (status.keychronMouse) status.keychronMouse.pairing = { ...value }; },
setKeychronDynamicDpi: async (value: NonNullable<NonNullable<MouseStatus["keychronMouse"]>["dynamicDpi"]>) => { if (status.keychronMouse) status.keychronMouse.dynamicDpi = structuredClone(value); },
resetKeychronMouse: async () => undefined,
setButtonMapping: async (button: string, action: string) => { if (status.buttonMappings) status.buttonMappings[button] = action; },
setMagneticTriggerPoint: async (button: 0 | 1, point: number) => { buttons()[button]!.triggerPoint = point; return point; },
setMagneticReleasePoint: async (button: 0 | 1, point: number | null) => { buttons()[button]!.releasePoint = point; return point; },
setMagneticRapidTrigger: async (button: 0 | 1, enabled: boolean, level: number) => {
Expand Down
25 changes: 25 additions & 0 deletions src/device/preview/preview-fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1161,6 +1161,31 @@ export const PREVIEW_FIXTURES: Record<FixturePreviewMode, PreviewFixture> = {
finalmouse: { label: "Finalmouse UltralightX", status: FINALMOUSE },
"finalmouse-slx": { label: "Finalmouse Starlight X", status: FINALMOUSE_SLX },
ninjutso: { label: "Ninjutso Sora V3", status: NINJUTSO },
"keychron-g6-he": { label: "Keychron G6 HE 8K", status: {
brand: "Keychron", name: "Keychron G6 HE 8K", batteryPercent: 82, batteryState: "Discharging",
dpi: 800, dpiStages: [400, 800, 1600, 3200, 5000], activeDpiStage: 1, pollingRateHz: 8000,
supportedPollingRates: [125, 500, 1000, 2000, 4000, 8000], activeProfile: 1, profileCount: 5,
connectionType: "Wired", liftOffDistance: null, motionSync: true, angleSnapping: false, rippleControl: false,
scrollDirection: "Forward", debounceMs: 8, sleepTimeout: 600, firmware: [],
ui: { family: "keychron-8k", dpiStageEditor: { maxStages: 5, countEditable: true, minDpi: 50, maxDpi: 40000, stepDpi: 50 } },
buttonMappings: { Left: "Left Click", Right: "Right Click", Middle: "Middle Click", Back: "Back", Forward: "Forward" },
buttonOptions: ["Default", "Left Click", "Right Click", "Middle Click", "Back", "Forward", "Disabled"],
keychronReceiver: {
name: "Keychron TurboLink 8K", firmware: "v1.2.3",
buttonMappings: { Polling: "Polling Loop", Lighting: "Lighting mode cycle", "Switch type": "Toggle optical / magnetic", DPI: "DPI Loop" },
buttonOptions: ["Default", "Polling Loop", "Lighting mode cycle", "Toggle optical / magnetic", "DPI Loop", "Disabled"],
lighting: { zone: "Receiver", modes: ["Off", "Static", "Breathing single", "Spectrum"], mode: "Static", color: "#20a080", color2: null,
colorModes: ["Static", "Breathing single"], dualColorModes: [], reactiveModes: ["Breathing single", "Spectrum"],
speeds: [1, 2, 3, 4, 5], speed: 3, brightness: 100, brightnessLevels: [25, 50, 75, 100] },
},
keychronMouse: { pairing: { mask: 9, holdTime: 4 }, factoryReset: true,
dynamicDpi: { profile: 0, enabled: false, mode: 0, points: [{ speed: 0, gain: 16 }, { speed: 40, gain: 24 }, { speed: 80, gain: 32 }, { speed: 140, gain: 44 }, { speed: 200, gain: 56 }] } },
magneticButtons: {
buttons: [0, 1].map(() => ({ switchType: "magnetic" as const, triggerPoint: 4, rapidTrigger: 1, rapidTriggerEnabled: false })),
triggerPointRange: { min: 1, max: 12 }, rapidTriggerRange: { min: 1, max: 11 }, rapidTriggerUnit: "level",
rapidTriggerSwitch: true, canChooseSwitchType: true, calibration: null, liveDepth: true,
},
} },
"nape-pro": { label: "Keychron Nape Pro", status: KEYCHRON },
"mx-master-3s": { label: "Logitech MX Master 3S", status: LOGITECH_MX_MASTER_3S },
g703: { label: "Logitech G703", status: LOGITECH_G703 },
Expand Down
2 changes: 2 additions & 0 deletions src/device/preview/preview-modes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const PREVIEW_KEYS = [
"finalmouse-slx",
"ninjutso",
"nape-pro",
"keychron-g6-he",
"mx-master-3s",
"g703",
"gwolves-pro",
Expand Down Expand Up @@ -91,6 +92,7 @@ export function parsePreviewMode(value: string | null): PreviewMode | null {
case "finalmouse": return "finalmouse";
case "finalmouse-slx": return "finalmouse-slx";
case "ninjutso": return "ninjutso";
case "keychron-g6-he": return "keychron-g6-he";
case "keychron":
case "keychron-nape":
case "nape-pro": return "nape-pro";
Expand Down
3 changes: 2 additions & 1 deletion src/device/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ import type { PreviewMode } from "./preview/preview-modes";
import type { DriverTraits } from "./traits";
import type { M2NexProfile } from "./m2nex-profiles";

export type WorkspaceTab = "overview" | "performance" | "buttons" | "macro" | "lighting" | "profiles" | "advanced";
export type WorkspaceTab = "overview" | "performance" | "buttons" | "macro" | "lighting" | "receiver" | "profiles" | "advanced";

export const WORKSPACE_TAB_ORDER: readonly WorkspaceTab[] = [
"overview",
"performance",
"buttons",
"macro",
"lighting",
"receiver",
"profiles",
"advanced",
];
Expand Down
19 changes: 19 additions & 0 deletions src/features/devices/ActuationGauge.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { t } from "../../i18n/index";
import type { InterfaceLocale } from "../settings/interface-preferences";

export function ActuationGauge({ value, min, max, disabled, locale }: {
value: number | null; min: number; max: number; disabled: boolean;
locale: InterfaceLocale;
}) {
return <div className="actuation-gauge" data-disabled={disabled}>
<div className="actuation-ticks" aria-hidden="true">
{Array.from({ length: max - min + 1 }, (_, i) => <i key={i} data-current={value === min + i}
data-zone={i < 3 ? "easy" : i < 7 ? "recommended" : "hard"} />)}
</div>
<div className="actuation-legend">
<span data-zone="easy">{t(locale, "magnetic.easy")}</span>
<span data-zone="recommended">{t(locale, "magnetic.recommended")}</span>
<span data-zone="hard">{t(locale, "magnetic.hard")}</span>
</div>
</div>;
}
Loading
Loading