The code was just meant to get you started, and should be easy to add to. Use the examples for
keyboard,
mouse and
joystick to help you.
So for right mouse button down add
Code:
Mouse.set_buttons(0, 0, 1);
and for right mouse button up add
Code:
Mouse.set_buttons(0, 0, 0);
Same goes for a button to key press, the simplest way is something like this...
First add the following to the setup function, changing 0 to match your digital pin.
Then before the delay(25) add the following...
Code:
if (!digitalRead(0))
Keyboard.press('e');
else
Keyboard.release('e');
Because the digital pin is normally high (1), thanks to the internal pullup, it goes low (0) when the button is pressed. This is why we use the !(NOT) operator on the digitalRead, so we are basically saying, if the input pin is low press the key, else release it. Add as many of these as you need, adjusting the pin number and key to suit.
The whole of this code will need tweaking for your requirements, the mouse code above for example, allowed reasonable control of the cursor in windows, but was way to slow in game for me. It could probably do with a logarithmic scale, but maths is not my strong point.
Regards,
Les