Back to index

Index

Joystick

Class Methods

 new  count

Instance Methods

 id  axes  balls  hats  buttons  axis  ball  hat  button

Events

JoyAxisEvent JoyBallEvent JoyHatEvent JoyButtonUpEvent JoyButtonDownEvent

Joystick

Class Methods

Joystick.new( id )

Creates a new joystick object. id is a number smaller than Joystick.count. This will also start events for this joystick.

Joystick.count

Returns the amount of joysticks attached to the computer.

Instance Methods

Joystick#id

Returns the id of the joystick as it was passed to Joystick.new.

Joystick#axes

Returns the amount of axes the joystick has.

Joystick#balls

Returns the amount of trackballs the joystick has.

Joystick#hats

Returns the amount of hats the joystick has.

Joystick#buttons

Returns the amount of buttons the joystick has.

Joystick#axis( nr )

Returns the state of axis nr, which is between -1 to 1.

Joystick#ball( nr )

Returns the state of ball nr, which is an array of [dx, dy] where dx and dy are between -1 to 1.

Joystick#hat( nr )

Returns the state of hat nr, which is an array of [dx, dy] where dx and dy can be -1, 0 or 1.

Joystick#button( nr )

Returns the boolean state of button nr.

Events

JoyAxisEvent

Contains id which is the joysticknumber, value which is the movement, ranging from -1 to 1 and axis which is the axis index.

JoyBallEvent

Contains id which is the joysticknumber, ball which is a trackball index and rel which is a movement array of [dx, dy].

JoyHatEvent

Contains id which is the joysticknumber, hat which is the hatnumber and a movement array of [dx, dy] called value where dx and dy can be -1, 0 or 1.

JoyButtonUpEvent

Contains id which is the joysticknumber and button which is the button index.

JoyButtonDownEvent

Contains id which is the joysticknumber and button which is the button index.

Back to index