Tryanks / go-accessoryhid

Emulate any hid device for Android.
MIT License
12 stars 1 forks source link

Introduction

The go-accessoryhid package is an implementation of the AOA 2.0 protocol for Android HID devices.

Dependence on gousb and libusb-1.0.

Documentation

TODO.

Installation

go get -u github.com/Tryanks/go-accessoryhid

Usage

Example:

package main

import accessory "github.com/Tryanks/go-accessoryhid"

func main() {
    devices, err := accessory.GetDevices(2)
    if err != nil {
        panic(err)
    }
    phone := devices[0]
    defer phone.Close()
    keyboard, err := phone.Register(accessory.KeyboardReportDesc) // Register keyboard report descriptor
    err = keyboard.SendEvent([]byte{
        0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
    }) // Hid event (pressing 'a')
    if err != nil {
        panic(err)
    }
    err = keyboard.SendEvent([]byte{
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    }) // Hid event (releasing 'a')
    if err != nil {
        panic(err)
    }
}