Joystick and gamepad
Joysticks and gamepads are supported through the joystick plugin.
- class joystick
- function joystick.__init__(experiment, device=0, joybuttonlist=None, timeout=None)
- function joystick.flush()
- function joystick.get_joyaxes(timeout=None)
- function joystick.get_joyballs(timeout=None)
- function joystick.get_joybutton(joybuttonlist=None, timeout=None)
- function joystick.get_joyhats(timeout=None)
- function joystick.get_joyinput(joybuttonlist=None, timeout=None)
- function joystick.input_options()
- function joystick.set_joybuttonlist(joybuttonlist=None)
- function joystick.set_timeout(timeout=None)
class joystick
If you insert the joystick plugin at the start of your experiment, a joystick object automatically becomes part of the experiment object and can be used within an inline_script item as joystick.
- class joystick
- function joystick.__init__(experiment, device=0, joybuttonlist=None, timeout=None)
- function joystick.flush()
- function joystick.get_joyaxes(timeout=None)
- function joystick.get_joyballs(timeout=None)
- function joystick.get_joybutton(joybuttonlist=None, timeout=None)
- function joystick.get_joyhats(timeout=None)
- function joystick.get_joyinput(joybuttonlist=None, timeout=None)
- function joystick.input_options()
- function joystick.set_joybuttonlist(joybuttonlist=None)
- function joystick.set_timeout(timeout=None)
function joystick.__init__(experiment, device=0, joybuttonlist=None, timeout=None)
Intializes the joystick object.
Arguments:
experiment
-- An Opensesame experiment.- Type: experiment
Keywords:
device
-- The joystick device number.- Type: int
- Default: 0
joybuttonlist
-- A list of buttons that are accepted orNone
to accept all buttons.- Type: list, NoneType
- Default: None
timeout
-- A timeout value in milliseconds orNone
for no timeout.- Type: int, float, NoneType
- Default: None
function joystick.flush()
Clears all pending input, not limited to the joystick.
Returns:
True if joyinput was pending (i.e., if there was something to flush) and False otherwise.
- Type: bool
function joystick.get_joyaxes(timeout=None)
Waits for joystick axes movement.
Keywords:
timeout
-- A timeout value in milliseconds orNone
to use default timeout.- Type: int, float, NoneType
- Default: None
Returns:
A (position, timestamp)
tuple. position
is None
if a timeout occurs. Otherwise, position
is an (x, y, z)
tuple.
- Type: tuple
function joystick.get_joyballs(timeout=None)
Waits for joystick trackball movement.
Keywords:
timeout
-- A timeout value in milliseconds orNone
to use default timeout.- Type: int, float, NoneType
- Default: None
Returns:
A (position, timestamp)
tuple. The position is None
if a timeout occurs.
- Type: tuple
function joystick.get_joybutton(joybuttonlist=None, timeout=None)
Collects joystick button input.
Keywords:
joybuttonlist
-- A list of buttons that are accepted orNone
to default joybuttonlist.- Type: list, NoneType
- Default: None
timeout
-- A timeout value in milliseconds orNone
to use default timeout.- Type: int, float, NoneType
- Default: None
Returns:
A (joybutton, timestamp) tuple. The joybutton is None
if a timeout occurs.
- Type: tuple
function joystick.get_joyhats(timeout=None)
Waits for joystick hat movement.
Keywords:
timeout
-- A timeout value in milliseconds orNone
to use default timeout.- Type: int, float, NoneType
- Default: None
Returns:
A (position, timestamp)
tuple. position
is None
if a timeout occurs. Otherwise, position
is an (x, y)
tuple.
- Type: tuple
function joystick.get_joyinput(joybuttonlist=None, timeout=None)
Waits for any joystick input (buttons, axes, hats or balls).
Keywords:
joybuttonlist
-- A list of buttons that are accepted orNone
to default joybuttonlist.- Type: list, NoneType
- Default: None
timeout
-- A timeout value in milliseconds orNone
to use default timeout.- Type: int, float, NoneType
- Default: None
Returns:
A (event, value, timestamp) tuple. The value is None
if a timeout occurs. event
is one of None
, 'joybuttonpress', 'joyballmotion', 'joyaxismotion', or 'joyhatmotion'
- Type: tuple
function joystick.input_options()
Generates a list with the number of available buttons, axes, balls and hats.
Returns:
A list with number of inputs as: [buttons, axes, balls, hats].
- Type: list
function joystick.set_joybuttonlist(joybuttonlist=None)
Sets a list of accepted buttons.
Keywords:
joybuttonlist
-- A list of buttons that are accepted orNone
to accept all buttons.- Type: list, NoneType
- Default: None
function joystick.set_timeout(timeout=None)
Sets a timeout.
Keywords:
timeout
-- A timeout value in milliseconds orNone
for no timeout.- Type: int, float, NoneType
- Default: None