Linux - fix tslib integration

  Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
thebestofall007 Offline
Junior Member
Posts: 47
Joined: May 2012
Reputation: 0
Post: #46
(2015-07-24 19:01)ultraman Wrote:  
Code:
git clone https://github.com/vpeter4/tslib -b ts_uinput_touch ts_uinput_touch
cd ts_uinput_touch
autoreconf --verbose --force --install
./configure
make
make install

and you should get this files
Code:
/usr/local/bin/ts_harvest
/usr/local/bin/ts_test
/usr/local/bin/ts_print_raw
/usr/local/bin/ts_calibrate
/usr/local/bin/ts_uinput_touch
/usr/local/bin/ts_print
/usr/local/etc
/usr/local/etc/ts.conf
/usr/local/lib
/usr/local/lib/libts.la
/usr/local/lib/pkgconfig
/usr/local/lib/pkgconfig/tslib.pc
/usr/local/lib/pkgconfig/tslib-1.0.pc
/usr/local/lib/ts
/usr/local/lib/ts/h3600.la
/usr/local/lib/ts/input.so
....
/usr/local/lib/ts/st1232.so
/usr/local/lib/libts-1.0.so.0.0.0
/usr/local/lib/libts.so
/usr/local/lib/libts-1.0.so.0
/usr/local/include
/usr/local/include/tslib.h

