
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
TheQWSCalibratedMouseHandler class provides mouse calibration and noise reduction in Qt for Embedded Linux.More...
| Header: | #include <QWSCalibratedMouseHandler> |
| Inherits: | QWSMouseHandler |
| virtual void | calibrate(const QWSPointerCalibrationData * data) |
| virtual void | clearCalibration() |
| void | readCalibration() |
| bool | sendFiltered(const QPoint & position, int state) |
| void | setFilterSize(int size) |
| QPoint | transform(const QPoint & position) |
| void | writeCalibration() |
TheQWSCalibratedMouseHandler class provides mouse calibration and noise reduction in Qt for Embedded Linux.
Note that this class is only available inQt for Embedded Linux.
Qt for Embedded Linux provides ready-made drivers for several mouse protocols, see thepointer handling documentation for details. In general, custom mouse drivers can be implemented by subclassing theQWSMouseHandler class. But when the system device does not have a fixed mapping between device and screen coordinates and/or produces noisy events (e.g., a touchscreen), you should derive from theQWSCalibratedMouseHandler class instead to take advantage of its calibration functionality. As always, you must also create a mouse driver plugin (derived fromQMouseDriverPlugin); the implementation of theQMouseDriverFactory class will then automatically detect the plugin, and load the driver into the server application at run-time using Qt'splugin system.
QWSCalibratedMouseHandler provides an implementation of thecalibrate() function to update the calibration parameters based on coordinate mapping of the given calibration data. The calibration data is represented by anQWSPointerCalibrationData object. The linear transformation between device coordinates and screen coordinates is performed by calling thetransform() function explicitly on the points passed to theQWSMouseHandler::mouseChanged() function. Use theclearCalibration() function to make the mouse driver return mouse events in raw device coordinates and not in screen coordinates.
The calibration parameters are recalculated whenevercalibrate() is called, and they can be stored using thewriteCalibration() function. Previously written parameters can be retrieved at any time using thereadCalibration() function (calibration parameters are always read when the class is instantiated). Note that the calibration parameters is written to and read from the file currently specified by thePOINTERCAL_FILE environment variable; the default file is/etc/pointercal.
To achieve noise reduction,QWSCalibratedMouseHandler provides thesendFiltered() function. Use this function instead ofmouseChanged() whenever a mouse event occurs. The filter's size can be manipulated using thesetFilterSize() function.
See alsoQWSMouseHandler,QWSPointerCalibrationData, andMouse Calibration Example.
[virtual]void QWSCalibratedMouseHandler::calibrate(constQWSPointerCalibrationData * data)Reimplemented fromQWSMouseHandler::calibrate().
Updates the calibration parameters based on coordinate mapping of the givendata.
Create an instance of theQWSPointerCalibrationData class, fill in the device and screen coordinates and pass that object to the mouse driver using this function.
See alsoclearCalibration() andtransform().
[virtual]void QWSCalibratedMouseHandler::clearCalibration()Reimplemented fromQWSMouseHandler::clearCalibration().
Clears the current calibration, i.e., makes the mouse driver return mouse events in raw device coordinates instead of screen coordinates.
See alsocalibrate().
[protected]void QWSCalibratedMouseHandler::readCalibration()Reads previously written calibration parameters which are stored in/etc/pointercal (separated by whitespace and in alphabetical order).
You can override the default/etc/pointercal by specifying another file using thePOINTERCAL_FILE environment variable.
See alsowriteCalibration().
[protected]bool QWSCalibratedMouseHandler::sendFiltered(constQPoint & position,int state)Notifies the system of a new mouse eventafter applying a noise reduction filter. Returns true if the filtering process is successful; otherwise returns false. Note that if the filtering process failes, the system is not notified about the event.
The givenposition is the global position of the mouse. Thestate parameter is a bitmask of theQt::MouseButton enum's values indicating which mouse buttons are pressed.
The noice is reduced by calculating an average position from a collection of mouse event positions and then calling themouseChanged() function with the new position. The number of positions that is used is determined by the filter size.
See alsomouseChanged() andsetFilterSize().
[protected]void QWSCalibratedMouseHandler::setFilterSize(int size)Sets the size of the filter used in noise reduction to the givensize.
ThesendFiltered() function reduces noice by calculating an average position from a collection of mouse event positions. The filter size determines the number of positions that forms the basis for these calculations.
See alsosendFiltered().
[protected]QPoint QWSCalibratedMouseHandler::transform(constQPoint & position)Transforms the givenposition from device coordinates to screen coordinates, and returns the transformed position.
This function is typically called explicitly on the points passed to theQWSMouseHandler::mouseChanged() function.
This implementation is a linear transformation using 7 parameters (a,b,c,d,e,f ands) to transform the device coordinates (Xd,Yd) into screen coordinates (Xs,Ys) using the following equations:
s*Xs= a*Xd+ b*Yd+ cs*Ys= d*Xd+ e*Yd+ f
See alsomouseChanged().
[protected]void QWSCalibratedMouseHandler::writeCalibration()Saves the current calibration parameters in/etc/pointercal (separated by whitespace and in alphabetical order).
You can override the default/etc/pointercal by specifying another file using thePOINTERCAL_FILE environment variable.
See alsoreadCalibration().
© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.