Qt 4.8
Public Functions | Private Slots | Private Functions | Properties | List of all members
QWSTslibMouseHandlerPrivate Class Reference
Inheritance diagram for QWSTslibMouseHandlerPrivate:
QObject

Public Functions

void calibrate (const QWSPointerCalibrationData *data)
 
void clearCalibration ()
 
 QWSTslibMouseHandlerPrivate (QWSTslibMouseHandler *h, const QString &device)
 
void resume ()
 
void suspend ()
 
 ~QWSTslibMouseHandlerPrivate ()
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Private Slots

void readMouseData ()
 

Private Functions

void close ()
 
bool get_sample (struct ts_sample *sample)
 
bool open ()
 

Properties

bool calibrated
 
struct tsdev * dev
 
QString devName
 
QWSTslibMouseHandlerhandler
 
int jitter_limit
 
int lastdx
 
int lastdy
 
struct ts_sample lastSample
 
QSocketNotifiermouseNotifier
 
bool wasPressed
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 102 of file qmousetslib_qws.cpp.

Constructors and Destructors

◆ QWSTslibMouseHandlerPrivate()

QWSTslibMouseHandlerPrivate::QWSTslibMouseHandlerPrivate ( QWSTslibMouseHandler h,
const QString device 
)

Definition at line 138 of file qmousetslib_qws.cpp.

140  : handler(h), dev(0), mouseNotifier(0), jitter_limit(3)
141 {
143  QRegExp jitterRegex(QLatin1String("^jitter_limit=(\\d+)$"));
144  int index = args.indexOf(jitterRegex);
145  if (index >= 0) {
146  jitter_limit = jitterRegex.cap(1).toInt();
147  args.removeAt(index);
148  }
149 
150  devName = args.join(QString());
151 
152  if (devName.isNull()) {
153  const char *str = getenv("TSLIB_TSDEVICE");
154  if (str)
156  }
157 
158  if (devName.isNull())
159  devName = QLatin1String("/dev/ts");
160 
161  if (!open())
162  return;
163 
164  calibrated = true;
165 
166  int fd = ts_fd(dev);
168  connect(mouseNotifier, SIGNAL(activated(int)),this, SLOT(readMouseData()));
169  resume();
170 }
static QString fromLocal8Bit(const char *, int size=-1)
Returns a QString initialized with the first size characters of the 8-bit string str.
Definition: qstring.cpp:4245
The QRegExp class provides pattern matching using regular expressions.
Definition: qregexp.h:61
#define SLOT(a)
Definition: qobjectdefs.h:226
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QSocketNotifier class provides support for monitoring activity on a file descriptor.
#define SIGNAL(a)
Definition: qobjectdefs.h:227
int indexOf(const QRegExp &rx, int from=0) const
Returns the index position of the first exact match of rx in the list, searching forward from index p...
Definition: qstringlist.h:195
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition: qstring.h:505
QString join(const QString &sep) const
Joins all the string list&#39;s strings into a single string with each element separated by the given sep...
Definition: qstringlist.h:162
quint16 index
QWSTslibMouseHandler * handler
QStringList split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
Splits the string into substrings wherever sep occurs, and returns the list of those strings...
Definition: qstring.cpp:6526
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
void removeAt(int i)
Removes the item at index position i.
Definition: qlist.h:480

◆ ~QWSTslibMouseHandlerPrivate()

QWSTslibMouseHandlerPrivate::~QWSTslibMouseHandlerPrivate ( )

Definition at line 172 of file qmousetslib_qws.cpp.

173 {
174  close();
175 }

Functions

◆ calibrate()

void QWSTslibMouseHandlerPrivate::calibrate ( const QWSPointerCalibrationData data)

Definition at line 307 of file qmousetslib_qws.cpp.

Referenced by QWSTslibMouseHandler::calibrate().

308 {
309  suspend();
310  close();
311  // default implementation writes to /etc/pointercal
312  // using the same format as the tslib linear module.
313  handler->QWSCalibratedMouseHandler::calibrate(data);
314  calibrated = true;
315  open();
316  resume();
317 }
QWSTslibMouseHandler * handler

◆ clearCalibration()

