piborg / gamepad Goto Github PK
View Code? Open in Web Editor NEWA simple library for getting game controller and joystick inputs into Python in Linux.
License: MIT License
A simple library for getting game controller and joystick inputs into Python in Linux.
License: MIT License
Hi,
I think the background thread never terminates because stopBackgroundUpdates()
just sets the running
flag that is checked in a while loop. But _getNexEventRaw()
blocks until there is an event. So, after stopBackgroundUpdates()
is called, there needs to be one last event (i.e. a button press) until the flag is checked and the thread actually terminates.
Does anybody have a good idea on how to gracefully stop the update thread? (Ctrl-C works to just terminate the process, but that is not very nice.)
I am using the XBox adaptive controller to make a robot for someone who has limited motion. This controller has two buttons and a D-Pad. The d-pad shows up as an axis, but the value always remains 0 regardless of if it is pressed or not. Is there a way to configure the D-pad to work like a button press rather than an analog axis?
The script I started with is the unmodified AsyncExample.py.
Thank you!
this library doesn't seem to detect wireless gamepads connected using BT.
When I run:
python3 PollingExample.py
script hangs on message:
Please connect your gamepad...
My hardware/software setup:
Xbox One wireless gamepad
Mac OS 12.5 Monterey
Python 3.8.9
The controller is working fine when tested on https://gamepad-tester.com/
Is there a chance to add support for wireless controllers?
I've been getting this error when I run any script, including EventExample.py
Gamepad connected
Traceback (most recent call last):
File "/mnt/raid1/Code/Useful/Gamepad/Gamepad.py", line 421, in addButtonPressedHandler
if callback not in self.pressedEventMap[buttonIndex]:
KeyError: 0
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/mnt/raid1/Code/Useful/Gamepad/EventExample.py", line 64, in
gamepad.addButtonPressedHandler(buttonHappy, happyButtonPressed)
File "/mnt/raid1/Code/Useful/Gamepad/Gamepad.py", line 424, in addButtonPressedHandler
raise ValueError('Button %i was not found' % buttonIndex)
ValueError: Button 0 was not found
The only thing changed in EventExample.py is this:
if not Gamepad.available(1):
print('Please connect your gamepad...')
while not Gamepad.available(1):
time.sleep(1.0)
gamepad = gamepadType(1)
print('Gamepad connected')
I put "1" in the parantheses instead of default value 0.
It says "GamePad Connected" even if the GamePad is not connected.
Describe the bug
PS4 gamepad is detected and connected. However the reported axis and buttons are wrong. Async doesn't update the values and events are not fired.
To Reproduce
Run any example from the folder
Hello!
I tried using the Gamepad.py
but kept running into a Key error, any idea how to solve it?
We have a Logitech F710 Gamepad, that we'd like to use for event based callbacks, so thought of using this library.
I tried running the Gamepad.py
on python3 with our controller to find the mappings to make my own class, so started with the PS4
class, ran into a key error, thought it was because I used the wrong class for my gamepad.
But after a few trials, found out that the problem wasn't with the Gamepad class. The Gamepad.py
generates an output for only 2 buttons (R1 and B) and 2 axes, for every other button or axis event, it throws a Key error. I haven't changed anything in the Gamepad.py
. Would be great if I could receive some insight into how to solve this issue.
Screenshots
Available device names:
Gamepad - Generic (numbers only)
Logitech - Logitech Rumblepad
MMP1251 - ModMyPi Raspberry Pi Wireless USB Gamepad
PS3 - PlayStation 3 controller
PS4 - PlayStation 4 controller
Xbox360 - Xbox 360 controller
example - Enter the human readable name of the device here
What device name are you using (leave blank if not in the list)
? Logitech
Gamepad connected
Logitech Rumblepad
BUTTON, R1, True
BUTTON, R1, False
BUTTON, R1, True
BUTTON, R1, False
BUTTON, R1, True
BUTTON, R1, False
BUTTON, R1, True
BUTTON, B, False
BUTTON, B, True
BUTTON, B, False
BUTTON, B, True
BUTTON, B, False
BUTTON, B, True
BUTTON, B, False
BUTTON, B, True
BUTTON, B, False
BUTTON, B, True
BUTTON, B, False
Traceback (most recent call last):
File "./Gamepad.py", line 613, in <module>
eventType, index, value = gamepad.getNextEvent()
File "./Gamepad.py", line 244, in getNextEvent
return self.getNextEvent()
File "./Gamepad.py", line 211, in getNextEvent
for callback in self.movedEventMap[index]:
KeyError: 3
Hardware setup
Thanks in advance
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.