0x4530 · dualPlatform
在两种操作系统族(iOS/macOS 与 Android/Windows)之间持久化并切换设备的 HID 键码表——读写当前选择并接收硬件按钮切换事件。
dualPlatform 功能允许设备在两种操作系统族之间持久化其 HID 键码表。该选择在配对时或通过短按专用 OS 选择按钮完成。getPlatform(function 1)读取当前设置;setPlatform(function 2)写入新值并将已提交的值回写——此操作不会触发 PlatformChanged 通知。只有用户通过硬件按钮切换时,才会发出 PlatformChanged 事件。
0x4530 是 0x4531 multiPlatform 的前代版本;如果设备同时暴露了 0x4531,应优先通过该功能驱动。
IosOrMac(0)—— iOS 或 macOS HID 键码表。AndroidOrWindows(1)—— Android 或 Windows HID 键码表。
规格: Logitech HID++ 2.0 —— dualPlatform。用于:
openlogi-hidpp中的类型化封装。
Function reference
The DualPlatformFeature wrapper (0x4530) exposes:
Methods
| Function | HID++ fn | Signature | Returns |
|---|---|---|---|
get_platform | 1 | () | DualPlatformSelection |
set_platform | 2 | (platform: DualPlatformSelection) | DualPlatformSelection |
listen | — | () | async_channel::Receiver<DualPlatformEvent> |
get_platform and set_platform are async and return Result<…, Hidpp20Error>. listen is synchronous and infallible.
Types
DualPlatformSelection
The platform a device is configured for. The selection is persistent, chosen during pairing or by short-pressing an OS-selection button; there is no default.
| Variant | Value | Description |
|---|---|---|
IosOrMac | 0 | iOS or macOS HID key-code table. |
AndroidOrWindows | 1 | Android or Windows HID key-code table. |
Events
DualPlatformFeature implements EmittingFeature<DualPlatformEvent>. Call listen() to obtain an async_channel::Receiver<DualPlatformEvent> that receives hardware-button switch events. set_platform does not trigger this event.
| Variant | Payload | Description |
|---|---|---|
PlatformChanged | DualPlatformSelection | The user changed the platform via an OS-selection button. |
Wire format
Each request carries a 3-byte payload; responses are read from the returned long payload via extend_payload(). The event payload is parsed from the raw HID++ message.
get_platform (fn 1)
Request: [0x00, 0x00, 0x00] — all bytes are unused padding.
Response (byte → field):
| Byte | Field | Notes |
|---|---|---|
| 0 | DualPlatformSelection | 0 = IosOrMac, 1 = AndroidOrWindows |
set_platform (fn 2)
Request: [platform, 0x00, 0x00] — byte 0 is the u8 representation of the new DualPlatformSelection; bytes 1–2 are unused padding.
Response (byte → field):
| Byte | Field | Notes |
|---|---|---|
| 0 | DualPlatformSelection | Device echo of the committed value |
PlatformChanged event (sub-id 0)
Emitted by the hardware OS-selection button. Decoded from the raw HID++ event message when the feature index and func.to_lo() == 0 match.
| Byte | Field | Notes |
|---|---|---|
| 0 | DualPlatformSelection | 0 = IosOrMac, 1 = AndroidOrWindows |
Usage (Rust)
use hidpp::{device::Device, feature::dual_platform::{DualPlatformFeature, DualPlatformEvent, DualPlatformSelection}};
// chan: Arc<HidppChannel>, device_index: u8
let mut device = Device::new(chan, device_index).await?;
device.enumerate_features().await?;
if let Some(feat) = device.get_feature::<DualPlatformFeature>() {
// Read the current platform setting.
let current = feat.get_platform().await?;
println!("Current platform: {:?}", current);
// Switch to Android/Windows key-code table and confirm the echo.
let committed = feat.set_platform(DualPlatformSelection::AndroidOrWindows).await?;
println!("Committed: {:?}", committed);
// Listen for hardware-button platform-switch events.
let rx = feat.listen();
if let Ok(DualPlatformEvent::PlatformChanged(p)) = rx.recv().await {
println!("Hardware switch → {:?}", p);
}
}