OpenLogi
功能(Features)

0x8040 · brightnessControl

设备背光亮度控制——读取支持的亮度范围与步数、读写当前亮度值,并可独立开关背光照明。

控制设备的显示屏或背光亮度。getInfo(function 0)返回一个 BrightnessInfo,其中包含最小/最大亮度、离散步数以及 BrightnessCapabilities 位掩码。getBrightness / setBrightness(functions 1–2)以 u16 格式读取和写入当前亮度值。当 ILLUMINATION 能力标志被置位时,getIllumination / setIllumination(functions 3–4)可在不改变已存储亮度值的情况下,独立查询和切换背光的开关状态。

  • HARDWARE_BRIGHTNESS —— 硬件可在无需主机命令的情况下自行调节亮度。
  • EVENTS —— 设备会主动上报亮度或背光状态变更事件。
  • ILLUMINATION —— 背光开关状态可独立于亮度值进行查询与控制。
  • HARDWARE_ON_OFF —— 硬件可直接切换背光的开/关状态。
  • TRANSIENT —— 亮度值不会在设备断电后持久化。

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

Function reference

The BrightnessControlFeature wrapper (0x8040) exposes:

Methods

FunctionHID++ fnSignatureReturns
get_info0()BrightnessInfo
get_brightness1()u16
set_brightness2(brightness: u16)()
get_illumination3()bool
set_illumination4(enabled: bool)()

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

Types

BrightnessInfo

Brightness range and capability information.

FieldTypeDescription
min_brightnessu16Minimum accepted brightness.
max_brightnessu16Maximum accepted brightness.
stepsu16Number of brightness steps advertised by the device.
capabilitiesBrightnessCapabilitiesFeature capabilities.

BrightnessCapabilities

Capabilities reported by BrightnessControl.

FlagBit/ValueDescription
HARDWARE_BRIGHTNESS1 << 0Hardware can change brightness directly.
EVENTS1 << 1The device emits brightness or illumination change events.
ILLUMINATION1 << 2Illumination can be queried and controlled separately from brightness.
HARDWARE_ON_OFF1 << 3Hardware can toggle illumination on and off directly.
TRANSIENT1 << 4Brightness is transient and not persisted by the device.

Wire format

Short requests carry a 3-byte payload; getInfo / getBrightness / getIllumination responses are read from the 16-byte extended payload returned by extend_payload().

get_info (fn 0)

Request: [0x00, 0x00, 0x00]

Response (extended 16-byte payload — byte → field):

Byte(s)FieldNotes
0–1max_brightnessBig-endian u16.
2steps (low byte)Combined with byte 6 — see note below.
3capabilitiesBrightnessCapabilities bitmask (see flag table above).
4–5min_brightnessBig-endian u16.
6steps (high byte)steps = u16::from_be_bytes([payload[6], payload[2]]).

The steps field is split across two non-adjacent bytes: high byte at index 6, low byte at index 2.

get_brightness (fn 1)

Request: [0x00, 0x00, 0x00]

Response (extended 16-byte payload — byte → field):

Byte(s)FieldNotes
0–1brightnessBig-endian u16 current brightness value.

set_brightness (fn 2)

Request: [hi, lo, 0x00] where hi and lo are the big-endian bytes of the u16 brightness value.

ByteContent
0(brightness >> 8) as u8
1brightness as u8
20x00 (padding)

No response payload is used.

get_illumination (fn 3)

Request: [0x00, 0x00, 0x00]

Response (extended 16-byte payload — byte → field):

ByteFieldNotes
0illumination enabledBit 0: payload[0] & 1 != 0. true = illumination on.

set_illumination (fn 4)

Request: [enabled, 0x00, 0x00]

ByteContent
00x01 if illumination should be enabled, 0x00 to disable
1–20x00 (padding)

No response payload is used.

Usage (Rust)

use hidpp::{device::Device, feature::brightness_control::BrightnessControlFeature};

// mut device: Device, already created via Device::new(channel, index)?
device.enumerate_features().await?;
if let Some(feat) = device.get_feature::<BrightnessControlFeature>() {
    let info = feat.get_info().await?;
    println!("Brightness range: {}–{} ({} steps)", info.min_brightness, info.max_brightness, info.steps);

    let current = feat.get_brightness().await?;
    println!("Current brightness: {current}");

    // Set brightness to 75 % of the reported maximum
    let target = (info.max_brightness as u32 * 75 / 100) as u16;
    feat.set_brightness(target).await?;

    if info.capabilities.contains(hidpp::feature::brightness_control::BrightnessCapabilities::ILLUMINATION) {
        let on = feat.get_illumination().await?;
        println!("Illumination currently: {on}");
        feat.set_illumination(true).await?;
    }
}

本页目录