Yeah but that not that badif your code is not good, it sends releases or other commands constantlycode
Cheaper than Teensy
- Oxodao
- Posts: 131
- Joined: Wed Jun 01, 2016 11:35 am
- Location: 127.0.0.1
- Has thanked: 4 times
- Been thanked: 30 times
- Contact:
Re: Cheaper than Teensy
Yep i'm working on that, I can handle this. Just tell me on which port you link the buttons
Arduino sketch for the gamepad (Teensy replacement): http://github.com/oxodao/GBZGamepad
- Fleder
- Posts: 849
- Joined: Thu May 05, 2016 9:04 am
- Location: Germany
- Has thanked: 183 times
- Been thanked: 258 times
Re: Cheaper than Teensy
Well, i had a micro that went into USB HID mode, sent inputs and i was not able to reprogramm it.Oxodao wrote:Yeah but that not that bad
I had to flash the ram again with a AVR programer to get it working again.
But thanks for your work here!
- Oxodao
- Posts: 131
- Joined: Wed Jun 01, 2016 11:35 am
- Location: 127.0.0.1
- Has thanked: 4 times
- Been thanked: 30 times
- Contact:
Re: Cheaper than Teensy
Just use a safe mode which prevents the arduino from typing with a switch
Arduino sketch for the gamepad (Teensy replacement): http://github.com/oxodao/GBZGamepad
- Fleder
- Posts: 849
- Joined: Thu May 05, 2016 9:04 am
- Location: Germany
- Has thanked: 183 times
- Been thanked: 258 times
Re: Cheaper than Teensy
That is the problem, i have no idea how to code this properly.Oxodao wrote:Just use a safe mode which prevents the arduino from typing with a switch
I know this trick, to conect a pin to gnd to disable USB HID mode, but the rest is a closed book to me.
And this can be a problem, if you are going to use all of the inputs for buttons.
- Oxodao
- Posts: 131
- Joined: Wed Jun 01, 2016 11:35 am
- Location: 127.0.0.1
- Has thanked: 4 times
- Been thanked: 30 times
- Contact:
Re: Cheaper than Teensy
I'm gonna do the code dont worry guys
Arduino sketch for the gamepad (Teensy replacement): http://github.com/oxodao/GBZGamepad
- Helder
- Trailblazer
- Posts: 2985
- Joined: Thu May 05, 2016 8:33 am
- Location: Rogers, AR
- Has thanked: 1459 times
- Been thanked: 3114 times
Re: Cheaper than Teensy
I'm actually working on a project using an atmega2560 with 2 other people that is way more advanced in complicity and code, and I can ask them for a little help on the code end to see if they can come up with something.
Chat with me and other members On Discord
Don't contact me about obtaining my board files (as you will not get them). If my Boards or PCB Kits are sold out, they will be restocked as soon as I can get them and there is demand for them. You can join the mailing list on my Website to be notified when they are available.
Helder's Game Tech Website
We will not support any cloned work so don't come to us with technical issues to resolve, go talk to the cloner for help.
Don't contact me about obtaining my board files (as you will not get them). If my Boards or PCB Kits are sold out, they will be restocked as soon as I can get them and there is demand for them. You can join the mailing list on my Website to be notified when they are available.
Helder's Game Tech Website
We will not support any cloned work so don't come to us with technical issues to resolve, go talk to the cloner for help.
- Oxodao
- Posts: 131
- Joined: Wed Jun 01, 2016 11:35 am
- Location: 127.0.0.1
- Has thanked: 4 times
- Been thanked: 30 times
- Contact:
Re: Cheaper than Teensy
Okay so here is the working code (At least for the D-pad, I did not try the other buttons since my wire unsoldered itself and I dont have any soldering iron where I am now...):
Here is the library: https://github.com/GAMELASTER/ArduinoGamepad
Just edit the Gamepad.cpp file and remove every call to "sendUpdate" in the setButtonState and Set...Axis functions, so that it update everything only once and not 12 times a run...
The code is licenced under WTFPL V2
Code: Select all
#include <Gamepad.h>
Gamepad gb;
// I'm wondering why this takes all of the ports, why it starts at 2 and skip the 11, 12 & 13...
#define BTN_UP 2
#define BTN_LEFT 3
#define BTN_DOWN 4
#define BTN_RIGHT 5
#define BTN_B 6
#define BTN_A 7
#define BTN_X 8
#define BTN_Y 9
#define BTN_SELECT 10
#define BTN_START 14
#define BTN_BCKLEFT 15
#define BTN_BACKRIGHT 16
void setup() {
for (int x = 2; x<16; x++){
if (x != 11 && x != 12 && x!= 13)
pinMode(x, INPUT_PULLUP);
}
}
void loop() {
bool downSet = digitalRead(BTN_DOWN);
bool upSet = digitalRead(BTN_UP); // No pun intended
bool leftSet = digitalRead(BTN_LEFT);
bool rightSet = digitalRead(BTN_RIGHT);
gb.setLeftXaxis(!leftSet ? -127 : !rightSet ? 127 : 0);
gb.setLeftYaxis(!downSet ? -127 : !upSet ? 127 : 0);
gb.setButtonState(1, digitalRead(BTN_A));
gb.setButtonState(2, digitalRead(BTN_B));
gb.setButtonState(3, digitalRead(BTN_X));
gb.setButtonState(4, digitalRead(BTN_Y));
gb.setButtonState(5, digitalRead(BTN_SELECT));
gb.setButtonState(6, digitalRead(BTN_START));
gb.setButtonState(7, digitalRead(BTN_BCKLEFT));
gb.setButtonState(8, digitalRead(BTN_BCKRIGHT));
gb.sendUpdate();
}
Just edit the Gamepad.cpp file and remove every call to "sendUpdate" in the setButtonState and Set...Axis functions, so that it update everything only once and not 12 times a run...
The code is licenced under WTFPL V2

