Hi everyone,
I use a Leonardo to control a joystick and some buttons for an arcade machine.
What I want to achive:
On holding a button (gameselectpin) and pressing left or right (pins 4,5) on the joystick, I want my sketch to
Read a word from a char-array and sent that via Keyboard.print
add letter "p" at the end of the word, then do a Keyboard.printnl
This works very well - if your cursor sits in an application like Excel or Word (Linux and Windows, both is fine). So it writes pacmanp, mspacmanp, jrpacmanp .... always followed by a new line.
As soon as you do it on a Linux command line (and this is the target platform) the behavior changes: it prints "spacmanp", then "rpacmanp" ... and, after that, the the first letters are missing ... "bertp" instead of "qbertp" ...
char* gameList[] = {"pacman", "mspacman", "jrpacman", "pacmania", "qbert","digdug", "mrdo", "galaga", "frogger", "kangaroo"};
const int gameselectpin = 13;
..//more code
if (actualGame != lastGame && digitalRead(gameselectpin)==LOW) {
Keyboard.write(KEY_ESC);
Keyboard.print(gameList[actualGame]);
Keyboard.println('p');
delay(fkey);
lastGame = actualGame;
}
// Right to the next game
if (digitalRead(5)==LOW && digitalRead(gameselectpin)==LOW) {
if (actualGame != numbGame) {
actualGame=actualGame + 1;
}
goto top;
}
// Left to the prev game
if (digitalRead(4)==LOW && digitalRead(gameselectpin)==LOW){
if (actualGame !=0 ) {
actualGame=actualGame -1;
goto top;
}
}
Any help would be highly appreciated.
Greetings,
Rigas