Hey folks,
Not a help request: I've kind of made automatic detection work as well as hotplugging. Mine is a"D-WAV Ltd eGalax TouchScreen" as reported by lsusb. But instructions should work for other devices, eventually with a bit of tweaking.This is how it goes; and requires that you managed to install and calibrate the extension first.
I was buggered that hardcoding /dev/input/eventX in ts_env.sh went wrong especially when I've plugged in other devices, or when I turn off and back on the touchscreen. So I've setup udev and systemd to make the work. Bear with me:
in /storage/.kodi/userdata/addon_data/service.touchscreen/ts_env.sh set the TSLIB_TSDEVICE to /dev/touchscreen:
export TSLIB_TSDEVICE="/dev/touchscreen"
Create a udev rule as /storage/.config/udev.rules.d/90-touchscreen.rules
KERNEL=="event*", SUBSYSTEM=="input", ATTRS{name}=="*Touchscreen*|*touchscreen*|*TOUCHSCREEN*", SYMLINK+="touchscreen", TAG+="systemd", ENV{SYSTEMD_ALIAS}="/dev/touchscreen", ENV{SYSTEMD_WANTS}="service.touchscreen.service"
Attention, no line breaks! Hopefully your device reports itself as Touchscreen (eGalax does) but you may need to change ATTRS{name} bit.
You can verify the rule by checking if /dev/touchscreen gets created when you plug in the screen (or turn it on). Oh: its udevadm control --reload-rules to apply your fresh rule. And you can dig ATTRS{name} with udevadm info --attribute-walk /dev/input/eventX if you need it.
Last part, we'll hook this to systemd service so it get started and stopped with the device. Edit /storage/.config/system.d/service.touchscreen.service and add at the end of [Unit] section:
[Unit]
...
BindsTo=dev-touchscreen.device
After=dev-touchscreen.device
apply changes with systemctl daemon-reload
And voilà! Your device should now be autodetected and recalibrated on hotplug.
Hope this is helpful to some