You are viewing unmaintained documentation for an older version of OpenSesame. Click here to view the current documentation. Your version of OpenSesame: Language:

OpenSesame 3.0.0 will bring amazing new features! Curious? Take it for a test spin, and help us iron out the kinks.

Joystick

Overview

About

Joysticks and gamepads are supported through the joystick plug-in.

Using a joystick through Python inline code

class basejoystick

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 accessed from within an inline_script item as exp.joystick.

Function list:

function basejoystick.__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 – An timeout value in milliseconds or None for no timeout.
    • Type: int, float, NoneType
    • Default: None

function basejoystick.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 basejoystick.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 basejoystick.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 basejoystick.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 basejoystick.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 basejoystick.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 basejoystick.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 basejoystick.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 basejoystick.set_timeout(timeout=None)

Sets a timeout.

Keywords:

  • timeout – An timeout value in milliseconds or None for no timeout.
    • Type: int, float, NoneType
    • Default: None