#!/bin/bash
echo "XBian touch installer by brantje"
if [ ! -f /etc/pointercal ]; then
echo "Listing event devices"
ls -l /dev/input/by-id | grep event
echo "What is the event number of the touchscreen? eg: event0 then you type 0, followed by [ENTER]"
read inputnumber
sudo systemctl stop mediacenter
echo "Getting tslib"
wget --no-check -O tslib_1-1_armhf.deb "https://github.com/brantje/xbian-touch/raw/master/tslib_1-1_armhf.deb"
echo "Installing tslib"
dpkg -i tslib_1-1_armhf.deb
export LD_LIBRARY_PATH=/usr/local/lib
export TSLIB_CONSOLEDEVICE=none
export TSLIB_FBDEVICE=/dev/fb0
export TSLIB_TSDEVICE=/dev/input/event$inputnumber
export TSLIB_CALIBFILE=/etc/pointercal
export TSLIB_CONFFILE=/usr/local/etc/ts.conf
export TSLIB_PLUGINDIR=/usr/local/lib/ts
echo "Please follow the instructions on the display..."
ts_calibrate
echo "Getting uimapper..."
wget --no-check -O uimapper.tar.gz "https://github.com/brantje/xbian-touch/raw/master/uimapper.tar.gz"
echo "Installing uimapper..."
sudo mkdir -p /scripts && sudo tar -zxf uimapper.tar.gz -C /scripts
echo "Generating config file"
echo "#!upstart
description \"uimapper\"
env UIMAPPER_DEV=\"/dev/input/event$inputnumber\"
env UIMAPPER_CONF=\"configs/touchscreen.py\"
env UIMAPPER_DIR=\"/scripts/uinput-mapper\"
start on (input-device-added SUBSYSTEM=input)
stop on input-device-removed
nice -10
kill timeout 1
expect fork
script
chdir \$UIMAPPER_DIR
exec ./input-read.py \$UIMAPPER_DEV -D | ./input-create.py \$UIMAPPER_CONF &
end script
respawn" >> uimapper.conf
echo "Moving config..."
sudo mv uimapper.conf /etc/init
sudo chmod +x /scripts/uinput-mapper/input-create.py
sudo chmod +x /scripts/uinput-mapper/input-read.py
echo "Cleaning up..."
rm uimapper.tar.gz
rm tslib_1-1_armhf.deb > /dev/null #Silent error
sudo start uimapper
sudo systemctl start mediacenter
echo "Installation done!"
else
echo "Already installed... Recalibrating"
echo "Listing event devices"
ls -l /dev/input/by-id | grep event
echo "What is the event number of the touchscreen? eg: event0 then you type 0, followed by [ENTER]"
read inputnumber
sudo systemctl stop mediacenter
sudo stop uimapper
export LD_LIBRARY_PATH=/usr/local/lib
export TSLIB_CONSOLEDEVICE=none
export TSLIB_FBDEVICE=/dev/fb0
export TSLIB_TSDEVICE=/dev/input/event$inputnumber
export TSLIB_CALIBFILE=/etc/pointercal
export TSLIB_CONFFILE=/usr/local/etc/ts.conf
export TSLIB_PLUGINDIR=/usr/local/lib/ts
sleep 3
echo "Please follow the instructions on the display..."
ts_calibrate
sudo start uimapper
sudo systemctl start mediacenter
fi
After some modifications on the script i am stuck on line number 36 (start on (input-device-added SUBSYSTEM=input)). Before this moment i can calibrate my touchscreen but after the script stop on the line 36. It seem that OSMC don’t recognize this command. So, is there someone who can help me to progress with this script ?
Thank you.
It would make things easier if you told us the make and model of the touch panel, its very unlikely this script will run on the current xbian (the script is 9 years old) or osmc.
Also I’ve edited your post to make the script easier to read.
Since I dont have any touch screen I can’t test it, there could be some spelling mistakes in the installer script, but i tried to keep it as close to the old source as posible.
Try and reboot, good luck =) If it works, you should be able to delete tempo_20230112_0040 folder, with all it’s contents.
Edit: For those that know better then me about these things, is python-uinput better/replacement for uinput-mapper, which was first built with C but has step over to the darkside (python)?
After test f your script it give:
osmc@osmc:~/tempo_20230112_0040$ sh osmc_touch_installer.sh
OSMC touch installer v. 0.01
Already installed… Recalibrating
Listing event devices
lrwxrwxrwx 1 root root 9 19 janv. 08:10 usb-2188_USB_OPTICAL_MOUSE-event-mouse → …/event0
lrwxrwxrwx 1 root root 9 19 janv. 08:10 usb-eGalax_Inc._USB_TouchController-event-if00 → …/event2
lrwxrwxrwx 1 root root 9 19 janv. 08:10 usb-eGalax_Inc._USB_TouchController-event-mouse → …/event1
What is the event number of the touchscreen? eg: event0 then you type 0, followed by [ENTER]
2
sudo: stop : commande introuvable
Please follow the instructions on the display…
xres = 1280, yres = 800
Took 1 samples…
Top left : X = 567 Y = 3827
Took 1 samples…
Top right : X = 467 Y = 315
Took 2 samples…
Bot right : X = 3614 Y = 311
Took 6 samples…
Bot left : X = 3620 Y = 3836
Took 2 samples…
Center : X = 2118 Y = 2080
1334.931763 0.000271 -0.335372
-61.790649 0.225708 -0.003400
Calibration constants: 87486088 17 -21978 -4049512 14792 -222 65536
open: Permission denied
sudo: start : commande introuvable
osmc@osmc:~/tempo_20230112_0040$
Now when you ran it again, I doubt you had a clean system? My thought is that if you just run my script, while you had old leftovers from the former script it might have interfered.
As I said before I have no touchscreen, and haven’t worked with them for a long time, but as I understood it, isn’t the touch mouse the event you want?`
The open and stop error, seems to be related to the script, which I haven’t really check out properly. I just got ahold of a “python3 ported version”. I can try to invest more time into this, but either there is a problem in finding the script that is asked, via sudo to open or stop. So a “where is the file problem”?
Still just “remote diagnosis”, I have no way to check it. Good Luck
Ps. Just did a little tweak, changed file permissions on the calibration file. Next step would be to rewrite the init.conf files to a service file instead. But I will have to get back to you there.
clearly an init issue, the start and stop command is for init.d? And If I remember correctly Debian was heading away form that and into services/systemd. So if this is time sensitive I would look for someone to rewrite the part of the scripts that echoes a few lines into uimapper.conf
That is, edit the line that echoes into a .conf file and instead echo into a uimapper.service file (with a correct syntax, differs from init.conf files), I would if I could test it between edits, but doing it blindly takes to much time away from other joys of life, like the monsters I’ve spawned.
Next step would be to read-up on how-to convert a “upstart”-script to systemd-service. Upstart seem to be some old Ubuntu-thing. removed around v.16.*. Have found some links describeing, but I don’t belive I have the time to learn upstart enough to translate it into .service file. There is forking mentioned and I have no idea if that is simple or forked in service-file. And I cant find a simple translation matrix.
Figured as much, but it’s the fork-bit in the script vs. simple or forked in .service. Didn’t find a simple, “this is how”. But If i get some extra time i might be able to check it out.