Arduino sketch for the gamepad (Teensy replacement): http://github.com/oxodao/GBZGamepad
- Fleder
- Posts: 849
- Joined: Thu May 05, 2016 9:04 am
- Location: Germany
- Has thanked: 183 times
- Been thanked: 258 times
Re: Cheaper than Teensy
So, you are going the joystick kind of route then?
Would you also consider the keyboard solution? Since some RetroPie versions do not come with Joystick support, only for keyboard inputs.
Would you also consider the keyboard solution? Since some RetroPie versions do not come with Joystick support, only for keyboard inputs.
- Oxodao
- Posts: 131
- Joined: Wed Jun 01, 2016 11:35 am
- Location: 127.0.0.1
- Has thanked: 4 times
- Been thanked: 30 times
- Contact:
Re: Cheaper than Teensy
Oh I did not know this.. I'll try to fix my first script so that the user can chose the way he go though I'm not sûre I'll be able to do this in Linux... I'll try as soon as I get my board fixed
EDIT: Here is the code, Still untested. I'll try it as soon as possible. No external libraries, and at least it compiles :p
EDIT2: OOOPS very bad idea. Not working, can't reprogram..
EDIT: Here is the code, Still untested. I'll try it as soon as possible. No external libraries, and at least it compiles :p
EDIT2: OOOPS very bad idea. Not working, can't reprogram..
Arduino sketch for the gamepad (Teensy replacement): http://github.com/oxodao/GBZGamepad
- Oxodao
- Posts: 131
- Joined: Wed Jun 01, 2016 11:35 am
- Location: 127.0.0.1
- Has thanked: 4 times
- Been thanked: 30 times
- Contact:
Re: Cheaper than Teensy
Okai, so 1.1v of the Gamepad script, fully working as far as I tried:
For the keyboard it won't be that easy so I'll spend more time on sunday 
Code: Select all
#include <Gamepad.h>
Gamepad gb;
// I'm wondering why this takes all of the ports, why it starts at 2 and skip the 11, 12 & 13...
#define BTN_UP 2
#define BTN_LEFT 3
#define BTN_DOWN 4
#define BTN_RIGHT 5
#define BTN_B 6
#define BTN_A 7
#define BTN_X 8
#define BTN_Y 9
#define BTN_SELECT 10
#define BTN_START 14
#define BTN_BCKLEFT 15
#define BTN_BCKRIGHT 16
void setup() {
for (int x = 2; x<16; x++){
if (x != 11 && x != 12 && x!= 13)
pinMode(x, INPUT_PULLUP);
}
}
void loop() {
bool downSet = digitalRead(BTN_DOWN);
bool upSet = digitalRead(BTN_UP); // No pun intended
bool leftSet = digitalRead(BTN_LEFT);
bool rightSet = digitalRead(BTN_RIGHT);
gb.setLeftXaxis(!leftSet ? -127 : !rightSet ? 127 : 0);
gb.setLeftYaxis(!downSet ? 127 : !upSet ? -127 : 0);
gb.setButtonState(1, !digitalRead(BTN_A));
gb.setButtonState(2, !digitalRead(BTN_B));
gb.setButtonState(3, !digitalRead(BTN_X));
gb.setButtonState(4, !digitalRead(BTN_Y));
gb.setButtonState(5, !digitalRead(BTN_SELECT));
gb.setButtonState(6, !digitalRead(BTN_START));
gb.setButtonState(7, !digitalRead(BTN_BCKLEFT));
gb.setButtonState(8, !digitalRead(BTN_BCKRIGHT));
gb.sendUpdate();
}

Arduino sketch for the gamepad (Teensy replacement): http://github.com/oxodao/GBZGamepad
Who is online
Users browsing this forum: No registered users and 1 guest