Documentation ¶
Index ¶
- func DeserializeGCControllers(data []byte) map[uint8]*rawGCInput
- type Buttons
- type GCAdapter
- func (adapter *GCAdapter) AllControllers() map[uint8]*GCInputs
- func (adapter *GCAdapter) Close() error
- func (adapter *GCAdapter) Controller(PORT uint8) *GCInputs
- func (adapter *GCAdapter) Controllers() map[uint8]*GCInputs
- func (adapter *GCAdapter) Poll() error
- func (adapter *GCAdapter) StartPolling()
- type GCInputs
- type Offsets
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeserializeGCControllers ¶ added in v0.1.0
Types ¶
type Buttons ¶
type Buttons struct { UP bool DOWN bool RIGHT bool LEFT bool Y bool X bool B bool A bool L bool R bool Z bool START bool }
Buttons represents the Gamecube controller buttons
type GCAdapter ¶
type GCAdapter struct {
// contains filtered or unexported fields
}
GCAdapter represents a Gamecube controller usb adapter
func NewGCAdapter ¶
NewGCAdapter connects to a Gamecube controller usb adapter and returns a pointer to it. An adapter should be closed with adapter.Close() once it's not required anymore or when the program closes. The best way of achieving that is calling defer adapter.Close() right after adapter, err := NewGCAdapter()
func (*GCAdapter) AllControllers ¶
AllControllers return the current state of the 4 controllers (even unplugged ones)
func (*GCAdapter) Controller ¶
Controller return the current state of the controller on port PORT.
func (*GCAdapter) Controllers ¶
Controllers return the current state of the plugged in controllers.
func (*GCAdapter) StartPolling ¶
func (adapter *GCAdapter) StartPolling()
StartPolling starts a Gamecube adapter polling loop, where the adapter is polled at its defined polling rate (which is 125Hz by default on the official adapter). The function is meant to be wrapped in a goroutine.
type GCInputs ¶
type GCInputs struct { Button Buttons StickX float32 StickY float32 CX float32 CY float32 LAnalog float32 RAnalog float32 PluggedIn bool }
GCInputs represent the state of the gamecube controller, with sticks values in [-1, 1], triggers values in [0, 1] and buttons as boolean Sticks and triggers values are calibrated, and sticks values are clamped inside the unit circle, but deadzones are not enforced.