0x4522 · disableKeysByUsage
Disable or re-enable arbitrary keyboard keys by HID usage code — cumulatively add or remove usages from the disabled set, or clear all at once.
Selectively disable arbitrary keyboard keys by their 8-bit HID usage code. Unlike 0x4521
(disableKeys), which toggles a fixed set of lock keys, this feature operates on any usage in the
standard keyboard page and accumulates changes across calls. getCapabilities (function 0) reports
the maximum number of usages the device can hold disabled at once.
disableKeys (function 1) adds usages to the disabled set without replacing it; enableKeys
(function 2) removes specific usages from the set; enableAllKeys (function 3) clears the entire
set in one call. Usages are sent in long-report packets of up to 16 bytes each, with 0x00 acting
as the list terminator; it cannot itself be disabled.
Spec: Logitech HID++ 2.0 — disableKeysByUsage. Used by: Typed wrapper in
openlogi-hidpp.
Function reference
The DisableKeysByUsageFeature wrapper (0x4522) exposes:
Methods
| Function | HID++ fn | Signature | Returns |
|---|---|---|---|
get_capabilities | 0 | () | u8 |
disable_keys | 1 | (usages: &[u8]) | () |
enable_keys | 2 | (usages: &[u8]) | () |
enable_all_keys | 3 | () | () |
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):
| Byte | Field | Notes |
|---|---|---|
| 0 | max_usages | Maximum number of usages the device can hold disabled simultaneously |
| 1–15 | — | Unused / 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):
| Bytes | Field | Notes |
|---|---|---|
| 0–15 | usages[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):
| Bytes | Field | Notes |
|---|---|---|
| 0–15 | usages[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?;
}