OpenLogi

0x4220 · LockKeyState

Read the Num Lock, Caps Lock, and Scroll Lock state, or decode an unsolicited lock-key report.

LockKeyState reports the engaged lock keys on keyboards that expose feature 0x4220. OpenLogi reads the state and uses later broadcasts for lock-key notices.

Spec: No public Logitech specification. Layout reverse-engineered from Logi Options+ 2.8 (static analysis). Used by: Lock-key notices.

Function reference

LockKeyStateFeature is creatable for feature version 0.

Methods

FunctionHID++ fnSignatureReturns
get_lock_state0()LockKeys
decode_broadcastevent decoder(&[u8; 16])LockKeys

get_lock_state is async and returns Result<LockKeys, Hidpp20Error>. decode_broadcast is an infallible associated function.

Types

LockKeys

LockKeys is a retained u8 bitfield. OpenLogi keeps unnamed bits rather than rejecting a newer keyboard state.

FieldBitDescription
NUM_LOCK1 << 0Num Lock is engaged.
CAPS_LOCK1 << 1Caps Lock is engaged.
SCROLL_LOCK1 << 2Scroll Lock is engaged.

Events

OpenLogi has no listen() method for this feature. The inventory path filters software ID 0, then calls decode_broadcast for reports at this feature index.

EventPayloadDescription
Lock-key stateLockKeysThe complete current lock-key bitmap.

Wire format

get_lock_state uses a 3-byte short request payload. OpenLogi normalizes its reply to 16 bytes before decoding byte 0.

get_lock_state (fn 0)

Request:

ByteFieldNotes
0–2—No parameters. OpenLogi sends 0x00, 0x00, 0x00.

Response:

ByteFieldNotes
0lock_keysLockKeys bitmap.
1–15—OpenLogi ignores these bytes.

Lock-key broadcast

Logi Options+ 2.8 reads byte 0 from any unsolicited report on this feature. OpenLogi follows that rule and does not validate the report function.

ByteFieldNotes
0lock_keysSame LockKeys bitmap as get_lock_state. Options+ 2.8
1–15—OpenLogi ignores these bytes.

How OpenLogi uses it

Since v0.8.15, OpenLogi reads the lock state once per online connection. That baseline lets it identify each named bit that changed in a later broadcast.

OpenLogi queues one notice update for each changed named key. It does not reconcile inventory or increase a settings revision for these transient states.

The agent honors lock_key_notifications, which defaults to true. It shows Caps Lock on macOS, Linux, and Windows, but Num Lock and Scroll Lock only on Linux and Windows.

OpenLogi does not write 0x4220 or restore state at exit. See On-screen notices for the visible behavior.

Usage (Rust)

use hidpp::{
    device::Device,
    feature::lock_key_state::{LockKeyStateFeature, LockKeys},
};

// `device` is a discovered HID++ device.
device.enumerate_features().await?;
if let Some(feature) = device.get_feature::<LockKeyStateFeature>() {
    let keys = feature.get_lock_state().await?;
    if keys.contains(LockKeys::CAPS_LOCK) {
        println!("Caps Lock is on");
    }
}

On this page