Weird interaction between dev con and HID input

Post Reply
User avatar
RootlessAgrarian
Posts: 383
Joined: 25 Nov 2015 18:43
Location: Cortes Island BC Canada

Weird interaction between dev con and HID input

#1 Post by RootlessAgrarian » 30 Apr 2017 04:10

I've been fooling about with dedicated HID emulator to automate some of my favourite ETS2 functions.

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('`');
}
So, ummm... you see that Backspace in the code? I had to put that in because... for some reason, after receiving the backquote that invokes the dev console, the game would insert a single forward quote before the next piece of text from the HID. [btw I'm not sure if the delays are even necessary -- I keep shrinking them and everything still works :-)]

Before the backspace, what I would see in dev con was

Code: Select all

'warp 2.54
(or whatever value it was)

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?
Level 42 and rising... i7 8700K -- AMD Radeon 5700XT -- ASUS MAXIMUS XI HERO - WIN10
NoCabView minimod
Euro Bike Simulator
The Beginner's Guide To SCS Mapping (WIP)
Post Reply

Return to “Technical Problems”

Who is online

Users browsing this forum: No registered users and 6 guests