Documentation
¶
Index ¶
- Constants
- Variables
- func ParseReport(data []byte, report *Xbox360ControllerReport) error
- type Device
- type DeviceInfo
- type Emulator
- type StadiaController
- type Vibration
- type VigemError
- type Xbox360Controller
- type Xbox360ControllerReport
- func (r *Xbox360ControllerReport) GetButtons() uint16
- func (r *Xbox360ControllerReport) GetLeftThumb() (x, y int16)
- func (r *Xbox360ControllerReport) GetLeftTrigger() byte
- func (r *Xbox360ControllerReport) GetRightThumb() (x, y int16)
- func (r *Xbox360ControllerReport) GetRightTrigger() byte
- func (r *Xbox360ControllerReport) MaybeSetButton(shiftBy int, isSet bool)
- func (r *Xbox360ControllerReport) SetButton(shiftBy int)
- func (r *Xbox360ControllerReport) SetButtons(buttons uint16)
- func (r *Xbox360ControllerReport) SetLeftThumb(x, y int16)
- func (r *Xbox360ControllerReport) SetLeftTrigger(value byte)
- func (r *Xbox360ControllerReport) SetRightThumb(x, y int16)
- func (r *Xbox360ControllerReport) SetRightTrigger(value byte)
Constants ¶
View Source
const ( VIGEM_ERROR_NONE = 0x20000000 VIGEM_ERROR_BUS_NOT_FOUND = 0xE0000001 VIGEM_ERROR_NO_FREE_SLOT = 0xE0000002 VIGEM_ERROR_INVALID_TARGET = 0xE0000003 VIGEM_ERROR_REMOVAL_FAILED = 0xE0000004 VIGEM_ERROR_ALREADY_CONNECTED = 0xE0000005 VIGEM_ERROR_TARGET_UNINITIALIZED = 0xE0000006 VIGEM_ERROR_TARGET_NOT_PLUGGED_IN = 0xE0000007 VIGEM_ERROR_BUS_VERSION_MISMATCH = 0xE0000008 VIGEM_ERROR_BUS_ACCESS_FAILED = 0xE0000009 VIGEM_ERROR_CALLBACK_ALREADY_REGISTERED = 0xE0000010 VIGEM_ERROR_CALLBACK_NOT_FOUND = 0xE0000011 VIGEM_ERROR_BUS_ALREADY_CONNECTED = 0xE0000012 VIGEM_ERROR_BUS_INVALID_HANDLE = 0xE0000013 VIGEM_ERROR_XUSB_USERINDEX_OUT_OF_RANGE = 0xE0000014 VIGEM_ERROR_MAX = VIGEM_ERROR_XUSB_USERINDEX_OUT_OF_RANGE + 1 )
View Source
const ( Xbox360ControllerButtonUp = 0 Xbox360ControllerButtonDown = 1 Xbox360ControllerButtonLeft = 2 Xbox360ControllerButtonRight = 3 Xbox360ControllerButtonStart = 4 Xbox360ControllerButtonBack = 5 Xbox360ControllerButtonLeftThumb = 6 Xbox360ControllerButtonRightThumb = 7 Xbox360ControllerButtonLeftShoulder = 8 Xbox360ControllerButtonRightShoulder = 9 Xbox360ControllerButtonGuide = 10 Xbox360ControllerButtonA = 12 Xbox360ControllerButtonB = 13 Xbox360ControllerButtonX = 14 Xbox360ControllerButtonY = 15 )
Bits that correspond to the Xbox 360 controller buttons.
Variables ¶
View Source
var RetryError = errors.New("retry")
Functions ¶
func ParseReport ¶
func ParseReport(data []byte, report *Xbox360ControllerReport) error
Types ¶
type Device ¶
type Device interface { // Close closes the device and associated resources. Close() // Write writes an output report to device. The first byte must be the // report number to write, zero if the device does not use numbered reports. Write([]byte) error // ReadCh returns a channel that will be sent input reports from the device. // If the device uses numbered reports, the first byte will be the report // number. ReadCh() <-chan []byte // ReadError returns the read error, if any after the channel returned from // ReadCh has been closed. ReadError() error }
A Device provides access to a HID device.
type DeviceInfo ¶
type DeviceInfo struct { // Path contains a platform-specific device path which is used to identify the device. Path string VendorID uint16 ProductID uint16 VersionNumber uint16 Manufacturer string Product string UsagePage uint16 Usage uint16 InputReportLength uint16 OutputReportLength uint16 }
DeviceInfo provides general information about a device.
func ByPath ¶
func ByPath(devicePath string) (*DeviceInfo, error)
ByPath gets the device which is bound to the given path.
func Devices ¶
func Devices() ([]*DeviceInfo, error)
Devices returns all HID devices which are connected to the system.
func (*DeviceInfo) Open ¶
func (di *DeviceInfo) Open() (Device, error)
Open openes the device for read / write access.
type Emulator ¶
type Emulator struct {
// contains filtered or unexported fields
}
func NewEmulator ¶
func (*Emulator) CreateXbox360Controller ¶
func (e *Emulator) CreateXbox360Controller() (*Xbox360Controller, error)
type StadiaController ¶
type StadiaController struct {
// contains filtered or unexported fields
}
func NewStadiaController ¶
func NewStadiaController() *StadiaController
func (*StadiaController) Close ¶
func (c *StadiaController) Close()
func (*StadiaController) GetReport ¶
func (c *StadiaController) GetReport() (Xbox360ControllerReport, error)
func (*StadiaController) Vibrate ¶
func (c *StadiaController) Vibrate(largeMotor, smallMotor byte) error
type VigemError ¶
type VigemError struct {
// contains filtered or unexported fields
}
func NewVigemError ¶
func NewVigemError(rawCode uintptr) *VigemError
func (*VigemError) Error ¶
func (err *VigemError) Error() string
type Xbox360Controller ¶
type Xbox360Controller struct {
// contains filtered or unexported fields
}
func (*Xbox360Controller) Close ¶
func (c *Xbox360Controller) Close() error
func (*Xbox360Controller) Connect ¶
func (c *Xbox360Controller) Connect() error
func (*Xbox360Controller) Disconnect ¶
func (c *Xbox360Controller) Disconnect() error
func (*Xbox360Controller) Send ¶
func (c *Xbox360Controller) Send(report *Xbox360ControllerReport) error
type Xbox360ControllerReport ¶
type Xbox360ControllerReport struct { Capture bool Assistant bool // contains filtered or unexported fields }
func NewXbox360ControllerReport ¶
func NewXbox360ControllerReport() Xbox360ControllerReport
func (*Xbox360ControllerReport) GetButtons ¶
func (r *Xbox360ControllerReport) GetButtons() uint16
func (*Xbox360ControllerReport) GetLeftThumb ¶
func (r *Xbox360ControllerReport) GetLeftThumb() (x, y int16)
func (*Xbox360ControllerReport) GetLeftTrigger ¶
func (r *Xbox360ControllerReport) GetLeftTrigger() byte
func (*Xbox360ControllerReport) GetRightThumb ¶
func (r *Xbox360ControllerReport) GetRightThumb() (x, y int16)
func (*Xbox360ControllerReport) GetRightTrigger ¶
func (r *Xbox360ControllerReport) GetRightTrigger() byte
func (*Xbox360ControllerReport) MaybeSetButton ¶
func (r *Xbox360ControllerReport) MaybeSetButton(shiftBy int, isSet bool)
func (*Xbox360ControllerReport) SetButton ¶
func (r *Xbox360ControllerReport) SetButton(shiftBy int)
func (*Xbox360ControllerReport) SetButtons ¶
func (r *Xbox360ControllerReport) SetButtons(buttons uint16)
func (*Xbox360ControllerReport) SetLeftThumb ¶
func (r *Xbox360ControllerReport) SetLeftThumb(x, y int16)
func (*Xbox360ControllerReport) SetLeftTrigger ¶
func (r *Xbox360ControllerReport) SetLeftTrigger(value byte)
func (*Xbox360ControllerReport) SetRightThumb ¶
func (r *Xbox360ControllerReport) SetRightThumb(x, y int16)
func (*Xbox360ControllerReport) SetRightTrigger ¶
func (r *Xbox360ControllerReport) SetRightTrigger(value byte)
Click to show internal directories.
Click to hide internal directories.