// A fake Finalmouse Starlight X for looking at the UI without hardware // (OPENMOUSE_MOCK=slx, ulx, x3 or mag; a trailing "!" hides the real devices). Nothing here talks to a device: writes are accepted // and only the in-memory status changes. export const isMockKey = (key: string) => key.startsWith("mock:"); /** Which fake devices OPENMOUSE_MOCK asked for ("slx", "ulx", "x3", or a comma list). */ export const mockCandidates = (wanted: string) => [ ...(wanted.includes("slx") ? [{ info: { key: "mock:slx", vendorId: 0x361d, productId: 0x0100, productString: "Starlight X (mock)", manufacturerString: "Finalmouse", collections: [] }, brands: ["Finalmouse"], }] : []), ...(wanted.includes("ulx") ? [{ info: { key: "mock:ulx", vendorId: 0x361d, productId: 0x0100, productString: "Finalmouse UltralightX (mock)", manufacturerString: "Finalmouse", collections: [] }, brands: ["Finalmouse"], }] : []), ...(wanted.includes("mag") ? [{ info: { key: "mock:mag", vendorId: 0x373b, productId: 0x1000, productString: "Magnetic mouse (mock)", manufacturerString: "Lamzu", collections: [] }, brands: ["Lamzu"], }] : []), ...(wanted.includes("kb") ? [{ info: { key: "mock:kb", vendorId: 0x1ca6, productId: 0x1b10, productString: "Keyboard (mock)", manufacturerString: "Wuque Studio", collections: [] }, brands: ["Wuque Studio"], kind: "keyboard", }] : []), ...(wanted.includes("x3") ? [{ info: { key: "mock:x3", vendorId: 0x046d, productId: 0xc0a9, productString: "PRO X 3 Superstrike (mock)", manufacturerString: "Logitech", collections: [] }, brands: ["Logitech"], }] : []), ]; export const mockKeyboard = () => ({ brand: "Wuque Studio", name: "Mock keyboard", connectionType: "Wired", firmwareVersion: "1.0.0.0", serial: "KB-0001", activeProfile: 0, pollingRateHz: 1000, supportedPollingRates: [1000, 4000, 8000], }); /** A made-up two-row board for the keyboard pages. Nothing is remembered. */ export const mockKeyboardOp = (op: string, args: any): unknown => { const actuation = { travel: 1.5, rtPress: 0.3, rtRelease: 0.3, deadPress: 0.2, deadRelease: 0.2 }; const key = (row: number, col: number, x: number, w: number, code: number, label: string) => ({ row, col, x, y: row, w, code, label, standard: code, standardLabel: label, actuation }); if (op === "keys") { return { layer: args.layer, layers: 4, width: 4, keys: [key(0, 0, 0, 1, 20, "Q"), key(0, 1, 1, 1, 26, "W"), key(0, 2, 2, 2, 8, "E"), key(1, 0, 0, 4, 44, "Space")], categories: [{ name: "Keys", keys: [{ code: 4, label: "A" }, { code: 5, label: "B" }] }], }; } if (op === "setActuation") return args.keys.map(([row, col]: number[]) => ({ row, col, actuation: { ...actuation, ...args.patch } })); if (op === "setKey") return { row: args.row, col: args.col, code: args.code, label: args.code === 4 ? "A" : "B" }; if (op === "lighting") return { on: true, effect: 1, brightness: 80, speed: 40, colour: 7, palette: [[255, 0, 0], [0, 255, 0]] }; if (op === "setLighting") return { ...args, palette: [[255, 0, 0], [0, 255, 0]] }; return true; }; /** A slow press and release on each button, for looking at the travel graph. */ export const mockDepths = () => { const now = Date.now(); const press = (offset: number) => Math.max(0, Math.sin(now / 400 + offset)) * 100; return [{ ageMs: 0, depths: [press(0), press(2)] }]; }; export const mockBrand = (key: string) => (key === "mock:x3" ? "Logitech" : key === "mock:mag" ? "Lamzu" : "Finalmouse"); export const mockStatus = (key: string) => (key === "mock:x3" ? mockX3() : key === "mock:mag" ? mockMag() : key === "mock:ulx" ? mockUlx() : mockSlx()); // Ultralight X as FinalmouseHidClient.readStatus() reports it: the whole // polling ladder and Motion Sync are adjustable, lift-off is the legacy 1/2 mm // pair, and none of the SLX-only click/TMR/PAW/profile fields are present. const mockUlx = () => ({ brand: "Finalmouse", name: "Finalmouse UltralightX", ui: { family: "finalmouse-ulx", defaultDisplayName: "Finalmouse UltralightX", hideUnsupportedPollingRates: true, forceShowBattery: true }, batteryPercent: 91, batteryVoltageMv: 4080, batteryState: "Discharging", dpi: 1600, pollingRateHz: 2000, supportedPollingRates: [500, 1000, 2000, 4000, 8000], activeProfile: null, unitId: "ULX-0A1B2C3D", connectionType: "Wireless", connectionDetail: "2.4 GHz receiver ยท -52 dBm", motionSync: true, signalStrength: 3, liftOffDistance: "Medium", supportedLiftOffDistances: ["Medium", "High"], liftOffScale: null, finalmouseIsSlx: false, finalmouseDongleLedMode: 1, finalmouseTournamentScrollMode: 0, finalmouseTournamentScrollTimeoutMs: 500, firmware: ["Mouse 1.0.8", "Dongle RF 1.0.3", "Dongle USB 1.0.5"], }); // A Hall-effect mouse as the Lamzu driver reports it: per-button trigger and // release travel, rapid trigger in ms with no switch of its own, selectable // switch type, and a sensor angle. const mockMag = () => ({ brand: "Lamzu", name: "Magnetic mouse", batteryPercent: 77, batteryState: "Discharging", connectionType: "Wireless", dpi: 1600, pollingRateHz: 1000, supportedPollingRates: [500, 1000, 2000, 4000], activeProfile: 1, angleTuning: 5, mockAngleTuningWritable: true, keychronMouse: { dynamicDpi: { enabled: false, mode: 0, points: [0, 10, 20, 50, 80].map((speed) => ({ speed, gain: 16 })) } }, dpiStages: [400, 800, 1600, 3200], dpiStagesY: [400, 800, 1600, 3200], dpiStageColors: ["#ff0000", "#00ff00", "#0000ff", "#ffff00"], activeDpiStage: 2, ui: { dpiStageEditor: { maxStages: 6, countEditable: true, minDpi: 50, maxDpi: 30000, stepDpi: 50 } }, magneticButtons: { buttons: [ { switchType: "magnetic", triggerPoint: 3, releasePoint: 3, rapidTrigger: 4, rapidTriggerEnabled: true }, { switchType: "magnetic", triggerPoint: 5, releasePoint: null, rapidTrigger: null, rapidTriggerEnabled: false }, ], triggerPointRange: { min: 1, max: 10 }, liveDepth: true, releasePointRange: { min: 1, max: 10 }, rapidTriggerRange: { min: 1, max: 15 }, rapidTriggerUnit: "ms", rapidTriggerSwitch: false, canChooseSwitchType: true, calibration: "calibrated", }, }); const mockX3 = () => ({ brand: "Logitech", name: "PRO X 3 Superstrike", batteryPercent: 64, batteryState: "Discharging", connectionType: "Wireless", dpi: 1600, pollingRateHz: 4000, supportedPollingRates: [125, 250, 500, 1000, 2000, 4000, 8000], firmware: ["MPM 4.1.18", "BL1 3.0.4"], unitId: "3EC2C515", supportsSeparateDpiAxes: false, liftOffDistance: "Low", supportedLiftOffDistances: ["Low", "Medium", "High"], gamingSurfaceMode: "Auto", deviceMode: "Onboard", onboardProfileFormat: { supported: true, id: 8, formatId: 8, writable: true }, activeProfile: 1, analogButtonTuning: { maxActuation: 10, maxRapidTrigger: 5, maxHaptics: 5, buttons: [ { actuation: 5, rapidTrigger: 2, haptics: 3, rapidTriggerEnabled: false }, { actuation: 5, rapidTrigger: 2, haptics: 3, rapidTriggerEnabled: true }, ], }, }); const mockSlx = () => ({ brand: "Finalmouse", name: "Starlight X", batteryPercent: 82, batteryState: "Discharging", connectionType: "Wireless", dpi: 800, pollingRateHz: 1000, // PerfectPolling: fixed rate, nothing selectable (as the real driver reports it). supportedPollingRates: [] as number[], ui: { family: "finalmouse-slx", hideUnsupportedPollingRates: true, forceShowBattery: true, pollingReadOnly: true, hideMotionSync: true }, finalmouseIsSlx: true, finalmouseDongleLedMode: 1, finalmouseClickModeL: 1, finalmouseClickModeR: 0, finalmouseClickReleaseL: 0, finalmouseClickReleaseR: 2, finalmouseTmrThrL: 15, finalmouseTmrThrR: 20, finalmouseTmrHystL: 200, finalmouseTmrHystR: 180, finalmouseTmrMspL: 420, finalmouseTmrMspR: 435, finalmousePawLodMm: 1.1, finalmousePawLodCustom: true, finalmouseProfileCount: 4, finalmouseProfileActive: 1, finalmouseProfileEnabledMask: 0b0111, finalmouseProfileNames: { 0: "FPS", 1: "Desktop", 2: "Tarkov" }, }); /** Stored profiles of the fake Superstrike, so the Profiles and Buttons tabs have something to show. */ let mockCurrent = 1; let mockMode = "Onboard"; const actions = ["Left click", "Right click", "Middle click", "Back", "Keyboard: Ctrl+C"]; export const mockOnboard = (allActions: string[]) => ({ profiles: [1, 2, 3].map((sector) => ({ sector, enabled: true, isCurrent: sector === mockCurrent, name: ["Default", "Valorant", "Desktop"][sector - 1], dpiStages: [{ dpi: 400 }, { dpi: 800 }, { dpi: 1600 }, { dpi: 3200 }], defaultDpiIndex: 2, reportRateWireless: [4000, 8000, 1000][sector - 1], reportRateWired: 8000, buttonAssignments: actions.map((action) => ({ layer: "primary", button: 0, action })), })), actions: allActions, }); export const mockOnboardAction = (action: string, value: any) => { if (action === "useProfile") { mockCurrent = Number(value); mockMode = "Onboard"; } else mockMode = value; return value; };