mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-03-16 07:56:38 +08:00
feat(hid): 添加 Consumer Control 多媒体按键和多平台键盘布局
- 新增 Consumer Control HID 支持(播放/暂停、音量控制等) - 虚拟键盘支持 Windows/Mac/Android 三种布局切换 - 移除键盘 LED 反馈以节省 USB 端点(从 2 减至 1) - InfoBar 优化:按键名称友好显示,移除未实现的 Num/Scroll 指示器 - 更新 HID 模块文档
This commit is contained in:
@@ -22,9 +22,15 @@ export interface HidMouseEvent {
|
||||
scroll?: number
|
||||
}
|
||||
|
||||
/** Consumer control event for HID input (multimedia keys) */
|
||||
export interface HidConsumerEvent {
|
||||
usage: number // Consumer Control Usage code (e.g., 0x00CD for Play/Pause)
|
||||
}
|
||||
|
||||
// Binary message constants (must match datachannel.rs / ws_hid.rs)
|
||||
export const MSG_KEYBOARD = 0x01
|
||||
export const MSG_MOUSE = 0x02
|
||||
export const MSG_CONSUMER = 0x03
|
||||
|
||||
// Keyboard event types
|
||||
export const KB_EVENT_DOWN = 0x00
|
||||
@@ -107,3 +113,15 @@ export function encodeMouseEvent(event: HidMouseEvent): ArrayBuffer {
|
||||
|
||||
return buffer
|
||||
}
|
||||
|
||||
/** Encode consumer control event to binary format (3 bytes) */
|
||||
export function encodeConsumerEvent(event: HidConsumerEvent): ArrayBuffer {
|
||||
const buffer = new ArrayBuffer(3)
|
||||
const view = new DataView(buffer)
|
||||
|
||||
view.setUint8(0, MSG_CONSUMER)
|
||||
// Usage code as u16 LE
|
||||
view.setUint16(1, event.usage, true)
|
||||
|
||||
return buffer
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user