Documentation ¶
Overview ¶
The joystick Package handles any joystick or gamepad events on the gl context, it can be used for feedback and input.
Index ¶
- Constants
- func Delegate(event sdl.Event)
- func GetJoystickCount() int
- type GameControllerAxis
- type GameControllerButton
- type Joystick
- func (joystick *Joystick) GetAxes() []float32
- func (joystick *Joystick) GetAxis(axisindex int) float32
- func (joystick *Joystick) GetAxisCount() int
- func (joystick *Joystick) GetButtonCount() int
- func (joystick *Joystick) GetGUID() string
- func (joystick *Joystick) GetGamepadAxis(axis GameControllerAxis) float32
- func (joystick *Joystick) GetHat(hatindex int) byte
- func (joystick *Joystick) GetHatCount() int
- func (joystick *Joystick) GetID() int
- func (joystick *Joystick) GetName() string
- func (joystick *Joystick) GetVibration() (float32, float32)
- func (joystick *Joystick) IsConnected() bool
- func (joystick *Joystick) IsDown(button int) bool
- func (joystick *Joystick) IsGamepad() bool
- func (joystick *Joystick) IsGamepadDown(button GameControllerButton) bool
- func (joystick *Joystick) IsVibrationSupported() bool
- func (joystick *Joystick) SetVibration(args ...float32) bool
Constants ¶
const ( AxisInvalid = GameControllerAxis(sdl.CONTROLLER_AXIS_INVALID) AxisLeftx = GameControllerAxis(sdl.CONTROLLER_AXIS_LEFTX) AxisLefty = GameControllerAxis(sdl.CONTROLLER_AXIS_LEFTY) AxisRightx = GameControllerAxis(sdl.CONTROLLER_AXIS_RIGHTX) AxisRighty = GameControllerAxis(sdl.CONTROLLER_AXIS_RIGHTY) AxisTriggerleft = GameControllerAxis(sdl.CONTROLLER_AXIS_TRIGGERLEFT) AxisTriggerright = GameControllerAxis(sdl.CONTROLLER_AXIS_TRIGGERRIGHT) AxisMax = GameControllerAxis(sdl.CONTROLLER_AXIS_MAX) )
const ( ButtonInvalid = GameControllerButton(sdl.CONTROLLER_BUTTON_INVALID) ButtonA = GameControllerButton(sdl.CONTROLLER_BUTTON_A) ButtonB = GameControllerButton(sdl.CONTROLLER_BUTTON_B) ButtonX = GameControllerButton(sdl.CONTROLLER_BUTTON_X) ButtonY = GameControllerButton(sdl.CONTROLLER_BUTTON_Y) ButtonBack = GameControllerButton(sdl.CONTROLLER_BUTTON_BACK) ButtonGuide = GameControllerButton(sdl.CONTROLLER_BUTTON_GUIDE) ButtonStart = GameControllerButton(sdl.CONTROLLER_BUTTON_START) ButtonLeftstick = GameControllerButton(sdl.CONTROLLER_BUTTON_LEFTSTICK) ButtonRightstick = GameControllerButton(sdl.CONTROLLER_BUTTON_RIGHTSTICK) ButtonLeftshoulder = GameControllerButton(sdl.CONTROLLER_BUTTON_LEFTSHOULDER) ButtonRightshoulder = GameControllerButton(sdl.CONTROLLER_BUTTON_RIGHTSHOULDER) ButtonDpadUp = GameControllerButton(sdl.CONTROLLER_BUTTON_DPAD_UP) ButtonDpadDown = GameControllerButton(sdl.CONTROLLER_BUTTON_DPAD_DOWN) ButtonDpadLeft = GameControllerButton(sdl.CONTROLLER_BUTTON_DPAD_LEFT) ButtonDpadRight = GameControllerButton(sdl.CONTROLLER_BUTTON_DPAD_RIGHT) ButtonMax = GameControllerButton(sdl.CONTROLLER_BUTTON_MAX) )
Variables ¶
This section is empty.
Functions ¶
Types ¶
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 (*Joystick) GetAxisCount ¶
GetAxisCount gets the number of axes on the joystick.
func (*Joystick) GetButtonCount ¶
GetButtonCount gets the number of buttons on the 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) GetHatCount ¶
GetHatCount gets the number of hats on the joystick.
func (*Joystick) GetVibration ¶
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 ¶
IsConnected gets whether the Joystick is connected.
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 ¶
IsVibrationSupported gets whether the Joystick supports vibration.
func (*Joystick) SetVibration ¶
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.