Qt 4.8
Public Functions | Private Slots | Properties | List of all members
QQnxMouseHandler Class Reference

The QQnxMouseHandler class implements a mouse driver for the QNX devi-hid input manager. More...

#include <qmouseqnx_qws.h>

Inheritance diagram for QQnxMouseHandler:
QObject QWSMouseHandler

Public Functions

 QQnxMouseHandler (const QString &driver=QString(), const QString &device=QString())
 Constructs a mouse handler for the specified device, defaulting to /dev/devi/mouse0. More...
 
void resume ()
 Reimplemented Function More...
 
void suspend ()
 Reimplemented Function More...
 
 ~QQnxMouseHandler ()
 Destroys this mouse handler and closes the connection to the mouse device. More...
 
- 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...
 
- Public Functions inherited from QWSMouseHandler
virtual void calibrate (const QWSPointerCalibrationData *)
 This virtual function allows subclasses of QWSMouseHandler to set the calibration information passed in the given data. More...
 
virtual void clearCalibration ()
 This virtual function allows subclasses of QWSMouseHandler to clear the calibration information. More...
 
virtual void getCalibration (QWSPointerCalibrationData *) const
 This virtual function allows subclasses of QWSMouseHandler to fill in the device coordinates in data with values that correspond to screen coordinates that are already in data. More...
 
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 QPointpos () const
 Returns the current mouse position. More...
 
 QWSMouseHandler (const QString &driver=QString(), const QString &device=QString())
 Constructs a mouse driver. More...
 
void setScreen (const QScreen *screen)
 Sets the screen for this mouse driver to be the given screen. More...
 
virtual ~QWSMouseHandler ()
 Destroys this mouse driver. More...
 

Private Slots

void socketActivated ()
 This function is called whenever there is activity on the mouse device. More...
 

Properties

bool absolutePositioning
 
int mouseButtons
 
int mouseFD
 
QSocketNotifiermouseNotifier
 
QPoint transformedMousePos
 

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
 
- Protected Variables inherited from QWSMouseHandler
QWSMouseHandlerPrivated_ptr
 
QPointmousePos
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

The QQnxMouseHandler class implements a mouse driver for the QNX devi-hid input manager.

This function is under development and subject to change.

Warning
This function is not part of the public interface.
Since
4.6

To be able to compile this mouse handler, Qt for Embedded Linux must be configured with the -qt-mouse-qnx option, see the Qt for Embedded Linux Pointer Handling{Pointer Handling} documentation for details.

In order to use this mouse handler, the devi-hid input manager must be set up and run with the resource manager interface (option -r). Also, Photon must not be running.

Example invocation from command line: /usr/photon/bin/devi-hid -Pr kbd mouse Note that after running devi-hid, you will not be able to use the local shell anymore. It is suggested to run the command in a shell scrip, that launches a Qt application after invocation of devi-hid.

To make Qt for Embedded Linux explicitly choose the qnx mouse handler, set the QWS_MOUSE_PROTO environment variable to qnx. By default, the first mouse device (/dev/devi/mouse0) is used. To override, pass a device name as the first and only parameter, for example QWS_MOUSE_PROTO=qnx:/dev/devi/mouse1; export QWS_MOUSE_PROTO.

See also
{Qt for Embedded Linux Pointer Handling}{Pointer Handling}, {Qt for Embedded Linux}

Definition at line 56 of file qmouseqnx_qws.h.

Constructors and Destructors

◆ QQnxMouseHandler()

QQnxMouseHandler::QQnxMouseHandler ( const QString driver = QString(),
const QString device = QString() 
)
explicit

Constructs a mouse handler for the specified device, defaulting to /dev/devi/mouse0.

The driver parameter must be "qnx".

Note that you should never instanciate this class, instead let QMouseDriverFactory handle the mouse handlers.

See also
QMouseDriverFactory

Definition at line 100 of file qmouseqnx_qws.cpp.

