Supported by Supported by Advertisement

Joystick and gamepad

Joysticks and gamepads are supported through the joystick plugin.

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.

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 or None to accept all buttons.
    • Type: list, NoneType
    • Default: None
  • timeout -- A timeout value in milliseconds or `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 or None 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_joyballs(timeout=None)

Waits for joystick trackball movement.

Keywords:

  • timeout -- A timeout value in milliseconds or None 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 or None to default joybuttonlist.
    • Type: list, NoneType
    • Default: None
  • timeout -- A timeout value in milliseconds or None 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 or None 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_joyinput(joybuttonlist=None, timeout=None)

Waits for any joystick input (buttons, axes, hats or balls).

Keywords:

  • joybuttonlist -- A list of buttons that are accepted or None to default joybuttonlist.
    • Type: list, NoneType
    • Default: None
  • timeout -- A timeout value in milliseconds or None to use default timeout.
    • Type: int, float, NoneType
    • Default: None

Returns:

A (event, value, timestamp) tuple. The value is None if a timeout occurs.

  • 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 or None 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 or None for no timeout.
    • Type: int, float, NoneType
    • Default: None