mholgatem / GPIOnext

The next evolution of GPioneer! Create virtual gamepads with your GPIO pins!
MIT License
134 stars 37 forks source link

Buttons sticking #68

Closed CannGramps closed 2 years ago

CannGramps commented 2 years ago

I'm running Retropie on a Raspberry Pi 4 and have joysticks and buttons wired to the GPIO pins. If a key is pressed multiple times in rapid succession sometimes the key sticks and acts as though it is held down until you press it again, I can get this to happen on multiple keys at the same time. I checked Htop and there are several more copies of the script running for each stuck key, but they go away after I press the key again and it becomes unstuck.

mholgatem commented 2 years ago

GPIOnext is multithreaded, so each time that a key is pressed, a new thread is created to handle whatever needs to be done, then it destroys itself upon completion (usually key release). So that is what you are seeing in HTOP.

As for the actual problem, it's a known issue that can't be avoided, but it can be mitigated. Unfortunately, due to the nature of python and the Linux kernel, GPIO polling is not suitable for real-time applications. Which means that sometimes events (like key release) gets missed. Here are some ways to mitigate the problems:

Hopefully this helps!