Okay, the build went well and I got the files you listed, but now how do I edit the environment variables to point to the proper directories and files (if that's what needs to be done)? I used the same setup as per post 13 and it complains about that missing "libts-1.0.so.0", yet I see it in /usr/local/lib when I run ls /usr/local/lib
(This post was last modified: 2015-07-24 20:47 by thebestofall007.)
find quote
ultraman Offline
Member
Posts: 80
Joined: Mar 2012
Reputation: 2
Post: #47
/usr/local/lib is not in dynamic linker search path.
run configure with prefix
Code:
./configure --prefix=/usr
(This post was last modified: 2015-07-24 21:04 by ultraman.)
find quote
thebestofall007 Offline
Junior Member
Posts: 47
Joined: May 2012
Reputation: 0
Post: #48
(2015-07-24 21:03)ultraman Wrote:  /usr/local/lib is not in dynamic linker search path.
run configure with prefix
Code:
./configure --prefix=/usr

Did that, but now when I run
Code:
ts_uinput_touch -d
it complains
Code:
Couldn't open tslib config file: no such file or directory
ts_config: no such file or directory
I really hate to be bugging you like this, man. This would be great to be made into a tutorial.
find quote
ultraman Offline
Member
Posts: 80
Joined: Mar 2012
Reputation: 2
Post: #49
(2015-07-24 23:13)thebestofall007 Wrote:  
Code:
Couldn't open tslib config file: no such file or directory
ts_config: no such file or directory
Because there is no environment variable TSLIB_CONFFILE set. Or it points to nonexistent file.

Don't forget: ts_uinput_touch program is using tslib library. And some things must be set before calling this program. To know which config file to open.


(2015-07-24 23:13)thebestofall007 Wrote:  would be great to be made into a tutorial.
Sure. But I'm using special system and not general purpose distribution. Maybe you can write when you succeed Wink
find quote
thebestofall007 Offline
Junior Member
Posts: 47
Joined: May 2012
Reputation: 0
Post: #50
Slowly getting there...

used the ./config --prefix=/usr option and it worked w/o errors, as well as on make and make install as well.
One question: when ts_uinput_touch complains "ts_config: no such file or directory", which file is it looking for? What is the name of the file in question and what directory is it in? What directory would the tslib library be?

the TSLIB_CONFFILE is set at /usr/etc/ts.conf and that file exists.
find quote
ultraman Offline
Member
Posts: 80
Joined: Mar 2012
Reputation: 2
Post: #51
Seems TSLIB_CONFFILE is not exported correctly and ts_uinput_touch doesn't see the variable.

export TSLIB_CONFFILE=/etc/ts.conf
# and other exports
ts_uinput_touch

Like I wrote ts_uinput_touch program is using tslib library and some things must be done as required.
http://www.armadeus.com/wiki/index.php?title=Tslib

And I think you have some mixup between my branch and tslib you installed. Because there is no error
Couldn't open tslib config file: no such file or directory
only
Couldnt open tslib config file: no such file or directory

If you would come to IRC (#openelec) it would be easier to explain.

Easy solution to this would be to make one bash script with exports and calling program at the end. And then only calling this script.
(This post was last modified: 2015-07-29 11:45 by ultraman.)
find quote
wsnipex Offline
Team-Kodi
Posts: 6,307
Joined: Jun 2011
Reputation: 162
Post: #52
(2015-07-24 21:03)ultraman Wrote:  /usr/local/lib is not in dynamic linker search path.
run configure with prefix
Code:
./configure --prefix=/usr

/usr/local/lib IS in the dynamic linker search path on every sane linux distro.
find quote
thebestofall007 Offline
Junior Member
Posts: 47
Joined: May 2012
Reputation: 0
Post: #53
I started over with a fresh osmc except where my touchscreen drivers were installed. I didn't install any other tslib libraries.

Some findings:
first:
Quote:Easy solution to this would be to make one bash script with exports and calling program at the end. And then only calling this script.
I did that with the following contents:

Code:
#!/bin/bash

export LD_LIBRARY_PATH=/usr/local/lib
export TSLIB_CONSOLEDEVICE=none
export TSLIB_FBDEVICE=/dev/fb0
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_uinput_touch -d

and the variables were all right. The first thing I had to do (and IMO the source of my grief!) was edit the /usr/local/etc/ts.conf file and uncomment the first line that says "module_raw input". Then I had to run ts_calibrate (with the above variables) to set up my /etc/pointercal

second: I run the script, and it appears to work. I get this time around, which looks promising:

Code:
using fb device /dev/fb0
resolution: 800x480
using touch device /dev/input/event0
Short tap time: 300 msec
Right tap time: 1.0 sec
daemonizing

Is this what we're looking for?

third: When I switch back to kodi, the touch is the same and doesn't work.

That leaves me with a question: if this is to be run before kodi starts (was that why the touch didn't work?), how do I start the script in the boot sequence before kodi starts?
(This post was last modified: 2015-07-31 05:40 by thebestofall007.)
find quote
ultraman Offline
Member
Posts: 80
Joined: Mar 2012
Reputation: 2
Post: #54
You can read this
http://openelec.tv/forum/20-development-...les#143795
and this
http://openelec.tv/forum/67-display/7759...with-tslib
to get some clues. If you calibrated successfully with ts_calibrate then you should also run successfully ts_test program. If this program doesn't work well, then something in ts.conf file is wrong.
When ts_test works also kodi should work.

Script with exports and ts_uinput_touch MUST run before Kodi starts. How to do that in osmc I don't know. Look how uinput mapper is started.
find quote
thebestofall007 Offline
Junior Member
Posts: 47
Joined: May 2012
Reputation: 0
Post: #55
(2015-07-31 11:29)ultraman Wrote:  You can read this
http://openelec.tv/forum/20-development-...les#143795
and this
http://openelec.tv/forum/67-display/7759...with-tslib
to get some clues. If you calibrated successfully with ts_calibrate then you should also run successfully ts_test program. If this program doesn't work well, then something in ts.conf file is wrong.
When ts_test works also kodi should work.

Script with exports and ts_uinput_touch MUST run before Kodi starts. How to do that in osmc I don't know. Look how uinput mapper is started.

Ok, gotcha on the program starting before kodi starts, and that's the next order on the docket. I was successfully able to run both ts_test and ts_calibrate (the ts_test program was actually fun, drawing and all). I think I'm going to write a tutorial on how to set your program up under osmc once I set it up. Thank you much for your guidance on this ultraman!
find quote
thebestofall007 Offline
Junior Member
Posts: 47
Joined: May 2012
Reputation: 0
Post: #56
I was able to make an init.d startup script with the following contents:

Code:
#! /bin/sh

### BEGIN INIT INFO
# Provides:          ts_uinput_touch
# Short-Description: daemon that enables touchscreen for kodi media player
# Required-Start:    $remote_fs $local_fs $syslog
# Required-Stop:     $remote_fs $local_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
### END INIT INFO

case "$1" in
  start)
        echo -n "Starting ts_uinput_touch:"
        export LD_LIBRARY_PATH=/usr/local/lib
        export TSLIB_CONSOLEDEVICE=none
        export TSLIB_FBDEVICE=/dev/fb0
        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_uinput_touch -d
        
        echo "OK"
        ;;
  stop)
        echo -n "Stopping ts_uinput_touch:"
        killall ts_uinput_touch
        echo "OK"
        ;;
  restart|reload)
        ;;
  *)
        echo "Usage: $0 {start|stop|restart}"
        exit 1
esac

exit $?

The script executed without error on boot and the ts_uinput_touch -d command executed, however, the touch still isn't working.
What went wrong? I am a noob at making init.d scripts, and is there anything I need to edit in this, or in any other file like the ts.conf? Do I have to apply any patches or have any addons to kodi as well?
(This post was last modified: 2015-08-02 06:25 by thebestofall007.)
find quote
thebestofall007 Offline
Junior Member
Posts: 47
Joined: May 2012
Reputation: 0
Post: #57
I did dmesg | tail and it shows to have a virtual device made at /devices/virtual/input/input3, and evtest on the entry shows output when the screen is touched. Something tells me I my need to patch kodi, but I'm not sure how to go about it in osmc.
(This post was last modified: 2015-08-07 06:37 by thebestofall007.)
find quote
ultraman Offline
Member
Posts: 80
Joined: Mar 2012
Reputation: 2
Post: #58
(2015-08-07 06:18)thebestofall007 Wrote:  I did dmesg | tail and it shows to have a virtual device made at /devices/virtual/input/input3, and evtest on the entry shows output when the screen is touched. Something tells me I my need to patch kodi
Yes, when you run ts_uinput_touch daemon new virtual input device is created. And that's the main point: hide touchscreen behind it. That's why you don't need or have to patch kodi to get touch working.

