mholgatem / GPIOnext

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

Add deadzone config option? #39

Closed wmoecke closed 4 years ago

wmoecke commented 4 years ago

I notice that there is way too much sensitivity for the direction pad. It really gets in the way of a good user experience (even navigating through ES menus is a pain) - playing games such as Pacman or any S'MUPs (any game that relies heavily on direction control) becomes a nightmare sometimes, as the buttons seem to be doing whatever they want to do, due to their extreme "out-of-center" (for the lack of a better term) sensitivity.

An easy fix for this is to add a specific config for setting deadzone values. By deadzone, I mean the threshold value for the daemon to detect a transition from the center (all 4 direction buttons released) to any direction. The greater this value, the more the direction pad must be moved to any direction.

Thank you.

mholgatem commented 4 years ago

This would be nice, but unfortunately the raspberry pi gpio do not support analog input. So they can't see how far from center a direction is being pushed, they only see off or on. Altering the debounce threshold to a higher value can help with menu navigation as it will help filter out false positives. There is a way to emulate analog input with hardware on the raspberry pi, but that is beyond the scope of this project. Thanks for the suggestions though! Keep'em coming!

wmoecke commented 4 years ago

This is not analog, I'm using a DPAD. It is the DPAD that's causing trouble due to the lack of a deadzone. I've been experimenting with different values for both the debounce and combo_delay settings but so far with no distinguishable results.

mholgatem commented 4 years ago

Got it. But when I'm talking analog, I mean an analog signal, as opposed to a digital signal.

Let's use your dpad as an example. If it used an analog signal, the further from center that you pushed it, the higher voltage the signal would be. Thus, you could say, "ignore all voltages that are less than 0.01" to create a dead zone where the dpad wouldn't respond.

Unfortunately, the raspberry pi is digital only and can only discern "off" or "on" (0 or 1). So as soon as that analog signal comes to the pi, it can't see how far from center it is, only that it's not at center. So there's no way to set a dead zone.

With some simple hardware and clever programming, you can fake an analog signal by pulsing the digital pin. The smaller the delay between pulses, the further from center you would say you are. And thus, you could measure the pulse width to determine your dead zone.