void QWSTslibMouseHandlerPrivate::clearCalibration ( )

Definition at line 297 of file qmousetslib_qws.cpp.

Referenced by QWSTslibMouseHandler::clearCalibration().

298 {
299  suspend();
300  close();
301  handler->QWSCalibratedMouseHandler::clearCalibration();
302  calibrated = false;
303  open();
304  resume();
305 }
QWSTslibMouseHandler * handler

◆ close()

void QWSTslibMouseHandlerPrivate::close ( )
private

Definition at line 198 of file qmousetslib_qws.cpp.

Referenced by calibrate(), clearCalibration(), open(), and ~QWSTslibMouseHandlerPrivate().

199 {
200  if (dev)
201  ts_close(dev);
202 }

◆ get_sample()

bool QWSTslibMouseHandlerPrivate::get_sample ( struct ts_sample *  sample)
inlineprivate

Definition at line 220 of file qmousetslib_qws.cpp.

Referenced by readMouseData().

221 {
222  if (!calibrated)
223  return (ts_read_raw(dev, sample, 1) == 1);
224 
225  return (ts_read(dev, sample, 1) == 1);
226 }

◆ open()

bool QWSTslibMouseHandlerPrivate::open ( )
private

Definition at line 177 of file qmousetslib_qws.cpp.

Referenced by calibrate(), clearCalibration(), and QWSTslibMouseHandlerPrivate().

178 {
179  dev = ts_open(devName.toLocal8Bit().constData(), 1);
180  if (!dev) {
181  qCritical("QWSTslibMouseHandlerPrivate: ts_open() failed"
182  " with error: '%s'", strerror(errno));
183  qCritical("Please check your tslib installation!");
184  return false;
185  }
186 
187  if (ts_config(dev)) {
188  qCritical("QWSTslibMouseHandlerPrivate: ts_config() failed"
189  " with error: '%s'", strerror(errno));
190  qCritical("Please check your tslib installation!");
191  close();
192  return false;
193  }
194 
195  return true;
196 }
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4049
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
Q_CORE_EXPORT void qCritical(const char *,...)
int errno

◆ readMouseData

void QWSTslibMouseHandlerPrivate::readMouseData ( )
privateslot

Definition at line 228 of file qmousetslib_qws.cpp.

Referenced by QWSTslibMouseHandlerPrivate().

229 {
230  if (!qt_screen)
231  return;
232 
233  for(;;) {
234  struct ts_sample sample = lastSample;
235  bool pressed = wasPressed;
236 
237  // Fast return if there's no events.
238  if (!get_sample(&sample))
239  return;
240  pressed = (sample.pressure > 0);
241 
242  // Only return last sample unless there's a press/release event.
243  while (pressed == wasPressed) {
244  if (!get_sample(&sample))
245  break;
246  pressed = (sample.pressure > 0);
247  }
248 
249  // work around missing coordinates on mouse release in raw mode
250  if (!calibrated && !pressed && sample.x == 0 && sample.y == 0) {
251  sample.x = lastSample.x;
252  sample.y = lastSample.y;
253  }
254 
255  int dx = sample.x - lastSample.x;
256  int dy = sample.y - lastSample.y;
257 
258  // Remove small movements in oppsite direction
259  if (dx * lastdx < 0 && qAbs(dx) < jitter_limit) {
260  sample.x = lastSample.x;
261  dx = 0;
262  }
263  if (dy * lastdy < 0 && qAbs(dy) < jitter_limit) {
264  sample.y = lastSample.y;
265  dy = 0;
266  }
267 
268  if (wasPressed == pressed && dx == 0 && dy == 0)
269  return;
270 
271 #ifdef TSLIBMOUSEHANDLER_DEBUG
272  qDebug() << "last" << QPoint(lastSample.x, lastSample.y)
273  << "curr" << QPoint(sample.x, sample.y)
274  << "dx,dy" << QPoint(dx, dy)
275  << "ddx,ddy" << QPoint(dx*lastdx, dy*lastdy)
276  << "pressed" << wasPressed << pressed;
277 #endif
278 
279  lastSample = sample;
280  wasPressed = pressed;
281  if (dx != 0)
282  lastdx = dx;
283  if (dy != 0)
284  lastdy = dy;
285 
286  const QPoint p(sample.x, sample.y);
287  if (calibrated) {
288  // tslib should do all the translation and filtering, so we send a
289  // "raw" mouse event
290  handler->QWSMouseHandler::mouseChanged(p, pressed);
291  } else {
292  handler->sendFiltered(p, pressed);
293  }
294  }
295 }
Q_GUI_EXPORT QScreen * qt_screen
Definition: qscreen_qws.cpp:69
Q_DECL_CONSTEXPR T qAbs(const T &t)
Definition: qglobal.h:1201
Q_CORE_EXPORT void qDebug(const char *,...)
bool sendFiltered(const QPoint &, int button)
Notifies the system of a new mouse event after applying a noise reduction filter. ...
Definition: qmouse_qws.cpp:639
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
QWSTslibMouseHandler * handler
bool get_sample(struct ts_sample *sample)

