Documentation
¶
Index ¶
- Constants
- Variables
- type Accessory
- type AccessoryDevice
- func GetDevice() (device *AccessoryDevice, err error)
- func GetDeviceWithSerial(serial string) (device *AccessoryDevice, err error)
- func GetDevices(protocolVersion uint16) (accessoryList []*AccessoryDevice, err error)
- func NewAccessoryDevice(device *gousb.Device, protocol uint16, manu string) *AccessoryDevice
- func (a *AccessoryDevice) Close() error
- func (a *AccessoryDevice) Register(reportDesc []byte) (accessory *Accessory, err error)
- func (a *AccessoryDevice) SendHidEvent(hidID uint16, event []byte) error
- func (a *AccessoryDevice) SerialNumber() (string, error)
- func (a *AccessoryDevice) Unregister(hidID uint16) error
Constants ¶
const ( AccessoryRegisterHid uint8 = 54 AccessoryUnregisterHid = 55 AccessorySetHidReportDesc = 56 AccessorySendHidEvent = 57 AccessoryGetProtocol = 51 )
AOAv2 Basic Protocol
const ( RTypeOut uint8 = gousb.ControlOut | gousb.ControlVendor RTypeIn = gousb.ControlIn | gousb.ControlVendor )
USB Control transfer type
Variables ¶
var ( ErrorNoAccessoryDevice = errors.New("ErrorNoAccessoryDevice") ErrorFailedToGetProtocol = errors.New("ErrorFailedToGetProtocol") )
Error definitions
var ConsumerReportDesc = []byte{
0x05, 0x0c,
0x09, 0x01,
0xa1, 0x01,
0x15, 0x00,
0x25, 0x01,
0x75, 0x01,
0x95, 0x04,
0x0a, 0x23, 0x02,
0x0a, 0x24, 0x02,
0x09, 0x40,
0x09, 0x34,
0x81, 0x06,
0x75, 0x04,
0x95, 0x01,
0x81, 0x03,
0xc0,
}
ConsumerReportDesc is the HID report descriptor for a consumer control.
var KeyboardReportDesc = []byte{
0x05, 0x01,
0x09, 0x06,
0xA1, 0x01,
0x05, 0x07,
0x19, 0xE0,
0x29, 0xE7,
0x15, 0x00,
0x25, 0x01,
0x75, 0x01,
0x95, 0x08,
0x81, 0x02,
0x75, 0x08,
0x95, 0x01,
0x81, 0x01,
0x05, 0x08,
0x19, 0x01,
0x29, 0x05,
0x75, 0x01,
0x95, 0x05,
0x91, 0x02,
0x75, 0x03,
0x95, 0x01,
0x91, 0x01,
0x05, 0x07,
0x19, 0x00,
0x29, scHidKeyboardKeys - 1,
0x15, 0x00,
0x25, scHidKeyboardKeys - 1,
0x75, 0x08,
0x95, reportKeyboardMaxKeys,
0x81, 0x00,
0xC0,
}
KeyboardReportDesc is the HID report descriptor for a keyboard.
var MouseReportDesc = []byte{
0x05, 0x01,
0x09, 0x02,
0xA1, 0x01,
0x09, 0x01,
0xA1, 0x00,
0x05, 0x09,
0x19, 0x01,
0x29, 0x05,
0x15, 0x00,
0x25, 0x01,
0x95, 0x05,
0x75, 0x01,
0x81, 0x02,
0x95, 0x01,
0x75, 0x03,
0x81, 0x01,
0x05, 0x01,
0x09, 0x30,
0x09, 0x31,
0x09, 0x38,
0x15, 0x81,
0x25, 0x7F,
0x75, 0x08,
0x95, 0x03,
0x81, 0x06,
0xC0,
0xC0,
}
MouseReportDesc is the HID report descriptor for a mouse.
var SkipList = []uint16{
0x8087,
0x1d6b,
0x2109,
}
SkipList is a list of vendor IDs that are known to not support the accessory protocol and should be skipped TODO: Add more vendor IDs to the list
var TouchscreenReportDesc = []byte{
0x05, 0x0d,
0x09, 0x04,
0xa1, 0x01,
0x09, 0x22,
0xa1, 0x00,
0x09, 0x42,
0x09, 0x51,
0x15, 0x00,
0x25, 0x01,
0x75, 0x01,
0x95, 0x02,
0x81, 0x02,
0x95, 0x0e,
0x81, 0x03,
0x05, 0x01,
0x75, 0x10,
0x95, 0x01,
0x55, 0x0d,
0x65, 0x33,
0x15, 0x00,
0x26, 0xff, 0x7f,
0x09, 0x30,
0x81, 0x02,
0x09, 0x31,
0x81, 0x02,
0xc0,
0xc0,
}
TouchscreenReportDesc is the HID report descriptor for a touchscreen.
Functions ¶
This section is empty.
Types ¶
type Accessory ¶
type Accessory struct { ParentDevice *AccessoryDevice // contains filtered or unexported fields }
func (*Accessory) Unregister ¶
type AccessoryDevice ¶
type AccessoryDevice struct { Device *gousb.Device Protocol uint16 Manufacturer string // contains filtered or unexported fields }
AccessoryDevice Connected Android Device
func GetDevice ¶ added in v0.9.2
func GetDevice() (device *AccessoryDevice, err error)
GetDevice return a single device match protocol version 2
func GetDeviceWithSerial ¶ added in v0.9.2
func GetDeviceWithSerial(serial string) (device *AccessoryDevice, err error)
GetDeviceWithSerial return a device match serial with device.SerialNumber()
func GetDevices ¶
func GetDevices(protocolVersion uint16) (accessoryList []*AccessoryDevice, err error)
GetDevices return a list of devices that support the specified protocol version
func NewAccessoryDevice ¶
func NewAccessoryDevice(device *gousb.Device, protocol uint16, manu string) *AccessoryDevice
NewAccessoryDevice Create a new AccessoryDevice
func (*AccessoryDevice) Close ¶
func (a *AccessoryDevice) Close() error
func (*AccessoryDevice) Register ¶
func (a *AccessoryDevice) Register(reportDesc []byte) (accessory *Accessory, err error)
func (*AccessoryDevice) SendHidEvent ¶
func (a *AccessoryDevice) SendHidEvent(hidID uint16, event []byte) error
func (*AccessoryDevice) SerialNumber ¶ added in v0.9.2
func (a *AccessoryDevice) SerialNumber() (string, error)
func (*AccessoryDevice) Unregister ¶
func (a *AccessoryDevice) Unregister(hidID uint16) error