stadiacontroller

package module
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2020 License: ISC Imports: 10 Imported by: 2

README

Stadia Controller

Support for using the Stadia Controller as an Xbox 360 controller on Windows.

Supported features
  • All buttons are mapped to their Xbox 360 equivalents.
    • Triggers are analog.
    • For the Assistant and Capture buttons which have no Xbox 360 equivalent, the command line flags -capture-pressed, -assistant-pressed, -capture-released and -assistant-released can be used to specify custom commands to run when those buttons are pressed and released.
      • For instance, -capture-pressed "sharex -PrintScreen" takes a screenshot when the Capture button is pressed.
  • Vibrations are supported.
  • Emulation via ViGEm (must be installed), which means that everything just works. There won't be pesky Denuvo games that refuse to accept that input.
Installation
  1. Install ViGEm.
  2. Download a release from the releases page.
  3. Extract the zip into a directory.
Alternative

XOutput does not support vibrations, analog triggers and additional buttons, but it has more features and is more stable overall.

Documentation

Index

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 NewEmulator(onVibration func(vibration Vibration)) (*Emulator, error)

func (*Emulator) Close

func (e *Emulator) Close() error

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 (*StadiaController) Vibrate

func (c *StadiaController) Vibrate(largeMotor, smallMotor byte) error

type Vibration

type Vibration struct {
	LargeMotor byte
	SmallMotor byte
}

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

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)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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