Version: v0.0.0-...-7296e18 Latest Latest

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

Go to latest
Published: Jul 18, 2017 License: MIT Imports: 2 Imported by: 0



The joystick Package handles any joystick or gamepad events on the gl context, it can be used for feedback and input.




This section is empty.


func Delegate

func Delegate(event sdl.Event)

Delegate is used by amore/event to pass events to the mouse package. It may also be useful to stub or fake events

func GetJoystickCount

func GetJoystickCount() int

Gets the number of connected joysticks.


type GameControllerAxis

type GameControllerAxis sdl.GameControllerAxis

Specifies which hardware axis on the controller

type GameControllerButton

type GameControllerButton sdl.GameControllerButton

Specifies the hardware button on the controller

type Joystick

type Joystick struct {
	// contains filtered or unexported fields

Joystick is an instance of any joystick or gamepad that is connected to the program.

func GetJoysticks

func GetJoysticks() []*Joystick

Gets a list of connected Joysticks.

func (*Joystick) GetAxes

func (joystick *Joystick) GetAxes() []float32

GetAxes gets the direction of each axis. Values are clamped.

func (*Joystick) GetAxis

func (joystick *Joystick) GetAxis(axisindex int) float32

GetAxis gets the direction of an axis. Values are clamped.

func (*Joystick) GetAxisCount

func (joystick *Joystick) GetAxisCount() int

GetAxisCount gets the number of axes on the joystick.

func (*Joystick) GetButtonCount

func (joystick *Joystick) GetButtonCount() int

GetButtonCount gets the number of buttons on the joystick.

func (*Joystick) GetGUID

func (joystick *Joystick) GetGUID() string

GetGUID gets a stable GUID unique to the type of the physical joystick.

func (*Joystick) GetGamepadAxis

func (joystick *Joystick) GetGamepadAxis(axis GameControllerAxis) float32

GetGamepadAxis gets the direction of a virtual gamepad axis. Values are clamped.

func (*Joystick) GetHat

func (joystick *Joystick) GetHat(hatindex int) byte

GetHat gets the direction of a hat.

func (*Joystick) GetHatCount

func (joystick *Joystick) GetHatCount() int

GetHatCount gets the number of hats on the joystick.

func (*Joystick) GetID

func (joystick *Joystick) GetID() int

GetID Gets the joystick's unique identifier.

func (*Joystick) GetName

func (joystick *Joystick) GetName() string

GetName the name of the joystick as it is identified on the os.

func (*Joystick) GetVibration

func (joystick *Joystick) GetVibration() (float32, float32)

GetVibration will return the current intensity of both the left and right motors currently vibrating. It will return 0s if they are not vibrating.

func (*Joystick) IsConnected

func (joystick *Joystick) IsConnected() bool

IsConnected gets whether the Joystick is connected.

func (*Joystick) IsDown

func (joystick *Joystick) IsDown(button int) bool

IsDown checks if a button on the Joystick is pressed.

func (*Joystick) IsGamepad

func (joystick *Joystick) IsGamepad() bool

IsGamepad gets whether the Joystick is recognized as a gamepad.

func (*Joystick) IsGamepadDown

func (joystick *Joystick) IsGamepadDown(button GameControllerButton) bool

IsGamePadDown checks if a virtual gamepad button on the Joystick is pressed.

func (*Joystick) IsVibrationSupported

func (joystick *Joystick) IsVibrationSupported() bool

IsVibrationSupported gets whether the Joystick supports vibration.

func (*Joystick) SetVibration

func (joystick *Joystick) SetVibration(args ...float32) bool

SetVibration sets the vibration motor speeds on a Joystick with rumble support. if passed no arguments it will stop the vibration. If passed one value it will set the vibration for both left and right with a duration of INFINITY. If passed two parameters it will set left and right intensities with a duration of INFINITY. If passed 3 parameters it will set both intensities and the diration as the third parameter, all other parameters will be ignored.

Jump to

Keyboard shortcuts

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