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.
You can set the following options:
Correct response is the name of the expected response. Usually you will set the correct_response variable elsewhere (e.g., in a loop item) and you can leave this field empty. Please note that setting correct responses via the joystick_response item is only possible for button input.
Allowed responses is a semicolon-separated list of buttons that are accepted, e.g., '1;2'.
Timeout contains a maximum response time in milliseconds or 'infinite' for no timeout.
The keyboard_response item sets a number of variables based on your response.
response is the name of the response key.
response_time is the time between the start of the response interval and the response.
correct is 1 if the response matches the correct_response and 0 otherwise.
avg_rt / average_response_time is the average response time since the last feedback item.
acc / accuracy is the average percentage of correct responses since the last feedback item.
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).
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