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

Public Functions

 QWSLinuxTPMouseHandlerPrivate (QWSLinuxTPMouseHandler *h, const QString &)
 
void resume ()
 
void suspend ()
 
 ~QWSLinuxTPMouseHandlerPrivate ()
 
- 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 ()
 

Properties

int currSample
 
QWSLinuxTPMouseHandlerhandler
 
int lastSample
 
uchar mouseBuf [mouseBufSize]
 
int mouseFD
 
int mouseIdx
 
QSocketNotifiermouseNotifier
 
int numSamples
 
QPoint oldmouse
 
QPoint oldTotalMousePos
 
QPolygon samples
 
int skipCount
 
bool waspressed
 

Static Private Attributes

static const int mouseBufSize = 2048
 

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 125 of file qmouselinuxtp_qws.cpp.

Constructors and Destructors

◆ QWSLinuxTPMouseHandlerPrivate()

QWSLinuxTPMouseHandlerPrivate::QWSLinuxTPMouseHandlerPrivate ( QWSLinuxTPMouseHandler h,
const QString device 
)

Definition at line 175 of file qmouselinuxtp_qws.cpp.

178  numSamples(0), skipCount(0), handler(h)
179 {
180  QString mousedev;
181  if (device.isEmpty()) {
182 #if defined(QT_QWS_IPAQ)
183 # ifdef QT_QWS_IPAQ_RAW
184  mousedev = QLatin1String("/dev/h3600_tsraw");
185 # else
186  mousedev = QLatin1String("/dev/h3600_ts");
187 # endif
188 #else
189  mousedev = QLatin1String("/dev/ts");
190 #endif
191  } else {
192  mousedev = device;
193  }
194  if ((mouseFD = QT_OPEN(mousedev.toLatin1().constData(), O_RDONLY | O_NDELAY)) < 0) {
195  qWarning("Cannot open %s (%s)", qPrintable(mousedev), strerror(errno));
196  return;
197  }
198 
200  this);
201  connect(mouseNotifier, SIGNAL(activated(int)),this, SLOT(readMouseData()));
202  waspressed=false;
203  mouseIdx = 0;
204 }
QWSLinuxTPMouseHandler * handler
#define SLOT(a)
Definition: qobjectdefs.h:226
#define O_RDONLY
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
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
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
Q_CORE_EXPORT void qWarning(const char *,...)
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
#define QT_QWS_TP_SAMPLE_SIZE
#define QT_OPEN
Definition: qcore_unix_p.h:186
#define qPrintable(string)
Definition: qglobal.h:1750
int errno

◆ ~QWSLinuxTPMouseHandlerPrivate()

QWSLinuxTPMouseHandlerPrivate::~QWSLinuxTPMouseHandlerPrivate ( )

Definition at line 206 of file qmouselinuxtp_qws.cpp.

207 {
208  if (mouseFD >= 0)
209  QT_CLOSE(mouseFD);
210 }
#define QT_CLOSE
Definition: qcore_unix_p.h:304

Functions

◆ readMouseData

void QWSLinuxTPMouseHandlerPrivate::readMouseData ( )
privateslot

Definition at line 230 of file qmouselinuxtp_qws.cpp.

Referenced by QWSLinuxTPMouseHandlerPrivate().

231 {
232  if(!qt_screen)
233  return;
234 
235  int n;
236  do {
238  if (n > 0)
239  mouseIdx += n;
240  } while (n > 0 && mouseIdx < mouseBufSize);
241 
242  //qDebug("readMouseData()");
243 
244  TS_EVENT *data;
245  int idx = 0;
246 
247  // perhaps we shouldn't be reading EVERY SAMPLE.
248  while (mouseIdx-idx >= (int)sizeof(TS_EVENT)) {
249  uchar *mb = mouseBuf+idx;
250  data = (TS_EVENT *) mb;
251 
253 #ifdef QT_QWS_SHARP
254  samples[currSample] = QPoint(1000 - data->x, data->y);
255 #else
256  samples[currSample] = QPoint(data->x, data->y);
257 #endif
258  numSamples++;
260  int sampleCount = qMin(numSamples + 1,samples.count());
261 
262  // average the rest
263  QPoint mousePos = QPoint(0, 0);
264  QPoint totalMousePos = oldTotalMousePos;
265  totalMousePos += samples[currSample];
266  if(numSamples >= samples.count())
267  totalMousePos -= samples[lastSample];
268 
269  mousePos = totalMousePos / (sampleCount - 1);
270 #if defined(QT_QWS_SCREEN_COORDINATES)
271  mousePos = handler->transform(mousePos);
272 #endif
273  if(!waspressed)
274  oldmouse = mousePos;
275  QPoint dp = mousePos - oldmouse;
276  int dxSqr = dp.x() * dp.x();
277  int dySqr = dp.y() * dp.y();
278  if (dxSqr + dySqr < (QT_QWS_TP_MOVE_LIMIT * QT_QWS_TP_MOVE_LIMIT)) {
279  if (waspressed) {
280  if ((dxSqr + dySqr > (QT_QWS_TP_JITTER_LIMIT * QT_QWS_TP_JITTER_LIMIT)) || skipCount > 2) {
282  oldmouse = mousePos;
283  skipCount = 0;
284  } else {
285  skipCount++;
286  }
287  } else {
289  oldmouse=mousePos;
290  waspressed=true;
291  }
292 
293  // save recuring information
294  currSample++;
295  if (numSamples >= samples.count())
296  lastSample++;
297  oldTotalMousePos = totalMousePos;
298  } else {
299  numSamples--; // don't use this sample, it was bad.
300  }
301  } else {
302  // build up the average
304  currSample++;
305  }
306  if (currSample >= samples.count())
307  currSample = 0;
308  if (lastSample >= samples.count())
309  lastSample = 0;
310  } else {
311  currSample = 0;
312  lastSample = 0;
313  numSamples = 0;
314  skipCount = 0;
315  oldTotalMousePos = QPoint(0,0);
316  if (waspressed) {
317  handler->mouseChanged(oldmouse,0);
318  oldmouse = QPoint(-100, -100);
319  waspressed=false;
320  }
321  }
322  idx += sizeof(TS_EVENT);
323  }
324 
325  int surplus = mouseIdx - idx;
326  for (int i = 0; i < surplus; i++)
327  mouseBuf[i] = mouseBuf[idx+i];
328  mouseIdx = surplus;
329 }
QPoint transform(const QPoint &)
Transforms the given position from device coordinates to screen coordinates, and returns the transfor...
Definition: qmouse_qws.cpp:589
Q_GUI_EXPORT QScreen * qt_screen
Definition: qscreen_qws.cpp:69
QWSLinuxTPMouseHandler * handler
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
#define QT_QWS_TP_PRESSURE_THRESHOLD
void mouseChanged(const QPoint &pos, int bstate, int wheel=0)
Notifies the system of a new mouse event.
Definition: qmouse_qws.cpp:285
#define QT_READ
Definition: qcore_unix_p.h:280
unsigned short pressure
unsigned char uchar
Definition: qglobal.h:994
static const char * data(const QByteArray &arr)
#define QT_QWS_TP_MOVE_LIMIT
unsigned short y
#define QT_QWS_TP_MINIMUM_SAMPLES
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
#define QT_QWS_TP_JITTER_LIMIT
unsigned short x

