Code Monkey home page Code Monkey logo

arduinogamepad's Introduction

Hi there 👋

Discord: GAMELASTER#8007

arduinogamepad's People

Contributors

gamelaster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

arduinogamepad's Issues

Installation instructions are outdate

Probably a minor thing, but I'm only weeks into Arduino use and the current way to install libraries seems to be to use the library manager to install the ZIP directly.

This works fine although I really wish they still supported the "copy and paste" version as that would make it easier to develop and debug, I suspect.

Anyway, I got it loaded so I can give it a go now. Why does USB have to be such a right royal pain the in butt?!

More Buttons

I'm working on a handheld using the pro micro and I need at least two more buttons.

Arduino Leonardo Controller Button Issue on Recalbox with Raspberry Pi 4B

Hello everyone!

I'm in need of some assistance with a custom Arduino Leonardo game controller I've been working on. I've utilized the library here to set up my controller. It's functioning perfectly when tested on the Windows gamepad settings—every button press and joystick movement is detected without any hiccups.

However, I've hit a snag with Recalbox on my Raspberry Pi 4B. While the system does recognize the controller as a Leonardo and allows me to use the joystick to navigate the Recalbox menu, none of the buttons are being detected within the controller configuration menu.

Has anyone experienced a similar issue, or can offer any insights into why this might be happening? Your help would be immensely appreciated to get my custom controller fully operational with Recalbox.

Thank you in advance!

Here is my arduino code:

`/*
Select: button8
Start: button9
Hotkey: button9
L: button4 (Joystick L button)
R: button5 (Joystick R button)
X: button0
Y: button3
A: button1
B: button2
D-U: axis 1-
D-D: axis 1+
D-L: axis 0-
D-R: axis 0+
*/
#include <Gamepad.h>

//left joystick
int leftXcenter = 500;
int leftYcenter = 500;
double multiplierLX = 0.254;
double multiplierLY = 0.254;

//right joystick
int rightXcenter = 500;
int rightYcenter = 500;
double multiplierRX = 0.254;
double multiplierRY = 0.254;

Gamepad gp;

void setup() {
//Left joystick
pinMode(A0, INPUT);
pinMode(A1, INPUT);
//Right joystick
pinMode(A2, INPUT);
pinMode(A3, INPUT);

//Start, Select buttons
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);

//ABXY
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
pinMode(7, INPUT_PULLUP);

//LR
pinMode(8, INPUT_PULLUP); //Joystick L button
pinMode(9, INPUT_PULLUP);//Joystick R button

calibrate();
}

void loop() {
int lx, ly, rx, ry;
//left joystick
lx = analogRead(A0);
ly = analogRead(A1);
lx = floor((lx - leftXcenter) * multiplierLX);
ly = floor((ly - leftYcenter) * multiplierLY);
if(lx > 127) lx = 127;
if(ly > 127) ly = 127;
gp.setLeftXaxis(lx);
gp.setLeftYaxis(ly);

//right joystick
rx = analogRead(A2);
ry = analogRead(A3);
rx = floor((rx - rightXcenter) * multiplierRX);
ry = floor((ry - rightYcenter) * multiplierRY);
if(rx > 127) rx = 127;
if(ry > 127) ry = 127;
gp.setRightXaxis(rx);
gp.setRightYaxis(ry);

int select, start, a, b, x, y, l, r;
select = digitalRead(2);
start = digitalRead(3);

a = digitalRead(4);
b = digitalRead(5);
x = digitalRead(6);
y = digitalRead(7);
l = digitalRead(8);
r = digitalRead(9);

if(select == LOW)
gp.setButtonState(8, true);
else
gp.setButtonState(8, false);

if(start == LOW)
gp.setButtonState(9, true);
else
gp.setButtonState(9, false);

if(a == LOW)
gp.setButtonState(1, true);
else
gp.setButtonState(1, false);

if(b == LOW)
gp.setButtonState(2, true);
else
gp.setButtonState(2, false);

if(x == LOW)
gp.setButtonState(0, true);
else
gp.setButtonState(0, false);

if(y == LOW)
gp.setButtonState(3, true);
else
gp.setButtonState(3, false);

//L R button
if(l == LOW)
gp.setButtonState(4, false);
else
gp.setButtonState(4, true);

if(r == LOW)
gp.setButtonState(5, false);
else
gp.setButtonState(5, true);

delay(20);
}

void calibrate()
{
int lx, ly, rx, ry;
int i = 0;
while(i < 8)
{
lx = analogRead(A0);
ly = analogRead(A1);
bool validLX = lx > (leftXcenter - 100) && lx < (leftXcenter + 100);
bool validLY = ly > (leftYcenter - 100) && ly < (leftYcenter + 100);

rx = analogRead(A2);
ry = analogRead(A3);
bool validRX = rx > (rightXcenter - 100) && rx < (rightXcenter + 100);
bool validRY = ry > (rightYcenter - 100) && ry < (rightYcenter + 100);

if(validLX && validLY && validRX && validRY)
{
  i++;
  //nothing to do here!
}
else i = 0;
delay(20);

}
leftXcenter = lx;
leftYcenter = ly;
multiplierLX = (double)127 / (double)lx;
multiplierLY = (double)127 / (double)ly;

rightXcenter = rx;
rightYcenter = ry;
multiplierRX = (double)127 / (double)rx;
multiplierRY = (double)127 / (double)ry;
}
`

uint8_t in readme

In the readme the setters for the axes all expect an uint8_t but that should be an int8_t.

Testing

I used this site: https://gamepad-tester.com/

and validated everything works - which (after having no luck with the alternatives) was a wonderful surprise. Of course, now that means I have no excuses not to build the hardware I'd promised my little trainee. Drat and triple drat!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.