Documentation
¶
Index ¶
- Constants
- func FindUDC() (string, error)
- type Gadget
- func (g *Gadget) CloseUDC() error
- func (g *Gadget) CreateFunction(funcName string) (string, error)
- func (g *Gadget) InitConfig() error
- func (g *Gadget) Mkdir(path string) error
- func (g *Gadget) Remove() error
- func (g *Gadget) Rmdir(path string) error
- func (g *Gadget) StartFunction(funcName string) error
- func (g *Gadget) StartUDC() error
- func (g *Gadget) Symlink(src, dest string) error
- func (g *Gadget) Unlink(path string) error
- func (g *Gadget) Write(path string, value string) error
- func (g *Gadget) WriteBytes(path string, data []byte) error
- type GadgetInterface
- type HID
- type KM
- type KMHIDController
- type KMInterface
- type MSD
- type MSDInterface
- type NET
- type NetInterface
- type OTGKMHIDControl
- func (d *OTGKMHIDControl) ClearScreen() error
- func (d *OTGKMHIDControl) ClickMouse(button byte) error
- func (d *OTGKMHIDControl) Close() error
- func (d *OTGKMHIDControl) IsAbsoluteMouse() bool
- func (d *OTGKMHIDControl) MoveAbsoluteMouse(x, y int) error
- func (d *OTGKMHIDControl) MoveMouse(dx, dy int) error
- func (d *OTGKMHIDControl) MoveRelativeMouse(dx, dy int) error
- func (d *OTGKMHIDControl) Open() error
- func (d *OTGKMHIDControl) PressKey(key byte) error
- func (d *OTGKMHIDControl) PressKeyWithModifier(modifier byte, key byte) error
- func (d *OTGKMHIDControl) PressKeyWithModifiers(modifier byte, keys ...byte) error
- func (d *OTGKMHIDControl) ProcessButton(button byte, state bool) error
- func (d *OTGKMHIDControl) ProcessKey(key byte, isModifier bool, state bool) error
- func (d *OTGKMHIDControl) ProcessMove(toX, toY int) error
- func (d *OTGKMHIDControl) ProcessRelativeMove(deltaX, deltaY int) error
- func (d *OTGKMHIDControl) ProcessWheel(deltaY int8) error
- func (d *OTGKMHIDControl) Reboot() error
- func (d *OTGKMHIDControl) ReleaseKey(key byte) error
- func (d *OTGKMHIDControl) ScrollMouse(wheel int8) error
- func (d *OTGKMHIDControl) SendAbsoluteMouseReport(buttons byte, x, y int, wheelY int8) error
- func (d *OTGKMHIDControl) SendKeyboardReport(modifier byte, keys []byte) error
- func (d *OTGKMHIDControl) SendMouseReport(buttons byte, dx, dy int, wheel int8) error
- func (d *OTGKMHIDControl) SendRelativeMouseReport(buttons byte, dx, dy int, wheelY int8) error
- func (d *OTGKMHIDControl) SetAbsoluteMouse(absolute bool) error
- func (d *OTGKMHIDControl) TypeString(s string) error
Constants ¶
const ( KeyA = 0x04 KeyB = 0x05 KeyC = 0x06 KeyD = 0x07 KeyE = 0x08 KeyF = 0x09 KeyG = 0x0A KeyH = 0x0B KeyI = 0x0C KeyJ = 0x0D KeyK = 0x0E KeyL = 0x0F KeyM = 0x10 KeyN = 0x11 KeyO = 0x12 KeyP = 0x13 KeyQ = 0x14 KeyR = 0x15 KeyS = 0x16 KeyT = 0x17 KeyU = 0x18 KeyV = 0x19 KeyW = 0x1A KeyX = 0x1B KeyY = 0x1C KeyZ = 0x1D Key1 = 0x1E Key2 = 0x1F Key3 = 0x20 Key4 = 0x21 Key5 = 0x22 Key6 = 0x23 Key7 = 0x24 Key8 = 0x25 Key9 = 0x26 Key0 = 0x27 KeyEnter = 0x28 KeyEscape = 0x29 KeyBackspace = 0x2A KeyTab = 0x2B KeySpace = 0x2C KeyMinus = 0x2D KeyEqual = 0x2E KeyLeftBrace = 0x2F KeyRightBrace = 0x30 KeyBackslash = 0x31 KeySemicolon = 0x33 KeyApostrophe = 0x34 KeyGrave = 0x35 KeyComma = 0x36 KeyDot = 0x37 KeySlash = 0x38 KeyCapsLock = 0x39 KeyF1 = 0x3A KeyF2 = 0x3B KeyF3 = 0x3C KeyF4 = 0x3D KeyF5 = 0x3E KeyF6 = 0x3F KeyF7 = 0x40 KeyF8 = 0x41 KeyF9 = 0x42 KeyF10 = 0x43 KeyF11 = 0x44 KeyF12 = 0x45 // 导航键 KeyPrintScreen = 0x46 KeyScrollLock = 0x47 KeyPause = 0x48 KeyInsert = 0x49 KeyHome = 0x4A KeyPageUp = 0x4B KeyDelete = 0x4C KeyEnd = 0x4D KeyPageDown = 0x4E KeyRightArrow = 0x4F KeyLeftArrow = 0x50 KeyDownArrow = 0x51 KeyUpArrow = 0x52 // 数字小键盘 KeyNumLock = 0x53 KeyKeypadSlash = 0x54 KeyKeypadAsterisk = 0x55 KeyKeypadMinus = 0x56 KeyKeypadPlus = 0x57 KeyKeypadEnter = 0x58 KeyKeypad1 = 0x59 KeyKeypad2 = 0x5A KeyKeypad3 = 0x5B KeyKeypad4 = 0x5C KeyKeypad5 = 0x5D KeyKeypad6 = 0x5E KeyKeypad7 = 0x5F KeyKeypad8 = 0x60 KeyKeypad9 = 0x61 KeyKeypad0 = 0x62 KeyKeypadDot = 0x63 KeyKeypadEqual = 0x67 // 更多功能键 KeyF13 = 0x68 KeyF14 = 0x69 KeyF15 = 0x6A KeyF16 = 0x6B KeyF17 = 0x6C KeyF18 = 0x6D KeyF19 = 0x6E KeyF20 = 0x6F KeyF21 = 0x70 KeyF22 = 0x71 KeyF23 = 0x72 KeyF24 = 0x73 // 特殊功能键和国际键盘相关按键 KeyIntlBackslash = 0x64 // 国际反斜杠键 KeyContextMenu = 0x65 // 上下文菜单键 KeyPower = 0x66 // 电源键 // 多媒体键 KeyAudioVolumeMute = 0x7F // 音量静音 KeyAudioVolumeUp = 0x80 // 音量增加 KeyAudioVolumeDown = 0x81 // 音量减少 )
OTG 键盘按键编码
const ( ModifierLeftCtrl = 0x01 ModifierLeftShift = 0x02 ModifierLeftAlt = 0x04 ModifierLeftGUI = 0x08 ModifierRightCtrl = 0x10 ModifierRightShift = 0x20 ModifierRightAlt = 0x40 ModifierRightGUI = 0x80 )
OTG 键盘修饰键
const ( MouseLeft = 0x01 MouseRight = 0x02 MouseMiddle = 0x04 MouseBack = 0x08 // Back/Up MouseForward = 0x10 // Forward/Down )
OTG 鼠标按键
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Gadget ¶
Gadget 管理USB Gadget的配置
func (*Gadget) CreateFunction ¶
CreateFunction 创建功能目录
func (*Gadget) StartFunction ¶
StartFunction 启动功能
type GadgetInterface ¶
type GadgetInterface interface {
// 基础操作
Mkdir(path string) error
Write(path string, value string) error
WriteBytes(path string, data []byte) error
Symlink(src, dest string) error
Rmdir(path string) error
Unlink(path string) error
// 初始化配置(usb产品信息)
InitConfig() error
// 功能管理
CreateFunction(funcName string) (string, error)
StartFunction(funcName string) error
// UDC设备管理
StartUDC() error
CloseUDC() error
// Remove 删除USB Gadget配置
Remove() error
}
type HID ¶
type KM ¶
type KM struct {
GadgetInterface
// contains filtered or unexported fields
}
KM 定义HID鼠标和键盘设备结构
type KMHIDController ¶
type KMHIDController interface {
// 基础设备操作
Open() error
Close() error
// 键盘操作
SendKeyboardReport(modifier byte, keys []byte) error
PressKey(key byte) error
ReleaseKey(key byte) error
PressKeyWithModifier(modifier byte, key byte) error
PressKeyWithModifiers(modifier byte, keys ...byte) error
// 鼠标操作
SendMouseReport(buttons byte, dx, dy int, wheel int8) error
MoveMouse(dx, dy int) error
ClickMouse(button byte) error
ScrollMouse(wheel int8) error
// 鼠标模式切换
SetAbsoluteMouse(absolute bool) error
IsAbsoluteMouse() bool
// 共有功能方法
ClearScreen() error
Reboot() error
}
KMHIDController 定义键盘鼠标控制器的统一接口
func NewOTGKMHIDControl ¶
func NewOTGKMHIDControl() KMHIDController
NewOTGKMHIDControl 创建新的OTGKMHIDControl实例
type KMInterface ¶
type KMInterface interface {
// 对外暴露的方法
AddKeyboard() error
AddMouse(absolute bool, horizontalWheel bool) error
// contains filtered or unexported methods
}
func NewKM ¶
func NewKM(gadget GadgetInterface) KMInterface
type MSD ¶
type MSD struct {
GadgetInterface
// contains filtered or unexported fields
}
type MSDInterface ¶
func NewMSD ¶
func NewMSD(gadget GadgetInterface) MSDInterface
type NET ¶
type NET struct {
GadgetInterface
// contains filtered or unexported fields
}
type NetInterface ¶
func NewNET ¶
func NewNET(gadget GadgetInterface) NetInterface
type OTGKMHIDControl ¶
type OTGKMHIDControl struct {
// contains filtered or unexported fields
}
OTGKMHIDControl 实现KMHIDController接口(OTG模式)
func (*OTGKMHIDControl) ClearScreen ¶
func (d *OTGKMHIDControl) ClearScreen() error
ClearScreen 清屏(模拟 Ctrl+L 快捷键)
func (*OTGKMHIDControl) ClickMouse ¶
func (d *OTGKMHIDControl) ClickMouse(button byte) error
ClickMouse 点击鼠标
func (*OTGKMHIDControl) IsAbsoluteMouse ¶
func (d *OTGKMHIDControl) IsAbsoluteMouse() bool
IsAbsoluteMouse 检查鼠标是否使用绝对模式
func (*OTGKMHIDControl) MoveAbsoluteMouse ¶
func (d *OTGKMHIDControl) MoveAbsoluteMouse(x, y int) error
MoveAbsoluteMouse 移动绝对鼠标
func (*OTGKMHIDControl) MoveMouse ¶
func (d *OTGKMHIDControl) MoveMouse(dx, dy int) error
MoveMouse 移动鼠标(相对模式)
func (*OTGKMHIDControl) MoveRelativeMouse ¶
func (d *OTGKMHIDControl) MoveRelativeMouse(dx, dy int) error
MoveRelativeMouse 相对移动鼠标
func (*OTGKMHIDControl) Open ¶
func (d *OTGKMHIDControl) Open() error
Open 实现KMHIDController接口的Open方法,不接受参数
func (*OTGKMHIDControl) PressKey ¶
func (d *OTGKMHIDControl) PressKey(key byte) error
PressKey 按下单个按键
func (*OTGKMHIDControl) PressKeyWithModifier ¶
func (d *OTGKMHIDControl) PressKeyWithModifier(modifier byte, key byte) error
PressKeyWithModifier 按下带有修饰键的按键
func (*OTGKMHIDControl) PressKeyWithModifiers ¶
func (d *OTGKMHIDControl) PressKeyWithModifiers(modifier byte, keys ...byte) error
PressKeyWithModifiers 按下带有多个修饰键和多个普通键的组合
func (*OTGKMHIDControl) ProcessButton ¶
func (d *OTGKMHIDControl) ProcessButton(button byte, state bool) error
ProcessButton 处理鼠标按键事件,与CH9329保持一致
func (*OTGKMHIDControl) ProcessKey ¶
func (d *OTGKMHIDControl) ProcessKey(key byte, isModifier bool, state bool) error
ProcessKey 处理键盘按键事件,与CH9329保持一致
func (*OTGKMHIDControl) ProcessMove ¶
func (d *OTGKMHIDControl) ProcessMove(toX, toY int) error
ProcessMove 处理鼠标绝对移动事件,与CH9329保持一致
func (*OTGKMHIDControl) ProcessRelativeMove ¶
func (d *OTGKMHIDControl) ProcessRelativeMove(deltaX, deltaY int) error
ProcessRelativeMove 处理鼠标相对移动事件,与CH9329保持一致
func (*OTGKMHIDControl) ProcessWheel ¶
func (d *OTGKMHIDControl) ProcessWheel(deltaY int8) error
ProcessWheel 处理鼠标滚轮事件,与CH9329保持一致
func (*OTGKMHIDControl) Reboot ¶
func (d *OTGKMHIDControl) Reboot() error
Reboot 重启系统(模拟 Ctrl+Alt+Delete 快捷键)
func (*OTGKMHIDControl) ReleaseKey ¶
func (d *OTGKMHIDControl) ReleaseKey(key byte) error
ReleaseKey 释放所有按键
func (*OTGKMHIDControl) ScrollMouse ¶
func (d *OTGKMHIDControl) ScrollMouse(wheel int8) error
ScrollMouse 滚动鼠标(垂直)
func (*OTGKMHIDControl) SendAbsoluteMouseReport ¶
func (d *OTGKMHIDControl) SendAbsoluteMouseReport(buttons byte, x, y int, wheelY int8) error
SendAbsoluteMouseReport 发送绝对鼠标HID报告
func (*OTGKMHIDControl) SendKeyboardReport ¶
func (d *OTGKMHIDControl) SendKeyboardReport(modifier byte, keys []byte) error
SendKeyboardReport 发送键盘HID报告,添加错误处理和重连机制
func (*OTGKMHIDControl) SendMouseReport ¶
func (d *OTGKMHIDControl) SendMouseReport(buttons byte, dx, dy int, wheel int8) error
SendMouseReport 实现KMHIDController接口的SendMouseReport方法
func (*OTGKMHIDControl) SendRelativeMouseReport ¶
func (d *OTGKMHIDControl) SendRelativeMouseReport(buttons byte, dx, dy int, wheelY int8) error
SendRelativeMouseReport 发送相对鼠标HID报告
func (*OTGKMHIDControl) SetAbsoluteMouse ¶
func (d *OTGKMHIDControl) SetAbsoluteMouse(absolute bool) error
SetAbsoluteMouse 设置鼠标是否使用绝对模式
func (*OTGKMHIDControl) TypeString ¶
func (d *OTGKMHIDControl) TypeString(s string) error
TypeString 输入字符串(支持字母、数字和符号,与CH9329保持一致)
Source Files
¶
- base.go
- km.go
- kmControl.go
- kmhid.go
- msd.go
- net.go
- utils.go