Skip to content
Draft
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
5 changes: 5 additions & 0 deletions public/devices/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file added public/devices/logitech-k400-plus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 23 additions & 1 deletion src/device/logitech-keyboard.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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 }
Expand Down Expand Up @@ -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))) {
Expand Down
68 changes: 68 additions & 0 deletions src/features/devices/cards/LogitechInputCards.tsx
Original file line number Diff line number Diff line change
@@ -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<number, I18nKey> = new Map([
[45, "kb.logitechGestureNaturalScroll"],
[43, "kb.logitechGestureVerticalScroll"],
[42, "kb.logitechGestureHorizontalScroll"],
[34, "kb.logitechGestureFnClick"],
]);
const GESTURE_ORDER = [...GESTURE_LABELS.keys()];

const KEY_LABELS: Readonly<Record<LogitechDisableKey, I18nKey>> = {
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 ? <article className="setting-card keyboard-workspace-card">
<div className="setting-heading"><Keyboard aria-hidden /><h2>{t(locale, "kb.logitechDisableKeys")}</h2></div>
{disabledKeys.supported.map(key => {
const disabled = disabledKeys.disabled.includes(key);
return <SwitchRow key={key} label={t(locale, KEY_LABELS[key])} disabled={busy} value={disabled}
onChange={off => void control.applyKeyboardCommand({
kind: "logitechDisabledKeys",
keys: off ? [...disabledKeys.disabled, key] : disabledKeys.disabled.filter(entry => entry !== key),
})} />;
})}
<p className="setting-note">{t(locale, "kb.logitechDisableKeysVolatile")}</p>
</article> : null}
{gestures.length || speed ? <article className="setting-card keyboard-workspace-card">
<div className="setting-heading"><MousePointer2 aria-hidden /><h2>{t(locale, "kb.logitechTouchpad")}</h2></div>
{speed ? <StepperSlider id="logitech-pointer-speed" label={t(locale, "kb.logitechPointerSpeed")}
value={speed.value} min={speed.min} max={speed.max} step={8}
scale={[percent(speed.min), percent(LOGITECH_POINTER_SCALE_NORMAL), percent(speed.max)]}
formatValue={percent} disabled={busy}
onCommit={value => control.applyKeyboardCommand({ kind: "logitechPointerSpeed", value })} /> : null}
{gestures.map(gesture => <SwitchRow key={gesture.id} label={t(locale, GESTURE_LABELS.get(gesture.id)!)} disabled={busy}
value={gesture.enabled}
onChange={enabled => void control.applyKeyboardCommand({ kind: "logitechGesture", gesture: gesture.id, enabled })} />)}
{anyVolatile ? <p className="setting-note">{t(locale, "kb.logitechTouchpadVolatile")}</p> : null}
</article> : null}
</>;
}
8 changes: 8 additions & 0 deletions src/features/devices/cards/LogitechKeyboardPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
Expand Down Expand Up @@ -72,9 +73,16 @@ export function LogitechKeyboardPanel({ snapshot }: { snapshot: ControlSnapshot
{status?.battery?.percent != null ? <div><dt>{t(locale, "kb.logitechBattery")}</dt><dd>{status.battery.percent}%</dd></div>
: status?.battery?.level ? <div><dt>{t(locale, "kb.logitechBattery")}</dt><dd>{t(locale, `kb.logitechBattery${status.battery.level}`)}</dd></div> : null}
</dl>
{status?.fnInversion != null ? <>
{/* Fn inversion on means media keys without Fn, so "F1–F12 without Fn" is its opposite. */}
<SwitchRow label={t(locale, "kb.logitechFnInversion")} disabled={busy} value={!status.fnInversion}
onChange={plainFKeys => void control.applyKeyboardCommand({ kind: "logitechFnInversion", enabled: !plainFKeys })} />
<p className="setting-note">{t(locale, "kb.logitechFnInversionNote")}</p>
</> : null}
{performanceNotice}
{refresh}
</article> : null}
{tab === "overview" && status ? <LogitechInputCards locale={locale} busy={busy} status={status} /> : null}
{tab === "performance" ? <article className="setting-card keyboard-workspace-card">
<div className="setting-heading"><div><h2>{t(locale, "kb.performance")}</h2></div></div>
{polling ? <div className="keyboard-fields">
Expand Down
16 changes: 16 additions & 0 deletions src/i18n/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
16 changes: 16 additions & 0 deletions src/i18n/locales/vendor-keyboard-ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
2 changes: 2 additions & 0 deletions src/shared/device-images.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -256,6 +257,7 @@ const LOCAL_OVERRIDES: Readonly<Record<string, string>> = {
"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",
Expand Down