开发者

Reload tslib touch screen calibration

开发者 https://www.devze.com 2023-02-01 03:56 出处:网络
Background: I am working on a somewhat large Qt-based GUI which handles all user interaction with a touch screen. The program is designed such that the user should not need to access a command prompt

Background: I am working on a somewhat large Qt-based GUI which handles all user interaction with a touch screen. The program is designed such that the user should not need to access a command prompt in order to do anything, i开发者_JAVA百科ncluding recalibrating the touch screen. I have written an imitation of tslib's ts_calibrate utility which runs as a QWidget and can modify tslib's calibration file at /etc/pointercal.

However, although I can modify the calibration file, changes to the calibration do not seem to be applied until I close and restart the program. I have written a script which can handle re-opening the program, but I would like to find a more elegant way of doing this so that the user's hassle is kept to a minimum.

Simply put, is there a function available in one of Qt's classes which will reload tslib's calibration file on the fly, without restarting the application? I have looked through the QWSServer class reference but I did not find anything that looks like it does what I want it to.


It turns out that the driver can be reloaded without restarting the application. To do so, you can close and re-open the pointer device(s), using methods in the QWSServer class like so:

#include <QWSServer>

...

QWSServer::instance()->closeMouse();
QWSServer::instance()->openMouse();

This will cause a reload of tslib's calibration file. E.g., if you started the program with a faulty calibration, correct the calibration file for the touch screen while the program is running, then invoke those methods, the pointer will adjust to the new calibration.


tslib has nothing to do with Qt. You can download the sources of tslib and look what tests/ts_calibrate.c does.


ts_reconfig() should do what you want.

0

精彩评论

暂无评论...
验证码 换一张
取 消