101  : QObject(), QWSMouseHandler(driver, device), mouseButtons(Qt::NoButton)
102 {
103  // open the mouse device with O_NONBLOCK so reading won't block when there's no data
104  mouseFD = QT_OPEN(device.isEmpty() ? "/dev/devi/mouse0" : device.toLatin1().constData(),
105  QT_OPEN_RDONLY | O_NONBLOCK);
106  if (mouseFD == -1) {
107  qErrnoWarning(errno, "QQnxMouseHandler: Unable to open mouse device");
108  } else {
109  struct _pointer_info data;
110  if (devctl(mouseFD, _POINTERGETINFO, &data, sizeof(data), NULL) == EOK)
111  absolutePositioning = (data.flags & _POINTER_FLAG_ABSOLUTE);
112  else
113  absolutePositioning = !device.isEmpty() && device.contains(QLatin1String("touch"));
114 
115  // register a socket notifier on the file descriptor so we'll wake up whenever
116  // there's a mouse move waiting for us.
118  connect(mouseNotifier, SIGNAL(activated(int)), SLOT(socketActivated()));
119 
120  qDebug("QQnxMouseHandler: connected.");
121  }
122 #ifndef QT_NO_QWS_TRANSFORMED
124 #endif
125 }
Q_GUI_EXPORT QScreen * qt_screen
Definition: qscreen_qws.cpp:69
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.h:904
QPoint transformedMousePos
Definition: qmouseqnx_qws.h:76
#define SLOT(a)
Definition: qobjectdefs.h:226
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
int deviceWidth() const
Returns the physical width of the framebuffer device in pixels.
Definition: qscreen_qws.h:233
void socketActivated()
This function is called whenever there is activity on the mouse device.
The QSocketNotifier class provides support for monitoring activity on a file descriptor.
Q_CORE_EXPORT void qDebug(const char *,...)
#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
static const char * data(const QByteArray &arr)
QWSMouseHandler(const QString &driver=QString(), const QString &device=QString())
Constructs a mouse driver.
Definition: qmouse_qws.cpp:223
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_OPEN
Definition: qcore_unix_p.h:186
QSocketNotifier * mouseNotifier
Definition: qmouseqnx_qws.h:71
int deviceHeight() const
Returns the full height of the framebuffer device in pixels.
Definition: qscreen_qws.h:234
Q_INVOKABLE QObject(QObject *parent=0)
Constructs an object with parent object parent.
Definition: qobject.cpp:753
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
int errno
void qErrnoWarning(const char *msg,...)
Definition: qglobal.cpp:2954

◆ ~QQnxMouseHandler()

QQnxMouseHandler::~QQnxMouseHandler ( )

Destroys this mouse handler and closes the connection to the mouse device.

Definition at line 130 of file qmouseqnx_qws.cpp.

131 {
132  if (mouseFD != -1)
133  QT_CLOSE(mouseFD);
134 }
#define QT_CLOSE
Definition: qcore_unix_p.h:304

Functions

◆ resume()

void QQnxMouseHandler::resume ( )
virtual

Reimplemented Function

Implements QWSMouseHandler.

Definition at line 137 of file qmouseqnx_qws.cpp.

138 {
139  if (mouseNotifier)
140  mouseNotifier->setEnabled(true);
141 }
QSocketNotifier * mouseNotifier
Definition: qmouseqnx_qws.h:71
void setEnabled(bool)
If enable is true, the notifier is enabled; otherwise the notifier is disabled.

◆ socketActivated

void QQnxMouseHandler::socketActivated ( )
privateslot

This function is called whenever there is activity on the mouse device.

Warning
This function is not part of the public interface.

By default, it reads up to 10 mouse move packets and calls mouseChanged() for each of them.

Definition at line 159 of file qmouseqnx_qws.cpp.

Referenced by QQnxMouseHandler().

