GP2040 icon indicating copy to clipboard operation
GP2040 copied to clipboard

Better support for analog inputs

Open FeralAI opened this issue 3 years ago • 4 comments

GP2040 supports sending analog values in the USB reports, however there is no specific implementation around the use/handling of those analog inputs.

The RP2040 MCU supports 4 ADC channels, with the Pi Pico only making 3 available. Having 4 channels is enough for 2 full joysticks, and there are a few RP2040 boards out there that make all 4 channels available, such as the Sparkfun RP2040 Thing Plus. The Arduino Nano RP2040 Connect actually supports up to 8 ADC channels, which is enough for a full analog XInput implementation.

Need to add features such as options for enabling, deadzone calibration, and possibly some kind of auto calibration to avoid drift.

FeralAI avatar Sep 04 '21 01:09 FeralAI

This may be better suited to the MPG library.

FeralAI avatar Sep 22 '21 01:09 FeralAI

maybe use analogue multiplexer to sample multiple analogue inputs with only 1 or 2 ADCs

fiefdx avatar Jan 24 '22 09:01 fiefdx

Hello, GP2040 is an amazing project! Thanks for all your work. Maybe multiplexer could have an impact on performance but it should work at all for no-fighting games. It would be perfect to get analog input to use analog joysticks. Even one for 2D games could be nice.

Oneil974 avatar Jan 26 '22 03:01 Oneil974

I have practically zero experience codin and my syntax is likely all wrong, so everything needs to be rewritten. But nevertheless, could this be a simple deadzone check in analog read after setting a shifted mean point of origin?

define Xy(x,y):

  define Xy_deadzonecheck():
     x = 0
     y = ROOT(X(shift)^2 + y(shift)^2)

     if deadzonecheck[x,y] =< 500:
        x = 0
        y = 0
     elif deadzonecheck[x,y] > 500:

I hope the meaning gets through. Kind regards Jonas Olesen

EditCanyon avatar Jul 16 '22 11:07 EditCanyon