Introduction
CircuitPython USB host driver for game controller devices.
Supports the following devices:
Generix XInput Controllers
Switch Pro Controller (Wired)
8BitDo Zero 2 (Wired)
PowerA Wired Controller
Sony PlayStation DUALSHOCK 4 Controller (Wired)
Some HID-compliant Joysticks * Microsoft SideWinder Force Feedback 2
Dependencies
This driver depends on:
Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading the Adafruit library and driver bundle or individual libraries can be installed using circup.
Installing from PyPI
On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally from PyPI. To install for current user:
pip3 install circuitpython-usb-host-gamepad
To install system-wide (this may be required in some cases):
sudo pip3 install circuitpython-usb-host-gamepad
To install in a virtual environment in your current project:
mkdir project-name && cd project-name
python3 -m venv .venv
source .env/bin/activate
pip3 install circuitpython-usb-host-gamepad
Installing to a Connected CircuitPython Device with Circup
Make sure that you have circup installed in your Python environment.
Install it with the following command if necessary:
pip3 install circup
With circup installed and your CircuitPython device connected use the
following command to install:
circup install relic_usb_host_gamepad
Or the following command to update an existing version:
circup update
Usage Example
import relic_usb_host_gamepad
gamepad = relic_usb_host_gamepad.Gamepad()
while True:
if gamepad.update():
for event in gamepad.events:
print(event)
Documentation
API documentation for this library can be found on Read the Docs.
For information on building library documentation, please check out this guide.
Contributing
Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.
Table of Contents
Examples
API Reference
- API Reference
relic_usb_host_gamepadBUTTON_ABUTTON_BBUTTON_DOWNBUTTON_HOMEBUTTON_JOYSTICK_DOWNBUTTON_JOYSTICK_LEFTBUTTON_JOYSTICK_RIGHTBUTTON_JOYSTICK_UPBUTTON_L1BUTTON_L2BUTTON_L3BUTTON_LEFTBUTTON_NAMESBUTTON_R1BUTTON_R2BUTTON_R3BUTTON_RIGHTBUTTON_SELECTBUTTON_STARTBUTTON_TOUCH_PADBUTTON_UPBUTTON_XBUTTON_YButtonsButtons.AButtons.BButtons.DOWNButtons.HOMEButtons.JOYSTICK_DOWNButtons.JOYSTICK_LEFTButtons.JOYSTICK_RIGHTButtons.JOYSTICK_UPButtons.L1Buttons.L2Buttons.L3Buttons.LEFTButtons.R1Buttons.R2Buttons.R3Buttons.RIGHTButtons.SELECTButtons.STARTButtons.TOUCH_PADButtons.UPButtons.XButtons.YButtons.changedButtons.eventsButtons.pressedButtons.reset()
DEVICE_NAMESDEVICE_TYPE_8BITDO_ZERO2DEVICE_TYPE_ADAFRUIT_SNESDEVICE_TYPE_HID_JOYSTICKDEVICE_TYPE_PLAYSTATION_DS4DEVICE_TYPE_POWERA_WIREDDEVICE_TYPE_SWITCH_PRODEVICE_TYPE_UNKNOWNDEVICE_TYPE_XINPUTGamepadGamepad.buttonsGamepad.connectedGamepad.device_typeGamepad.disconnect()Gamepad.eventsGamepad.joystick_deadzoneGamepad.joystick_thresholdGamepad.left_joystickGamepad.left_joystick_invert_xGamepad.left_joystick_invert_yGamepad.left_triggerGamepad.portGamepad.right_joystickGamepad.right_joystick_invert_xGamepad.right_joystick_invert_yGamepad.right_triggerGamepad.trigger_thresholdGamepad.update()
Related Products