Detailed Description

Qt for Embedded Linux provides ready-made drivers for several mouse protocols, see the 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 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.

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.

[protected] void QWSCalibratedMouseHandler::setFilterSize(int size)

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.