FeralAI / GP2040

Gamepad firmware for Raspberry Pi Pico and other RP2040 microcontrollers supporting Nintendo Switch, XInput and DirectInput
https://gp2040.info
MIT License
586 stars 125 forks source link

Better support for analog inputs #5

Open FeralAI opened 3 years ago

FeralAI commented 3 years ago

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 commented 3 years ago

This may be better suited to the MPG library.

fiefdx commented 2 years ago

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

Oneil974 commented 2 years ago

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.

EditCanyon commented 2 years ago

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