Gamepad#
- class genesis_forge.gamepads.Gamepad(config: GamepadConfig = None, vendor_id=None, product_id=None, debug=False)[source]#
Bases:
objectGeneral gamepad controller, which automatically attempts to connect to known gamepads (currentlyLogitech F710 and F310).
Example:
>>> gamepad = Gamepad() >>> gamepad.state GamepadState(axis=[0.0, 0.0, 0.0, 0.0], buttons=[A], dpad=UP) >>> gamepad.state.axis [0.0, 0.0, 0.0, 0.0] >>> gamepad.state.buttons ["A"] >>> gamepad.state.dpad "UP" >>> gamepad.state.buttons = [Button.A]
Example connecting to a specific gamepad:
>>> gamepad = Gamepad(config=LOGITECH_F710_CONFIG)
Adapted from: google-deepmind/mujoco_playground.
- connect(vendor_id=None, product_id=None)[source]#
Attempt to connect to a gamepad.
- Parameters:
vendor_id – The vendor id of the gamepad to connect to.
product_id – The product id of the gamepad to connect to.
- Returns:
True if the gamepad connected successfully, False otherwise.
- property state: GamepadState#
The current state of the gamepad.