gamepad

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2021 License: MIT Imports: 10 Imported by: 2

Documentation

Overview

Package gamepad implements access to the system's gamepad or joystick API.

This package currently supports windows, linux, android, and js/wasm.

There are no semantics associated with the indices of axes or buttons in the current version of this package, but a given gamepad will always have the same order of axes and buttons.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Update

func Update() error

Update updates the state of the known gamepads.

This function should be called before gamepad states are checked on each frame.

Types

type Gamepad

type Gamepad struct {
	// contains filtered or unexported fields
}

func List

func List() []*Gamepad

List returns the currently known gamepads.

The returned slice is valid until Update is called.

func (*Gamepad) Axis

func (g *Gamepad) Axis(index int) float32

Axis returns the current state of the given axis on the gamepad.

If index is not in [0, NumAxis), this method returns NaN.

func (*Gamepad) Button

func (g *Gamepad) Button(index int) (float32, bool)

Button returns the current state of the given button on the gamepad.

If index is not in [0, NumButton), this method returns NaN, false.

If the platform does not support variable button presses, the value of the float is either 0 or 1.

func (*Gamepad) Name

func (g *Gamepad) Name() string

Name returns an identifier for this gamepad. It does not change, although on Windows, multiple gamepads may have the same name.

func (*Gamepad) NumAxis

func (g *Gamepad) NumAxis() int

NumAxis returns the number of axes on the gamepad.

func (*Gamepad) NumButton

func (g *Gamepad) NumButton() int

NumButton returns the number of buttons on the gamepad.

Jump to

Keyboard shortcuts

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