Hello, thanks for looking at my thread. Here's what I'm trying to do:
I want to push a button and have my Leonardo simulate multiple keypresses. This is pretty straightforward with a simple "if" statement.
The complexity arises by adding a selector knob. When the selector knob is in the first position, the button should simulate keypress "A" and "B", but when the selector switch is moved to the second position the button should simulate keypress "X" "Y" and "Z".
Here's what I tried in pseudo-code.
chars* firstSetOfValues = Keyboard.press("A") , Keyboard.press("B"); // No idea what the syntax should look like here, this is just fake code.
chars* secondSetOfValues = Keyboard.press("X") , Keyboard.press("Y") , Keyboard.press("Z") // Once again fake code.
chars* buttonPress [] = { firstSetOfValues , secondSetOfValues }; // The 2 commands for the button depending on the selector knob
int a = 0; // This links the knob position with what the button is supposed to do.
...
if( knob position is in the first position){ // Simplified fake code for the sake of example.
a = 0; // knob is in the first position
}
else{
a = 1; // knob is in the second position
}
if (the button is pushed){ //simplified for example
buttonPress[a]; //do all the things found at this location
Keyboard.releaseAll(); // then stop
}
My intention with this code is to relay what I've been trying to use to get a solution, not to proofread hundreds of lines of code. One of my many problems is that a) I'm clearly an idiot, and b) I have no experience with C++.
I know that I can't assign multiple variables to one global variable, but I want to, because I think I need to. I've been Googling for a day and a half and don't know enough to ask good questions, and not smart enough to understand the answers I find.
I've found some "buzz words" that I've been looking into for solutions. "Multi-dimensional arrays", "Array of objects", "Classes". But I'm really turning up a big goose egg.
Now granted , one solution is just to write a very lengthy if statement, identifying all the commands for all the positions. This becomes time consuming when applied to my real life project which contains 8 switches each with 2 positions, 2 buttons, and a 6 position selector switch.
Thanks again for your time.
-Kirk