So I have an Arduino Leonardo sending keyboard input at the game, for example to set warp based on a potentiometer reading:
Code: Select all
void setWarp(float val) {
Keyboard.write('`');
Keyboard.write(KEY_BACKSPACE);
delay(50);
Keyboard.print("warp ");
Keyboard.print(val);
Keyboard.println(" \n");
delay(50);
Keyboard.write('`');
}
Before the backspace, what I would see in dev con was
Code: Select all
'warp 2.54
I know that it was not my code emitting that spurious single quote, because I used xev to examine the keyboard events that take place when the button on my Arduino is pressed. There was definitely no single quote. There was only backquote press followed by backquote release, then "w" press followed by "w" release, and so on. And yet the game kept putting one in (and then throwing a syntax error).
I have no idea why this happens. It is simple to work around, as you see. I was just curious... how is it that an extra character gets inserted into my input, without my approval? anyone have a clue? When I typed the same characters into xev the event stream was identical, i.e. xev saw no difference between manual keyboard input and programmed keyboard input. But ETS2 does. How?