But you also wrote you see evtest program showing some data. And this is wrong. All input devices are handled by kodi and you can't run kodi and having evtest show something. This means that kodi didn't pick up this input device probably because it was started to early. Like I wrote first ts_uinput_touch daemon must be started and THEN Kodi. Only this way will works. You can see in kodi debug log which input devices it handles.
If you restart kodi and still doesn't work then it is something wrong in /usr/local/etc/ts.conf.
When you run evtest you must see coordinates around 0,0 when you are on top left part of the screen. You see max_x,0 when you are on top right and so on.

I saw you were searching me at IRC but I was already afk.
find quote
thebestofall007 Offline
Junior Member
Posts: 47
Joined: May 2012
Reputation: 0
Post: #59
Okay, Gotcha on the evtest.

here is my ts.conf:
Code:
# Uncomment if you wish to use the linux input layer event interface
module_raw input

# Uncomment if you're using a Sharp Zaurus SL-5500/SL-5000d
# module_raw collie

# Uncomment if you're using a Sharp Zaurus SL-C700/C750/C760/C860
# module_raw corgi

# Uncomment if you're using a device with a UCB1200/1300/1400 TS interface
# module_raw ucb1x00

# Uncomment if you're using an HP iPaq h3600 or similar
# module_raw h3600

# Uncomment if you're using a Hitachi Webpad
# module_raw mk712

# Uncomment if you're using an IBM Arctic II
# module_raw arctic2

module pthres pmin=1
module variance delta=30
module dejitter delta=100
module linear

module_raw input grab_events=1

# or for eGalax touchscreen
# module_raw galax grab_events=1
# or use swap_xy to swap axes
# module linear swap_xy=1



Unfortunately I accidentally broke my lcd screen when I was on the irc, and now I have to order another one and I'll be down until I receive the new one sadly. Sad

I'll let you know when I'm back.
find quote
thebestofall007 Offline
Junior Member
Posts: 47
Joined: May 2012
Reputation: 0
Post: #60
(2015-08-07 11:13)thebestofall007 Wrote:  Okay, Gotcha on the evtest.

here is my ts.conf:
Code:
# Uncomment if you wish to use the linux input layer event interface
module_raw input

# Uncomment if you're using a Sharp Zaurus SL-5500/SL-5000d
# module_raw collie

# Uncomment if you're using a Sharp Zaurus SL-C700/C750/C760/C860
# module_raw corgi

# Uncomment if you're using a device with a UCB1200/1300/1400 TS interface
# module_raw ucb1x00

# Uncomment if you're using an HP iPaq h3600 or similar
# module_raw h3600

# Uncomment if you're using a Hitachi Webpad
# module_raw mk712

# Uncomment if you're using an IBM Arctic II
# module_raw arctic2

module pthres pmin=1
module variance delta=30
module dejitter delta=100
module linear

module_raw input grab_events=1

# or for eGalax touchscreen
# module_raw galax grab_events=1
# or use swap_xy to swap axes
# module linear swap_xy=1



Unfortunately I accidentally broke my lcd screen when I was on the irc, and now I have to order another one and I'll be down until I receive the new one sadly. Sad

I'll let you know when I'm back.

Okay, I got my screen finally. I did a little digging and found that ts_uinput_touch is started by a service script and not an init.d script. The code is included here:

Code:
[Unit]
Description=Touchscreen support daemon
Before=kodi.service
After=graphical.target

[Service]
Type=oneshot
Environment=HOME=/storage
ExecStartPre=-/bin/sh -c "exec /bin/sh /usr/bin/ts_calibrate.sh service"
ExecStart=-/bin/sh -c ". /usr/bin/ts_env.sh; exec ts_uinput_touch -d"
RemainAfterExit=yes

[Install]
WantedBy=kodi.service

I am in the process of adapting it to work with osmc, as this one is for openelec.

Here's what I've done so far with the code:

Code:
[Unit]
Description=Touchscreen support daemon
Before=mediacenter.service
After=graphical.target

[Service]
Type=oneshot
Environment=/usr/local/lib
ExecStartPre=-/bin/sh -c "exec /bin/sh /usr/local/bin/ts_calibrate"
ExecStart=-/bin/sh -c "exec ts_uinput_touch -d"
RemainAfterExit=yes

[Install]
WantedBy=mediacenter.service

Is there anything missing? What is the purpose for the "ts_env.sh" file? What would I have for My setup doesn't have it or it hasn't been created yet.
(This post was last modified: 2015-08-21 04:04 by thebestofall007.)
find quote
Post Reply