AprilNEA / AprilNEA/OpenLogi

Feature: 增加软件侧主动切换主机(Add software-initiated host switching / Easy-Switch)

Open
#650 1 comment 0 reactions 0 assignees View on GitHub
area: hidpp platform: all type: feature
Dominant language
Rust
Stars
21k
Forks
675
Avg merge
2d 5h
Merged PRs (30d)
172

Description

# Feature: 软件侧主动切换主机(Software-initiated host switching / Easy-Switch)

## 现状

- `openlogi-hidpp` 已有完整的 `0x1814 ChangeHost` / `0x1815 HostsInfo` 实现(读槽位、`set_current_host` fire-and-forget、cookie 读写)。
- 应用层目前只有**键盘联动切换**(`host_switch_targets`:按键盘 Easy-Switch 键时联动鼠标跟随)。
- GUI / CLI 都没有"把这只鼠标切到某个通道"的主动入口。

## 使用场景

1. **鼠标不在手边**:演示、客厅、KVM 场景,鼠标够不着底部的通道键,需要从软件把它切走/切回来。
2. **无障碍**:部分用户无法操作鼠标底部的物理通道键。
3. **自动化**:脚本/远程场景下按主机编排设备去向。

## 提议的设计(在动手前想先听维护者的意见)

- **IPC**(`openlogi-ipc/src/ipc.rs`):`Agent` trait 末尾追加
`switch_host(route, host: u8) -> Result<(), WriteError>` 与
`read_host_info(route) -> Result`,
`PROTOCOL_VERSION` 18 → 19。
- **HID 层**(`openlogi-hid/src/write/host.rs`):按 `set_dpi_on` 的既有模式新增
`switch_host_on(_channel)` / `get_host_info_on(_channel)`,内部调用现成的
`ChangeHostFeature::set_current_host`(notify 语义,不等应答)。
- **GUI**(`openlogi-gui`):设备详情页新增"主机切换"区块——用 `HostsInfoFeature`
逐槽位显示配对状态/连接类型,每通道一个按钮、当前通道置灰、点击弹确认
(切换后设备会从 inventory 消失,返回时走既有的 re-apply 逻辑恢复 DPI/SmartShift)。
- **错误语义**:不支持 0x1814 的设备(如 Signature M650)返回
`WriteError::FeatureUnsupported`,GUI 隐藏该区块。

我在 MX Master 4(BLE 直连)上验证过 0x1814 fn0/fn1 的实际行为:读出 3 个通道
(当前通道 0,通道 1 已配对 BLE),`set_current_host` 以 notify 发送后设备离线、
在目标主机上线——协议行为与 crate 文档一致。

想请教:
1. 这个方向是否符合项目定位?若符合,区块放在设备详情页是否合适,还是倾向托盘菜单入口?
2. 是否需要连带提供 CLI 子命令(`openlogi-cli`)?

## English summary

The hidpp crate already implements `0x1814 ChangeHost`, but only the
keyboard-link flow exposes switching. Proposal: an IPC `switch_host` /
`read_host_info` pair, an hid-layer helper following the `set_dpi_on` pattern,
and a per-channel section on the device detail page (current channel disabled,
confirmation dialog, settings re-applied on the mouse's return via the
existing reconnect path). Use cases: mouse out of reach, accessibility,
automation. Verified on an MX Master 4 over BLE. Would love maintainer
feedback on direction and preferred entry point (detail page vs. tray) before
starting the implementation.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reading openlogi-ipc/src/ipc.rs and openlogi-hid/src/write/host.rs, comparing the proposed APIs with set_dpi_on and the existing ChangeHostFeature and HostsInfoFeature implementations. Then trace the GUI device detail page and existing reconnect re-apply path. Done means software can read host slots, switch a supported mouse with confirmation, hide the section for unsupported devices, and restore settings after return.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend-api-design, desktop
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.