diff --git a/public/devices/README.md b/public/devices/README.md index 5e618273..2699d97f 100644 --- a/public/devices/README.md +++ b/public/devices/README.md @@ -370,6 +370,11 @@ from Logitech G. The local preview uses the official CDN's transparent trim at 900 pixels wide. Use the existing artwork upload workflow when preparing the upstream contribution. +`logitech-k400-plus.png` is Logitech's black K400 Plus product photo (top-down, +UK layout), supplied by the contributor who tested the K400 Plus driver. It is +vendor product art: treat it as a request for the maintainer upload workflow, +like the other Logitech renders, before it leaves this local override. + `steelseries-aerox-3-wireless.png` is the SteelSeries Aerox 3 Wireless (wired `0x1038:0x183a`, 2.4 GHz `0x1038:0x1838`; the CS2 Dragon Lore Edition, wired `0x1038:0x187a` and 2.4 GHz `0x1038:0x1878`, and the Gen 2 match the same name rule). Normalized from diff --git a/public/devices/logitech-k400-plus.png b/public/devices/logitech-k400-plus.png new file mode 100644 index 00000000..8af91ff1 Binary files /dev/null and b/public/devices/logitech-k400-plus.png differ diff --git a/src/device/logitech-keyboard.ts b/src/device/logitech-keyboard.ts index aad84561..aee6ba02 100644 --- a/src/device/logitech-keyboard.ts +++ b/src/device/logitech-keyboard.ts @@ -1,6 +1,6 @@ import { LogitechKeyboardHidClient, type LogitechKeyboardReceiverEndpoint } from "@openmouse/keyboard-protocol/drivers/logitech/hid"; import type { KeyboardStatus } from "@openmouse/keyboard-protocol/drivers"; -import { logitechRgbMode, type LogitechAnimation, type LogitechOnboardMemory, type LogitechOnboardProfileChanges, type LogitechRgbColor, type LogitechStartupLighting, type LogitechRgbMode, type LogitechRgbTarget, type LogitechRgbTimers, type LogitechRgbWaveDirection } from "@openmouse/keyboard-protocol/logitech"; +import { logitechRgbMode, type LogitechDisableKey, type LogitechAnimation, type LogitechOnboardMemory, type LogitechOnboardProfileChanges, type LogitechRgbColor, type LogitechStartupLighting, type LogitechRgbMode, type LogitechRgbTarget, type LogitechRgbTimers, type LogitechRgbWaveDirection } from "@openmouse/keyboard-protocol/logitech"; import type { KeyboardClient } from "./keyboard-client.ts"; import type { KeyboardCommand, KeyboardWorkspace } from "./keyboard-workspace.ts"; import type { KeyboardIdentityView, KeyboardPollingView } from "./types.ts"; @@ -11,6 +11,10 @@ export type LogitechKeyboardCommand = | { kind: "logitechBrightness"; value: number } | { kind: "logitechRapidTrigger"; enabled: boolean } | { kind: "logitechKeyPriority"; enabled: boolean } + | { kind: "logitechFnInversion"; enabled: boolean } + | { kind: "logitechDisabledKeys"; keys: readonly LogitechDisableKey[] } + | { kind: "logitechGesture"; gesture: number; enabled: boolean } + | { kind: "logitechPointerSpeed"; value: number } | { kind: "logitechRgbEffect"; mode: LogitechRgbMode; cluster?: number; target?: LogitechRgbTarget; color?: LogitechRgbColor; intensity?: number; periodMs?: number; direction?: LogitechRgbWaveDirection } | { kind: "logitechZoneColors"; colors: readonly (LogitechRgbColor & { zone: number })[] } | { kind: "logitechLiveZones"; colors: readonly (LogitechRgbColor & { zone: number })[]; wake: boolean } @@ -161,6 +165,24 @@ export class LogitechKeyboardClient implements KeyboardClient { if (state.analog?.keyPriority === null || state.analog?.keyPriority === undefined) throw new Error("Key priority is not available on this keyboard."); await this.client.setAnalogKeyPriority(action.enabled); break; + case "logitechFnInversion": + if (state.fnInversion === null || state.fnInversion === undefined) throw new Error("Fn inversion is not available on this keyboard."); + await this.client.setFnInversion(action.enabled); + break; + case "logitechDisabledKeys": + if (!state.disabledKeys) throw new Error("Disabling keys is not available on this keyboard."); + await this.client.setDisabledKeys(action.keys); + break; + case "logitechGesture": + if (!state.touchpad?.gestures.some(gesture => gesture.id === action.gesture && gesture.canEnable)) { + throw new Error("That touchpad gesture cannot be changed on this keyboard."); + } + await this.client.setGesture(action.gesture, action.enabled); + break; + case "logitechPointerSpeed": + if (!state.touchpad?.pointerSpeed) throw new Error("Pointer speed is not available on this keyboard."); + await this.client.setPointerSpeed(action.value); + break; case "logitechRgbEffect": { const clusters = state.lighting?.rgbZones.filter(zone => action.cluster === undefined || zone.index === action.cluster); if (!clusters?.length || !clusters.every(zone => zone.effects.some(effect => logitechRgbMode(effect.id) === action.mode))) { diff --git a/src/features/devices/cards/LogitechInputCards.tsx b/src/features/devices/cards/LogitechInputCards.tsx new file mode 100644 index 00000000..360c9b51 --- /dev/null +++ b/src/features/devices/cards/LogitechInputCards.tsx @@ -0,0 +1,68 @@ +import type { ReactNode } from "react"; +import { LOGITECH_POINTER_SCALE_NORMAL, type LogitechDisableKey, type LogitechKeyboardState } from "@openmouse/keyboard-protocol/logitech"; +import { Keyboard, MousePointer2 } from "lucide-react"; +import * as control from "../../../device/controller"; +import { t, type I18nKey } from "../../../i18n/index"; +import type { InterfaceLocale } from "../../settings/interface-preferences"; +import { StepperSlider, SwitchRow } from "../../../shared/ui"; + +/** + * Gestures offered as settings, in display order. Tested on a K400 Plus: + * the individual tap gestures (1, 2, 10, 30) toggle without effect (the + * firmware does not flag them for a UI), and the edge swipes (64–67) and + * pinch zoom (84) are Windows 8 charms that current Windows ignores. Tapping + * follows gesture 34, the Fn + left click switch, so it is the only tap row. + */ +const GESTURE_LABELS: ReadonlyMap = new Map([ + [45, "kb.logitechGestureNaturalScroll"], + [43, "kb.logitechGestureVerticalScroll"], + [42, "kb.logitechGestureHorizontalScroll"], + [34, "kb.logitechGestureFnClick"], +]); +const GESTURE_ORDER = [...GESTURE_LABELS.keys()]; + +const KEY_LABELS: Readonly> = { + capsLock: "kb.logitechDisableCapsLock", + numLock: "kb.logitechDisableNumLock", + scrollLock: "kb.logitechDisableScrollLock", + insert: "kb.logitechDisableInsert", + windows: "kb.logitechDisableWindows", +}; + +/** Pointer speed as a percentage of the normal scale factor. */ +const percent = (scale: number): string => `${Math.round(scale * 100 / LOGITECH_POINTER_SCALE_NORMAL)}%`; + +export function LogitechInputCards({ locale, busy, status }: { locale: InterfaceLocale; busy: boolean; status: LogitechKeyboardState }): ReactNode { + const disabledKeys = status.disabledKeys; + const touchpad = status.touchpad; + const gestures = (touchpad?.gestures.filter(gesture => GESTURE_LABELS.has(gesture.id)) ?? []) + .sort((a, b) => GESTURE_ORDER.indexOf(a.id) - GESTURE_ORDER.indexOf(b.id)); + const speed = touchpad?.pointerSpeed; + const anyVolatile = gestures.some(gesture => !gesture.persistent) || !!speed; + return <> + {disabledKeys?.supported.length ?
+

{t(locale, "kb.logitechDisableKeys")}

+ {disabledKeys.supported.map(key => { + const disabled = disabledKeys.disabled.includes(key); + return void control.applyKeyboardCommand({ + kind: "logitechDisabledKeys", + keys: off ? [...disabledKeys.disabled, key] : disabledKeys.disabled.filter(entry => entry !== key), + })} />; + })} +

{t(locale, "kb.logitechDisableKeysVolatile")}

+
: null} + {gestures.length || speed ?
+

{t(locale, "kb.logitechTouchpad")}

+ {speed ? control.applyKeyboardCommand({ kind: "logitechPointerSpeed", value })} /> : null} + {gestures.map(gesture => void control.applyKeyboardCommand({ kind: "logitechGesture", gesture: gesture.id, enabled })} />)} + {anyVolatile ?

{t(locale, "kb.logitechTouchpadVolatile")}

: null} +
: null} + ; +} diff --git a/src/features/devices/cards/LogitechKeyboardPanel.tsx b/src/features/devices/cards/LogitechKeyboardPanel.tsx index c4b94913..0793a2bd 100644 --- a/src/features/devices/cards/LogitechKeyboardPanel.tsx +++ b/src/features/devices/cards/LogitechKeyboardPanel.tsx @@ -6,6 +6,7 @@ import { displayText, t } from "../../../i18n/index"; import { Palette, Power, Timer } from "lucide-react"; import { Segmented, StepperSlider, SwitchRow } from "../../../shared/ui"; import { logitechPerformanceControls } from "../workspace-tabs"; +import { LogitechInputCards } from "./LogitechInputCards"; import { LogitechClusterEffects, LogitechInactivity, LogitechStartupEditor, LogitechZoneEditor } from "./LogitechLightingEditor"; const MODES: readonly LogitechRgbMode[] = ["Off", "Static", "Cycling", "Wave", "Breathing single"]; @@ -72,9 +73,16 @@ export function LogitechKeyboardPanel({ snapshot }: { snapshot: ControlSnapshot {status?.battery?.percent != null ?
{t(locale, "kb.logitechBattery")}
{status.battery.percent}%
: status?.battery?.level ?
{t(locale, "kb.logitechBattery")}
{t(locale, `kb.logitechBattery${status.battery.level}`)}
: null} + {status?.fnInversion != null ? <> + {/* Fn inversion on means media keys without Fn, so "F1–F12 without Fn" is its opposite. */} + void control.applyKeyboardCommand({ kind: "logitechFnInversion", enabled: !plainFKeys })} /> +

{t(locale, "kb.logitechFnInversionNote")}

+ : null} {performanceNotice} {refresh} : null} + {tab === "overview" && status ? : null} {tab === "performance" ?

{t(locale, "kb.performance")}

{polling ?
diff --git a/src/i18n/index.ts b/src/i18n/index.ts index 048a283b..862d1052 100644 --- a/src/i18n/index.ts +++ b/src/i18n/index.ts @@ -2095,6 +2095,22 @@ const en = { "kb.logitechBatterygood": "Good", "kb.logitechBatteryfull": "Full", "kb.logitechKeyPriority": "Key priority", + "kb.logitechFnInversion": "F1–F12 without Fn", + "kb.logitechFnInversionNote": "When off, the top row sends media keys and Fn gives F1–F12. Some keyboards, such as the K400 Plus, forget this when they turn off; set it again after the keyboard restarts.", + "kb.logitechDisableKeys": "Disable keys", + "kb.logitechDisableKeysVolatile": "Some keyboards, such as the K400 Plus, forget disabled keys when they turn off; set them again after the keyboard restarts.", + "kb.logitechDisableCapsLock": "Disable Caps Lock", + "kb.logitechDisableNumLock": "Disable Num Lock", + "kb.logitechDisableScrollLock": "Disable Scroll Lock", + "kb.logitechDisableInsert": "Disable Insert", + "kb.logitechDisableWindows": "Disable the Windows key", + "kb.logitechTouchpad": "Touchpad", + "kb.logitechPointerSpeed": "Pointer speed", + "kb.logitechGestureFnClick": "Turn off tap-to-click (same as Fn + left click)", + "kb.logitechGestureHorizontalScroll": "Two-finger horizontal scroll", + "kb.logitechGestureVerticalScroll": "Two-finger vertical scroll", + "kb.logitechGestureNaturalScroll": "Natural scrolling", + "kb.logitechTouchpadVolatile": "The keyboard keeps the tap-to-click switch when it turns off, but forgets pointer speed and the scrolling switches. Logi Options+ applies those again in the background; here, set them again after the keyboard restarts.", "kb.logitechRgbEffect": "RGB effect", "kb.logitechStaticBlack": "Static (black)", "kb.logitechRgbNoReadback": "The keyboard does not report the active RGB effect.", diff --git a/src/i18n/locales/vendor-keyboard-ui.ts b/src/i18n/locales/vendor-keyboard-ui.ts index e7a2f704..6b77d1eb 100644 --- a/src/i18n/locales/vendor-keyboard-ui.ts +++ b/src/i18n/locales/vendor-keyboard-ui.ts @@ -134,6 +134,22 @@ export const VENDOR_KEYBOARD_UI_STRINGS = { "kb.logitechBatterygood": "Good", "kb.logitechBatteryfull": "Full", "kb.logitechKeyPriority": "Key priority", + "kb.logitechFnInversion": "F1–F12 without Fn", + "kb.logitechFnInversionNote": "When off, the top row sends media keys and Fn gives F1–F12. Some keyboards, such as the K400 Plus, forget this when they turn off; set it again after the keyboard restarts.", + "kb.logitechDisableKeys": "Disable keys", + "kb.logitechDisableKeysVolatile": "Some keyboards, such as the K400 Plus, forget disabled keys when they turn off; set them again after the keyboard restarts.", + "kb.logitechDisableCapsLock": "Disable Caps Lock", + "kb.logitechDisableNumLock": "Disable Num Lock", + "kb.logitechDisableScrollLock": "Disable Scroll Lock", + "kb.logitechDisableInsert": "Disable Insert", + "kb.logitechDisableWindows": "Disable the Windows key", + "kb.logitechTouchpad": "Touchpad", + "kb.logitechPointerSpeed": "Pointer speed", + "kb.logitechGestureFnClick": "Turn off tap-to-click (same as Fn + left click)", + "kb.logitechGestureHorizontalScroll": "Two-finger horizontal scroll", + "kb.logitechGestureVerticalScroll": "Two-finger vertical scroll", + "kb.logitechGestureNaturalScroll": "Natural scrolling", + "kb.logitechTouchpadVolatile": "The keyboard keeps the tap-to-click switch when it turns off, but forgets pointer speed and the scrolling switches. Logi Options+ applies those again in the background; here, set them again after the keyboard restarts.", "kb.logitechRgbEffect": "RGB effect", "kb.logitechStaticBlack": "Static (black)", "kb.logitechRgbNoReadback": "The keyboard does not report the active RGB effect.", diff --git a/src/shared/device-images.ts b/src/shared/device-images.ts index 150ed976..a7e848c1 100644 --- a/src/shared/device-images.ts +++ b/src/shared/device-images.ts @@ -32,6 +32,7 @@ function resolveDeviceImageFilename(_device: HIDDevice | null | undefined, displ function computeDeviceImageFilename(displayName: string): string { if (/\bg915\s*x\b.*\btkl\b/i.test(displayName)) return "logitech-g915-x-tkl.png"; + if (/\bk400\s*plus\b/i.test(displayName)) return "logitech-k400-plus.png"; // Lightspeed receivers are shared product IDs, so paired G502 X variants // must use the friendly name read from the mouse itself. if (/g502\s*x\s*plus/i.test(displayName)) return "logitech-g502-x-plus.png"; @@ -256,6 +257,7 @@ const LOCAL_OVERRIDES: Readonly> = { "vxe-r1-se.png": "/devices/vxe-r1-se.png", "redragon-m991.png": "/devices/redragon-m991.png", "logitech-g915-x-tkl.png": "/devices/logitech-g915-x-tkl.png", + "logitech-k400-plus.png": "/devices/logitech-k400-plus.png", "steelseries-aerox-3-wireless.png": "/devices/steelseries-aerox-3-wireless.png", "scyrox-v6.png": "/devices/scyrox-v6.png", "scyrox-v8.png": "/devices/scyrox-v8.png",