pyremoteplay.gamepad package
Submodules
Module contents
Gamepad interface to controlller.
- class pyremoteplay.gamepad.Gamepad(joystick)
Bases:
objectGamepad. Wraps a PyGame Joystick to interface with RP Controller. Instances are not re-entrant after calling close. Creating an instance automatically starts the event loop. Instances are closed automatically when deallocated. If creating a new instance with the same joystick as an existing gamepad, the existing gamepad will be returned. This ensures that only one gamepad instance will exist per joystick.
- Parameters
joystick (
Union[int,Joystick]) – Either the id from pygame.joystick.Joystick.get_instance_id() or an instance of pygame.joystick.Joystick.
- static joysticks()
Return All Joysticks.
- static get_all()
Return All Gamepads.
- static check_map(mapping)
Check map. Return True if valid.
- Return type
bool
- classmethod register(callback)
Register a callback with a single argument for device added/removed events.
- classmethod unregister(callback)
Unregister a callback from receiving device added/removed events.
- classmethod start()
Start Gamepad loop. Called automatically when an instance is created.
- classmethod stop()
Stop Gamepad loop.
- classmethod running()
Return True if running.
- Return type
bool
- load_map(filename)
Load map from file and apply. Mapping must be in yaml or json format.
- Parameters
filename (
str) – Absolute Path to File.
- save_map(filename)
Save current map to file.
- Parameters
filename (
str) – Absolute Path to File.
- default_map()
Return Default Map.
- Return type
dict
- close()
Close. Quit handling events.
- get_button(button)
Return button value.
- Return type
int
- get_axis(axis)
Return axis value.
- Return type
float
- get_config()
Return Joystick config.
- property controller: Controller
Return Controller.
- Return type
- property deadzone: float
Return axis deadzone. Will be positive. This represents the minimum threshold of the axis. If the absolute value of the axis is less than this value, then the value of the axis will be 0.0.
- Return type
float
- property mapping: dict
Return mapping.
- Return type
dict
- property instance_id: int
Return instance id.
- Return type
int
- property guid: str
Return GUID.
- Return type
str
- property name: str
Return Name.
- Return type
str
- property available: bool
Return True if available.
- Return type
bool