Raspberry Pi, RaspBMC & eGalax touchscreen
RaspBMC: Touchscreen calibration & extra features
The following tutorial describes additional steps, after installation of RaspBMC, to enable calibration and extra functionality for the eGalax touchscreen in XBMC. By using a modified version of ts_calibrate for touchscreen calibration and python utility uinput-mapper, it’s possible to generate a user-input device even which handles the calibration transformations and gives additional BTN_LEFT/RIGHT functionality within XBMC on the Raspberry Pi.
The procedure requires to install the following:
- ts_calibrate
- uinput-mapper & Upstart script – uimapper.conf
The Upstart script uimapper.conf starts/stops the python script uinput-mapper whenever the input-device is added/removed allowing hot-plugging and grabbing of the device within XBMC.
Step 1: Install ts_calibrate
Stop XBMC…
1 2 3 |
sudo stop xbmc |
Download files…
1 2 3 |
wget --no-check -O tslib_1-1_armhf.deb "https://docs.google.com/uc?export=download&id=0B4lrG9aRe-8MUlRaRW5LcXNDaDA" |
1 2 3 |
wget --no-check -O ts_calib.sh "https://docs.google.com/uc?export=download&id=0B4lrG9aRe-8MOV94Nl90SExsVE0" |
Install the deb package…
1 2 3 |
sudo dpkg -i tslib_1-1_armhf.deb |
Next, edit the file ts_calib.sh and change the event-device to the correct event# for the touchscreen device on your system…
1 2 3 |
sudo nano ts_calib.sh |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
#!/bin/bash export LD_LIBRARY_PATH=/usr/local/lib export TSLIB_CONSOLEDEVICE=none export TSLIB_FBDEVICE=/dev/fb0 #NOTE: Change '/dev/input/event2', to find event# use 'ls -l /dev/input/by-id' export TSLIB_TSDEVICE=/dev/input/event2 export TSLIB_CALIBFILE=/etc/pointercal export TSLIB_CONFFILE=/usr/local/etc/ts.conf export TSLIB_PLUGINDIR=/usr/local/lib/ts ts_calibrate |
Now run the script and calibrate the touchscreen….
1 2 3 |
sudo sh ts_calib.sh |
Step 2: Install uinput-mapper & uimapper.conf
Download files and extract tar…
1 2 3 |
wget --no-check -O uimapper.tar.gz "https://docs.google.com/uc?export=download&id=0B4lrG9aRe-8MN0dXcEtLTzRSNkE" |
1 2 3 |
wget --no-check -O uimapper.conf "https://docs.google.com/uc?export=download&id=0B4lrG9aRe-8MM2RIWFh1WjJWUW8" |
1 2 3 |
sudo mkdir -p /scripts && sudo tar -zxvf uimapper.tar.gz -C /scripts |
Next, edit the file uimapper.conf and change the event-device to the correct event# for the touchscreen device on your system and then move it to the correct directory…
1 2 3 |
sudo nano uimapper.conf |
1 2 3 4 5 6 7 8 |
#!upstart description "uimapper" #NOTE: Change '/dev/input/event2', to find event# use 'ls -l /dev/input/by-id' env UIMAPPER_DEV="/dev/input/event2" ... ... |
Move file to correct directory…
1 2 3 |
sudo mv uimapper.conf /etc/init |
That’s all, you can now Reboot.
NOTE:
You can start uimapper by re-plugging the device, or by typing…
1 2 3 |
sudo start uimapper |
To see the processes running in the background type…
1 2 3 |
ps aux |
Xbian1.0 Beta 1 – eGalax video Raspberry Pi 2, OSMC & eGalax touchscreen
Wow, that absolutely what I am looking for. Tried it with Raspbmc on the PI, but the touchpad is not shown in the list when using ‘ls -l /dev/input/by-id’. So I installed the kernel, modules and firmware from here:
http://code.google.com/p/andrei-development/downloads/list
The touchpad is then shown to set the correct event#. Unfortunately the calibration did not worked correctly (mouse pointer is still off) or hangs up when trieing to recalibrate.
It seems, some steps are missing to get the touchpad available to the system?
Sorry to hear you have problems, what model is it…the kernel modules should already be in the release as it uses the latest kernel.
Try to install evtest (sudo apt-get install evtest) so you can see the input events, you can also see it uimapper is running also. You can type ‘stop uimapper’ or ‘start uimapper’ to check if the pythonn script works ok. Uimapper grabs the device before XBMC does, so make sure when testing via SSH to stop XBMC also.
Think I found the problem, for some reason the file /scripts/input-create.py lost it permissions, typing…
sudo chmod +x /scripts/uinput-mapper/input-create.py
should fix the problem, I will update the file in the tar so install prcoess should work ok
You were right about the uimapper. Nevertheless, the uimapper still won´t start automatically on system startup, and the display isn´t calibrated. i have to
stop xbmc
start uimapper
start xbmc
and everything works fine again.. until next reboot :/
I am using a Raspberry PI model B with 256MB RAM and the latest RaspBMC installed. The touchscreen did _not_ directly run out of the box after RaspBMC Installation. It is shown in lsusb as an eGalax touchscreen, but can not be found with …input/by-id or evtest
Hi Stefan, are you using the corect uimapper.conf file in the /etc/init/umapper.conf….I think I had to change the raspbmc uimapper.conf to start at boot the line that works for me should read….
start on startup or virtual-filesystems or (input-device-added SUBSYSTEM=input)
The calibration is only used when uimapper is running, it creates a user input device and adds the translations ans scales external;ly to xbmc. The calibration file is automatically created with ts_calibrate and stored in /etc/pointercal. Other functions of uimapper can be changed in the touchscreen.py file located in /scripts/uinput-mapper/configs folder; if you want to try other things.
best wishes
mark
Thanks alot, that was the trick