160 {
161 #ifndef QT_NO_QWS_TRANSFORMED
162  QPoint queuedPos = transformedMousePos;
163 #else
164  QPoint queuedPos = mousePos;
165 #endif
166 
167  // _mouse_packet is a QNX structure. devi-hid is nice enough to translate
168  // the raw byte data from mouse devices into generic format for us.
169  struct _mouse_packet buffer[32];
170  int n = 0;
171 
172  forever {
173  int bytesRead = QT_READ(mouseFD, reinterpret_cast<char *>(buffer) + n, sizeof(buffer) - n);
174  if (bytesRead == -1) {
175  // EAGAIN means that there are no more mouse events to read
176  if (errno != EAGAIN)
177  qErrnoWarning(errno, "QQnxMouseHandler: Could not read from input device");
178  break;
179  }
180 
181  n += bytesRead;
182  if (n % sizeof(buffer[0]) == 0)
183  break;
184  }
185  n /= sizeof(buffer[0]);
186 
187  for (int i = 0; i < n; ++i) {
188  const struct _mouse_packet &packet = buffer[i];
189 
190  // translate the coordinates from the QNX data structure to the Qt coordinates
191  if (absolutePositioning) {
192  queuedPos = QPoint(packet.dx, packet.dy);
193  } else {
194  // note the swapped y axis
195  queuedPos += QPoint(packet.dx, -packet.dy);
196 
197  // QNX only tells us relative mouse movements, not absolute ones, so
198  // limit the cursor position manually to the screen
199  limitToScreen(queuedPos);
200  }
201 
202  // translate the QNX mouse button bitmask to Qt buttons
203  int buttons = Qt::NoButton;
204  if (packet.hdr.buttons & _POINTER_BUTTON_LEFT)
205  buttons |= Qt::LeftButton;
206  if (packet.hdr.buttons & _POINTER_BUTTON_MIDDLE)
207  buttons |= Qt::MidButton;
208  if (packet.hdr.buttons & _POINTER_BUTTON_RIGHT)
209  buttons |= Qt::RightButton;
210 
211  if (buttons != mouseButtons) {
212  // send the MouseEvent to avoid missing any clicks
213  mouseChanged(queuedPos, buttons, 0);
214  // mousePos updated by the mouseChanged()
215 #ifndef QT_NO_QWS_TRANSFORMED
216  queuedPos = transformedMousePos;
217 #else
218  queuedPos = mousePos;
219 #endif
221  }
222  }
223 
224 #ifndef QT_NO_QWS_TRANSFORMED
225  if (queuedPos != transformedMousePos) {
226  mouseChanged(queuedPos, mouseButtons, 0);
227  transformedMousePos = queuedPos;
228  }
229 #else
230  if (queuedPos != mousePos)
231  mouseChanged(queuedPos, mouseButtons, 0);
232 #endif
233 }
QPoint transformedMousePos
Definition: qmouseqnx_qws.h:76
static Qt::MouseButtons buttons
QPoint & mousePos
Definition: qmouse_qws.h:87
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
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
void limitToScreen(QPoint &pt)
Ensures that the given position is within the screen&#39;s boundaries, changing the position if necessary...
Definition: qmouse_qws.cpp:248
int errno
void qErrnoWarning(const char *msg,...)
Definition: qglobal.cpp:2954
#define forever
This macro is provided for convenience for writing infinite loops.
Definition: qglobal.h:2452

◆ suspend()

void QQnxMouseHandler::suspend ( )
virtual

Reimplemented Function

Implements QWSMouseHandler.

Definition at line 144 of file qmouseqnx_qws.cpp.

145 {
146  if (mouseNotifier)
147  mouseNotifier->setEnabled(false);
148 }
QSocketNotifier * mouseNotifier
Definition: qmouseqnx_qws.h:71
void setEnabled(bool)
If enable is true, the notifier is enabled; otherwise the notifier is disabled.

Properties

◆ absolutePositioning

bool QQnxMouseHandler::absolutePositioning
private

Definition at line 74 of file qmouseqnx_qws.h.

Referenced by QQnxMouseHandler(), and socketActivated().

◆ mouseButtons

int QQnxMouseHandler::mouseButtons
private

Definition at line 73 of file qmouseqnx_qws.h.

Referenced by socketActivated().

◆ mouseFD

int QQnxMouseHandler::mouseFD
private

Definition at line 72 of file qmouseqnx_qws.h.

Referenced by QQnxMouseHandler(), socketActivated(), and ~QQnxMouseHandler().

◆ mouseNotifier

QSocketNotifier* QQnxMouseHandler::mouseNotifier
private

Definition at line 71 of file qmouseqnx_qws.h.

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

◆ transformedMousePos

QPoint QQnxMouseHandler::transformedMousePos
private

Definition at line 76 of file qmouseqnx_qws.h.

Referenced by QQnxMouseHandler(), and socketActivated().


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