Reload tslib touch screen calibration

2020-07-26 03:12发布

问题:

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, including 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.

回答1:

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.



回答2:

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



回答3:

ts_reconfig() should do what you want.