“start on startup or virtual-filesystems” was missing. Seems like I adopted a wrong config file when playing with Brantje´s install script for xbian.
Thanks for you great help and effort, the touchscreen works perfectly now
Thought is was only fair to have both distro’s on separate threads, the solution is the same for both, except for the hot-plug in RaspBMC, hence the change to uimapper.conf file.
Glad it’s working ok. Have fun!
First of all thanks for this. Being new to this (RPi, Linux…) I was struggling quite a bit to get my touchscreen to work. Thanks to your efforts it is running now. I am using a small 8.4″ Touchscreen by cartft.com. My question now is, is there a way to increase the dead zone? If I understand correctly BTN_right is triggered by holding the finger within a certain radius. However due to my small touchscreen this is quite difficult. Or maybe is has nothing to do with the size at all. When I look at the pointercal the scaler value is quite big (65536), maybe this is the reason. On Xbian I had to manually adjust the pointercal, since after calibration there was still an offset (half the screen). On Raspbmc the calibration worked fine – no idea why.
Thanks for any input that can point me in the right direction
Hi Michael,
I have a 7″ eGalax, hence why I wanted to control externally of xbmc.
First of all….make sure the resolution and overscan are set correctly in /boot/config.txt file in either xbian or raspbmc distro.
When running ts_calib, it will give you the info on the resolution that it is using for calib file.
The /etc/pointercal file generated automatically stores all offset and scale values in integer values (i.e. all are multiplied by the 65536 factor). Then when I use them later (in the file ‘/scripts/uinput-mapper/configs/touchscreen.py’) I recalculate the values. It is the same solution for both distros.
You can check when in xbmc for resolution and overscan settings in video calibration also.
But first, check you are using uimapper and not native egalax driver in xbmc.
if you can SSH your rpi from a pc, I use putty…
type
sudo su
stop xbmc
stop uimapper
apt-get install evtest
start uimapper
evtest
(check you can see your egalax device and a new userinput device uimapper….)
If you select uimapper, then pressing the screen will give you position feedback and you can check for BTN_RIGHT too.
This will make sure the distro can see and use the device…
Basically, uimapper.conf starts two processes,
1. /scripts/uinput-mapper/input-read.py
(for the egalax device)
2. /scripts/uinput-mapper/input-create.py
(creates a uimapper device using scale/offset values from pointercal, adding BTN_RIGHT)
You can change range values and timing values easily in the python code in input-create.py (near the EOF)
You can also remap other buttons etc in the file: /scripts/uinput-mapper/configs/touchscreen.py
Any changes need a stop uimapper, start uimapper and some might prevent it working, but you can always revert to original.
Hope all of this makes sense.
Perfect. I increased the radius by 1.7 and it works much more reliable now. The calibration is still not working, however I want to connect both a touchscreen for control and my HD TV at the same time and I need some additional hardware for that. For testing and setup I am using the composite output right now, so this is not the final resolution. My goal is to use a splitter and scaler on the HDMI out. But splitter and scaler have not been delivered.
Thank you again for your help
Next thing is I also want to do more adjustments on the confluence skin so that the buttons are easier to hit on a small touchscreen.
Ok Michael, glad to hear it’s ok….bit weird about the calibration though!? I had to recompiled the code and packaged in a deb to add axis swap check, other than that it’s the original ‘ts_lib’ framebuffer calibration tool and should be spot on.
Hi Mark,
it’s not my language
it’s very good now and work in lower resolution Perfectly,
one thing when i connect mouse and do the calibration it’s not work good and i discoverd that i must remove all usb hardware and leave only the usb touch screen cable it’s work nice now thank you
sorry for bad english
Again, this seems odd. I have a touch-pad/keyboard plugged all the time it should have zero effect on the touchscreen calibration, it only uses the info from that specific event.
I wonder if it’s a power issue, are you using a externally powered usb-hub, the rpi shouldn’t be used to power usb-hub
.
At least you can calibrate once successfully and then this should remain ok as and when you change resolution.
Well done!
mark
hello, how can i edit the boot logo and text that appear before xbmc start,
thank you
Hi again,
For this I would recommend searching in the relevant distro forum, either Raspbmc or Xbian, think they have a solution.
Cheers
Mark
Hi. I’ve bought this screen for my Raspberry Pi: http://www.ebay.com/itm/New-SAMSUNG-7-LED-LCD-Touch-Screen-Monitor-Kit-Outdoor-/110659973152?ssPageName=ADME:L:OC:DE:3160
I’m using RaspBMC and I’ve got a little problem with the calibration. I followed the instructions. With event 2 set in ts_calib.sh, the calibration starts, but doesn’t react. When I install uimapper, it changes to event 3, which also works for the calibration, but after reboot, it goes back to event 2 with the effect, that that touchscreen doesn#t react at all under XBMC. So basically, I cannot calibrate the screen with the event set to event2 and can’t use the screen with event3. Also starting xbmc with the calibration made with event3 doesn’t affect the touchscreen input
Any ideas?
Ok, I guess you found a solution using the install script and posted on the other xbian blog.
Hey, first I want to thank you for your great job!
I’m runnig RaspBMC on a 512MB Pi.
The only connected input device is an egalaxTouchscreen via USB.
I used you tutorial and so far all worked fine. evtest returned this:
root@raspbmc:/dev/input# evtest
No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0: eGalax Inc. USB TouchController
I made the change in ts_calib
#!/bin/bash
export LD_LIBRARY_PATH=/usr/local/lib
export TSLIB_CONSOLEDEVICE=none
export TSLIB_FBDEVICE=/dev/fb0
#NOTE: Change ‘/dev/input/event2′, to find event# use ‘ls -l /dev/input/by-id’
export TSLIB_TSDEVICE=/dev/input/event0
export TSLIB_CALIBFILE=/etc/pointercal
export TSLIB_CONFFILE=/usr/local/etc/ts.conf
export TSLIB_PLUGINDIR=/usr/local/lib/ts
ts_calibrate
Then I made the calibration and all worked fine
Now I made the changes to uimapper.conf
#!upstart
description “uimapper”
#NOTE: Change ‘/dev/input/event2′, to find event# use ‘ls -l /dev/inpu
/by-id’
env UIMAPPER_DEV=”/dev/input/event0″
env UIMAPPER_CONF=”configs/touchscreen.py”
env UIMAPPER_DIR=”/scripts/uinput-mapper”
start on startup or virtual-filesystems or (input-device-added
SUBSYSTEM=input)
stop on (input-device-removed SUBSYSTEM=input)
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
After then I restarted but the new calibration didnt work.
Uimapper is runnig but it seems it doesnt catch my touchpanel.
Evtest still returns only my egalaxtouch
ps aux returns this:
root@raspbmc:/# ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.5 0.4 3140 1736 ? Ss 22:01 0:05 /sbin/init
root 2 0.0 0.0 0 0 ? S 22:01 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? S 22:01 0:00 [ksoftirqd/0]
root 5 0.0 0.0 0 0 ? S< 22:01 0:00 [kworker/0:0H]
root 6 0.0 0.0 0 0 ? S 22:01 0:00 [kworker/u2:0]
root 7 0.3 0.0 0 0 ? S 22:01 0:04 [rcu_kthread]
root 8 0.0 0.0 0 0 ? S< 22:01 0:00 [khelper]
root 9 0.0 0.0 0 0 ? S 22:01 0:00 [kdevtmpfs]
root 10 0.0 0.0 0 0 ? S< 22:01 0:00 [writeback]
root 11 0.0 0.0 0 0 ? S< 22:01 0:00 [bioset]
root 12 0.0 0.0 0 0 ? S< 22:01 0:00 [kblockd]
root 13 0.0 0.0 0 0 ? S 22:01 0:00 [khubd]
root 15 0.0 0.0 0 0 ? S< 22:01 0:00 [rpciod]
root 18 0.0 0.0 0 0 ? S 22:01 0:00 [kswapd0]
root 19 0.0 0.0 0 0 ? S 22:01 0:00 [fsnotify_mark]
root 20 0.0 0.0 0 0 ? S< 22:01 0:00 [nfsiod]
root 21 0.0 0.0 0 0 ? S< 22:01 0:00 [crypto]
root 30 0.5 0.0 0 0 ? S< 22:01 0:05 [VCHIQ-0]
root 31 0.1 0.0 0 0 ? S< 22:01 0:02 [VCHIQr-0]
root 32 0.0 0.0 0 0 ? S< 22:01 0:00 [VCHIQs-0]
root 33 0.0 0.0 0 0 ? S< 22:01 0:00 [bcm2708_spi.0]
root 34 0.0 0.0 0 0 ? S< 22:01 0:00 [dwc_otg]
root 35 0.0 0.0 0 0 ? S< 22:01 0:00 [DWC Notificatio]
root 37 0.0 0.0 0 0 ? S< 22:01 0:00 [deferwq]
root 38 0.0 0.0 0 0 ? S 22:01 0:00 [kworker/u2:2]
root 46 0.2 0.0 0 0 ? S 22:01 0:02 [mmcqd/0]
root 68 0.0 0.0 0 0 ? S 22:01 0:00 [jbd2/mmcblk0p2-]
root 69 0.0 0.0 0 0 ? S< 22:01 0:00 [ext4-dio-unwrit]
root 77 0.0 0.0 0 0 ? S 22:01 0:00 [scsi_eh_0]
root 79 0.1 0.0 0 0 ? S 22:01 0:01 [usb-storage]
root 103 0.1 0.3 27932 1532 ? Sl 22:01 0:01 rsyslogd -c5
root 135 0.0 0.3 2880 1168 ? Ss 22:01 0:00 udevd –daemon
root 458 0.0 0.2 2876 984 ? S 22:01 0:00 udevd –daemon
root 461 0.0 0.2 2876 976 ? S 22:01 0:00 udevd –daemon
root 478 0.0 0.0 0 0 ? S 22:01 0:00 [kworker/0:2]
root 483 0.0 0.0 1496 296 ? Ss 22:01 0:00 /usr/bin/cachemon
101 530 0.0 0.3 3404 1300 ? Ss 22:01 0:00 dbus-daemon –system
root 592 0.0 0.3 3060 1376 ? Ss 22:01 0:00 /bin/bash /scripts/x
root 601 0.0 0.7 81456 2820 ? S<sl 22:01 0:00 /usr/bin/pulseaudio
root 621 0.0 0.1 2104 744 ? Ss 22:01 0:00 eventlircd –evmap=/
root 637 0.0 0.9 27508 3800 ? Sl 22:01 0:00 /usr/sbin/console-ki
root 673 0.0 0.4 3772 1568 ? S 22:01 0:00 su – pi -c export XB
root 795 0.0 0.8 22740 3416 ? Sl 22:01 0:00 /usr/lib/policykit-1
root 796 0.1 1.2 26568 4700 ? Ssl 22:01 0:01 NetworkManager
root 878 0.0 0.0 0 0 ? S 22:01 0:00 [VCHIQka-0]
pi 935 0.0 0.3 3444 1464 ? Ss 22:01 0:00 -su -c export XBMC_H
pi 948 25.0 11.4 297004 43852 ? Sl 22:01 4:11 /home/pi/.xbmc-curre
pi 949 0.0 0.1 2152 648 ? S 22:01 0:00 logger -t xbmc
pi 950 0.0 0.4 6116 1820 ? Ss 22:01 0:00 udisks-glue
root 953 0.0 0.8 14496 3228 ? Sl 22:01 0:00 /usr/lib/udisks/udis
root 958 0.0 0.2 6144 828 ? S 22:01 0:00 udisks-daemon: polli
root 960 0.0 0.7 4856 3012 ? S 22:01 0:00 /sbin/dhclient -d -4
root 999 0.0 0.9 26360 3592 ? Sl 22:01 0:00 /usr/lib/upower/upow
root 1007 0.0 0.1 2024 716 ttyAMA0 Ss+ 22:01 0:00 /sbin/getty -L ttyAM
ntp 1165 0.0 0.5 5512 1972 ? Ss 22:02 0:00 /usr/sbin/ntpd -p /v
root 1176 0.0 0.5 14908 2176 ? Ss 22:02 0:00 /usr/sbin/winbindd
root 1179 0.0 0.3 14908 1336 ? S 22:02 0:00 /usr/sbin/winbindd
root 1286 0.0 0.2 2548 784 tty2 Ss+ 22:02 0:00 /sbin/getty -8 38400
root 1287 0.0 0.2 2548 784 tty3 Ss+ 22:02 0:00 /sbin/getty -8 38400
avahi 1405 0.0 0.4 3472 1632 ? S 22:02 0:00 avahi-daemon: runnin
avahi 1407 0.0 0.1 3340 528 ? S 22:02 0:00 avahi-daemon: chroot
root 1481 0.0 0.2 2976 976 ? Ss 22:02 0:00 /usr/sbin/xinetd -do
root 1503 0.0 0.0 1628 188 ? Ss 22:02 0:00 /usr/bin/raspdog –d
root 1545 0.0 0.1 2304 708 ? Ss 22:02 0:00 rpcbind -w
root 1659 0.1 0.2 2828 1148 ? Ss 22:02 0:00 dropbear -i
root 1663 0.0 0.4 3172 1688 pts/0 Ss 22:03 0:00 -bash
root 1673 0.0 0.1 1692 532 pts/0 S+ 22:03 0:00 evtest
root 1936 0.0 0.6 9868 2544 ? Ss 22:06 0:00 nmbd
root 2087 0.0 0.0 0 0 ? S 22:08 0:00 [kworker/0:0]
root 2250 0.2 0.2 2828 1148 ? Ss 22:10 0:01 dropbear -i
root 2266 0.0 0.4 3176 1716 pts/1 Ss 22:10 0:00 -bash
root 2634 0.0 0.0 0 0 ? S 22:13 0:00 [kworker/0:1]
root 3122 18.0 0.8 6704 3124 ? R< 22:18 0:00 python ./input-read.
root 3123 17.0 0.7 6356 2940 ? R< 22:18 0:00 python ./input-creat
root 3124 0.0 0.2 2888 976 pts/1 R+ 22:18 0:00 ps aux
The calibration is always the same wether uimapper is runnig or not
Can you help me with this problem. I also have do a double click all the time
Hi Thomas,
Thanks for the detailed reply, it seems you are nearly there.
You are correct, umapper.conf has started the python scripts, you can see here for the output of ps aux…
root 3122 18.0 0.8 6704 3124 ? R< 22:18 0:00 python ./input-read. root 3123 17.0 0.7 6356 2940 ? R< 22:18 0:00 python ./input-creat I think xbmc is grabbing the device before uimapper can and therefore not applying the calibrations. When the pi is booted, can you SSH the pi…..then ‘stop xbmc’, ‘stop uimapper’, and ‘evtest’ to check if you can see egalax event. Then ‘start uimapper’ and then ‘evtest’ to see if it captures egalax and creates a ‘uimapper – touchscreen’ event; you can compare top-left/bot right values with the egalax event(stop uimapper) to check calibrations are working, or having an effect. If uimapper is running, it has control of the egalax, then ‘start xbmc’ and the calibration should be ok, if the calib is incorrect, then the ts_calib values might be wrong…(overscan, default resolution, etc) hope it helps, please let me know, cheers, mark
Thanks for your quit reply!
I made another test an there is no event for uimapper when running evtest without the xbmc system runnig. You can see below:
root@raspbmc:~# reboot
Broadcast message from root@raspbmc
(/dev/pts/0) at 16:01 …
The system is going down for reboot NOW!
root@raspbmc:~#
login as: root
root@192.168.2.14‘s password:
root@raspbmc:~# stop xbmc
xbmc stop/waiting
root@raspbmc:~# stop uimapper
uimapper stop/waiting
root@raspbmc:~# evtest
No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0: eGalax Inc. USB TouchController
Select the device event number [0-0]:
root@raspbmc:~# start uimapper
uimapper start/running, process 1520
root@raspbmc:~# evtest
No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0: eGalax Inc. USB TouchController
Select the device event number [0-0]:
You see there is no event for Uimapper.
You have any ideas why the event isnt created?
I made another test and now is see from “PS AUX” that only the input-read.py is running
root 95 1.0 1.3 8332 5120 ? S< 16:37 0:00 python ./input-read.py /dev/input/event0 -D
Ok, I will check later with the new raspbmc. You can test both the ‘./input-read.py’ and ‘./input-create.py’ programs on the command line, using the options from the uimapper.conf file (more info later). You will need to kill the process manually though, not via ‘uimapper stop’. I think input-create worked before, but you can check permission or just ‘chmod +x input-create.py’ to make sure it executes ok.
cheers,
mark
Hi Thomas,
I’ve found the problem…It’s my fault, I use tvservice to find the resolution to set some values in the touchscreen config file. For some reason, it needs the path in Raspbmc.
if you do the following it should work, I will also update the download.
OPTION 1:
Simply….
cp /opt/vc/bin/tvservice /usr/local/bin
OPTION 2:
Change the path to tvservice in touchscreen.py config file….
sudo nano /scripts/uinput-mapper/configs/touchscreen.py
and change the line fourth line to include the path to tvservice as follows:-
(*i.e. add ‘/opt/vc/bin/’ before ‘tvservice’)
#Read screen resolution from tvservice (not framebuffer)
sres = subprocess.check_output("/opt/vc/bin/tvservice -s", shell=True)
Both solutions worked for me, sorry for the error and thanks for keeping me on my toes!
cheers,
mark
———————————————————
NB.
ATM, xbian seems far more suited to this solution, more responsive without changing the uimapper.conf priority to nice -20
You are my hero! I works great.
But I have on further question:
I have always to perform a quite fast double click on my touchpanel.
Is ther a possibility to hit “Enter” only by one touch?
I will check this, but with uimapper running then only one press is necessary, It injects an extra BTN_TOUCH event if touch press is within 0.2 to 0.5 seconds; the duration can be altered inside the input_create.py file.
You can check with evtest too, you should see a extra BTN_TOUCH event, if you touch for longer then you get a BTN_RIGHT event.
It is working, but with the lag it makes it less responsive, I will investigate….
in the meantime, try xbian, it is faster imho
cheers,
mark
Its alle working now. The problem was the inrange value was to low.
Thank you very much for you help. You did me a favour!
Greets form Bavaria
No problem Thomas, glad it’s working, Feel free to contribute if you find any other tweaks,
Greets from Manchester
cheers,
Mark
Hi,
great job! My display works fine. But I also have the problem with the “doubleclick”. I have to touch always twice.
I tried to to the same as Thomas, but I didn’t get it…Could you explain for a noob how to change that “inrage value”?
Many thanks!
Fredrik
Hi there,
Although these instructions are very easy to follow, I have troubles with my faytech touch screen (10 inch – eGalax driver).
The touch control works fine out of the box, but the calibration is not correct:
There seems to be a multiplicator from touch to mouse cursor position, as the top-left corner is correct but when moving down or right the mouse cursor moves faster.
That is why I wanted to do what you described here.
But when I do *sudo sh ts_calib.sh* the hairline cross appears on the screen but it does NOT react to any touching!
What am I missing?
Or is there another way to correct the *multiplicator*?
Thanks in advance.
Koolman
Hi Koolman,
If ‘sudo sh ts_calib.sh’ doens’t work, then it cannot grab your device. Make sure xbmc & uimapper, or anyother program that might use the device are stopped. Also check the event number of your touchscreen, by using ‘evtest’.
Let me know,
cheers
mark
Hello Mark,
I got evtest running and it gives the following output (only touchscreen connected, no keyboard or mouse):
root@xbian:/home/xbian# stop uimapper
stop: Unknown job: uimapper
root@xbian:/home/xbian# evtest
No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0: eGalax Inc. USB TouchController
/dev/input/event1: eGalax Inc. USB TouchController
/dev/input/event2: eGalax Inc. USB TouchController
/dev/input/event3: eGalax Inc. USB TouchController
/dev/input/event4: eGalax Inc. USB TouchController
Select the device event number [0-4]: 3
Input driver version is 1.0.1
Input device ID: bus 0x3 vendor 0xeef product 0x1 version 0x210
Input device name: “eGalax Inc. USB TouchController”
Supported events:
Event type 0 (EV_SYN)
Event type 1 (EV_KEY)
Event code 330 (BTN_TOUCH)
Event type 3 (EV_ABS)
Event code 0 (ABS_X)
Value 120
Min 0
Max 4095
Event code 1 (ABS_Y)
Value 74
Min 0
Max 4095
Event code 47 (ABS_MT_SLOT)
Value 0
Min 0
Max 7
Event code 53 (ABS_MT_POSITION_X)
Value 0
Min 0
Max 4095
Event code 54 (ABS_MT_POSITION_Y)
Value 0
Min 0
Max 4095
Event code 57 (ABS_MT_TRACKING_ID)
Value 0
Min 0
Max 65535
Event code 59 (?)
Value 0
Min 0
Max 1
Properties:
Property type 1 (INPUT_PROP_DIRECT)
Testing … (interrupt to exit)
Touching and moving produces lots of events, so #3 seems right.
Then I made sure that xmbc and uimapper were stopped (what else could interfere?), and called *sudo sh ts_calib.sh*.
The hairline appears, but no reaction to touching or moving.
Your tutorial and comments make it look so simple, so it must be me overlooking something.
Your help is greatly appreciated.
Regards, Koolman
Hi Koolman,
Did you change ts_calib.sh to the correct event number also?
You have a multitouch screen. So this following so of this thread may help too..
http://forum.xbian.org/thread-832-post-14603.html#pid14603
Basically, ATM ,(until I have time to fix) you need to grab all additional events from the toucscreen in uimapper as dummy events.to prevent XBMC grabbing before uimapper. This is done inside /etc/uimapper.conf.
hope this helps.
cheers
mark
Hello admin,
Nice try 😉
Seriously, yes. I am pretty sure that I changed ts_calib.sh to the correct event number. But I might have mixed up the instructions for raspBMC and xbian.
I just followed your instructions above with a new installation of raspBMC from noob and it worked like a charm !!
I don*t know what I did differently this time and I would like to use xbian, so I will try it again (with your instructions for xbian: http://markamc.cybaman.net/?p=50 or the script from brantje).
Just two more questions;
– The calibration is still not perfect: starting from the center, the pointer is too fast. Can I edit the calibration values manually (maybe using arithmetic means of multiple runs of ts_calib) or does ts_calib need more samples ?
– A left mouse click can be done by a double tap (hard, but managable), but how can you do a right mouse click (for context menues) ?
Thank you for your patience.
Koolman
Hi Koolman,
Firstly, if the calibration is off, then please check overscan and config.txt and make sure tvservice -s gives you the same screen resolution as ts-calib and xbmc.
If still off, then change the values in /etc/pointercal or change multitouch.py ot toucscreen.py equations to suit scale and offsets.
If uimapper is running then single click select and btn-right should work ok; you can demonstrate this in evtest by selecting uimapper, A touch event over .25s issues an extra btn_touch and longer than 0.5 sec issues a btn_right. Values changeable inside /scripts/uinput-mapper/input-create.py (section near file end, values may differ, it’s been a while since i looked!)
If the btn-right event isn’t available, then try using the the multitouch config file in uimapper. (i.e. there is no BTN_RIGHT event capability in evtest output, check it’s created in uiimapper with evtest)
Below is an example of a capacitive multitouch uimapper.conf file. He also changed the single click time to 0.02 secs to make it work better (this is NOT necessary in XBIAN since it uses Andrei’s improved single click select hard-coded method. (RASPBMC to change soon)
Hope this is of use to you, good look and best wishes,
mark
#!upstart
description "uimapper"
env UIMAPPER_DEV="/dev/input/event3"
env UIMAPPER_CONF="configs/multitouch.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 &
exec ./input-read.py "/dev/input/event4" -D &
end script
respawn
hi,
till now i used this image
http://engineering-diy.blogspot.be/2013/02/raspberry-pi-raspbian-xbmc-and-egalax-7.html?m=1
now i would like to use raspbmc, coz its still under developement.
when i use your how-to, i get the touchscreen working, but not so good as the link above. can u tell me why? in general raspmc runs not so smooth and the usage of the touch is more war then fun.
the worst thing is the click. i need do it 5-10 times to click on a button, in different timings and hardness of it.
how can i fix it?
if i edit the touchscreen.py in script and uncomment the last passage the touchscreen doesnt work anymore…
i need to patch xbmc or install new kernel?
Hi Peter,
Yes I am familiar with Andrei’s work; I originally recommended to Xbian the use of his XBMC patch for the egalax (and other) touchscreens. They are still using his modified patch in the latest release which includes single press select, inconguntion with uimapper, you get ts_calibrtation, and BTN_RIGHT for easier navigation on any skin.
As described in tutorial, i wanted an solution that was external to XBMC to prevent the need for recompiling.
The solution I provide was working very well with Raspbmc but since august/sertember release it seems a little laggy in comparison to Xbian. I think this is the main cause of the slow reaction to the click.
I really need to have a look to try to resolve the problem. In the meantime, try xbian, it is really good support with on going development.
cheers,
mark
Hi again,
yesterday i recompiled frodo 12.2 (not git, tar.gz) successful with andrejs patch.
BUT i use it with the last raspbmc build.
i only put andrejs patch into the tutorial of raspbmc and compiled my version and it works rly smooth.
i asked sam (developer of raspbmc) to put andrejs patch in his main build. he said he is on it….
regards
Ok Peter,
I’m pleased for you, thanks for letting me know.
Kindest regards,
mark
Hey there
first of all it´s a great description for a great project. So i tried it myself, i built it the same like the description but i have the problem that after calibrating the screen and restarting xbmc the screen won´t work correctly like it´s not calibrated (curser moves into different directions and stuff like this).
My hardware is:
raspberry pi rev 2 board
eGalax 7″ touchscreen
uimapper is running
the pointercal includes some ratings
i hope you have any idea how i could fix this
regards
unti
Hi unti,
Yes, this is an issue I am aware of with RaspBMC, uimapper start but XBMC already has ‘grabbed’ the input event. Two options read thread from freefish here…..
http://markamc.cybaman.net/?p=50#comment-168
Cheers,
mark
hey now it works great!
thanx a lot
greetz
unti
thanks for that great solution….
Hi there,
based on this article I did the same for GeexBox. Only thing I haven’t worked out is the calibration (wrong scaling) but I am working on it :-).
Do you want to create the same documentation also for the GeexBox for other users looking for this kind of information?
tia
Hi Sebastian,
Glad it helped. Please take/use what you need. Unfortunately I have no time to create more documentation or continue to improve and develop this solution. Although I have a similar solution working using a rockchip rk3066 android tv too.
Let me know if I can help in any way.
cheers,
mark
Just wanted to say thanks heaps for this. Managed to get my eGalax screen working, for some reason mine gave reversed x & y values so just switched them in your script and took button press delay down to 0.05 seconds and found it is now accurate and responsive in Raspbmc
Great news, thanks for the feedback
cheers
mark
Many thanks to you. Got our TM-868 working without trouble. http://www.innovatek.cn/products/lcd/tm-868/tm-868.htm
But I still have a problem using the BTN_RIGHT event which is generated by the input-create.py when touching long enough. I want to use this event for the context menu in XBMC.
But since input-create.py first creates a BTN_TOUCH (which translates to mouseclick in XBMC) and then an additional BTN_RIGHT the context menu is always started on the wrong level.
Am I missing something important?
Hi Marek,
I have moved away from this solution. From memory it’s best to check every issued event with evtest and xbmc not running.
input-create will issue an exact copy of the events created by the TS input. So when a touch event to occurs a BTN_TOUCH = 1 (press) and BTN_TOUCH = 0 (release) event is generated.
Additionally, the time and distance are recorded between the ‘press/release’ event and extra BTN_RIGHT is forced where necessary.
Originally, I also added an extra BTN_TOUCH (time checked) to force a ‘double click’ for single press select. Since Andrei’s solution has been implemented into xbian/raspbmc (recently) this is no longer needed. Maybe this is the problem.
Edit input-create and comment-out the lines below by inserting a ‘#’ at the line start leave the spacing-indent as is (python etc).
Change two lines of code at approximately lines 139 and 141, the ‘d.fire_event(rev)’
#Range and time check
if inrange < = 400: if holdtime > 0.20 and holdtime < = 0.50: rev.code = BTN_TOUCH rev.value = 1 # d.fire_event(rev) rev.value = 0 # d.fire_event(rev)
Thinking about it, this can't be the problem. The touch event is only forced within a time and position range. Change the file anyway and check the evtest output
Worked Perfectly!
Thanks
Hi mark
Your solution seems like the only one currently working that doesn’t involve the painful patching of the xbmc. So kudos for that. However it seems that I have a new issue that nobody here had before.
I have this small TFT:
http://learn.adafruit.com/adafruit-pitft-28-inch-resistive-touchscreen-display-raspberry-pi/touchscreen-install-and-calibrate
calibration works ok and evtest as well but it seems there is something wrong with the uimapper for me.
the it seems the input-create script doesn’t run automaticaly on my raspi all i see runing is:
root 1462 0.1 1.1 8368 5132 ? S< 18:44 0:00 python ./input-read.py /dev/input/event2 -D
so the evtest doesn’t even show the uimapper device i can only see these:
/dev/input/event0: Primax Icon7 Rondo Keyboard
/dev/input/event1: Primax Icon7 Rondo Keyboard
/dev/input/event2: stmpe-ts
I tried to run the create script manualy it runs and doesn’t show any error but no device is created whatsoever.
Can you help me with this please?
oh and I forgot that this is causing xbmc not to pick up the touchscreen at all ofcourse
Hi Michal,
Yes you are right, input-create.py is not running for some reason. Sorry if I am repeating advice…
I think it might be a problem in the config file in /scripts/uinput-mapper/config/touchscreen.py. I made some changes to check screen resolution, so line 5 reads…
sres = subprocess.check_output(“/opt/vc/bin/tvservice -s”, shell=True)
It uses ‘tvservice’ , you could check it still exists. Being lazy, i didn’t check if/where it exists. If it doesn’t then install it, or change the path to the new location.
This has been a previous problem when new xbian versions have been released and the file location was changed.
If the config file fails then it will generate an error and stop input-create from executing.
To test, you can try to stop other processes that may grab the device and use the command lines below to test if you can see in evtest….
stop xbmc
cd /scripts/uinput-mapper
./input-read.py /dev/input/event2 -D | ./input-create.py configs/touchscreen.py &
evtest
and then hopefully see the uimapper device
Hope this helps,
cheers
mark
Hello Mark,
thank you so much for this tutorial !
I spent a lot of hours trying to make my Touchscreen work correctly with raspbmc. Today I have found your tutorial and now it works like it should :-)))))
Thank you so much for posting this tutorial and the work you did.
Greetings from Germany
Randolph
No problem Randolph
thanks for the feedback
Mark
I’m getting errors cannot create directory when running the following lines, any advice for a newbie?
sudo mkdir -p /scripts && tar -zxvf uimapper.tar.gz -C /scripts
Hi Simon,
I’m not really supporting this blog atm, although I am reluctant to remove it since the daily visits.
Sorry to hear you have problems, I have tested in the past on both distros without errors. The tutorial was an attempt to make it easy and avoid confusion and problems.
if possible all that is needed is to copy the files/structure to the script folder.
Perhaps you can separate the lines…
mkdir -p /scripts
tar -zxvf uimapper.tar.gz -C /scripts
…to see where the error is generated.
hope this helps
cheers
mark
I had the same problem. the tar command was missing the sudo.
Thanks Stefan, I’ll add the ‘sudo’ to the tutorial.
cheers
mark
Hello! Thanks for the great tutorial and I almost got it to work. It is all done, but my calibration is still off for like 1cm. I think it has to do something with my resolution.
I got a touchscreen with 800x480p resolution, but that is not supported by XBMC so I use 720x480p. Now I also changed my /scripts/uinput-mapper/configs/touchscreen.py to 720x480p, but still the calibration is 1cm off.
Are there more resolution settings who I dont know? (I’m a raspberry n00b)
cheers
Tom
Hi Tom,
Have you tried changing the resolution of the pi, in the config file, then performing the calibration?. So the resolution is the same in both pi and xbmc.
It’s a while since I used this solution, but I think this can be found earlier in either the xbian or raspbmc blog. If all else fails, you can manually change the values in as described for fine tweaking, i needed to do this to compensate for a 6.5″ bezel around a 7″ screen.
Hope this helps,
mark
Hi,
first of all thank you for your work, i’m getting the following error by
Available devices:
/dev/input/event0: Dell Dell USB Keyboard
/dev/input/event1: HID 041e:30d3
/dev/input/event2: eGalax Inc. USB TouchController
./input-read.py /dev/input/event2 -D | ./input-create.py configs/touchscreen.py
FAIL MUCH?
Failed to open uinput
Traceback (most recent call last):
File “./input-create.py”, line 59, in
d = UInputDevice()
File “/scripts/uinput-mapper/uinputmapper/cinput.py”, line 194, in __init__
raise OSError
OSError
Exception TypeError: ‘argument must be an int, or have a fileno() method.’ in <bound method UInputDevice.__del__ of > ignored
Hi Torben,
Sorry for the delay, it sounds like the device you are trying to ‘grab’ with uimapper is already ‘grabbed’ by another process, maybe xbmc, or perhaps it’s already running the uimapper process.
Further info may be in this or the other xbian thread.
Hope this helps,
cheers
mark
Hi,
i had the same Error Message and solved it by running my start script with the command “./input-read.py /dev/input/event2 -D | ./input-create.py configs/touchscreen.py” as user root.
Maybe this helps somebody to save time finding out what that error means.
please, where did you buy the eGalax touchscreen???
Sorry for delay, here http://www.ebay.co.uk/itm/New-SAMSUNG-7-LED-LCD-Touch-Screen-Monitor-Kit-Outdoor-/110659973152
I just tried your tutorial at my raspbmc via putty, but unfortunately I get stuck at “sudo dpkg -i tslib_1-1_armhf.deb”, I get the following error:
“dpkg: regarding tslib_1-1_armhf.deb containing tslib:
libts-0.0-0:armhf conflicts with tslib
tslib (version 1-1) is to be installed.
tslib provides tslib and is to be installed.
dpkg: error processing tslib_1-1_armhf.deb (–install):
conflicting packages – not installing tslib
Errors were encountered while processing:
tslib_1-1_armhf.deb”
Any help or ideas what went wrong?
It might be you already have tslib installed, try removing it using ‘apt-get remove packagename’, you need to find the exact packagename.
Some info here, https://wiki.debian.org/ListInstalledPackages
cheers mark
I’m trying to run your instructions but when I run anything with google docs I get a 404 Not Found error…
Any information on the location of the files?
HI Brandon,
Try it now, for some reason, the code highlighter (wordpress) had changed the dash ‘-‘ character to another slightly longer one in every step.
I have tried the links and ‘dpkg’ command and they seem to work, any problems let me know.
Thanks for your input,
cheers mark
Hi,
I’m using Xbian 3.15.6 (Jul 21 2014) and have used the install.sh to get and execute the uimapper scripts. I can calibrate the screen but XBMC doesn’t use the scaled settings. On investigation I found that input-create.py is not creating a new event & I think it is complaining that an event is still in use:
I had the same issue on Rasbmc too. Any ideas?
Steve
Hi Steve,
It’s been a while but here goes….
Yep I think you are right, it looks like a ‘grab’ issue. Did you ‘stop xbmc’ too before evtest? this will hopefully release the device and allow capture in evtest to see if this is the problem.
Brantje (from XBIAN), hosts old files and did his own install script for xbian. I have changed things many times since and recommend the ‘long-hand’ way; this is good since it gives an idea of what’s being put where etc.
If you look at my uimapper.conf, it is slightly different for both distros of xbmc, i changed to get uimapper to grab the device before xbmc starts. Best to use the ‘long’ method with the newer files. Then you can see if uimapper works without xbmc in evtest.
Hope this helps
Cheers
mark
Hi Mark,
Yes I’d stopped XBMC (just a login prompt in the eGalax screen). Running evtest only ever shows events0-2 for keyboard, mouse & eGalax. I’ve never seen a new event created by uimapper. Is there a way to determine which process is using an event?
Cheers,
Steve
Not sure, I’ll look.
If xbmc is stopped, and uimapper stopped, check to see no ‘stray’ processes using ‘ps aux’. If you find input-read.py running this will grab the device, despite input-create.py running or not. Kill the process using ID number.
You really need to prove egalax input using evtest, then check why input-create is failing when running ‘start uimapper’. See info after running with ‘dmesg’.
Again try the versions from my google drive, I think they might be different.
1. If evetest works and provides feedback with event2 egalax,
2. then try uimapper next. if that fails, look at dmesg.
3. try to test input-read.py..—…input create.py. commands from the conf file, obviously adding the correct config file etc.
think it might be input-read grabing, if not, check dmesg for info
Not tried in a while and have no test-bed to check, so can give ideas on past problems. If I find a way to check which process has control I’ll let you know.
Cheers
mark
Mark,
It’s all working!
I installed your scripts, didn’t need to calibrate again (I’d done that before), rebooted & it’s all good. Looking to use this in the kitchen as a family notice board & add extra plugins to XBMC for family appointments and maybe a feed in from a CCTV camera.
Thanks.
Steve
Hi, I’ve run your steps and the touchscreen is “useable” at this point in RaspBMC.
However, I have noticed that the touchscreen behavior is non-linear, and this makes it only partially usable. I can’t touch some areas of the screen even with calibration.
For example: Touching near the top of the LCD (1280×800 LCD, 7″) the pointer goes to the correct coordinates. However, the further down I go, the calibration/response to coordinates is increasingly off.
I can’t touch the “home” and other icons in the bottom bar in XBMC. Near the bottom, I can’t move touch pointer any further. Below 1/2 way down the LCD/touch layer, the coordinates are not as accurate as near the top, so I can’t precisely touch the XBMC options.
Has anyone else seen this? Other ideas? Thanks.
hi, i finally found something easy and clear!
But i have a problem, everything seems to works fine till…
i have an egalax 7″, now the pointer is ALMOST calibrated…
if i move the finger in the first quarter of the monitor, i see the pointer move accordingly but in the last quarter of the screen, any idea?
(latest noobs with raspbmc updated and rpi b 512 v2)
Hey,
i installed everything according to your instructions, but it is not quite working right:
After having everything set up, the touchscreen is still “out of alignment”, but if i go to the console and stop xbmc and uimapper and run ts_test, everything is complelety fine (i just took the ts_calibrate.sh and replaced the last line with “ts_test”).
Manually executing the uimapper scripts ( sudo python ./input-read.py $UIMAPPER_DEV -D | .sudo python /input-create.py $UIMAPPER_CONF & ) does not display any errors, but if i try to run “cat /dev/uinput” it returns “no suitable device found”. Shouldn’t i be able to see at least some sort of output there?
Assuming there should be output there, i think the script either fails to register the /dev/uinput device (but then it should return with an OSError, which it seemingly doesn’t), or it just fails to post any events to the device (but shouldn’t cat at least be able to “connect to the device then?).
If i am wrong with my assumptions, where could things go wrong?
dmesg output is clean (except for unrelated pcm512x errors).
just fyi: i tried running the scripts and writing the output to txt files and encountered and error in the input_create.py where it ran into an EOF error in line 35… so i replaced the calls in the uimapper.conf with absolute filenames instead of the relative ones and the error vanished, but the rest of the problem persists…
my new uimapper start call looks as follows:
exec /scripts/uinput-mapper/input-read.py $UIMAPPER_DEV -D | /scripts/uinput-mapper/input-create.py $UIMAPPER_CONF &
with $UIMAPPER_DEV=”/dev/input/event1″ and $UIMAPPER_CONF=”/scripts/uinput-mapper/configs/touchscreen.py”
(I had “2> /home/pi/read.txt” and “&> /home/pi/create.txt” added to the end of the two calls respectively to check for error output but neither file got populated anymore after i fixed the relative/absolute path error)
after fiddling around a bit more and having a quick glance at the source of both tslib and uimapper, it looks to me like uimapper is completely disregarding the xymix/yxmix variables and is doing some other weird stuff… not knowing exactly how that works, it seems to me that this might be the source of my problems. unfortunately i know too little python to tell for sure or to try to code a solution.
but shouldn’t a EV_ABS event have both the ABS_X and ABS_Y values in any case? if so, why disregard them and use the formula “(x*xscale + xoffset)*xcalib/(scaler) + (xmres – xsres)” instead of “(xtemp*xscale + ytemp*xymix + xoffset)*xcalib / scaler” (xtemp/ytemp are the ABS_X / ABS_Y values)? as far as i can see from the tslib code, that is how they calculate the calibrated position. is there any possibility to get that corrected?
nevermind, removing the very weird bit a the end ( […] + (xmres – xsres) ) did the job for me… since i am not running at 720p (or 1280*720), that part messed up my calibration quite a bit… i don’t really see the point for that anyway?! the missing rest only accounts for maybe 6-7 pixels at worst for me, so it’s “accurate enough”.
Sorry for delay and glad to see you found a solution.
I really have no time or equipment for testing anymore. At the time of creating the blog everything worked ok. If XBMC has been compiled with other updates since then this may create situations causing problems.
cheers
mark
Hey Mark!
Sorry for posting this on the wrong thread before…
Your solution seems to work for many people so thumbs up for that, solid work. I do encounter some problems tho and hope that you can give me a hand.
I freshly installed RaspBMC and went through your solution, calibrated the eGalax screen, which seemed to work.
Then I installed uimapper and evtest and changed the uimapper event to the right one.
starting and stopping uimapper works and evtest shows uimapper as an extra event (I have 2 eGalax Touchscreen events and one uimapper) evtest also shows that it’s touched when I tap on the screen.
But when I start xbmc again it’s not at all calibrated.
Is it possible that I have to use an older version of RaspBMC?
I wonder if you could help me with that.
Thanks for your awesome work.
I used brantje’s script on Xbian and it worked like a charm. I’d like to use RaspBMC tho to get dac support
hey guys,
i found out, if you’re using a higher or lower resolution (instead of
1280×720) in config.txt, you’ll got problems with the calibration. the
mouse-pointer will appear a little bit beside the touched point.
the solution is to change the configured resolution in
/scripts/uinput-mapper/configs/touchscreen.py
from uinputmapper.cinput import *
import subprocess
#Read screen resolution from tvservice (not framebuffer)
sres = subprocess.check_output(“/opt/vc/bin/tvservice -s”, shell=True)
sres = sres.split(“, “)
sres = sres[1].split(” @”)
sres = sres[0].split(“x”)
xsres = int(sres[0])
ysres = int(sres[1])
xmres = 1024
ymres = 600
if xsres >= xmres: xsres = xmres ysres =
ymres
# Read ts_calibrate data from /etc/pointercal
filename = “/etc/pointercal”
good evening,
i’ve been asking me, if there will be any possibility to run this calibration with osmc. i’ve tried it, but it doesn’t work. the calibration input seems to be ok, but the uimapper doesn’t start at all.
any support for osmc in the future?
same problem here.
I can’t promise anything, I Haven’t looked at this for a very long time and not developing anymore due to time constrains and other projects. I may have a look into this in the next month or so, if I can setup a test rig again, with rpi2 also, but I cannot promise anything as yet.
I thought there was enough on here to help someone find a fix or other work on related sites using this solution.
cheers
markamc
NB: if it wont start on boot, look into the Upstart script – uimapper.conf, that used to be the issue. Please bear in mind this only worked when installing as tutorial described, brantje script used different file versions and only for xbian.
hi mark,
thx for your VERY fast reply 😉
i didnt use brantjes script but followed this tutorial step by step.
everything works until Step 2.
The problem is that OSMC uses systemd and i have no clue on how to convert the provided upstart script to systemd.
I am not sure if thats the only issue.
Not sure yet, but I looked here, https://wiki.ubuntu.com/SystemdForUpstartUsers
Maybe helpful. Can’t test for a while yet, need a touchscreen!
cheers
markamc
hi there,
i got it running (kind of)…
i extracted the important parts from the upstart script and ran them without systemd as a normal script and it works.
Its very ugly because i need to do this after every boot… as systemd is still a mystery to me i have lots of reading up ahead.
I plan to tinker the next few days with the systemd part and i will post everything here once im satisfied (hopefully i manage it until sunday evening)
cya
Great you are almost there. If you look at the document end from last link i gave there is a comparison of an upstart conf file and a systemd file, I think it might be easier than you think to change.
cheers
m
@mark: at first thank you mark for doing this script. without it i would be throwing the pi in anger away. 😀
would be great if you would make another tutorial for osmc. but i understand if there are other priorities.
@radi: isn’t it possible to run your extracted scripts at boot with cronjob or something?
or do i misunderstand the problem?
anything new about it? would be great, i don’t know enough about linux/debian for doing it by myself.
sorry for writing bad sentences, the english lessons in school are a long time ago.
I’ll try to have a look this weekend, hopefully find a solution.
Cheers
mark
Hi Mark, thanks for you’re help on this touchscreen issue. I find it strange that it isn’t just built in by now… Anyways, I have a few questions before I start diving into this. I’m building a stand alone device that will run one python script 24/7. Is there a way to just import libraries youve made into my script? The PI is currently running raspbian, but soon it will boot straight to my script. Also, do you know of a way to get rid of the arrow so the user will just press on buttons like a tablet?
Sorry these may be silly questions, I’m fairly new to python and development.
Thanks!
Bryan
Hi Bryan,
If python is installed then this script should start as-is; if you using the upstart script. If the system is not using upstart then follow procedure as normal and use run the script by calling the following, from another script or on-boot or even within your script, once.
./input-read.py /dev/input/event# -D | ./input-create.py configs/multitouch.py &
from the install directory i.e.
/scripts/uinput-mapper
Hope this helps,
cheers,
mark
hm, the blog complains about double posting, but i cant see my answer anywhere… not even with the ‘waiting for admin …’ tag -.-
Hi Radi,
no double posting, this is the first reply I’ve seen that you have posted since March 19, 2015 at 21:09
cheers
mark
Hi, not working, maybe too long or something. here is my answer: pastebin. com/fBmkgmjH
could you extend your guide with the information i gathered / link to my github?
(if this comment works your blog really doesnt like links (note: space before com)
cya
PASTEBIN CONTENTS:-
hi there,
i got it running a few days ago and put the files into my github. (link below)
sorry for not writing earlier, got distracted 😉
to get your ts working just follow this guide but leave out the upstart script. It is not compatible with OSMC as it uses the ‘new’ init systemd.
the systemd unit file and the extracted script (where you specify your eventX) is found here: https://github.com/radi-ka/eGalax-ts-calibration
then just configure the touchscreen size in /scripts/uinput-mapper/configs/touchscreen.py as you stated before. (maybe you need to customize your HDMI resolution also. there is a guide here: http://www.raspberrypi.org/forums/viewtopic.php?f=29&t=24679 )
and then youre good to go 😉
i am not quite satisfied with my solution as it doesnt allow for plug and play as the originial script. but maybe someone can improve on it
party on!
Hi Radi,
Sorry you seem to have problems, not sure why. Anyhow, added your ‘pastebin’ contents to your post, hope you don’t mind.
In the meantime, I have converted the upstart to systemd script, all seems well, just need to check a few things.
Using OSMC RC on RPI2.
cheers
mark
Hi all,
OSMC Solution
Here is a solution to get working with RPI2 and OSMC latest , including ‘hotplug’.
I will prepare another full tutorial soon since things have changed slightly with jessie.
Disclaimer :
At the moment it works and has not failed in testing, most things i.e. calibration remain the same, except ‘uimapper.conf’, only thing I have changed is using the systemd service to monitor input devices and execute the python script. There may be other, better ways to do this (see link below), but hey, I really am a novice and have never claimed to be an expert!
(alternative method using pyudev to monitor events and start scripts)
Firstly, some useful tools:
After install and first run of OSMC RC. SSH to rpi, I use putty.
‘Upstart’ no longer works, we are now using ‘systemd’. Also ‘evtest ‘is no available so alternative is now, ‘evmu-tools’. You can use evemu-record to display input events.
To stop media centre type,
systemctl stop mediacenter
apt-get install evemu-tools
evemu-record
Find the touchscreen event no. that gives you feedback when using touchscreen. For me event3.
Add the following text into the file /etc/udev/rules.d/99-input-tagging.rules
sudo nano /etc/udev/rules.d/99-input-tagging.rules
ACTION=="add", KERNEL=="event*", SUBSYSTEM=="input", TAG+="systemd", , ENV{SYSTEMD_ALIAS}+="/sys/subsystem/input/devices/$env{ID_SERIAL}"
Next,
sudo reboot
For the above to work, I think it needs a reboot, then by typing
systemctl list-units --all --full | grep "Touch"
You can see your device mine is here (i.e. dev-input-event3.device)
root@osmc:/home/osmc# systemctl list-units --all --full | grep "Touch"
dev-input-by\x2did-usb\x2deGalax_Inc._Touch\x2devent\x2dmouse.device loaded active plugged Touch
dev-input-by\x2dpath-platform\x2dbcm2708_usb\x2dusb\x2d0:1.5:1.0\x2devent\x2dmouse.device loaded active plugged Touch
dev-input-event2.device loaded active plugged Touch
dev-input-event3.device loaded active plugged Touch
sys-devices-platform-bcm2708_usb-usb1-1\x2d1-1\x2d1.5-1\x2d1.5:1.0-0003:0EEF:0001.0003-input-input2-event2.device loaded active plugged Touch
sys-devices-platform-bcm2708_usb-usb1-1\x2d1-1\x2d1.5-1\x2d1.5:1.0-0003:0EEF:0001.0003-input-input3-event3.device loaded active plugged Touch
sys-subsystem-input-devices-eGalax_Inc._Touch.device loaded active plugged Touch
No we create the uimapper.service file in /lib/systemd/system/ and add the text below and change the event description in ‘BindsTo=’ and ‘After=’ lines to suit your device.
sudo nano /lib/systemd/system/uimapper.service
[Unit]
Description=uimapper
BindsTo=dev-input-event3.device
After=dev-input-event3.device
[Service]
Type=forking
Environment=UIMAPPER_DEV=/dev/input/event3
Environment=UIMAPPER_CONF=configs/touchscreen.py
Environment=UIMAPPER_DIR=/scripts/uinput-mapper
WorkingDirectory=/scripts/uinput-mapper
ExecStart=/bin/sh -ec "exec ./input-read.py $UIMAPPER_DEV -D | ./input-create.py $UIMAPPER_CONF &"
[Install]
WantedBy=dev-input-event3.device
Make sure mediacenter is stopped,
systemctl stop mediacenter
All left to do is enable/start service by typing,
systemctl enable uimapper.service
systemctl start uimapper.service
and reboot.
Cheers, hope it works for you,
mark
Other useful commands, to check status and reload service after changes:
systemctl status uimapper.service
systemctl daemon-reload