0x4530 · dualPlatform
读取或选择两种持久键盘 OS 族之一,并接收硬件平台变化事件。
DualPlatform 为双平台设备选择 HID 键码族。IosOrMac 的值为 0,AndroidOrWindows 的值为 1。
**规格:**Logitech 没有公开此功能的规格。布局根据 Logi Options+ 2.8(静态分析)逆向得出。**交叉核对:**Solaar。**用于:**OpenLogi 除
openlogi-hidpp封装外未使用此功能。
函数参考
DualPlatformFeature 可为功能版本 0 创建。
方法
| 函数 | HID++ fn | 签名 | 返回值 |
|---|---|---|---|
get_platform | 0 | () | DualPlatformSelection |
set_platform | 2 | (platform: DualPlatformSelection) | DualPlatformSelection |
listen | 事件 | () | async_channel::Receiver<DualPlatformEvent> |
get_platform 和 set_platform 是 async 方法,并返回 Result<…, Hidpp20Error>。listen 来自 EmittingFeature<DualPlatformEvent>。
类型
DualPlatformSelection
| 变体 | 值 | 说明 |
|---|---|---|
IosOrMac | 0 | iOS 或 macOS HID 键码族。 |
AndroidOrWindows | 1 | Android 或 Windows HID 键码族。 |
选择会持久保存。用户可在配对时或短按 OS 选择按钮后选择该值。
事件
| 变体 | 载荷 | 说明 |
|---|---|---|
PlatformChanged | DualPlatformSelection | 用户通过 OS 选择按钮更改了平台。 |
set_platform 不会发出此事件。OpenLogi 只接受函数 0 的事件。
线格式
每个请求使用 3 字节短载荷。OpenLogi 将响应规范化为 16 字节,再把字节 0 解析为 DualPlatformSelection。
get_platform(fn 0)
请求:
| 字节 | 字段 | 说明 |
|---|---|---|
| 0–2 | — | 没有参数。OpenLogi 发送 0x00, 0x00, 0x00。 |
响应:
| 字节 | 字段 | 说明 |
|---|---|---|
| 0 | platform | 0 = IosOrMac;1 = AndroidOrWindows。 |
| 1–15 | — | OpenLogi 忽略这些字节。 |
set_platform(fn 2)
请求:
| 字节 | 字段 | 说明 |
|---|---|---|
| 0 | platform | DualPlatformSelection 的 u8 值。 |
| 1–2 | — | 填充。OpenLogi 发送 0x00。 |
响应:
| 字节 | 字段 | 说明 |
|---|---|---|
| 0 | platform | OpenLogi 将此字节解析为设备回显。 |
| 1–15 | — | OpenLogi 忽略这些字节。 |
PlatformChanged 事件(fn 0)
| 字节 | 字段 | 说明 |
|---|---|---|
| 0 | platform | 0 = IosOrMac;1 = AndroidOrWindows。 |
| 1–15 | — | OpenLogi 忽略这些字节。 |
OpenLogi 的用法
OpenLogi v0.8.15 提供此类型化封装及其广播监听器。设备层、代理、CLI 和用户界面都不会读取或写入 0x4530。
封装不会缓存选择值。它不会在退出时恢复此持久设置。
未确认的细节
Logi Options+ 2.8 使用函数 0 读取,并使用函数 1 写入。Solaar 使用函数 0 读取,并使用函数 2 写入。
OpenLogi v0.8.15 使用函数 0 读取,并使用函数 2 写入。PR #1766 在 v0.8.14 修正了读取,因此读取不再发送可能的设置请求。
没有公开函数表或硬件抓包能确定写入函数索引。Logi Options+ 也不会解析设置回显,因此 OpenLogi 返回字节的含义尚未验证。
Rust 用法
use hidpp::{
device::Device,
feature::{
EmittingFeature,
dual_platform::{DualPlatformEvent, DualPlatformFeature, DualPlatformSelection},
},
};
// `device` is a discovered HID++ device.
device.enumerate_features().await?;
if let Some(feature) = device.get_feature::<DualPlatformFeature>() {
let current = feature.get_platform().await?;
println!("current platform: {current:?}");
let echoed = feature
.set_platform(DualPlatformSelection::AndroidOrWindows)
.await?;
println!("returned platform: {echoed:?}");
let events = feature.listen();
if let Ok(DualPlatformEvent::PlatformChanged(platform)) = events.recv().await {
println!("hardware platform change: {platform:?}");
}
}