Change keyboard settings in arduino

Hi guys. I just wrote a code that theoretically can translate a joysticks 16 directions into wasd (see code below). My problem is that by default, keyboards only input one character at a time (i.e. ewwwwwwwwwwwwwww or waaaaaaaaaaa). Is there any way to get around this? Any help would be appreciated!!!

Note: I am using an arduino uno (can get a mega if necessary) and a motor shield with power supply. I am also using a logitech extreme 3d pro joystick

_16DirWASDControl.ino (7.8 KB)

Is there any way to get around this?

Keyboards don't IMPORT anything. Keyboards are OUTPUT devices.

Applications import data.

void shuffle(char ara []) {
  char ins = Serial.read();
  Serial.flush();

Block until all outgoing serial data has been sent. How the hell is that useful?

I just removed that from my code but still that doesn't solve my problem. I am wondering what code I can implement that will remove the delay time of key presses (to 0 ideally) and that will allow me to input multiple keys such that the joystick outputs something allows the other 12 non cardinal directions to operate.

I am wondering what code I can implement that will remove the delay time of key presses (to 0 ideally) and that will allow me to input multiple keys such that the joystick outputs something allows the other 12 non cardinal directions to operate.

I still don’t understand the question. What are you inputting the keys to? Supposedly, you are reading the joystick values and calculating some value to output. There should only be a value output if the joystick readings have changed.

When the joystick is on a diagonal, you'll have to send wawawawawa or sdsdsdsdsd or even wwawwawwawwa.

Your code will have to deal with all 16 possibilities.

PaulS: I will try to clarify my question. I am trying to convert a joystick movement into wasd movement such that you can also move in diagonals. My joystick (logitech extreme 3d pro), has 3 programmable axes, two of which are the standard x and y. I am trying to convert my motion on x and y to key strokes. As of now, I have:
right:d, left:a, up:w, down:s (standard wasd control seen in many games, programs, etc). However, if I move diagonally on the joystick, the motion is converted to just one letter instead of a mix. As Delta_G suggested, I should try to output wdwdwdwdwdwd if pointed in a diagonal, however, keyboards do not do this by default. As I noted earlier, typically keyboard output someting like wddddddddddddd if you try to hit two keys at once. I am asking if there is any way to write code such that the input would instead read wdwdwdwdwdwdwdwdwd if I pointed my joystick up and right.

Delta_G: I wish that there were 16 buttons or slots I could map to my joystick but unfortunately this is not the case. Currently, it has 3 programmable axes, only two of which correlate with x and y movement. For the x axis, I have a and d set for the extremes and for the y axis, I have w and s set for the extremes. I havent been able to find a software that can map my joystick with diagonals settings so I am stuck trying to manipulate key presses.

Thanks for the replies!

So how does the joystick know it’s being moved to a diagonal? Your program is going to have to think a little harder. If both the up and right directions are engaged then it is on a diagonal. So in that case send keystrokes to move diagonal.

In my code, I have a char array which collects no more than 4 characters. The number of w,a,s or d’s is counted by method countDirec. In each while loop, see code I attached, the direction is determined by the number of each variable, which allows me to get directions such as NNW, NW, or WNW. I tested this in the serial monitor and found that the arduino was able to determine which direction based on keyboard input but I had to manually type in keystrokes such as wawawa in order to yield these results. My challenge is now finding out how the joy stick can output wawawa.

_16DirWASDControl.ino (7.8 KB)

Because no solution was found, I will just share what I know:

A keyboard listener could potentially be used (keyboard class in arduino) however, it only works for the Leonardo board I believe. In my case, I am using an uno so this capability is missing. Without this, I am at the mercy of the joystick software which sadly does not let me code the diagonals. It seems that mapping to a keyboard is hopeless so the next best solution is to download a usb shield that could read data directly from the joystick or try your hand at inbetwino.