OpenLogi
功能(Features)

0x4522 · disableKeysByUsage

通过 HID Usage 码禁用或重新启用任意键盘按键——累积地向禁用集合添加或移除 Usage,或一次性全部清除。

通过 8 位 HID Usage 码选择性禁用任意键盘按键。与仅切换固定锁定键集合的 0x4521disableKeys)不同,本功能可对标准键盘页面内的任意 Usage 进行操作,且每次调用会累积变更。getCapabilities(function 0)报告设备最多可同时保持禁用的 Usage 数量。

disableKeys(function 1)将 Usage 追加到已禁用集合中而非替换它;enableKeys(function 2)从集合中移除指定 Usage;enableAllKeys(function 3)一次性清空整个集合。Usage 以长报文包的形式发送,每包最多 16 字节,0x00 作为列表终止符——其自身不能被禁用。

规格: Logitech HID++ 2.0 —— disableKeysByUsage用于: openlogi-hidpp 中的类型化封装。

Function reference

The DisableKeysByUsageFeature wrapper (0x4522) exposes:

Methods

FunctionHID++ fnSignatureReturns
get_capabilities0()u8
disable_keys1(usages: &[u8])()
enable_keys2(usages: &[u8])()
enable_all_keys3()()

All methods are async and return Result<…, Hidpp20Error>.

disable_keys and enable_keys split the usage slice into long-report packets of up to 16 bytes each and send them sequentially; the device accumulates the results. A usage value of 0x00 acts as the list terminator and is rejected with InvalidArgument before any packet is sent.

Wire format

get_capabilities and enable_all_keys use the 7-byte short report (3-byte payload). disable_keys and enable_keys use the 20-byte long report (16-byte payload) and may issue multiple requests for large usage lists. Responses are always read from the 16-byte extended payload (extend_payload()).

get_capabilities (fn 0)

Request: [0x00, 0x00, 0x00] — no arguments.

Response (byte → field):

ByteFieldNotes
0max_usagesMaximum number of usages the device can hold disabled simultaneously
1–15Unused / zero

disable_keys (fn 1)

One long-report request is sent per chunk of up to 16 usages. Requests are sent sequentially; the device accumulates all received usages into its disabled set.

Request (16-byte long payload per packet):

BytesFieldNotes
0–15usages[0..16]Up to 16 HID usage bytes; remaining bytes in a partial chunk are 0x00 (end-of-list terminator). A full 16-byte packet carries no explicit terminator.

Response: not inspected by the crate (the call succeeds if no error is returned).

enable_keys (fn 2)

Same wire layout as disable_keys (fn 1), but removes the listed usages from the disabled set instead of adding them. Enabling a usage that is not currently disabled is a no-op on the device.

Request (16-byte long payload per packet):

BytesFieldNotes
0–15usages[0..16]Same packetization rules as disable_keys.

Response: not inspected by the crate.

enable_all_keys (fn 3)

Request: [0x00, 0x00, 0x00] — no arguments; clears the entire disabled-usage set in one call.

Response: not inspected by the crate.

Usage (Rust)

use hidpp::{device::Device, feature::disable_keys_by_usage::DisableKeysByUsageFeature};

// device: mut Device, already created via Device::new(channel, index)
device.enumerate_features().await?;
if let Some(feat) = device.get_feature::<DisableKeysByUsageFeature>() {
    // Query how many usages the device can disable simultaneously.
    let max_usages = feat.get_capabilities().await?;
    println!("Device supports up to {max_usages} disabled usages");

    // Disable F1–F3 (HID usages 0x3a, 0x3b, 0x3c) — cumulative, does not clear existing set.
    feat.disable_keys(&[0x3a, 0x3b, 0x3c]).await?;

    // Re-enable F2 only.
    feat.enable_keys(&[0x3b]).await?;

    // Clear all disabled keys at once.
    feat.enable_all_keys().await?;
}

本页目录