Raspberry Pi 2, OSMC & eGalax touchscreen

UPDATE: uimapper – calibration works if different resolution selected in KODI, after re-plug/restart.

Thanks to ‘NIce Guy’ for figuring I’d messed up the tarball!! (now fixed…hopefully

NEW: check HERE to make changes to improve event assignment and UDEV persistence

The following tutorial describes additional steps, after installation of OSMC, to enable calibration and extra functionality for the eGalax touchscreen in KODI. 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 KODI on the Raspberry Pi.

The procedure requires to install the following:

ts_calibrate

uinput-mapper & systemd service script – uimapper.service

evemu-tools (not essential, replaces evtest)

The systemd script uimapper.service starts/stops the python script uinput-mapper whenever the input-device is added/removed allowing hot-plugging and grabbing of the device within KODI.

Next, edit the file uimapper.service and change the event-device to the correct event description (‘BindsTo=’, ‘After= ‘, ‘/dev/input/event#’ and ‘WantedBy=”) for the touchscreen device on your system and then move it to the correct directory…

40 thoughts on “Raspberry Pi 2, OSMC & eGalax touchscreen”

something that came up in the comments of the older post:
uncle-sam suggested that one should edit the file
/scripts/uinput-mapper/configs/touchscreen.py
to change the screen touchscreen resolution if the cursor is displaced

Regarding the screen resolution. This is a difficult one for a universal solution, I have tried many things on my system. I had it working for me when I changed to different resolutions in both config.txt and KODI. I came to the conclusion that if the ‘user’ has to change a couple of lines of code then it ain’t too bad!
It’s also possible to create custom config files based on the touchscreen.py one that I did to suit your requirements.

The ts_calib file uses the screen info given in config.txt, also reported in tvservice command. This may be different value than the screen resolution in KODI and overscan adjustment setting ( I needed to combat the bezel i have reducing the 7″ to 6.5″ screen). I tried many combinations to achieve a universal solution for every combination to suit my needs and early blog comments.

The conclusion was to calibrate the screen in the same resolution you were going to use in KODI.

With the new OSMC skin, the pointer is off to the right, it’s not designed for mouse or touchscreen. The top left of the arrow is the original pointer datum.

My main philosophy was to create a solution that would work and give people the ability to play/learn as I have with no prior knowledge of Linux hardware or software.

Hey Mark, this is working best! Forget about my post in the old Raspbmc Tutorial! But I have an Issue with the double clicks or “enter klicks”! Is it not possible to tell the pi, that every touch is a click!? Thank u!
Best, Daniel

Q1. I have been looking at previous problem, yes their is a bug which has been flagged before, but only just found real cause. I am in process of resolving and will post Q&A’s when done. (in short, tvservice -s matchs KODI resolution selection, but KODI log reports different resolution, in some cases which could cause touchscreen scaling issues)

Q2. If the single click (long press) or right-click (longer press) isn’t working, stop mediacenter and check evemu-record to see if you get uimapper and both (double BTN_LEFT) for long press and (BTN_RIGHT) for longer press.

Check the range and time section at the bottom of the file, try different values.

Once saved, either re-plug touchscreen, or by SSH type:
sudo systemctl restart uimapper.service

If you want it more responsive , I think you can add a nice value to systemd script under [Service] section in uimapper.service file. (for example Nice=-10)
sudo nano /lib/systemd/system/uimapper.service

thanks, it should work in 1024×600, it does for me, if your monitor natively supports it that is. Calibrate in that screen and change kodi to DESKTOP resolution, test with ‘tvservice -s’ via ssh and then check kodi.log in
sudo find / -name kodi.log

you should see something like this within:
22:12:46 T:1956696064 NOTICE: Found resolution 1024 x 600 for display 0 with 1024 x 600 @ 59.000000 Hz

This looks good, I still need to fix things, but basically,
1. set your display in config.txt,
2. check with tvservice -s that it is the same and calibrate.
3. Then set KODI to DESKTOP. It should work ok, for now you could try setting the following in touchscreen.py (but this is a old ‘fudge’ to ‘fudge’ my ‘fudge’) (fudge meaning a dodge/cheat)

xmres = 1024
ymres = 600

I can check later hopefully with my completed modifications. Don’t forget you can change overscan etc in KODI video calibration too.

i got some trouble with the events. if i connect my vigo usb-soundcard the events are changing and the calibration doesn’t work anymore. are there any known issues? for calibrating and installing uimapper and even for testing i disconnected the usb-soundcard.

sudo sh ts_calib.sh took variables into /etc/pointercal
Thats all ok. No problem with permissions or other.

After calibration i do a reboot. The touchscreen doesn’t function as well.
Slide to the right > pointer goes at the bottom.
Slide to the left > pointer goes at the top.
Slide to the top > pointer goes at the left.
Slide to the bottom > pointer goes at the right.

Hi Nice Guy,
Sounds like x/y axis are swapped, what does pointercal look like? check bottom top-left/bottom right values in evemu-record when uimapper/mediacenter service stopped compared with the touch event values when uimapper is running (i.e. should it be swapped).
hope it helps!

Think I will try to post a troubleshooting section soon, to show how to diagnose a fault,; think I keep falling into the ‘it works for me’ trap!!

Btw, some users seem not to be aware that the main purpose of this solution was to add more functionally within KODI.
– single short touch just ‘selects’,
– longer touch is a double click and,
– even longer touch gives a right click (useful for options menus/return from page)

This was the whole point of using this over other solutions.

Also, if it seems ‘laggy’, then add a Nice=-10 to the uimapper.service file (under [Service], it makes a big difference.

This is not a perfect solution, I’m looking into others. I’ve also had it working on an android system, which I prefer since KODI is not my favorite.

There was a problem with the tar file, I’d ‘tarred’ it within another folder. I am thinking of adding my latest version too, soon. Monitoring for screen changes (with tvservice -m) and then resetting the touchscreen to the new resolution.

Hi again,
Finally made some progress, I will post a new section with the changes to uimapper. These include monitoring for resolution changes and auto adjustment.
Changes to uimapper.service/udev input tagging for hotplug and persistence. In the event of re-plugging usb device and or adding other devices, I have symlinked the touchscreen device event that creates the touch event output, hopefully will work for all.

Changes to udev tagging rules for inputs.

This symlinks a device called ‘/dev/uimapper’ (linked to ‘/dev/input/event#’

I have NO idea what I am doing wrong but although I have my Touch Screen plugged in correctly, I only get ” evemu-record [output file] ” when I try and run the evemu-record. It’s like it’s not seeing my touch screen. Hopefully someone can help me in this case, as I am a definite N00B.

Are you using te correct version of OSMC, RPI2? (think theere were inital issues with kernel configurations.

Try directly into pi, not using hub.
Things to try to check if device is working on system, or to find reasons why it’s not.
1. try ‘lsusb’, first install ‘usbutils’ using ‘apt-get install usbutils’
2. Check output of ‘dmesg’ , look for usb input devices.

Hope this helps,
Btw, what is the make, maybe someone else has similar?

Try entering ‘systemctl status uimapper’ for more info and also check you have the correct device event. It seems uimapper is not starting since the python scripts are not executing. Maybe wrong device event.
Iif you stop uimapper & medicenter, you can try to run scripts from command line. i.e.

Hi Thanks for a great tutorial. I have been in a match trying to get this to work. For some reason when I do the evemu command I do not see my screen. However when I an lsusb command I see it. Any thought or help on what I can do to see this and start to use my new touchscreen. Much appreciated and thank you so much.

Sorry to hear you are having problems, looks like you can see the usb device connected, but it isn’t generating the the input event, maybe?
if this is the case, then you should try new install of OSMC to check everything works as expected (without calibration) prior to installing uimapper.

IF all as expected, then there may be an issue with the udev input tagging, try editing/removing the file to test:
sudo nano /etc/udev/rules.d/99-input-tagging.rules

Remove it, reboot and see if your device shows up. Might be related to this post here? I can only test on my system so may need refining.

This particular post is specific to OSMC, I haven’t tried xbian/rpi2 with this method. IN your case if you cannot install evemu-tools, try evtest and see if that works.
Not sure if xbian still uses UPSTART or has changed to systemd, which will present you with start-up problems using this method.