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 16-bit relative movement
DX, DY int16
// Wheel: signed 16-bit vertical scroll
Wheel int16
// Pan: signed 16-bit horizontal scroll
Pan int16
}
InputState represents the mouse state used to build a report. viiper:wire mouse c2s buttons:u8 dx:i16 dy:i16 wheel:i16 pan:i16
func (*InputState) BuildReport ¶
func (m *InputState) BuildReport() []byte
BuildReport encodes an InputState into the 9-byte HID mouse report.
Report layout (9 bytes):
Byte 0: Button bitfield (bit 0=Left, 1=Right, 2=Middle, 3=Back, 4=Forward, bits 5-7=padding) Bytes 1-2: DX (int16 little-endian, -32768 to +32767) Bytes 3-4: DY (int16 little-endian) Bytes 5-6: Wheel (int16 little-endian) Bytes 7-8: Pan (int16 little-endian)
func (*InputState) MarshalBinary ¶
func (m *InputState) MarshalBinary() ([]byte, error)
MarshalBinary encodes InputState to 9 bytes.
func (*InputState) UnmarshalBinary ¶
func (m *InputState) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes 9 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).