Skip to content

feat(gui): expose the Fn-lock toggle in the Device tab - #1450

Open
4ni1ak wants to merge 2 commits into
AprilNEA:masterfrom
4ni1ak:feat/fn-lock-toggle-gui
Open

4ni1ak wants to merge 2 commits into
AprilNEA:masterfrom
4ni1ak:feat/fn-lock-toggle-gui

Conversation

@4ni1ak

@4ni1ak 4ni1ak commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • fn_lock: Option<bool> and its agent-side write path (apply_fn_locks in the orchestrator, driving HID++ 0x40a2/0x40a3) already exist, but nothing in the GUI could set it — I grepped all of openlogi-desktop and found zero references to fn_lock before this change. See [Feature]: MX Keys键盘功能区按键映射太少 #1310 (the linked comment specifically asks for "Fn+Esc toggle for hardware Fn-Lock").

Changes

  • crates/openlogi-core/src/config.rs: Config::set_fn_lock accessor, mirroring the existing set_invert_scroll/set_dpi_presets pair (fn_lock's reader already existed).
  • crates/openlogi-desktop/src/state/fn_lock.rs (new): AppState::current_device_supports_fn_lock/current_fn_lock/commit_fn_lock, following the same shape as state/scroll.rs's invert_scroll wiring.
  • crates/openlogi-desktop/src/app/detail.rs: a Fn-lock Switch row in the Device tab's existing configuration card, shown only when the active device is a keyboard.
  • crates/openlogi-ui/locales/*.toml: two new keys (device.fn_lock, device.fn_lock_description), added at the same position in every catalog; non-English catalogs carry the English text pending Crowdin translation.

Scope

This only covers the Fn-lock toggle. The other two asks in #1310's comment (Fn as a live chord modifier for custom shortcuts, and independent F13–F19 press vs. Fn+press overrides) are much larger — new OS-hook-layer work and a real product-design question respectively — and are intentionally left out of this PR.

Testing

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace (all green, including a new test in state::fn_lock::tests covering the default-false/toggle round trip)
  • cargo test -p openlogi-ui locale (catalog parity) and cargo test -p openlogi-desktop i18n
  • cargo doc --workspace --no-deps --document-private-items (excluding the GPUI crates)
  • Not visually verified — no safe display available in this environment to screenshot the new toggle. A maintainer/reviewer should confirm it renders and round-trips through config.toml before merging.

Fixes #1310

fn_lock: Option<bool> and the agent-side write path (HID++
0x40a2/0x40a3, apply_fn_locks in the orchestrator) have existed for a
while, but nothing in the GUI ever let a user set it -- grepping
openlogi-desktop for fn_lock turned up nothing. The only way to change
Fn-lock was the keyboard's own onboard toggle, with no way to see or
set the state OpenLogi persists and re-applies on reconnect.

Add a Switch to the Device tab's configuration card, shown only for
keyboards, wired to a new Config::set_fn_lock accessor mirroring the
existing set_invert_scroll/set_dpi_presets pair. No wire or schema
change -- fn_lock already round-trips through config.toml.

Fixes AprilNEA#1310
@4ni1ak
4ni1ak requested a review from AprilNEA as a code owner September 17, 2026 03:25
@greptile-apps

greptile-apps Bot commented Sep 17, 2026

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

The PR appears safe to merge; the previously reported unsupported-keyboard behavior is fixed by capability-based gating, with no new actionable defects identified.

Summary

The PR exposes the existing Fn-lock configuration through the desktop Device tab and now advertises support only when the keyboard reports a compatible HID++ feature.

  • Adds capability detection for HID++ 0x40a2 and 0x40a3.
  • Persists Fn-lock changes and requests an agent configuration reload.
  • Adds the capability to IPC serialization and advances the protocol version.
  • Adds localized labels and state-level coverage for supported and unsupported keyboards.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
    A[Enumerate HID++ features] --> B{0x40a2 or 0x40a3?}
    B -->|Yes| C[Capabilities.fn_lock = true]
    B -->|No| D[Capabilities.fn_lock = false]
    C --> E[DeviceRecord capabilities]
    D --> E
    E --> F{Fn-lock supported?}
    F -->|Yes| G[Render Device-tab switch]
    F -->|No| H[Hide switch]
    G --> I[Persist Config.fn_lock]
    I --> J[Reload agent configuration]
    J --> K[Apply Fn-lock to hardware]
Loading

Reviews (2) · Last reviewed commit: "fix(gui,core,ipc): gate the Fn-lock togg..."

Comment thread crates/openlogi-desktop/src/state/fn_lock.rs
current_device_supports_fn_lock() only checked DeviceKind::Keyboard, so
a keyboard exposing neither 0x40a2 nor 0x40a3 still showed and
persisted the toggle while the background hardware write silently
logged an unsupported-feature error and changed nothing — the UI kept
reporting a state the device never applied.

Adds Capabilities::fn_lock, derived from the feature table like every
other capability flag, and gates the toggle on it instead of kind.
Capabilities rides the IPC wire, so this bumps PROTOCOL_VERSION 31->32
and regenerates the wire_format golden.

Addresses the Greptile P1 finding on AprilNEA#1450.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: MX Keys键盘功能区按键映射太少

1 participant