controller

package
v0.0.0-...-6124d3d Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SwitchProControllerButtonY             = 0
	SwitchProControllerButtonX             = 1
	SwitchProControllerButtonB             = 2
	SwitchProControllerButtonA             = 3
	SwitchProControllerButtonRightShoulder = 6
	SwitchProControllerButtonRightTrigger  = 7

	SwitchProControllerButtonMinus      = 0
	SwitchProControllerButtonPlus       = 1
	SwitchProControllerButtonRightThumb = 2
	SwitchProControllerButtonLeftThumb  = 3
	SwitchProControllerButtonHome       = 4
	SwitchProControllerButtonCapture    = 5

	SwitchProControllerButtonDown         = 0
	SwitchProControllerButtonUp           = 1
	SwitchProControllerButtonRight        = 2
	SwitchProControllerButtonLeft         = 3
	SwitchProControllerButtonLeftShoulder = 6
	SwitchProControllerButtonLeftTrigger  = 7
)
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 HIDDeviceMap map[string]*hid.DeviceInfo

Functions

func CreateLocalControllerService

func CreateLocalControllerService()

func CreateWebControllerService

func CreateWebControllerService(Addr string) *http.Server

func NewSwitchProController

func NewSwitchProController(DeviceInfo *hid.DeviceInfo)

func Notification

func Notification(title, message string)

Types

type ControllerMsg

type ControllerMsg struct {
	Buttons []byte  `json:"buttons"`
	Axes    []int16 `json:"axes"`
}

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 StickCalibration

type StickCalibration struct {
	MaxX     uint16
	MaxY     uint16
	CenterX  uint16
	CenterY  uint16
	MinX     uint16
	MinY     uint16
	DeadZone uint16
}

func (StickCalibration) StickCalibrate

func (StickCal StickCalibration) StickCalibrate(ThumbX uint16, ThumbY uint16) (float32, float32)

type SwitchProController

type SwitchProController struct {
	Name          string
	Device        hid.Device
	CommmandID    byte
	StickCalLeft  StickCalibration
	StickCalRight StickCalibration
	AccNeutral    [3]uint16
	AccSensiti    [3]uint16
	GyrNeutral    [3]uint16
	GyrSensiti    [3]uint16
}

func (*SwitchProController) Init

func (Controller *SwitchProController) Init() error

func (*SwitchProController) ReadSPI

func (Controller *SwitchProController) ReadSPI(cmd []byte) ([]byte, error)

func (*SwitchProController) Subcommand

func (Controller *SwitchProController) Subcommand(sc byte, cmd []byte) ([]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) SetButtonFromGamePadAPI

func (r *Xbox360ControllerReport) SetButtonFromGamePadAPI(button int, value byte)

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)

Jump to

Keyboard shortcuts

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