xbox.py
Python class to support reading xbox 360 wired and wireless controller input under Linux. Makes it easy to get real-time input from controller buttons, analog sticks and triggers. Built and tested on RaspberryPi running Raspbian.
Requires that xboxdrv be installed first:
sudo apt-get install xboxdrv
To test the driver, issue the following command and see if the controller inputs are recognized
sudo xboxdrv --detach-kernel-driver
See http://pingus.seul.org/~grumbel/xboxdrv/ for details on xboxdrv
Download the python module and sample code with the following:
wget https://raw.githubusercontent.com/FRC4564/Xbox/master/xbox.py
wget https://raw.githubusercontent.com/FRC4564/Xbox/master/sample.py
You can run the sample code to see how the Joystick class works.
sudo python sample.py
Example class usage:
import xbox
joy = xbox.Joystick() #Initialize joystick
if joy.A(): #Test state of the A button (1=pressed, 0=not pressed)
print 'A button pressed'
x_axis = joy.leftX() #X-axis of the left stick (values -1.0 to 1.0)
(x,y) = joy.leftStick() #Returns tuple containing left X and Y axes (values -1.0 to 1.0)
trigger = joy.rightTrigger() #Right trigger position (values 0 to 1.0)
joy.close() #Cleanup before exit
Note: Run your code with sudo privileges to allow xboxdrv the necessary control over USB devices. If you want, you can provide your user account with the proper access, so you needn't use sudo.
First, add your user to the root group. Here's how to do this for the user ‘pi’
sudo usermod -a -G root pi
Create a permissions file using the nano text editor.
sudo nano /etc/udev/rules.d/55-permissions-uinput.rules
Enter the following rule and save your entry.
KERNEL=="uinput", MODE="0660", GROUP="root"
Troubleshooting
I find that xboxdrv occasionally has trouble connecting to the controller. You may see a USB device error or something similar. Issuing the following command will detach and reconnect the controller.
sudo xboxdrv --detach-kernel-driver
You should now be able to move the joysticks and press buttons to see the controller state display for all inputs. Just press Ctrl-C to exit and then relaunch your python code that uses xbox.py.
If your wireless controller still won't connect, press the sync button on the controller and the receiver (both devices need to be powered).
Usage
A good application for an XBox controller is for robot control. Check out Basic PiBot for more details.
Metadata
Release files for xbox-remote 1.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| xbox-remote-1.0.5.tar.gz | 5.8 kB | Without provenance | Details for xbox-remote-1.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| xbox_remote-1.0.5-py3-none-any.whl | Python 3 | none | any | Details for xbox_remote-1.0.5-py3-none-any.whl |
Total release size: 12.1 kB
Release files / xbox-remote-1.0.5.tar.gz
| Download URL | xbox-remote-1.0.5.tar.gz |
|---|---|
| Size | 5.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d0e51d94d83341b9c8d18c9fb4df530cba3afbe163c0821a324dc63935f1232d
|
|
BLAKE2b-256 checksum How to use checksums |
aa6d2aa5bd3a9c55338088d3a19268a7f8513e66033051b21d0f8a02bb109dfa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.8.5
|
Release files / xbox_remote-1.0.5-py3-none-any.whl
| Download URL | xbox_remote-1.0.5-py3-none-any.whl |
|---|---|
| Size | 6.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
723bd41490bd73c382edd99d6e6ea45e025999d11fb638edbbba0f5e02aa9271
|
|
BLAKE2b-256 checksum How to use checksums |
20bfad64b5e3aae46ba5a7c3532075eb1eb1ac1e5cd4014994a066860a006b17
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.8.5
|
Security for xbox-remote 1.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.