Documentation
¶
Overview ¶
Package mouse provides a HID mouse device implementation.
Index ¶
Constants ¶
const ( Btn_Left = 0x01 Btn_Right = 0x02 Btn_Middle = 0x04 Btn_Back = 0x08 Btn_Forward = 0x10 )
Button bit masks for virtual mouse input reports. These align with the Buttons bitfield in InputState.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type InputState ¶
type InputState struct {
// Button bitfield: bit 0=Left, 1=Right, 2=Middle, 3=Back, 4=Forward
Buttons uint8
// Delta X/Y: signed 8-bit relative movement
DX, DY int8
// Wheel: signed 8-bit vertical scroll
Wheel int8
// Pan: signed 8-bit horizontal scroll
Pan int8
}
InputState represents the mouse state used to build a report. viiper:wire mouse c2s buttons:u8 dx:i8 dy:i8 wheel:i8 pan:i8
func (InputState) BuildReport ¶
func (st InputState) BuildReport() []byte
BuildReport encodes an InputState into the 5-byte HID mouse report.
Report layout (5 bytes):
Byte 0: Button bitfield (bit 0=Left, 1=Right, 2=Middle, 3=Back, 4=Forward, bits 5-7=padding) Byte 1: DX (int8, -127 to +127) Byte 2: DY (int8) Byte 3: Wheel (int8) Byte 4: Pan (int8)
func (*InputState) MarshalBinary ¶
func (m *InputState) MarshalBinary() ([]byte, error)
MarshalBinary encodes InputState to 5 bytes.
func (*InputState) UnmarshalBinary ¶
func (m *InputState) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes 5 bytes into InputState.
type Mouse ¶
type Mouse struct {
// contains filtered or unexported fields
}
Mouse implements the minimal Device interface for a 5-button HID mouse with vertical and horizontal wheels.
func (*Mouse) GetDescriptor ¶
func (m *Mouse) GetDescriptor() *usb.Descriptor
func (*Mouse) HandleTransfer ¶
HandleTransfer implements interrupt IN for Mouse.
func (*Mouse) UpdateInputState ¶
func (m *Mouse) UpdateInputState(state InputState)
UpdateInputState updates the device's current input state (thread-safe).