python driver for g29 wheel/pedals
Project description
g29py
python driver for logitech g29 wheel/pedals
Install
pip install g29py
g29py depends on the PyPI hidapi package, which provides prebuilt wheels on common platforms.
If a wheel is not available for your platform and pip falls back to a source build on Linux, you may still need system HID dependencies such as:
sudo apt install libusb-1.0-0-dev libudev-dev
Use
from g29py import G29
g29 = G29()
g29.set_range(500)
g29.listen()
while True:
state = g29.get_state()
events = g29.get_events()
print(state["steering"], state["accelerator"], state["brake"])
if events:
print(events)
Read
State vs Events
The driver exposes two read models:
get_state()- latest snapshot
- use for steering, pedals, and held buttons
get_events()- buffered transient input events
- use for button edges and dial pulses
Rule of thumb:
- if you want to know what is true now, use state
- if you want to know what happened since the last poll, use events
Pedals/Steering
| Pedal | Value Range | Neutral Position |
|---|---|---|
steering |
Float: -1 to 1 | 0 (Centered) |
accelerator |
Float: -1 to 1 | -1 (Not pressed) |
clutch |
Float: -1 to 1 | -1 (Not pressed) |
brake |
Float: -1 to 1 | -1 (Not pressed) |
Buttons
| Button | Value |
|---|---|
up |
0/1 |
down |
0/1 |
left |
0/1 |
right |
0/1 |
X |
0/1 |
O |
0/1 |
S |
0/1 |
T |
0/1 |
R2 |
0/1 |
R3 |
0/1 |
L2 |
0/1 |
L3 |
0/1 |
right_paddle |
0/1 |
left_paddle |
0/1 |
Share |
0/1 |
Options |
0/1 |
+ |
0/1 |
- |
0/1 |
back |
0/1 |
PS |
0/1 |
State is returned in a flattened shape:
state = {
"steering": 0.0,
"accelerator": -1.0,
"clutch": -1.0,
"brake": -1.0,
"buttons": {
"up": 0,
"down": 0,
"left": 0,
"right": 0,
"X": 0,
"O": 0,
"S": 0,
"T": 0,
"R2": 0,
"R3": 0,
"L2": 0,
"L3": 0,
"right_paddle": 0,
"left_paddle": 0,
"Share": 0,
"Options": 0,
"+": 0,
"-": 0,
"back": 0,
"PS": 0,
},
}
Events
Transient inputs are exposed through get_events().
events = g29.get_events()
Current event shapes:
{"type": "button_down", "control": "X"}
{"type": "button_up", "control": "X"}
{"type": "dial", "delta": 1}
{"type": "dial", "delta": -1}
get_events() clears the buffered event queue on read.
Write
| Method Name | Default Parameters | Parameter Types |
|---|---|---|
reset |
wait_seconds=5.0 |
wait_seconds: float |
force_constant |
val=0.0 |
val: float (-1 to 1) |
set_friction |
val=0.5 |
val: float |
set_range |
val=400 |
val: int (400-900) |
set_autocenter |
ccw_proportion=0.5, cw_proportion=0.5, force=0.5 |
ccw_proportion: float (0-1), cw_proportion: float (0-1), force: float (0-1) |
set_anticenter |
slot=1, cw_position=0.5, ccw_position=0.5, cw_proportion=0.5, ccw_proportion=0.5, cw_reverse=False, ccw_reverse=False, force=0.5 |
slot: int (1-4), cw_position: float (0-1), ccw_position: float (0-1), cw_proportion: float (0-1), ccw_proportion: float (0-1), cw_reverse: bool, ccw_reverse: bool, force: float (0-1) |
autocenter_off |
None | None |
force_off |
slot=0xf3 |
slot: int off-mask / slot command (0xf3 clears active force effects) |
Development
Use Python 3.9+
Setup:
poetry install
Useful commands:
make test
make build
make twine-check
make release-test
Examples:
poetry run python -u examples/dial_events.py
poetry run python scripts/test_effects.py set_friction --val 0.5 --hold 5
Support
Only Logitech G29 Driving Force Racing Wheels & Pedals kit supported on linux in ps3 mode.
On linux, remove sudo requirements by adding udev rule.
echo 'KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c24f", MODE="0664", GROUP="plugdev"' \
| sudo tee /etc/udev/rules.d/99-g29py.rules
sudo udevadm control --reload-rules
sudo udevadm trigger
Sources
- Commands were originally informed by nightmode's logitech-g29 node.js driver.
- Effects/layout were cross-checked against WiiBrew's Logitech USB steering wheel reference.
- HID access is provided by the Python
hidapipackage. - Behavior has also been manually verified against a real Logitech G29 on Linux.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file g29py-0.0.14.tar.gz.
File metadata
- Download URL: g29py-0.0.14.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.3 CPython/3.12.3 Linux/6.17.0-14-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32981f93aebcc9c5c267663135e8ae738f38954cd0a175fa69d5efdeee5e5a6a
|
|
| MD5 |
cdfd1c91d860d87d6a8daa54ab77d578
|
|
| BLAKE2b-256 |
28c2bcab80b668af01d0731f88815db0a4feeb6f1f1525da9c38963225fb88bc
|
File details
Details for the file g29py-0.0.14-py3-none-any.whl.
File metadata
- Download URL: g29py-0.0.14-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.3 CPython/3.12.3 Linux/6.17.0-14-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1f329c8a4107bec9295805c25e674dd50562f13a21c2ea8a1ab305a5242a8db
|
|
| MD5 |
fabdc8a09b951b9ec625e46284bf7b63
|
|
| BLAKE2b-256 |
6517063b0ff05b7b291805d76ab414a5fd1114ef835828c03d72fa9a353b8132
|