expyriment.io.GamePad

class expyriment.io.GamePad(gamepad_id, track_button_events=True, track_motion_events=False)

A class for creating gamepad/joystick input.

__init__(gamepad_id, track_button_events=True, track_motion_events=False)

Create a gamepad/joystick input.

Parameters:
gamepad_idint

id of the gamepad

track_button_eventsbool, optional

Track button events (default=True)

track_motion_eventsbool, optional

Track motion events (default=False)

clear()

Clear gamepad events from cue.

get_axis(axis)

Get current axis state.

Parameters:
axisint

axis to get the current state from

get_ball(ball)

Get current ball state.

Parameters:
ballint

ball to get the current state from

get_button(button)

Get current button state.

Parameters:
buttonint

button to get the current state from

static get_gampad_count()

Get the number of gamepads/joysticks connected to the system.

get_hat(hat)

Get current hat state.

Parameters:
hatint

hat to get the current state from

get_numaxes()

Get the number of axes.

get_numballs()

Get the number of balls.

get_numbuttons()

Get the number of buttons.

get_numhats()

Get the number of hats.

property id

Getter for id.

property joystick

Getter for joystick.

property logging

Getter for logging.

property name

Getter for name.

set_logging(onoff)

Set logging of this object on or off

Parameters:
onoffbool

set logging on (True) or off (False)

property track_button_events

Getter for track_button_events.

property track_motion_events

Getter for track_motion_events.

wait_press(buttons=None, duration=None, callback_function=None, process_control_events=True)

Wait for gamepad button press.

Returns the found button and the reaction time.

Parameters:
buttonsint or list, optional

specific buttons to wait for

durationint, optional

maximal time to wait in ms

callback_functionfunction, optional

function to repeatedly execute during waiting loop

process_control_eventsbool, optional

process io.Keyboard.process_control_keys() and io.Mouse.process_quit_event() (default = True)

Returns:
buttonint

button _id of the pressed button

rtint

reaction time in ms

Notes

This will also by default process control events (quit and pause). Thus, keyboard events will be cleared from the cue and cannot be received by a Keyboard().check() anymore!