Linux - fix tslib integration

  Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
dcallebaut Offline
Junior Member
Posts: 38
Joined: Jun 2012
Reputation: 0
Post: #1
As seen in many threads there is a long lasting issue with touchscreens. Even when working perfectly in any X window manager and through TSLIB is seems to remain an issue when trying to use on an standalone running xbmc.

Several examples of threads discussing this:

http://forum.xbmc.org/showthread.php?tid=129299
http://forum.xbmc.org/showthread.php?tid=141358
http://forum.xbmc.org/showthread.php?tid=89536
http://forum.xbmc.org/showthread.php?tid=84008
And there are several topics on plenty of other forums.

My own detailed description on the issue:
http://forum.xbmc.org/showthread.php?tid=162538


I truly believe this to be a core-xbmc issue as I have been trying for a couple of weeks already on several linux flavours (Debian, Ubuntu, Arch, Linux Mint, Raspbian, OpenELEC, etc...) and several custom build solutions and tutorials out there all with the same result.

So, if this could please be considered I'm sure a lot of touchscreen users out there will greatly appreciate.

PS: although I'm not a developer, please do reach out to me if I can help in any way.
find quote
Ned Scott Offline
Banned
Posts: 31,461
Joined: Jan 2011
Location: Arizona, USA
Post: #2
All in good time. Android touch screen support is still being tweaked, and Windows 7/8 touch screen support finally got fixed in the most recently nightly builds (wiki) (and even then, I think it's the first time Windows got multitouch).
find quote
dcallebaut Offline
Junior Member
Posts: 38
Joined: Jun 2012
Reputation: 0
Post: #3
That's great to hear it is on the radar, even if not immediately.

Thanks for the feedback, Ned.

Let me know if I can help in any way!
find quote
ultraman Offline
Member
Posts: 80
Joined: Mar 2012
Reputation: 2
Post: #4
I was also looking into better touchscreen support. Was using some Kodi patches for this but I'm not very satisfied. So I was start to look how whole thing actually works (like how touchscreen gets the values and send input events). I noticed that there are solutions using python script uinput-mapper. But I read it can slow down the system.

So I was looking further. I tried tslib and it's calibration and did some tests. I was very satisfied with the result. But how to add support into Kodi... Then I got an idea: why not using similar approach as used in uinput-mapper.
So I created one small application which is running as a daemon. On one side it gets events from touchscreen using tslib library. On the other end it creates one new virtual device using uinput kernel module that allows to handle the input subsystem from user land. Inside application I'm just receiving data from tslib and send correct events to uinput. Whole thing is very simple and also works very well. It behaves in a similar way than touchpad. Short tap sends button press event and long slide sends only xy coordinates.

I'm writing this post to get some feedback about this approach. And to see if this idea is actually worth something. For me it is at this time very much.

Update: I'm also working on a Kodi addon for calibration. Calibration is done in daemon itself and addon just shows five cross points on screen to touch.
Update: I also add waveshare screen support.
(This post was last modified: 2015-08-31 10:43 by ultraman.)
find quote
dcallebaut Offline
Junior Member
Posts: 38
Joined: Jun 2012
Reputation: 0
Post: #5
Hey Ultraman,

I was thrilled reading your post. I'm an absolutely noob when it comes to developing modules and daemons. So I was delighted to read that you would like to give it a go. If you need a beta-tester or anything, please do let me know. Would be happy to help.

Quote:I tried tslib and it's calibration and did some tests. I was very satisfied with the result. But how to add support into Kodi...

I've had some experience with tslib myself and I was happy to see that my touchscreen (which is a 17" eGalax USB screen) worked great with the eGalax drivers combined with tslib. The only thing that I was never able to work properly is the integration of that in Kodi (Xbmc). Again, I'm not able to code something myself...

Quote:And to see if this idea is actually worth something. For me it is at this time very much.

I want to support you in any way possible :-) so if any help needed in terms of testing, just give me a yell.

PS: I'm using that touchscreen with a Raspberry Pi (Model B) and currently a (old) Xbian that is using the uimapper "trick". I works but it could be improved as touch reaction is limited (no multitouch) and sometimes slow
(This post was last modified: 2015-06-23 10:30 by dcallebaut.)
find quote
ultraman Offline
Member
Posts: 80
Joined: Mar 2012
Reputation: 2
Post: #6
(2015-06-23 10:27)dcallebaut Wrote:  It works but it could be improved as touch reaction is limited (no multitouch) and sometimes slow
I don't think Kodi can be used with multitouch.
find quote
dcallebaut Offline
Junior Member
Posts: 38
Joined: Jun 2012
Reputation: 0
Post: #7
[/quote]I don't think Kodi can be used with multitouch.
[/quote]
find quote
dcallebaut Offline
Junior Member
Posts: 38
Joined: Jun 2012
Reputation: 0
Post: #8
I wanted to say: no multitouch is no showstopper for me. But the current "patchy" setup I'm using does not work "fluently"..so any improvement is welcome Blush
find quote
ultraman Offline
Member
Posts: 80
Joined: Mar 2012
Reputation: 2
Post: #9
I'm preparing OpenELEC image for Udoo system with tslib any my new daemon. Also one special image for one heavy user. If all goes well I will commit whole changes and everyone can use them. For now the daemon is very simple but doing the job it suppose to.
find quote
ultraman Offline
Member
Posts: 80
Joined: Mar 2012
Reputation: 2
Post: #10
My work is currently here: https://github.com/vpeter4/tslib/commit/...28d9769bfe
If anyone wants to use it be my guest. And let me know the results.

