usbhid

package
v0.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 31, 2026 License: MIT Imports: 8 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
var (
	ErrVMNotRunning = errors.New("vm not running")
	ErrNotReady     = errors.New("vm not accepting HID reports")
)

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) Ready

func (s *Sender) Ready() bool

Ready reports whether the VM is running and accepting HID input.

func (*Sender) SendDigitizerEvents

func (s *Sender) SendDigitizerEvents(events unsafe.Pointer, deviceIndex uint32) error

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) SendKeyboardEvents

func (s *Sender) SendKeyboardEvents(events unsafe.Pointer, keyboardID uint32) error

SendKeyboardEvents sends keyboard events to the VM. The events parameter is an NSArray of keyboard event objects and keyboardID identifies which keyboard device to target (typically 0).

func (*Sender) SendMouseEvents

func (s *Sender) SendMouseEvents(events unsafe.Pointer, deviceIndex uint32) error

SendMouseEvents sends mouse events to the VM. The events parameter is an NSArray of mouse event objects and deviceIndex identifies which pointing device to target (typically 0).

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

func (s *Sender) SendScrollWheelEvents(events unsafe.Pointer, deviceIndex uint32) error

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).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL