Fork me on GitHub
View source

package com.haxepunk.utils

class Joystick

A joystick.

Get one using Input.joystick.

Currently doesn't work with flash and html5 targets.

Static variables

View source

static read only deadZone : Float

Determines the joystick's deadZone. Anything under this value will be considered 0 to prevent jitter.

Variables

write only axis : Array<Float>

Each axis contained in an array.

ball : Point

A Point containing the joystick's ball value.

buttons : Map<Int, JoyButtonState>

A map of buttons and their states

connected : Bool

If the joystick is currently connected.

hat : Point

A Point containing the joystick's hat value.

Functions

View source

check (button : Int) : Bool

If the joystick button is held down. Omit argument to check for any button.


Parameters:
button   

The button index to check.

View source

getAxis (a : Int) : Float

Returns the axis value (from 0 to 1)


Parameters:
a   

The axis index to retrieve starting at 0

View source

pressed (button : Int) : Bool

If the joystick button was pressed this frame. Omit argument to check for any button.


Parameters:
button   

The button index to check.

View source

released (button : Int) : Bool

If the joystick button was released this frame. Omit argument to check for any button.


Parameters:
button   

The button index to check.