Wondering where should post the news to get better attention...
(This post was last modified: 2015-06-30 17:35 by ultraman.)
find quote
emka1981 Offline
Junior Member
Posts: 8
Joined: Jul 2015
Reputation: 0
Post: #11
Hello, i really like your work. I am running on raspbian wheezy with kodi 14.2 and now compiled your source code

- git clone https://github.com/vpeter4/tslib
- cd tslib
- ./autogen.sh
- ./configure
- make && make install

it worket perfect, i can calibrate my screen with ts_calibrate i have tested it with ts_test and its perfect. But in kodi it is still the same, the mouse is anywhere else. How can i start the daemon ts_uinput_touch ? I don't have the binary. Where can i find it ? How can i use it ?

i am really looking foreward that this calibration problem can come to an end ....

regards Martin
find quote
ultraman Offline
Member
Posts: 80
Joined: Mar 2012
Reputation: 2
Post: #12
You must clone ts_uinput_touch branch
Code:
git clone https://github.com/vpeter4/tslib -b ts_uinput_touch

Then you will get my new binary. Also there is a folder kodi-addon which holds addon for calibration.
Whole thing will not run magically. You need to configure tslib first.

For this you need to edit file /etc/ts.conf with content like this
Code:
module_raw input grab_events=1
# or for eGalax touchscreen
#module_raw galax grab_events=1
module pthres pmin=1
module variance delta=30
module dejitter delta=100
module linear
# or use swap_xy to swap axes
#module linear swap_xy=1

You also need environment variables set up. For example in /root/.bashrc add these lines
Code:
export TSLIB_TSDEVICE=/dev/input/event0
export TSLIB_PLUGINDIR=/usr/lib/ts
export TSLIB_CONSOLEDEVICE=none
export TSLIB_FBDEVICE=/dev/fb0
export TSLIB_CALIBFILE=/etc/ts/pointercal
export TSLIB_CONFFILE=/etc/ts/ts.conf

To get TSLIB_TSDEVICE event# use program evtest (must be separately installed). On left you will get event number (whole path) and on right is the name of your display. If you have attached keyboard remove it and reboot your system. After the system is up attach it back. This way touchscreen will have always same event number.

The other (probably better option) is to use device by-id. Run command
Code:
ls -l /dev/input/by-id
and you will see something like
Code:
usb-eGalax_Inc._USB_TouchController-event-mouse -> ../event6

Then set TSLIB_TSDEVICE as
Code:
/dev/input/by-id/usb-eGalax_Inc._USB_TouchController-event-mouse

Then you need to run ts_uinput_touch daemon before Kodi is started
Code:
ts_uinput_touch -d

This depends on your distro (maybe adding to /etc/rc.local would work). After reboot ts_uinput_touch should be running and Kodi should see new input device. Then calibrate the screen with kodi addon or do it manually from console with ts_calibrate program (stop Kodi and ts_uinput_touch first).

If things would not work come to #openelec on IRC and I will explain more.

Update: I think it would be easier to set those environment variables export (TSLIB_TSDEVICE, ..) before calling ts_uinput_touch. I will add support for loading file from daemon itself in a day or two.
(This post was last modified: 2015-07-20 09:14 by ultraman.)
find quote
zag Offline
Retired Team-Kodi Member
Posts: 4,006
Joined: Oct 2007
Reputation: 75
Location: UK
Post: #13
Moved to the development forum

@ultraman, if you create a PR for Kodi, it will get more attention
(This post was last modified: 2015-07-03 11:58 by zag.)
find quote
ultraman Offline
Member
Posts: 80
Joined: Mar 2012
Reputation: 2
Post: #14
@zag: This is not Kodi thing. It is separate program which creates new virtual device which Kodi understand.
Sadly I don't understand how input system really works in Kodi to integrate tslib directly. Maybe on one rainy day I will check the code again.
find quote
zag Offline
Retired Team-Kodi Member
Posts: 4,006
Joined: Oct 2007
Reputation: 75
Location: UK
Post: #15
OK thanks, I'll leave it in the development forum as its still some nice code that others could use Wink
(This post was last modified: 2015-07-03 12:19 by zag.)
find quote
Post Reply