Raspberry Pi-eyed

Raspberry Pi KODI Touchscreen support

Raspberry Pi, Xbian & eGalax touchscreen

XbianXbian: Touchscreen calibration & extra features

UPDATE: See tutorial end for easy install script…

The following tutorial describes additional steps, after installation of Xbian1.0beta1, 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…

Download files…

Install the deb package…

Next, edit the file ts_calib.sh and change the event-device to the correct event# for the touchscreen device on your system…

Now run the script and calibrate the touchscreen….

Step 2: Install uinput-mapper & uimapper.conf

Download files and extract tar…

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…

Move file to correct directory…

That’s all, you can now Reboot.

NOTE:

You can start uimapper by re-plugging the device, or by typing…

To see the processes running in the background type…

UPDATE:

The tutorial is to show how to add the functionality manually.  There is now an install script for this procedure available thanks to Brantje,

Open a ssh connection to xbian  and type…

After download is complete type…

And follow the on screen instructions

112 thoughts on “Raspberry Pi, Xbian & eGalax touchscreen

  • raspuca says:

    You’re the number 1! I’ll try this in the evening :)

  • Andrei says:

    Hi Mark!

    Great tutorial! I can wait to go home from work and try this.
    Thank you for letting me know on my blog!

  • themad06 says:

    Hello,

    Thank you very much :-) Your tutorial is great !

  • raspuca says:

    I’ve done all..but when I type “sudo start uimapper” or “sudo service uimapper start” there is this error “uimapper: unrecognized service”
    Why??
    :)

    • admin says:

      Hi Raspuca,

      can you see the file uimapper.conf in the /etc/init/ folder?

      if so you can start/stop by
      start uimapper
      stop uimapper

      Have you change the event device number in the uimapper.conf file too?>

  • raspuca says:

    Yes the uimappper.conf is in the /etc/init folder.. but when I type “start uimapper”
    “stop uimapper”
    i have this “bash: start: command not found”

    I have changed the device number of uimapper.conf and in the ts_calib.sh

  • admin says:

    Is this a new xbian-beta install, are there any other fles in the /etc/init folder?

    • raspuca says:

      This is the result of ls in /etc/init :)

      network-interface-container.conf startpar-bridge.conf udevmonitor.conf
      network-interface-security.conf udev-fallback-graphics.conf udevtrigger.conf
      network-interface.conf udev-finish.conf uimapper.conf
      networking.conf udev.conf

      Thanks for your help!! :)

  • admin says:

    have you edited the files in windows,or on the rpi? if you cannot run uimapper, the error is normally..

    start: Unknown job: uimapper

  • admin says:

    no, it might be my fault, just moving files to git…i wll update in a moment

    Bash error is from python i think, I wl let you know give my 10 minutes thanks

    mark

  • admin says:

    Ok, raspuca,

    I just tried it and all went ok, the only thing I could think of was if you copy/pasted all from the code box, the ‘wget’ commands need to be on a separate line

    Try step 2 again and see if it work, I’ve split them to make it clearer

  • admin says:

    this is odd, did ts_calibrate work ok?
    let’s isolate the problem

    try:
    sudo su

    go through step 2: in tutorial…

    check if uimapper.conf exists in /etc/init/
    check if /scripts/uinput-mapper folder is present

    apt-get install evtest

    then use evtest to check your input/device exists

    • raspuca says:

      I tried. The uimapper.conf is in the /etc/init/
      The /script/uinput-mapper folder is present
      and the evtest say that exists eGalax :)

      The problem in my opinion is in the syntax of command “start uimapper”, it seems not recognized by shell..

      • admin says:

        can you start/stop xbmc?

        I have tried this may times tonight and everything is ok, Brantje has confirmed it too on xbian forum, so can you try again from the start? it should work…

        try
        ps aux

        to see if the processes are ruining…..

        root 1822 0.3 2.1 11492 8260 ? S< Jul08 0:04 python ./input-read.py /dev/input/event2 -D root 1823 0.2 1.9 10620 7416 ? S< Jul08 0:03 python ./input-create.py configs/touchscreen.py

        • raspuca says:

          Yes, I can starto/stop xbmc but with the command “service xbmc start/stop/restart” and the processes don’t run :(
          I don’t understand the reason

          • admin says:

            so, you can..

            stop xbmc
            start xbmc
            but not
            start uimapper

            I don’t understand the problem, I will try later on my 256 pi, I tested on 512pi

  • raspuca says:

    I have 512pi too…but when I start or stop xmbc i have to type “sudo SERVICE xbmc start/stop/restart”..not only “xbmc start/stop/restart”…this is the difference between /etc/init.d and /etc/init I think..

  • Brantje says:

    For a faster installation:

    Open a ssh connection to xbian Then type:

    wget https://github.com/brantje/xbian-touch/raw/master/install.sh

    After download is complete type: sudo sh install.sh

    And follow the instructions on screen.

    Enjoy!

  • admin says:

    Are you running beta 1 fresh or updated, XBMC is started in Upstart now i think? Try a fresh new beta1 from Brantje’s link here:

    Fresh beta 1: http://download.brantje.com/xbian/XBian1.0Beta1.7z

    Brantje has now added a simple installer and posted files on github, here’s the link

    https://github.com/brantje/xbian-touch

  • pim66 says:

    Hi, thanks for the good work. I´m new on all this !!!

    for me the touchpad doesn´t work like it should. in the middle of the screen it´s ok, but up, down, left and right side the arrow goes “away”, means its in front of my finger . is it possible that the resolution is the issue? my tp has 1024×768, but calibrate says 1280.

  • admin says:

    Hi Pim66,

    what is your model? you say touchpad , or is it touchscreen, some touchpads give out REL_X, Y values and not AB_X, ABS_Y.

    You can check, if you install evtest

    sudo apt-get install evtest

    It will tell you the touchpad resolution and if it produces ABS_X events too
    You can also check if uimapper is running in that too, you should see an extra device called – uimapper – touchscreen

  • pim66 says:

    thx, will do and tell you. my model is a faytech 10″ touch monitor.

  • raspuca says:

    PERFECT!! ALL WORKS! :) I LOVE IT! :)

  • pim66 says:

    Hi all,
    looks like after a fresh install it works perfect, thx for all your help.
    I thought about the problem, for the new install I unplugged my mouse, maybe that was the issue, what do you think?

    @Brantje – great script, makes it very easy and fast to do a new installation.
    @all – keep up the great work

  • Oli says:

    hi
    i have a 7″ touchscreen
    the touch is working, but not fine
    how i can calibrate it?

    oli

    • admin says:

      Hi oli, sorry for delay, I’ve been away….

      try installing evtest to identify your touchscreen input event and check it works. The guide above should install ts_calibrate for xbian and raspbmc distro and allow you to calibrate

      • oli says:

        hi
        i can run the ts_calibrater
        but it doesn´t calibrate it.
        why it don´t save the callibration?

        oli

        • admin says:

          check if it generates the /etc/pointercal file. Then check if you can see uimapper device when running evtest (sudo apt-get install evtest). The uimapper uses the calibration file.

  • freefish says:

    I’m using a 7′ 800×480 screen(Model at070tn94) with eGalax touch screen.I’ve done with your guide,but how to calibrate the screen?
    When I run the ts_calibrate,it prompts:
    root@xbian:/home/xbian# ts_calibrate
    ts_calibrate: error while loading shared libraries: libts-1.0.so.0: cannot open shared object file: No such file or directory

    How could I to calibrate the touchscreen?

    • admin says:

      Hi freefish,

      Again my apologies for a delayed reply.

      I have seen this error before, I thought i had fixed it for a fresh install of xbian beta1 and raspbmc….is this an upgrade? or have you previously installed ts_calibrate, tslib_dev etc. Maybe removing the package tslib first might help. It looks like the paths set in the config file are incorrect and the library can’t be found.

      • freefish says:

        thx i’ve fixed.
        but the calibration data does not fit my touchscreen?
        when i exectued ts_calib.sh,it prompts:
        (top left:x=185 y= 1717,top right:x=1882 y=1733,bot right:x=1862 y=325,bot left:x=220 y=362 took 6 samples …center:x=1030 y=1028
        -36.360718 0.419179 0.002106 525.750916 -0.001653 -0.274965 Calibration constants:-2382936 27471 138 34455612 -108 -18020 65536, 800 480 1
        I compiled a new kernel with egalax driver on raspbian ,the calibration data was familar with xbian,it works normal on raspbian ,it doesn’t work on xbian. how could i to solve it?

        • admin says:

          Ok, It looks like a calib file was generated…/etc/pointercal. Next you need to see if uimapper is running, ‘apt-get install evtest’ and it should be able to see uimapper device in the list.

          It is the userinput device uimapper that grabs the touchscreen and implements the calib file, without uimapper the touchscreen will not use the calibrations from pointercal.

          There have been a few people who needed to recompile kernel to get touchscreen to be recognized, must be different to my egalax which works with all distros with latest kernel.

          Ps. it also looks like you calibrated screen in 800×480 resolution too

          • freefish says:

            xbian@xbian ~ $ sudo sh ts_calib.sh
            xres = 800, yres = 480
            Took 3 samples…
            Top left : X = 193 Y = 1693
            Took 1 samples…
            Top right : X = 1877 Y = 1729
            Took 2 samples…
            Bot right : X = 1856 Y = 321
            Took 4 samples…
            Bot left : X = 190 Y = 288
            Took 7 samples…
            Center : X = 1043 Y = 984
            -27.716125 0.417947 -0.003511
            505.253357 0.005539 -0.270158
            Calibration constants: -1816404 27390 -230 33112284 363 -17705 65536

            These are the /etc/pointercal contenet:
            27390 -230 -1816404 363 -17705 33112284 65536 800 480 0

            The Y-axis is upside down. and zoom is not accurate.

            How could I fixed?
            How is the /etc/pointercal data generated?

  • admin says:

    Hi freefish,

    Ok, the pointercal file is generated automatically when execute ts_calib and select 5 points. The information looks ok to me, you can see top left and bottom right values will give you an inverted Y axis. The problem , I think is that uimapper is not running for some reason. It is uimapper that uses the pointercal file.

    Using SSH, login in and type…

    stop xbmc
    start uimapper

    apt-get install evtest
    evtest

    Did uimapper start?
    Can you see, in the device list, a uimapper device entry?

    We need to see this so xbmc can use the calib file, if not, xbmc wiull grab the egalax device and not uimapper, therefore xbmc will use the egalax directly and not add the scale and offset values from the pointercal file.

    Hope this helps, if uimapper is not running then we can check the device values in the /etc/init/uimapper.conf file

    • freefish says:

      Well finally calibrate the touch screen, ts_calib.sh generated data, only the X-axis and Y-bearing offset offset a little mistake, I manually calibrated Well, thank you very much! One to start the calibration data is not accurate because the touch screen ID set incorrectly. UIMAPPER not properly get to touch the device. Thanks again!

      • admin says:

        Ok good news, if you think you calibration is off, then maybe it’s worth checking to see if overscan is set when calibrating or the video overscan in xbmc, obviously the two should match. The other reason may be, the ts_lib calibration equation accounts for skew in the touchscreen too by adding compensation of x,y in the x & y equations; I didn’t include this at this stage into the calibration in uimapper.

        Just to confirm and help others, in order to get it working you had to manually edit the ts_calib.sh script and uimapper.conf line and assign the correct /dev/input/event# as described in detail in the above tutorial?

        • freefish says:

          I’m a newbie at linux.

          I have these settings in /boot/config.txt
          hdmi_mode=2
          hdmi_group=87
          hdmi_cvt 800 480 60 0 0 0
          ovserscan=1

          In /etc/init/uimapper.conf When i insert more input devices, event? is not fixed, so do not run correctly uimapper,this is the reason why I can’t calibrate the correct device.I just changed the ts deviceid in ts_calib.sh but not in uimapper.conf

          i’ve tried add these line to uimapper.conf but it doesn’t work.
          tsDev=$(ls -l /dev/input/by-id | grep “eGalax”)
          teDev=${tsDev##*/}
          tsDev=”/dev/input/$tsDev”
          env UIMAPPER_DEV=$tsDev

          could you give me more advice?^_^

          • admin says:

            Sorry thought I’d fixed it…will keep trying and post shortly

            mark

          • admin says:

            Hi freefish,

            Yes, it’s taken me this long!! I’m a noob too!!

            The only way I found to do it in upstart is by changing the uimapper.conf file, I will mail you a copy of the new one, it gets the correct event for eGalax automatically now. The only problem I can see is with RASPBMC, I have 2 eGalax events one for BTN_ events and one for touchscreen pos and BTN_TOUCH

            Here is the modified uimapper.conf file:

            #!upstart
            description "uimapper"

            #NOTE: Change '/dev/input/event2', to find event# use 'ls -l /dev/input/by-id'

            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 -7

            kill timeout 1

            expect fork

            pre-start script
            TS_EV=$(ls -l /dev/input/by-id | grep "eGalax")
            TS_EV=${TS_EV#*/}
            exec >>"/tmp/$UPSTART_JOB"
            echo "UIMAPPER_DEV="/dev/input/$TS_EV""
            end script

            #UIMAPPER_DEV='$TS_EV'

            script
            chdir $UIMAPPER_DIR
            . "/tmp/$UPSTART_JOB"
            exec ./input-read.py "$UIMAPPER_DEV" -D | ./input-create.py $UIMAPPER_CONF &
            end script

            post-start script
            rm -f "/tmp/$UPSTART_JOB"
            end script

            respawn

          • freefish says:

            Perfect! The Great Markamc!

  • seamoan says:

    Hi,

    great tutorial! I tried it the manual way (seen the automatic way too late).
    The calibration is working: I had to choose event4, first try event3 (which is also my touchscreen) didn’t work.
    The crosshairs disappear, after touching them and I get an output from it.

    But in my xbmc, which runs via raspbmc in framebuffer, doesn’t mind the touchscreen calibration, still working but no change, pointer is fart away from my fingertip.

    Does the visual resolution have any effect?

    How do I get the calibration data into a screen running in framebuffer (raspxbmc).

    • admin says:

      Hi seamoan,

      I have the same thing with raspbmc, ther are 2 events, one for BTN_ events and the other for touchscreen position and BTN_TOUCH, this is the one you need. If you install evtest, you can see the event that gives the position feedback.

      sudo apt-get install evtest

      you also need to change uimapper.conf file to the correct event number. To test it is working , use ssh..

      stop xbmc
      start uimapper

      evtest

      (you should see a uimapper – touchscreen event too)

      start xbmc

      Now, it should have correct position and BTN_RIGHT.

      Make sure the calibration is done in the same resolution when in framebuffer and xbmc, also check for overscan.

      Check /boot/config.txt

      the file /etc/pointercal has the calibration values and the screen resolution at which they were calculated.

      Hope this helps

      cheers

      mark

  • astaza says:

    hello, can you provide your full sd card img ?
    thank you

  • astaza says:

    hello,
    it’s worked for me but the touch not good
    like this video
    http://v.youku.com/v_show/id_XNTkyMzQ4Mzc2.html

    i tried to make calibration but not fiexd
    any way to fix this issus
    thank you

    • admin says:

      Hi astaza,

      Sounds like you have the incorrect event set in uimapper.conf or the uimapper is not running, as described the reply to ‘freefish’ in the thread.

      If you have performed the calibration, it generates th efile /etc/pointercal.

      Next check that /etc/init/uimapper.conf file has correct event value too.
      Type in SSH…

      stop xbmc
      apt-get install evtest

      start uimapper

      (it should say started with process id)

      evtest

      (you should see an extra uimapper – touchscreen device if all is working)

      cheers

      mark

  • astaza says:

    thank you sir, it’s only working good if resolution is 1280x 720
    but not working good if resolution is 720×520
    i need it work for lower resolution i have 6.5 touch screen for car project
    when it calibration it i got “xres = 1280, yres = 720 ”
    even i change the xbian setting to other resolution
    how to fix this

  • admin says:

    Hi Astaza,

    I am working on a solution, you have found an anomaly!
    I will provide a work-a-round in uimapper, so only one calibration necessary and then it will scale correctly in any resolution.

    The reason:
    i recalibrated ts_calib in a lower resolution in config.txt. The values given out are as expected in evtest and correctly scaled. The situation arises in xbmc, irrespective of the resolution, the mouse position is always from 0,0 to 1280,720 (depending on overcscan). So this makes gives incorrect mosue position when using touch.

    You can diagnose x,y co-ordinates in xbmc too. In the skin folder you can edit addon.xml file. Changing debugging=”false” to “true” displays the pointer position on the screen. Using this you can see how the overscan effects the pointer max/min values

    http://wiki.xbmc.org/index.php?title=Addon.xml

    Will be in touch soon,

    cheers

    mark

    • admin says:

      Hi Astaza,

      I’ve just finished updating uimapper so the calibration should still be ok if you decide to change screen resolution. Now you can calibrate in default (720p) resolution and if you reduce resolution and replug device (or restart uimapper/xbmc) then calibration with change to suit screen mode.

      Also, you can calibrate in lower resolution to by changing /boot/config.txt. If you then change config.txt back to default (720p) the calibration should still work ok too.

      There seems to be a problem however above 720p (1080p), still need some work, but as this is mainly for touchscreens, then I think most situations will be ok.

      Please give it a try, by doing the following fro SSH to pi:

      stop xbmc
      stop uimapper

      wget --no-check -O uimapper.tar.gz "https://docs.google.com/uc?export=download&id=0B4lrG9aRe-8MaXgzQmthY2lNUFU"

      sudo mkdir -p /scripts && tar -zxvf uimapper.tar.gz -C /scripts

      start uimapper
      start xbmc

      I will ask Brantje to update the install.sh script soon on github, and add a new post on main blog.

      cheers

      mark

  • astaza says:

    thank you mr mark,
    i tried it but dos not good it’s working but not ok
    when i touch the touch not in same place ,there are a padding to top
    i am sorry for my english :)

    thank you

    • admin says:

      Hi,

      Best advice I can give to you is to follow my original tutorial, don’t use the install script just yet.

      1. Set the /boot/config.txt to the screen resolution you want. This will set the resolution in XBMC also.

      2. Follow tutorial, and calibrate screen ( check resolution in ts_calib output).
      You can run ‘sh ts_calib.sh’ as many times as you wish, until you are happy with the values, or accuracy. I recommend using a small fine tip to be accurate.

      3. Install UIMAPPER as described in part 2 of tutorial. This is the new version ans should have better results for resolutions other than 720P.

      4. If you are still not getting accurate behavior, you have two options.
      option I:
      Change manually the etc/pointercal file:

      nano etc/pointercal

      see here for info:
      http://forum.xbian.org/thread-832-post-12468.html#pid12468

      option II:
      Edit touchscreen.py config file:

      nano /scripts/uinput-mapper/configs/touchscreen.py

      Add offset data to equation to tweak position

      Hope it helps, I’ve tried many times in many resolutions and managed to get it to work, I think you will do it eventually if you try.

      Good luck

      Mark

  • astaza says:

    thank you mr mark,
    it’s work good now i will edit font.xml in xbmc to make menu items bigger
    thank you

  • Tirtha says:

    Hey Mark – this is a great walk-through. Thanks for maintaining it and supporting those of us trying this for the first time.

    I have a Lilliput 869 monitor with an 8″ touchscreen. The resolution on this is 800×480, but ts_calibrate uses xres = 720, yres = 480.

    I am seeing bad accuracy towards the edges of the screen. I am not sure, but I suspect it is related to the incorrect resolution at calibration time. I was looking to modify /boot/config.txt, but 800×480 doesn’t seem to be a supported setting.

    Any thoughts on how I can fix the accuracy on this screen?

    Thanks,
    Tirtha

    • admin says:

      Hi Tirtha,

      You could try this…

      Use ‘evtest’ to display the max values of your touchscreen for each axis.

      stop xbmc
      stop uimapper
      evtest

      Then edit the file /scripts/uinput-mapper/configs/touchscreen.py

      nano /scripts/uinput-mapper/configs/touchscreen.py

      Change the max values of the touchscreen parameters in the following locations (approx line 71 in the config section of the code)….

      config = {
      (0, EV_ABS) : {
      ABS_X : {
      'type' : (0, EV_ABS),
      'code' : X_ABS,
      'value' : x_value,
      'prop' : {
      'max' : 2047,
      'min' : 0,
      'flat' : 0,
      'fuzz' : 0
      }

      If that doesn’t work, again in touchscreen.py, you can modify the x, y equations to slightly change the scale and offset value for each axis to fine tune the result, remembering to stop/start xbmc and uimapper to see the changes.

      def transform_x(x):
      x = (x*xscale + xoffset)*xcalib/(scaler) + (xmres - xsres)
      return int(x)

      def transform_y(y):
      y = (y*yscale + yoffset)*ycalib/(scaler) + (ymres - ysres)
      return int(y)

      Hope this helps

      Mark

      • Tirtha says:

        Thanks Mark. I’ll give it a shot tonight and report back.

        • Tirtha says:

          Hi Mark – here is the update. In short, I think it is fixed now. I ran evtest and it looked like the x/y matched the x/y min/max settings in touchscreen.py. Before I started playing with the formulas, I decided I would try to force the screen resolution correctly and re-run the calibration. This is what I did:

          Add these lines to /boot/config.txt to set the resolution:

          #set specific CVT mode
          hdmi_cvt 800 480 60 6 0 0 0

          #set CVT as default
          hdmi_group=2
          hdmi_mode=87

          Then reboot (shutdown -r 0). After the system restarts, stop xbmc and uimapper and re-run calibration:

          sudo stop xbmc
          sudo stop uimapper
          sudo sh ts_calib.sh

          Then reboot (shutdown -r 0). Now in XBMC it seems that the pointer is tracking linearly instead of progressively getting worse towards the edges.

          Thanks again for supporting us and the quick replies.

          Tirtha

  • Karsten says:

    Hi. I would like to thank you guys a lot. I tried the manual installation and it wouldn’t work at all. Not a bit. Now I put on a new imagie and tried out the install.sh. This took just 2 minutes and tadaah …. it works. Thank you heaps!

  • dcallebaut says:

    Hi Mark – none of the above seem to work for me.

    in 720 the x scales seems off, in 1080 the y scale is off and none of the above tips work. I have a 17″ touch.

    Additionally I see uimapper “jumping” around and doing button clicks without touching the screen in the 1080 mode – not sure if related

    After putting several hours into trying changing all sorts of values, re-calibrating 50 times I’m about to give up. :-S

    Any tips would be helpful.

    I posted a video on YouTube showing what I mean

    • admin says:

      Hi David,

      Yes I can see in on youtube, the scale and offsets are not correct.

      There must be a solution above that will work for you. If ‘uimapper’ is running then maybe try editing the scale and offset values directly in /etc/pointercal file, or the /scripts/uinput-mapper/configs/touchscreen.py file.
      If you stop uimapper and xbmc, make changes and then start both again you can see if it changes the result; basically the offset values move the origin +/- back towards top left and the scale values reduce/increase the move size.

      It might help to display the x,y coordiates on xbmc, and compare with the values form evtest. (top left, bottom right)

      Regarding jumping, you can change the ‘nice’ value to ‘-20′ for higher priority, this may improve lag (large number of transformations); it is for a touchscreen so no real need for mouse-dragging.

      Calibration should work though, check /boot/config.txt for screen res. and overscan. Post the output from evtest and ts_calib and I can see. Also info on your TS.

      Hope it helps, you are the guy that helped me get ts_calib to work.

      Mark

      • dcallebaut says:

        Thanks for the tips Mark – I’ll give it another go this weekend and let you know.

        It’s my pleasure helping out, combined efforts are better efforts 😉

        • dcallebaut says:

          Hey Mark,

          Got it to working fine in the end. the solution turned out to be actually very simple.

          First I (re-)started to tweak the pointercal values, but that didn’t change anything. even with values of 0 (zero) for both xoffset and yoffset I had exactly the same behavior (which is abnormal in my opinion). the scales values did have some “effect” but no solution as I was changing them…

          Then I was going over all the replies in this blog and saw a few entries about the hdmi resolution – I though to give it a try. Debugging the XBMC skin confirmed that the resolution is 1280×720 so I forced the hdmi output to be the same by adding this in the /boot/config.txt

          hdmi_cvt=1280 720 60 4
          hdmi_group=2
          hdmi_mode=87

          rebooted.. and guess what? problem solved! In the end the solution turns out to be as simple as logical :-)
          I have no idea if, when using a small touch (< 10inch), the resolution of the hdmi plays a lesser important role but I can confirm that the default resolution was causing my issue.

          Thanks for the help and this great tutorial! 😀

          • admin says:

            That’s great news, thanks for the clarification. I will add a section at the tutorial end showing additional steps to take when troubleshooting.

            (just for reference, if you change pointercal file and no resultant change in pointer behaviour, then uimappper is not being used. It uses the values directly for calculating position)

            Cheers

            Mark

          • dcallebaut says:

            That’s the weird thing here. evtest confirmed that uimapper was running and capturing the touch events. it’s a mystery to me too 😐

  • John says:

    Hi
    Many thanks for this
    My touch is opposite ie left is right and right is left
    Is there a way to solve this

    Regards
    John

    • admin says:

      Hi John,

      If you run ts_clib and generate the file /etc/pointercal, then the axis directions and swap, if necessary, are automatically handled, but only if uimapper is running. Please ‘stop xbmc’ and use evtest to check if the entry ‘uimapper – touchscreen’ event is created in the event list.

      Hope it helps

      cheers,
      mark

      • John says:

        Hi Mark
        Thanks for the reply
        This is the result of evtest
        /dev/input/event0: Microsoft Microsoft Basic Optical Mouse v2.0
        /dev/input/event1: CHICONY HP Basic USB Keyboard
        /dev/input/event2: eGalax Inc.

        So it looks like uimapper is not running

        This the contents of pointercal
        -22991 -265 46838900 -95 16564 -323748 65536 720 480 0

        Regards
        John

        • admin says:

          Hi John,

          Yes, uimapper.conf is not starting the python scripts.
          Are you using Xbian or Raspbmc.

          Check you have the correct event set in uimapper.conf, start uimapper and check evtest again.

          If no joy, then diagnose uimapper by doing the following steps via SSH…

          sudo stop xbmc

          cd /scripts/uinput-mapper

          ./input-read.py /dev/input/event2 -D | ./input-create.py configs/touchscreen.py

          last command is meant to be on one line!

          let me know the result,

          cheers,

          mark

        • John says:

          Hi Mark
          I saw this on the other thread
          #Read screen resolution from tvservice (not framebuffer)
          sres = subprocess.check_output(“/opt/vc/bin/tvservice -s”, shell=True)

          Great news the uimapper now shows up in evtest
          and the axes are correct just the calibration is way off
          I am currently using RCA video (HDMI to VGA still on it’s way)
          Is there a resolution I should be setting in config.txt for this ?
          or anywhere else

          Once again thanks for the software and the great help

          John

          • admin says:

            Hi John,

            good to hear it’s nearly working, I need to update the download tonight. I have not tried on composite output, with overscan so not sure how it will look. I will look into this. In the meantime there is info in thread above detailing how to tweak calib values (offset/scales) to refine the calibration within the /scritps/uinput-mapper/configs/touchscreen.py’ file.

            Again, I’ll check the composite solution later,

            cheers,

            mark

            ——————————–

            UPDATE:

            Hi again John,

            Not forgotten about the issue. Some of the touchscreen.py config were changed to suit the “egalax patch (andrei) applied to xbian.

            It is important to make sure the config.txt screen res is the same one used by ts_calib. I read the current resolution set by xbmc, using ‘tvservice -s’, the mouse returns values between 0,0 & 1280,720. Using these values if I calibrate in 720p, change resolution in xbmc and then stop/start uimapper & xbmc, my calibration works for most resolutions from 480p upwards. I am working on a fix to restart uimapper if screen resolution is changed in xbmc, thus maintaining calibration, to avoid the restart.

            For now, if you can get ts_calib res and config.txt res etc the same, the calib should work, if not try tweaking the equations in touchscreen.py using the scale factors and linear offsets in both x and y equations.

            Be in touch soon with update , hopefully

            cheers,

            mark

  • John says:

    Hi Mark
    Thanks for the update
    The results from tvservice
    state 0x40001 [NTSC 4:3], 720×480 @ 60Hz, interlaced
    config.txt
    arm_freq=800
    gpu_mem=128
    disable_overscan=1
    force_turbo=1
    start_file=start_x.elf
    fixup_file=fixup_x.dat
    framebuffer_width=720
    framebuffer_height=480

    Regards
    John

    • admin says:

      Hi John,

      I/m wondering whether the interlaced resolution is causing the problem. Your config.txt res. and the ts_calib res. are ok, so calib should work. You should also be able the get this resolution in xbmc, albeit interlaced, i need to test this on my system.

      cheers,

      mark

      • admin says:

        Hi John,

        I have used hdmi mode to set 720x480i in config.txt and then calibrated in 720x480i in ts_calib (tvservice giving the same res.) and it works ok….I can also select 720x480i in xbmc and the pointer scale and offsets work fine. I’m sorry if this doesn’t help you, maybe you can change some values manually in the touchscreen.py file or change the pointercal values until it gives a better result. The pointercal values are described in the thread or in the xbian forum.

        Cheers,

        mark

  • freefish says:

    HI Mark,the newest Raspbmc has been added touchscreen support,but I tried the way to support touchscreen like Xbian,It doesn’t succed,Can you have a try with Raspbmc?

  • freefish says:

    I’ve tried again.manualy exit xbmc,then start uimapper,then start xbmc.everything goes to normal.
    It’s seems to be the uimapper can’t start auto.how can run uimapper first on raspbmc?

  • astaza says:

    hello,
    i have update to xbian beta 2, but not work i will install fresh xbian and start agian your installer
    but any tip for the new verison
    thanks

  • astaza says:

    hello mark,
    thank you for rplay
    i update and install it again and all work without any proplems
    but how i can hide mouse cursor ?
    thank you

  • astaza says:

    Hello Mark,
    it’s very bad touch on xbian beta 2
    it’s need to press two times to open any thing also some times not work it’s only make like mouse hover not click

    i download the last image of xbian
    and update it
    and follow your instractions
    and touch not that good like xbian 1.1

    any adive or revert back to xbian 1.1
    thanks

  • Stefan Ambros says:

    Xbian beta 2 EGalaxy with 7″ Touchscreen.
    For all the People they have problems with the right position of the mouse finger if you touch. —-> install all the things step by step by hand and you will not have any problems.

  • Lukas Berger says:

    Hey Mark!
    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.

    • admin says:

      Hi Lukas,
      It’s becoming increasingly difficult to provide support due to time/work commitments.

      It did work with Raspbmc, even with it’s in-built support for touchscreens.

      Install using the guide, not script, and make sure using SSH (putty) that when XBMC is running that uimapper is started by using the ‘ps -aux’ command and looking for the relevant processes.

      It might be that it is necessary to alter the uimapper.conf file to ensure it grabs the device before xbmc does.

      hope this helps (from memory, I have nothing to test anymore…)

      cheers
      mark

  • pego says:

    Hello,

    Thank you for your excellent tutorial. Unfortunately I sill have some problems with my x- and y axes. THEY ARE INVERTED!

    If I press the Top Left Corner the cursor will be display lower right and vice versa.

    I have the following event sources:

    lrwxrwxrwx 1 root root 9 Jan 22 21:04 usb-eGalax_Inc._Touch-event-mouse -> ../event1
    lrwxrwxrwx 1 root root 6 Jan 22 21:04 usb-eGalax_Inc._Touch-mouse -> ../js0

    ts_calibrate prints the following output:

    xres = 1280, yres = 720
    Took 4 samples...
    Top left : X = 90 Y = 214
    Took 21 samples...
    Top right : X = 1946 Y = 176
    Took 12 samples...
    Bot right : X = 1973 Y = 1898
    Took 9 samples...
    Bot left : X = 85 Y = 1930
    Took 8 samples...
    Center : X = 1028 Y = 1054
    -1.331299 0.630218 -0.004044
    -27.150391 0.006737 0.360630
    Calibration constants: -87248 41301 -265 -1779328 441 23634 65536

    And /etc/pointercal holds the following values:

    41301 -265 -87248 441 23634 -1779328 65536 1280 720 0

    Any ideas how I can fix this?

    • pego says:

      oh…for calibration I used event1 ! :)

      • admin says:

        Hi Pego,

        I think you need to check whether the uimapper is working and grabbing the device, drop out of xbmc and use evtest to check. The pointercal is calculated automatically and from the values displayed in the ts-calib event it shows that the minimum x,y are top left, this is correct.

        hope it helps

        mark

        • pego says:

          thx for your reply. I did a new calibration and instead of pressing the top left corner I pressed the lower right one, and so on. LOL

          now everything is working perfectly :) THUMBS UP FOR YOUR WORK

  • Cameron says:

    Hey there,
    great guide.
    Having a slight issue, I used BrBranjte’s script and that worked fine for me, but my x and y axis’ are both inverted despite recalibration and trying to calibrate with inversion in mind.
    Any idea as to what might be causing this?

    (Using fully updated RASBMC, and the usual 7″ touch screen)

  • Patrick says:

    I have everything configured, but the touch only works on part of the screen. It was the bottom left corner, but I switched the touchscreen output cable around and now it is the upper left corner. I can use the cursor a little bit, but it is across the screen from my finger press. I have tried the suggestions with running evtest and it detects input on every part of the screen. I go through the calibration just fine and am able to touch all of the points. uimapper is running. I modified the config file so that it starts on start-up.

    I tried the manual installation with the same result.
    I will post my calibration output.
    Please follow the instructions on the display…
    xres = 720, yres = 576
    Took 1 samples…
    Top left : X = 309 Y = 1885
    Took 1 samples…
    Top right : X = 280 Y = 186
    Took 3 samples…
    Bot right : X = 1757 Y = 183
    Took 1 samples…
    Bot left : X = 1751 Y = 1861
    Took 1 samples…
    Center : X = 1025 Y = 1026
    740.951294 -0.003364 -0.367151
    -43.722839 0.326072 -0.002242
    Calibration constants: 48558984 -220 -24061 -2865420 21369 -146 65536
    uimapper start/running, process 3189
    xbmc start/running, process 3258
    xbian@xbian ~ $ Please follow the instructions on the display…
    Calibration constants: 48558984 -220 -24061 -2865420 21369 -146 65536
    uimapper start/running, process 3189
    xbmc start/running, process 3258

    I know you are busy, but any help is appreciated. If I find an answer I will post back.

  • Mawi says:

    I´m a complete noob on linux – tried to get my egalax touch to work but hanging on startig the uimapper.service – getting the message – no such file or directory – may could you please help me out?

  • admin says:

    I’m sorry, I have no time left to work on this site despite the fact that it gets viewed daily , but i cannot support it anymore. There is enough info within for any “novice” (like i was/am) to get into linux/python/coding an enjoy!! good luck!

  • Paul Hart says:

    Hey I’m a complete noob at Linux and really need some help with the calibration I noticed that free fish was having similar problems with his the only difference in mine is that the x axis is inverted and the y axis is above where I touch and if I go for the bottom of the screen to the top the pointer gets farther away from my finger but I’m running the latest version of xbian and I have the egalax at070tn92 touch screen which is 720 bye 576 or at least as far as tscalib think any help you can give me would be very much appreciated I’m literally out of ideas and have tried apt get evtest and it says “not found in library” so yeah I can use any help you could offer thanks

  • Paul Kengeter says:

    After finishing the calibration, it seem to work. Just when touch top left corner the pointer is at the bottom right corner. how can I invert the touch?

Leave a Reply to themad06 Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre prompt="" escaped="" class="" title="" data-url=""> <span class="" title="" data-url="">