https://github.com/team1157/controller-library
Originally requested to have its own repository within our teams, this repository houses our python controller library using the `inputs` package
https://github.com/team1157/controller-library
Last synced: 3 months ago
JSON representation
Originally requested to have its own repository within our teams, this repository houses our python controller library using the `inputs` package
- Host: GitHub
- URL: https://github.com/team1157/controller-library
- Owner: Team1157
- License: mit
- Created: 2023-02-01T04:38:12.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-13T06:42:59.000Z (about 1 year ago)
- Last Synced: 2025-01-13T00:24:18.563Z (5 months ago)
- Language: Python
- Homepage:
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Landshark's Controller Library
This code originally comes from [TensorKart's utils.py](https://github.com/kevinhughes27/TensorKart/blob/master/utils.py), which is under the MIT License.The code has been adapted to fit our needs, but remains under the MIT License.
## General Changes:
- Checking if the controller is plugged in at the start/ever gets unplugged or disconnected somehow
- Stopping the program by checking if the monitor thread is no longer alive, with a message to the user!## Dict Values:
- `"a"`: A Button
- `"b"`: B Button
- `"x"`: X Button
- `"y"`: Y Button
- `"ls"`: Left Joystick Pushed
- `"rs"`: Right Joystick Pushed
- `"back"`: "View" (Double Square) Button
- `"start"`: "Menu" (Hamburger/3 Lines) Button
- `"share"`: Share Button (Below Xbox Button, Series X/S Only)
- `"xbox"`: Xbox Logo Button
- `"lb"`: Left Bumper
- `"rb"`: Right Bumper
- `"dx"`: D-Pad X
- `"dy"`: D-Pad Y
- `"lt"`: Left Trigger (0 to 1)
- `"rt"`: Right Trigger (0 to 1)
- `"lsx"`: Left Joystick X (-1 to 1)
- `"lsy"`: Left Joystick Y (-1 to 1)
- `"rsx"`: Right Joystick X (-1 to 1)
- `"rsy"`: Right joystick Y (-1 to 1)## Example Usage:
```python
from controller import XboxControllercontroller = XboxController()
readDict = controller.read()
print(readDict["lsy"]) # Print the value of the left joystick y
# EX: 0.672638 (This will be a range of -1 to 1, inclusive)print(int(round(readDict["lsy"], 2) * 100)) # Print the value of the left joystick y but rounded to 2 spots and multiplied by 100
# EX: 67 (This will be a range of -100 to 100, inclusive, and never have decimals)
```