Difference between revisions of "Gamepad Module"
(Created page with "== pressed == '''boolean gamepad.pressed(number gamepadId, number button)''' If the given gamepad has had its button pressed since last polling, returns true. Else, false. ...") |
|||
Line 1: | Line 1: | ||
+ | == Global variables == | ||
+ | To make working with the POV hat (aka D-pad) a bit easier, a few variables have been added to global scope: | ||
+ | {| class="wikitable" | ||
+ | |- | ||
+ | | JOY_POVBACKWARD | ||
+ | | The "Down" button; A value of 180 | ||
+ | |- | ||
+ | | JOY_POVFORWARD | ||
+ | | The "Up" button; A value of 0 | ||
+ | |- | ||
+ | | JOY_POVCENTERED | ||
+ | | No direction; A value of 655 | ||
+ | |- | ||
+ | | JOY_POVLEFT | ||
+ | | The "Left" button; A value of 270 | ||
+ | |- | ||
+ | | JOY_POVRIGHT | ||
+ | | The "Right" button; A value of 90 | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | |||
== pressed == | == pressed == | ||
'''boolean gamepad.pressed(number gamepadId, number button)''' | '''boolean gamepad.pressed(number gamepadId, number button)''' | ||
Line 21: | Line 43: | ||
Returns the angle of the POV hat (D-pad). If centered, returns JOY_POVCENTERED. | Returns the angle of the POV hat (D-pad). If centered, returns JOY_POVCENTERED. | ||
+ | This angle is in degrees with "up" being 0° and rotating in a clockwise fashion. | ||
Revision as of 18:04, 30 May 2014
Global variables
To make working with the POV hat (aka D-pad) a bit easier, a few variables have been added to global scope:
JOY_POVBACKWARD | The "Down" button; A value of 180 |
JOY_POVFORWARD | The "Up" button; A value of 0 |
JOY_POVCENTERED | No direction; A value of 655 |
JOY_POVLEFT | The "Left" button; A value of 270 |
JOY_POVRIGHT | The "Right" button; A value of 90 |
pressed
boolean gamepad.pressed(number gamepadId, number button)
If the given gamepad has had its button pressed since last polling, returns true. Else, false.
released
boolean gamepad.released(number gamepadId, number button)
If the given gamepad has had its button released since last polling, returns true. Else, false.
isDown
boolean gamepad.isDown(number gamepadId, number button)
If the given gamepad currently has a given button held down (as of last polling), returns true. Else, returns false.
getPOV
number gamepad.getPOV(number gamepadId)
Returns the angle of the POV hat (D-pad). If centered, returns JOY_POVCENTERED. This angle is in degrees with "up" being 0° and rotating in a clockwise fashion.
getAxis
number gamepad.getAxis(number gamepadId, number axisId)
Returns the axis value for a given gamepad. The value will be between 0 (minimum) and 100(maximum). If centered, the value will be ~50.
This will not always be exact! Due to calibration, floating-point inaccuracies, and physical defects, you may receive a value that is a fraction off the intended value. I.e. ~49-51 while centered.
getCount
number gamepad.getCount()
Returns the number of connected gamepads.