◆ resume()

void QWSLinuxTPMouseHandlerPrivate::resume ( )

Definition at line 218 of file qmouselinuxtp_qws.cpp.

Referenced by QWSLinuxTPMouseHandler::resume().

219 {
220  mouseIdx=0;
221  currSample=0;
222  lastSample=0;
223  numSamples=0;
224  skipCount=0;
225  if (mouseNotifier)
226  mouseNotifier->setEnabled(true);
227 }
void setEnabled(bool)
If enable is true, the notifier is enabled; otherwise the notifier is disabled.

◆ suspend()

void QWSLinuxTPMouseHandlerPrivate::suspend ( )

Definition at line 212 of file qmouselinuxtp_qws.cpp.

Referenced by QWSLinuxTPMouseHandler::suspend().

213 {
214  if (mouseNotifier)
215  mouseNotifier->setEnabled(false);
216 }
void setEnabled(bool)
If enable is true, the notifier is enabled; otherwise the notifier is disabled.

Properties

◆ currSample

int QWSLinuxTPMouseHandlerPrivate::currSample
private

Definition at line 141 of file qmouselinuxtp_qws.cpp.

Referenced by readMouseData(), and resume().

◆ handler

QWSLinuxTPMouseHandler* QWSLinuxTPMouseHandlerPrivate::handler
private

Definition at line 147 of file qmouselinuxtp_qws.cpp.

Referenced by readMouseData().

◆ lastSample

int QWSLinuxTPMouseHandlerPrivate::lastSample
private

Definition at line 142 of file qmouselinuxtp_qws.cpp.

Referenced by readMouseData(), and resume().

◆ mouseBuf

uchar QWSLinuxTPMouseHandlerPrivate::mouseBuf[mouseBufSize]
private

Definition at line 146 of file qmouselinuxtp_qws.cpp.

Referenced by readMouseData().

◆ mouseBufSize

const int QWSLinuxTPMouseHandlerPrivate::mouseBufSize = 2048
staticprivate

Definition at line 135 of file qmouselinuxtp_qws.cpp.

Referenced by readMouseData().

◆ mouseFD

int QWSLinuxTPMouseHandlerPrivate::mouseFD
private

◆ mouseIdx

int QWSLinuxTPMouseHandlerPrivate::mouseIdx
private

Definition at line 145 of file qmouselinuxtp_qws.cpp.

Referenced by QWSLinuxTPMouseHandlerPrivate(), readMouseData(), and resume().

◆ mouseNotifier

QSocketNotifier* QWSLinuxTPMouseHandlerPrivate::mouseNotifier
private

Definition at line 148 of file qmouselinuxtp_qws.cpp.

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

◆ numSamples

int QWSLinuxTPMouseHandlerPrivate::numSamples
private

Definition at line 143 of file qmouselinuxtp_qws.cpp.

Referenced by readMouseData(), and resume().

◆ oldmouse

QPoint QWSLinuxTPMouseHandlerPrivate::oldmouse
private

Definition at line 137 of file qmouselinuxtp_qws.cpp.

Referenced by readMouseData().

◆ oldTotalMousePos

QPoint QWSLinuxTPMouseHandlerPrivate::oldTotalMousePos
private

Definition at line 138 of file qmouselinuxtp_qws.cpp.

Referenced by readMouseData().

◆ samples

QPolygon QWSLinuxTPMouseHandlerPrivate::samples
private

Definition at line 140 of file qmouselinuxtp_qws.cpp.

Referenced by readMouseData().

◆ skipCount

int QWSLinuxTPMouseHandlerPrivate::skipCount
private

Definition at line 144 of file qmouselinuxtp_qws.cpp.

Referenced by readMouseData(), and resume().

◆ waspressed

bool QWSLinuxTPMouseHandlerPrivate::waspressed
private

Definition at line 139 of file qmouselinuxtp_qws.cpp.

Referenced by QWSLinuxTPMouseHandlerPrivate(), and readMouseData().


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