BlueWave Studio forum
Strange input issue when AA running - Printable Version

+- BlueWave Studio forum (https://bluewavestudio.io/community)
+-- Forum: OpenAuto Pro (https://bluewavestudio.io/community/forumdisplay.php?fid=86)
+--- Forum: Android Auto (https://bluewavestudio.io/community/forumdisplay.php?fid=79)
+--- Thread: Strange input issue when AA running (/showthread.php?tid=2673)



Strange input issue when AA running - Ripmax - 05-22-2021

Hi All,

I'm running OpenAuto Pro 12.0.

My input is handled by an ESP32 reading CAN signals from the car, which then sends the commands as serial to the Raspberry Pi.

I am using a RPi 3 B+, and an external USB serial adapter. My python script to monitor these is running as a systemd service. The script then uses xdotool to mimic a keyboard press, which then navigates the menu. (see below0

Snippet of my python event monitor code below.
		if line==b'EVENT_LEFT\n':
			os.system('export DISPLAY=:0.0 && xdotool search --class autoapp key --window %@ 1')
		if line==b'EVENT_RIGHT\n':
			os.system('export DISPLAY=:0.0 && xdotool search --class autoapp key --window %@ 2')

So this all works fine.. Until Android Auto is opened. When Android Auto is open, all commands are fired twice. I have verified that the EVENT_* commands are only being sent once by adding a print() to my python script. When I plug in a USB keyboard, the commands are only fired once, and I can navigate Android Auto (if pressing the keyboard).

If I then close the AA connection by turning off WiFi on my phone, the commands start working as normal (firing once).

I have verified that the service isn't at fault, by disabling that and manually running my python script in the terminal.

Have been bashing my head against this for hours and I am out of ideas. Anyone help?

My theory is that opening AA is running a "second instance?" of "autoapp", and xdotool is hitting it twice.

Thanks


RE: Strange input issue when AA running - BlueWave - 05-22-2021

Try to not use search --class switch in xdotool command. As far as we know it will send key event to each window created by the application. When Android Auto is launched, OpenAuto Pro creates new window for rendering the projection. Most probably xdotool sends key event to main OpenAuto Pro window and the one created by Android Auto. Rather than choosing receiver window by hand, try to send key event globally and let X11 do the dispatching job.

Also we suggest to run X11 scripts via /etc/xdg/lxsession/LXDE-pi/autostart file instead of systemd - it will allow you to get rid of exporting DISPLAY env variable.


RE: Strange input issue when AA running - Ripmax - 05-23-2021

That did the trick!

Thank you for the help and quick reply. Much appreciated!