1

I have a arm based board with embedded linux on it and I believe it has a FT5x06 touch screen controller but seems like tslib has some problems with multitouch capacitive touch screen controllers. I cross compiled tslib with arm-linux-gcc4.5.1 and when after copying necessary files and setting necassary environmental variables for tslib on the target when I ran ts_calibrate a window shows up and it says that:

tslib: Selected device is not a touchscreen (must support ABS_X and ABS_Y events)

And it doesn't accept my touches. Now I think somehow I'm supposed to get tslib to work with the controller as a single touch device but I'm not sure how to do that or which file to change. Do I have to edit driver file in kernel and rebuild it too?

Do you have any ideas?

I want to use tslib as an input for my Qt4 program.

mostafanfs
  • 65
  • 3
  • 13
  • Related: [Tslib not creating device](http://stackoverflow.com/questions/8397680/tslib-not-creating-device), [What is the dataflow of using touchscreen with tslib](http://stackoverflow.com/questions/14351399/what-is-the-dataflow-of-using-touchscreen-with-tslib), [etc...](http://stackoverflow.com/search?q=tslib) – artless noise Oct 14 '14 at 17:12
  • What is the environment value `TSLIB_TSDEVICE`? Ie, `ls -l ${TSLIB_TSDEVICE}`. There are [various programs](http://cgit.freedesktop.org/~whot/evtest/tree/evtest.c) to debug the FT2x06 driver, if it exists; although you should have source? – artless noise Oct 14 '14 at 19:51

2 Answers2

2

Tslib will require the setup of several files and/or environment variables to work out of the box. Here is a sample of some environment variables,

 TSLIB_CONSOLEDEVICE=none
 TSLIB_FBDEVICE=/dev/fb0
 TSLIB_TSDEVICE=/dev/input/touch
 TSLIB_CALIBFILE=/etc/pointercal
 TSLIB_CONFFILE=/etc/ts.conf

Many variables are not needed to run Qt with tslib. However, you will need the TSLIB_TSDEVICE, TSLIB_CALIBFILE, and TSLIB_CONFFILE to use with Qt. The binaries ts_calibrate will use the TSLIB_FBDEVICE device to display some text. This will then write a configuration to the TSLIB_CALIBFILE.

To determine the correct TSLIB_TSDEVICE to use, the files /sys/class/input/input*/name can be examined. The name should be something like FT5202 Touchscreen. I use this information at boot time to soft link /dev/input/inputX to /dev/input/touch in the example above. The inputX file may change as other input drivers are plugged into a system, such as a USB mouse, etc. These file locations may depend on the type of udev or mdev you use for the /dev directory population in user space.

The ts.conf file is a list of modules to load. Here is an example for the 'Focal Tech' device,

module_raw input
module linear

Tslib is structured with several modules (shared libraries) which are loaded dynamically at run time. Typically, these modules need to be loaded to /usr/lib/ts and your kernel and filesystem (libc) need to support shared libraries. Specifically, the linear module will use the output of the ts_calibrate program to map touch co-ordinates to screen co-ordinates. This was much more useful with resistive touch technology where x and y parameters may inter-mix, including sheering, etc.

Note: it is possible to avoid this calibration step, which is highly desirable if you are manufacturing large quantities.

The numbers in the /etc/pointercal are read into an array a[0] -> a[7]. The formula is like this,

x' = (a2 + a0 *x + a1 * y) / a6;
y' = (a5 + a3 *x + a4 * y) / a6;

For the capacitive case, there is no sheer. Moreover, the values for the FocalTech devices seem to be restricted so that screen position (0,0) is touch position (0,0) and all the devices give the same maximum (x,y) values. So the equations reduce to,

x' = (a1 * x) / a6;
y' = (a4 * y) / a6;

So the only purpose of the pointercal file is to map touch to screen co-ordinates AND the same for each device. So you can manual hex-edit a pointercal file when you back solve the equations for the maximum screen positions. You can get this information via the ts_print_raw binary.

Finally, the Qt Mouse Calibration class can be used to completely avoid tslib. You only need code with the fixed three constants that will transform the co-ordinates. You avoid the tslib package entirely.

artless noise
  • 21,212
  • 6
  • 68
  • 105
  • `a[7]` is used as a pressure for devices that support it. Qt4.8 can not support multi-touch features in devices like the FT5x06. – artless noise Oct 14 '14 at 17:09
  • This answer assumes you have a working driver. The touch driver is just an i2c interface and the protocol on the i2c needs to be decoded to provide the *linux input* system co-ordinates so that it looks like a *mouse device*. I think that **Focal Tech** supplies a driver. – artless noise Oct 14 '14 at 17:14
  • Well that was a pretty great answer. Actually the problem was with some variables specially TSLIB_TSDEVICE. But thank you for explaining the way that tslib works. Also I liked the Qt Mouse Calibration class idea. – mostafanfs Oct 17 '14 at 15:50
  • Hi @artlessnoise, I have same problem . I check all of tslib config on my nanopc_t2 friendlyARM, but my toch device not work. I found my device is /dev/input/event2 (I test it with `cat` command and it works).when I run `#ts_calibrate` it shows me this error `root@NanoPC-T2:~# ts_calibrate TouchDevice: /dev/input/event1 xres = 1024, yres = 600 tslib: Selected device is not a touchscreen (must support ABS_X and ABS_Y events) `and it does not work,BUT touch is works for default app on my device . – H.Ghassami May 18 '17 at 05:08
  • @H.Ghassami Use `export TSLIB_TSDEVICE=/dev/input/event2` to tell *tslib* to use *event2*. – artless noise May 18 '17 at 12:33
  • @artlessnoise, thanks to reply, it solved with `export TSLIB_CONFFILE=/etc/ts-mt.conf`, ts-mt is multi touch configure file for capacitive touch – H.Ghassami May 20 '17 at 05:05
0

Your chip's driver simply uses ABS_MT_POSITION_X/Y event codes only. As of tslib 1.3, this is supported and tslib should work without problems. As of now, there is tslib-1.3-rc3 which should be safe to use. There won't be many changes until tslib-1.3 is released, see tslib's project page.

merge
  • 36
  • 3