Joystick items

In psychological research a large amount of input devices are being used to record participants' responses. This joystick item can handle input from joystick devices, including trackballs and video-game-style gamepads. Using the joystick module of PyGame, joystick allows for the use of a joystick with buttons, axes, trackballs and hats.

Options

You can set the following options:

Variables set by joystick

The keyboard_response item sets a number of variables based on your response.

Button names

Depending on the kind of joystick or gamepad you use, a different number of buttons, axes, tracksballs and hats are available. Please make sure you know which button corresponds to which buttonnumber (same goes for axes, hats and trackballs).

Inline scripting

After a joystick item has been used in your experiment, you can use the following functions in inline_script items as well:


set_joybuttonlist(joybuttonlist=None)

Sets a list of accepted buttons

Keyword arguments:

joybuttonlis – a list of button numbers that are accepted or

None to accept all buttons (default = None)



set_timeout(timeout=None)

Sets a timeout

Keyword arguments:

timeout – an integer value specifying a timeout in milliseconds

or None for no timeout (default = None)



get_joybutton(joybuttonlist=None,timeout=None)

Waits for a joystick button input

Keyword arguments:

joybuttonlist – a list of button numbers that are accepted or

None to use the default. This parameter does not

change the default joybuttonlist, as can be set

using set_joybuttonlist. (default = None)

timeout – an integer value specifying a timeout in

milliseconds or None to use the default, as can be

set by set_timeout. (default = None)

Returns:

A (joybutton, timestamp) tuple. The joybutton is None if a

timeout occurs.



get joyaxes(timeout=None)

Waits for joystick axes input

Keyword arguments:

timeout -- an integer value specifying a timeout in milliseconds

or None to use the default, as can be set by set_timeout.

(default = None)

Returns:

A (position, timestamp) tuple. The position is None if a timeout

occurs.



get_joyballs(timeout=None)

Waits for joystick trackball movement

Keyword arguments:

timeout -- an integer value specifying a timeout in milliseconds

or None to use the default, as can be set by set_timeout.

(default = None)

Returns:

A (position, timestamp) tuple. The position is None if a timeout

occurs.



get_joyhats(timeout=None)

Waits for joystick hat movement

Keyword arguments:

timeout -- an integer value specifying a timeout in milliseconds

or None to use the default, as can be set by set_timeout.

(default = None)

Returns:

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



get_joyinput(joybuttonlist=None,timeout=None)

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

Keyword arguments:

joybuttonlist – a list of button numbers that are accepted or None to

use the default. This parameter does not change the

default joybuttonlist, as can be set using set_joybuttonlist.

(default = None)

timeout – an integer value specifying a timeout in milliseconds or

None to use the default, as can be set by set_timeout.

(default = None)

Returns:

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



input_options()

Generates a list with the amount of available buttons, axes, balls and hats

Returns:

List with number of inputs as [buttons, axes, balls, hats]



flush()

Clears all pending input, not limited to the joystick

Returns:

True if a joyinput has been made (i.e.: if there was something to flush) and False otherwise