◆ resume()

void QWSTslibMouseHandlerPrivate::resume ( )

Definition at line 210 of file qmousetslib_qws.cpp.

Referenced by calibrate(), clearCalibration(), QWSTslibMouseHandlerPrivate(), and QWSTslibMouseHandler::resume().

211 {
212  memset(&lastSample, 0, sizeof(lastSample));
213  wasPressed = false;
214  lastdx = 0;
215  lastdy = 0;
216  if (mouseNotifier)
217  mouseNotifier->setEnabled(true);
218 }
void setEnabled(bool)
If enable is true, the notifier is enabled; otherwise the notifier is disabled.

◆ suspend()

void QWSTslibMouseHandlerPrivate::suspend ( )

Definition at line 204 of file qmousetslib_qws.cpp.

Referenced by calibrate(), clearCalibration(), and QWSTslibMouseHandler::suspend().

205 {
206  if (mouseNotifier)
207  mouseNotifier->setEnabled(false);
208 }
void setEnabled(bool)
If enable is true, the notifier is enabled; otherwise the notifier is disabled.

Properties

◆ calibrated

bool QWSTslibMouseHandlerPrivate::calibrated
private

◆ dev

struct tsdev* QWSTslibMouseHandlerPrivate::dev
private

Definition at line 118 of file qmousetslib_qws.cpp.

Referenced by close(), get_sample(), open(), and QWSTslibMouseHandlerPrivate().

◆ devName

QString QWSTslibMouseHandlerPrivate::devName
private

Definition at line 128 of file qmousetslib_qws.cpp.

Referenced by open(), and QWSTslibMouseHandlerPrivate().

◆ handler

QWSTslibMouseHandler* QWSTslibMouseHandlerPrivate::handler
private

Definition at line 117 of file qmousetslib_qws.cpp.

Referenced by calibrate(), clearCalibration(), and readMouseData().

◆ jitter_limit

int QWSTslibMouseHandlerPrivate::jitter_limit
private

Definition at line 120 of file qmousetslib_qws.cpp.

Referenced by QWSTslibMouseHandlerPrivate(), and readMouseData().

◆ lastdx

int QWSTslibMouseHandlerPrivate::lastdx
private

Definition at line 124 of file qmousetslib_qws.cpp.

Referenced by readMouseData(), and resume().

◆ lastdy

int QWSTslibMouseHandlerPrivate::lastdy
private

Definition at line 125 of file qmousetslib_qws.cpp.

Referenced by readMouseData(), and resume().

◆ lastSample

struct ts_sample QWSTslibMouseHandlerPrivate::lastSample
private

Definition at line 122 of file qmousetslib_qws.cpp.

Referenced by readMouseData(), and resume().

◆ mouseNotifier

QSocketNotifier* QWSTslibMouseHandlerPrivate::mouseNotifier
private

Definition at line 119 of file qmousetslib_qws.cpp.

Referenced by QWSTslibMouseHandlerPrivate(), resume(), and suspend().

◆ wasPressed

bool QWSTslibMouseHandlerPrivate::wasPressed
private

Definition at line 123 of file qmousetslib_qws.cpp.

Referenced by readMouseData(), and resume().


The documentation for this class was generated from the following file: