Documentation
¶
Overview ¶
Package usbhid provides safe HID input event helpers for Apple Virtualization framework virtual machines.
It wraps the private VZVirtualMachine send* methods with state guards that return errors instead of crashing when the VM is not running or not yet accepting HID reports.
All methods dispatch on the caller-supplied vm.Queue so they are safe to call from any goroutine.
Index ¶
- Variables
- type Sender
- func (s *Sender) Ready() bool
- func (s *Sender) SendDigitizerEvents(events unsafe.Pointer, deviceIndex uint32) error
- func (s *Sender) SendIOHIDEventObjects(events []pvz.VZIOHIDEvent, hidDeviceIndex uint32) error
- func (s *Sender) SendIOHIDEvents(events pvz.VZOpaqueIOHIDEvents, hidDeviceIndex uint32) errordeprecated
- func (s *Sender) SendKeyEvents(events []pvz.VZKeyEvent, keyboardID uint32) error
- func (s *Sender) SendKeyboardEvents(events pvz.VZOpaqueKeyboardEvents, keyboardID uint32) errordeprecated
- func (s *Sender) SendKeyboardNSEvent(event objectivec.IObject, keyboardID uint32) error
- func (s *Sender) SendKeyboardNSEvents(events []objectivec.IObject, keyboardID uint32) error
- func (s *Sender) SendMouseEvents(events pvz.VZOpaqueMouseEvents, deviceIndex uint32) errordeprecated
- func (s *Sender) SendPointerNSEvent(event objectivec.IObject, deviceIndex uint32) error
- func (s *Sender) SendScrollWheelEvents(events unsafe.Pointer, deviceIndex uint32) error
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Sender ¶
type Sender struct {
// contains filtered or unexported fields
}
Sender sends HID events to a virtual machine.
func NewSender ¶
func NewSender(queue *vm.Queue, vm vz.VZVirtualMachine) *Sender
NewSender creates a new HID event sender for a running VM.
func (*Sender) SendDigitizerEvents ¶
SendDigitizerEvents sends digitizer (mouse/touch) events to the VM. The events parameter is an NSArray of digitizer event objects and deviceIndex identifies which pointing device to target (typically 0).
func (*Sender) SendIOHIDEventObjects ¶ added in v0.5.4
func (s *Sender) SendIOHIDEventObjects(events []pvz.VZIOHIDEvent, hidDeviceIndex uint32) error
SendIOHIDEventObjects sends typed _VZIOHIDEvent objects to the selected HID device.
This is only safe when the caller already has valid _VZIOHIDEvent objects. The private _VZIOHIDEvent initializer takes an IOHIDEventRef-style pointer, not an Objective-C event object, so this package does not currently expose a higher-level constructor for keyboard IOHID events.
func (*Sender) SendIOHIDEvents
deprecated
added in
v0.5.4
func (s *Sender) SendIOHIDEvents(events pvz.VZOpaqueIOHIDEvents, hidDeviceIndex uint32) error
SendIOHIDEvents sends an opaque private IOHID event payload to the VM.
Deprecated: Prefer Sender.SendIOHIDEventObjects when you already have _VZIOHIDEvent objects. This raw method still exposes an undocumented `void *` contract.
func (*Sender) SendKeyEvents ¶ added in v0.5.4
func (s *Sender) SendKeyEvents(events []pvz.VZKeyEvent, keyboardID uint32) error
SendKeyEvents sends typed private key event objects to the selected keyboard.
This is the recommended keyboard path. It avoids the undocumented `sendKeyboardEvents:keyboardID:` buffer contract and instead uses _VZKeyboard.sendKeyEvents: with _VZKeyEvent objects.
func (*Sender) SendKeyboardEvents
deprecated
func (s *Sender) SendKeyboardEvents(events pvz.VZOpaqueKeyboardEvents, keyboardID uint32) error
SendKeyboardEvents sends an opaque private keyboard-event payload to the VM.
Deprecated: Prefer Sender.SendKeyEvents or Sender.SendKeyboardNSEvents. This method forwards a private `void *` contract whose pointed-to layout is not documented and is not a raw USB HID report buffer.
func (*Sender) SendKeyboardNSEvent ¶ added in v0.5.4
func (s *Sender) SendKeyboardNSEvent(event objectivec.IObject, keyboardID uint32) error
SendKeyboardNSEvent sends a single NSEvent keyboard event.
func (*Sender) SendKeyboardNSEvents ¶ added in v0.5.4
func (s *Sender) SendKeyboardNSEvents(events []objectivec.IObject, keyboardID uint32) error
SendKeyboardNSEvents converts NSEvent keyboard events into _VZKeyEvent objects, then sends them through _VZKeyboard.sendKeyEvents:.
func (*Sender) SendMouseEvents
deprecated
func (s *Sender) SendMouseEvents(events pvz.VZOpaqueMouseEvents, deviceIndex uint32) error
SendMouseEvents sends mouse events to the VM.
Deprecated: this still forwards an opaque private payload.
func (*Sender) SendPointerNSEvent ¶
func (s *Sender) SendPointerNSEvent(event objectivec.IObject, deviceIndex uint32) error
SendPointerNSEvent forwards an AppKit NSEvent to the VM as pointer input. The event is sent directly (not wrapped in an array) and deviceIndex identifies which pointing device to target (typically 0).
func (*Sender) SendScrollWheelEvents ¶
SendScrollWheelEvents sends scroll wheel events to the VM. The events parameter is an NSArray of scroll wheel event objects and deviceIndex identifies which pointing device to target (typically 0).