![logo](website/logo.svg)
[![Coverity Scan Build Status](https://scan.coverity.com/projects/11027/badge.svg)](https://scan.coverity.com/projects/tslib)
[![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/libts/tslib.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/libts/tslib/context:cpp)
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/752/badge)](https://bestpractices.coreinfrastructure.org/projects/752)
# C library for filtering touchscreen events
tslib consists of the library _libts_ and tools that help you _calibrate_ and
_use it_ in your environment.
## contact
If you have problems, questions, ideas or suggestions, please contact us by
writing an email to [tslib@lists.infradead.org](mailto:tslib@lists.infradead.org),
which is [our mailing list](http://lists.infradead.org/mailman/listinfo/tslib).
## website
Visit the [tslib website](http://tslib.org) for an overview of the project.
## table of contents
* [setup and configure tslib](#setup-and-configure-tslib)
* [filter modules](#filter-modules)
* [the libts library](#the-libts-library)
* [building tslib](#building-tslib)
* [hardware support](#touchscreen-hardware-support)
* [contribute](#contributors)
## setup and configure tslib
### install tslib
tslib runs on various hardware architectures and operating systems, including GNU/Linux,
FreeBSD or Android/Linux. See [building tslib](#building-tslib) for details.
Apart from building the latest tarball release, running
`./configure`, `make` and `make install`, tslib is available from distributors like
[Arch Linux](https://www.archlinux.org/packages/?q=tslib) / [Arch Linux ARM](https://archlinuxarm.org/packages/aarch64/tslib),
[Buildroot](https://buildroot.org/),
[Debian](https://tracker.debian.org/pkg/tslib) / [Ubuntu](https://launchpad.net/ubuntu/+source/tslib),
[Fedora](https://apps.fedoraproject.org/packages/tslib/) or
[OpenSUSE](https://software.opensuse.org/package/tslib)
and their package management.
### configure tslib
This is just an example `/etc/ts.conf` file. Touch samples flow from top to
bottom. Each line specifies one module and its parameters. Modules are
processed in order. Use _one_ module_raw on top, that accesses your device,
followed by any combination of filter modules.
module_raw input
module median depth=3
module dejitter delta=100
module linear
see the [section below](#filter-modules) for available filters and their
parameters. On Linux, your first commented-in line should always be
`module_raw input` which offers one optional parameter: `grab_events=1`
if you want it to execute EVIOCGRAB on the device.
With this configuration file, we end up with the following data flow
through the library:
driver --> raw read --> median --> dejitter --> linear --> application (using ts_read_mt())
module module module module
### calibrate the touch screen
Calibration is done by the `linear` plugin, which uses its own config file
`/etc/pointercal`. Don't edit this file manually. It is created by the
[`ts_calibrate`](https://manpages.debian.org/unstable/libts0/ts_calibrate.1.en.html) program:
# ts_calibrate
The calibration procedure simply requires you to touch the cross on screen,
where it appears, as accurate as possible.
![ts_calibrate](doc/screenshots/ts_calibrate.png?raw=true)
### test the filtered input behaviour
You may quickly test the touch behaviour that results from the configured
filters, using [`ts_test_mt`](https://manpages.debian.org/unstable/libts0/ts_test_mt.1.en.html):
# ts_test_mt
![ts_test_mt](doc/screenshots/ts_test_mt.png?raw=true)
On the bottom left of the screen, you see the available concurrent touch contacts
supported, and whether it's because the driver says so, or ts_test_mt was started
with the `-j` commandline option to overwrite it.
### environment variables (optional)
You may override defaults. In most cases you won't need to do so though:
TSLIB_TSDEVICE Touchscreen device file name.
Default: automatic detection (on Linux)
TSLIB_CALIBFILE Calibration file.
Default: ${sysconfdir}/pointercal
TSLIB_CONFFILE Config file.
Default: ${sysconfdir}/ts.conf
TSLIB_PLUGINDIR Plugin directory.
Default: ${datadir}/plugins
TSLIB_CONSOLEDEVICE Console device. (not needed when using --with-sdl2)
Default: /dev/tty
TSLIB_FBDEVICE Framebuffer device.
Default: /dev/fb0
### use the filtered result in your system (X.org method)
If you're using X.org graphical X server, things should be very easy. Install
tslib and [xf86-input-tslib](https://github.com/merge/xf86-input-tslib),
reboot, and you should instantly have your `ts.conf` filters running, without
configuring anything else yourself.
### use the filtered result in your system (ts_uinput method)
**TL;DR:** Run `tools/ts_uinput_start.sh` during startup and use
`/dev/input/ts_uinput` as your evdev input device.
tslib tries to automatically find your touchscreen device in `/dev/input/event*`
on Linux. Now make `ts_uinput` use it, instead of your graphical environment
directly:
# ts_uinput -d -v
`-d` makes the program return and run as a daemon in the background. `-v` makes
it print the __new__ `/dev/input/eventX` device node before returning.
Now make your graphical environment use that new input device, using **evdev**
drivers.
* For *Qt5* for example you'd probably set something like this:
QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS=/dev/input/eventX:rotate=0
* For *X11* you'd probably edit your `xorg.conf` `Section "InputDevice"` for your
touchscreen to have
Option "Device" "/dev/input/eventX"
Please consult your input system's documentation on how to use a specific
evdev input device.
Let's recap the data flow here:
driver --> raw read --> filter(s) ... --> ts_uinput --> libevdev read --> GUI app/toolkit
module module(s) ... daemon e.g. in libinput
#### symlink /dev/input/ts_uinput to the new event file
/dev/input/event numbers are not persistent. In order to know in advance,
*what* enumerated input device file is created by `ts_uinput`, you can use
a symlink:
* use the included `tools/ts_uinput_start.sh` script that starts
`ts_uinput -d -v` and creates the symlink called `/dev/input/ts_uinput` for
you, or
* if you're using *systemd*, create the following udev rule, for
example `/etc/udev/rules.d/98-touchscreen.rules`:
SUBSYSTEM=="input", KERNEL=="event[0-9]*", ATTRS{name}=="NAME_OF_THE_TOUCH_CONTROLLER", SYMLINK+="input/ts", TAG+="systemd" ENV{SYSTEMD_WANTS}="ts_uinput.service"
SUBSYSTEM=="input", KERNEL=="event[0-9]*", ATTRS{name}=="ts_uinput", SYMLINK+="input/ts_uinput"
where `NAME_OF_THE_TOUCH_CONTROLLER` the touchscreen found in your `cat /proc/bus/input/devices | grep Name`. The first rule is only needed, if tslib doesn't automatically choose
the correct device for you.
#### running as systemd service (optional)
In case you have to use non-default paths, create a file containing the
environment for tslib, like `/etc/ts.env`
TSLIB_CALIBFILE=/etc/pointercal
TSLIB_CONFFILE=/etc/ts.conf
TSLIB_PLUGINDIR=/usr/lib/ts
and create a systemd service file, like `/usr/lib/systemd/system/ts_uinput.service`
[Unit]
Description=touchscreen input
BindsTo=dev-input-ts.device
After=dev-input-ts.device
RequiresMountsFor=/etc/ts.env
[Service]
Type=forking
EnvironmentFile=/etc/ts.env
ExecStart=/usr/bin/ts_uinput -d
Adjust the paths. They could as well be in `/usr/local/` too.
### other operating systems
There is no tool that we know of that reads tslib samples and uses the
[Windows t
gec6818 tslib.tar.gz s
需积分: 7 68 浏览量
2022-11-06
11:48:19
上传
评论
收藏 1.96MB GZ 举报
kui9702
- 粉丝: 1w+
- 资源: 8
最新资源
- 基于matlab实现用有限元法计算电磁场的Matlab工具 .rar
- 基于matlab实现有限元算法 计算电磁场问题 边界条件包括第一类边界和第二类边界.rar
- 基于matlab实现用于计算不同车重下的电动汽车动力性和经济性.rar
- 基于matlab实现遗传算法求解多车场车辆路径问题 有多组算例可以用.rar
- 浏览器.apk
- 基于matlab实现是一个matlab中的power system 中搭建的一个模型
- 基于JSP毕业设计-教学管理系统(源代码+论文).zip
- 基于JSP毕业设计-家政管理系统-毕业设计.zip
- 基于Python实现淘宝商品评论采集(含逆向)源代码
- 基于matlab实现多目标进化算法NSGAⅡ&Matlab讲解.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