Qt 4.8
|
The QWSCalibratedMouseHandler class provides mouse calibration and noise reduction in Qt for Embedded Linux. More...
#include <qmouse_qws.h>
Public Functions | |
virtual void | calibrate (const QWSPointerCalibrationData *) |
Updates the calibration parameters based on coordinate mapping of the given data. More... | |
virtual void | clearCalibration () |
Clears the current calibration, i.e., makes the mouse driver return mouse events in raw device coordinates instead of screen coordinates. More... | |
virtual void | getCalibration (QWSPointerCalibrationData *) const |
Fills cd with the device coordinates corresponding to the given screen coordinates. More... | |
QWSCalibratedMouseHandler (const QString &driver=QString(), const QString &device=QString()) | |
Public Functions inherited from QWSMouseHandler | |
void | limitToScreen (QPoint &pt) |
Ensures that the given position is within the screen's boundaries, changing the position if necessary. More... | |
void | mouseChanged (const QPoint &pos, int bstate, int wheel=0) |
Notifies the system of a new mouse event. More... | |
const QPoint & | pos () const |
Returns the current mouse position. More... | |
QWSMouseHandler (const QString &driver=QString(), const QString &device=QString()) | |
Constructs a mouse driver. More... | |
virtual void | resume ()=0 |
Implement this function to resume reading and handling mouse events, e. More... | |
void | setScreen (const QScreen *screen) |
Sets the screen for this mouse driver to be the given screen. More... | |
virtual void | suspend ()=0 |
Implement this function to suspend reading and handling of mouse events, e. More... | |
virtual | ~QWSMouseHandler () |
Destroys this mouse driver. More... | |
Protected Functions | |
void | readCalibration () |
Reads previously written calibration parameters which are stored in /etc/pointercal (separated by whitespace and in alphabetical order). More... | |
bool | sendFiltered (const QPoint &, int button) |
Notifies the system of a new mouse event after applying a noise reduction filter. More... | |
void | setFilterSize (int) |
Sets the size of the filter used in noise reduction to the given size. More... | |
QPoint | transform (const QPoint &) |
Transforms the given position from device coordinates to screen coordinates, and returns the transformed position. More... | |
void | writeCalibration () |
Saves the current calibration parameters in /etc/pointercal (separated by whitespace and in alphabetical order). More... | |
Properties | |
int | a |
int | b |
int | c |
int | currSample |
int | d |
int | e |
int | f |
int | numSamples |
int | s |
QPolygon | samples |
Additional Inherited Members | |
Protected Variables inherited from QWSMouseHandler | |
QWSMouseHandlerPrivate * | d_ptr |
QPoint & | mousePos |
The QWSCalibratedMouseHandler class provides mouse calibration and noise reduction in Qt for Embedded Linux.
Note that this class is only available in Qt for Embedded Linux.
Qt for Embedded Linux provides ready-made drivers for several mouse protocols, see the Qt for Embedded Linux Pointer Handling{pointer handling} documentation for details. In general, custom mouse drivers can be implemented by subclassing the QWSMouseHandler 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 the QWSCalibratedMouseHandler class instead to take advantage of its calibration functionality. As always, you must also create a mouse driver plugin (derived from QMouseDriverPlugin); the implementation of the QMouseDriverFactory class will then automatically detect the plugin, and load the driver into the server application at run-time using Qt's How to Create Qt Plugins{plugin system}.
QWSCalibratedMouseHandler provides an implementation of the calibrate() function to update the calibration parameters based on coordinate mapping of the given calibration data. The calibration data is represented by an QWSPointerCalibrationData object. The linear transformation between device coordinates and screen coordinates is performed by calling the transform() function explicitly on the points passed to the QWSMouseHandler::mouseChanged() function. Use the clearCalibration() function to make the mouse driver return mouse events in raw device coordinates and not in screen coordinates.
The calibration parameters are recalculated whenever calibrate() is called, and they can be stored using the writeCalibration() function. Previously written parameters can be retrieved at any time using the readCalibration() 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 the POINTERCAL_FILE environment variable; the default file is /etc/pointercal
.
To achieve noise reduction, QWSCalibratedMouseHandler provides the sendFiltered() function. Use this function instead of mouseChanged() whenever a mouse event occurs. The filter's size can be manipulated using the setFilterSize() function.
Definition at line 92 of file qmouse_qws.h.
|
explicit |
Definition at line 382 of file qmouse_qws.cpp.
|
virtual |
Updates the calibration parameters based on coordinate mapping of the given data.
Create an instance of the QWSPointerCalibrationData class, fill in the device and screen coordinates and pass that object to the mouse driver using this function.
Reimplemented from QWSMouseHandler.
Reimplemented in QIntMouseHandler, and QWSTslibMouseHandler.
Definition at line 526 of file qmouse_qws.cpp.
Referenced by QIntMouseHandler::calibrate().
|
virtual |
Clears the current calibration, i.e., makes the mouse driver return mouse events in raw device coordinates instead of screen coordinates.
Reimplemented from QWSMouseHandler.
Reimplemented in QIntMouseHandler, and QWSTslibMouseHandler.
Definition at line 416 of file qmouse_qws.cpp.
Referenced by QIntMouseHandler::clearCalibration(), QWSCalibratedMouseHandler(), and readCalibration().
|
virtual |
Fills cd with the device coordinates corresponding to the given screen coordinates.
Reimplemented from QWSMouseHandler.
Definition at line 395 of file qmouse_qws.cpp.
|
protected |
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 the POINTERCAL_FILE environment variable.
Definition at line 469 of file qmouse_qws.cpp.
Referenced by QWSCalibratedMouseHandler().
|
protected |
Notifies the system of a new mouse event after 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 given position is the global position of the mouse. The state parameter is a bitmask of the Qt::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 the mouseChanged() function with the new position. The number of positions that is used is determined by the filter size.
Definition at line 639 of file qmouse_qws.cpp.
Referenced by QIntMouseHandler::readMouseData(), and QWSTslibMouseHandlerPrivate::readMouseData().
|
protected |
Sets the size of the filter used in noise reduction to the given size.
The sendFiltered() 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.
Definition at line 610 of file qmouse_qws.cpp.
Transforms the given position from device coordinates to screen coordinates, and returns the transformed position.
This function is typically called explicitly on the points passed to the QWSMouseHandler::mouseChanged() function.
This implementation is a linear transformation using 7 parameters (a
, b
, c
, d
, e
, f
and s
) to transform the device coordinates (Xd
, Yd
) into screen coordinates (Xs
, Ys
) using the following equations:
Definition at line 589 of file qmouse_qws.cpp.
Referenced by QIntMouseHandler::QIntMouseHandler(), QWSLinuxInputMousePrivate::readMouseData(), QIntMouseHandler::readMouseData(), QWSLinuxTPMouseHandlerPrivate::readMouseData(), and sendFiltered().
|
protected |
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 the POINTERCAL_FILE environment variable.
Definition at line 437 of file qmouse_qws.cpp.
Referenced by calibrate().
|
private |
Definition at line 111 of file qmouse_qws.h.
Referenced by calibrate(), clearCalibration(), getCalibration(), readCalibration(), transform(), and writeCalibration().
|
private |
Definition at line 111 of file qmouse_qws.h.
Referenced by calibrate(), clearCalibration(), getCalibration(), readCalibration(), transform(), and writeCalibration().
|
private |
Definition at line 111 of file qmouse_qws.h.
Referenced by calibrate(), clearCalibration(), getCalibration(), readCalibration(), transform(), and writeCalibration().
|
private |
Definition at line 115 of file qmouse_qws.h.
Referenced by sendFiltered(), and setFilterSize().
|
private |
Definition at line 112 of file qmouse_qws.h.
Referenced by calibrate(), clearCalibration(), getCalibration(), readCalibration(), sendFiltered(), transform(), and writeCalibration().
|
private |
Definition at line 112 of file qmouse_qws.h.
Referenced by calibrate(), clearCalibration(), getCalibration(), readCalibration(), transform(), and writeCalibration().
|
private |
Definition at line 112 of file qmouse_qws.h.
Referenced by calibrate(), clearCalibration(), getCalibration(), readCalibration(), transform(), and writeCalibration().
|
private |
Definition at line 116 of file qmouse_qws.h.
Referenced by sendFiltered(), and setFilterSize().
|
private |
Definition at line 113 of file qmouse_qws.h.
Referenced by calibrate(), clearCalibration(), getCalibration(), readCalibration(), transform(), and writeCalibration().
|
private |
Definition at line 114 of file qmouse_qws.h.
Referenced by sendFiltered(), and setFilterSize().