summaryrefslogtreecommitdiffstats
path: root/src/gui/embedded
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/embedded')
-rw-r--r--src/gui/embedded/embedded.pri55
-rw-r--r--src/gui/embedded/qdirectpainter_qws.cpp8
-rw-r--r--src/gui/embedded/qdirectpainter_qws.h2
-rw-r--r--src/gui/embedded/qkbd_qws.cpp8
-rw-r--r--src/gui/embedded/qkbddriverfactory_qws.cpp28
-rw-r--r--src/gui/embedded/qkbdlinuxinput_qws.cpp14
-rw-r--r--src/gui/embedded/qkbdqnx_qws.cpp231
-rw-r--r--src/gui/embedded/qkbdqnx_qws.h (renamed from src/gui/embedded/qkbdyopy_qws.h)25
-rw-r--r--src/gui/embedded/qkbdsl5000_qws.cpp365
-rw-r--r--src/gui/embedded/qkbdsl5000_qws.h92
-rw-r--r--src/gui/embedded/qkbdtty_qws.cpp18
-rw-r--r--src/gui/embedded/qkbdvfb_qws.cpp9
-rw-r--r--src/gui/embedded/qkbdvr41xx_qws.cpp185
-rw-r--r--src/gui/embedded/qkbdyopy_qws.cpp209
-rw-r--r--src/gui/embedded/qlock.cpp74
-rw-r--r--src/gui/embedded/qmousebus_qws.cpp238
-rw-r--r--src/gui/embedded/qmousedriverfactory_qws.cpp42
-rw-r--r--src/gui/embedded/qmouselinuxinput_qws.cpp205
-rw-r--r--src/gui/embedded/qmouselinuxinput_qws.h (renamed from src/gui/embedded/qmousevr41xx_qws.h)32
-rw-r--r--src/gui/embedded/qmouselinuxtp_qws.cpp7
-rw-r--r--src/gui/embedded/qmousepc_qws.cpp41
-rw-r--r--src/gui/embedded/qmouseqnx_qws.cpp190
-rw-r--r--src/gui/embedded/qmouseqnx_qws.h (renamed from src/gui/embedded/qmousebus_qws.h)33
-rw-r--r--src/gui/embedded/qmousevfb_qws.cpp9
-rw-r--r--src/gui/embedded/qmousevr41xx_qws.cpp250
-rw-r--r--src/gui/embedded/qmouseyopy_qws.cpp184
-rw-r--r--src/gui/embedded/qmouseyopy_qws.h80
-rw-r--r--src/gui/embedded/qscreendriverfactory_qws.cpp8
-rw-r--r--src/gui/embedded/qscreenlinuxfb_qws.cpp20
-rw-r--r--src/gui/embedded/qscreenproxy_qws.cpp8
-rw-r--r--src/gui/embedded/qscreenqnx_qws.cpp447
-rw-r--r--src/gui/embedded/qscreenqnx_qws.h (renamed from src/gui/embedded/qkbdvr41xx_qws.h)35
-rw-r--r--src/gui/embedded/qsoundqss_qws.cpp9
-rw-r--r--src/gui/embedded/qtransportauth_qws.cpp7
-rw-r--r--src/gui/embedded/qtransportauth_qws.h2
-rw-r--r--src/gui/embedded/qunixsocket.cpp18
-rw-r--r--src/gui/embedded/qwindowsystem_qws.cpp37
-rw-r--r--src/gui/embedded/qwindowsystem_qws.h4
-rw-r--r--src/gui/embedded/qwsembedwidget.h2
-rw-r--r--src/gui/embedded/qwsmanager_qws.h2
40 files changed, 1358 insertions, 1875 deletions
diff --git a/src/gui/embedded/embedded.pri b/src/gui/embedded/embedded.pri
index 4a9aa3f..e8eb959 100644
--- a/src/gui/embedded/embedded.pri
+++ b/src/gui/embedded/embedded.pri
@@ -114,11 +114,18 @@ embedded {
SOURCES += embedded/qscreenlinuxfb_qws.cpp
}
+ contains( gfx-drivers, qnx ) {
+ HEADERS += embedded/qscreenqnx_qws.h
+ SOURCES += embedded/qscreenqnx_qws.cpp
+ LIBS += -lgf
+ }
+
contains( gfx-drivers, qvfb ) {
HEADERS += embedded/qscreenvfb_qws.h
SOURCES += embedded/qscreenvfb_qws.cpp
}
+
contains( gfx-drivers, vnc ) {
VNCDIR = $$QT_SOURCE_TREE/src/plugins/gfxdrivers/vnc
INCLUDEPATH += $$VNCDIR
@@ -141,15 +148,7 @@ embedded {
!contains( kbd-drivers, qvfb ) {
kbd-drivers += qvfb
}
- }
-
- contains( kbd-drivers, sl5000 ) {
- HEADERS +=embedded/qkbdsl5000_qws.h
- SOURCES +=embedded/qkbdsl5000_qws.cpp
- !contains( kbd-drivers, tty ) {
- kbd-drivers += tty
- }
- }
+ }
contains( kbd-drivers, tty ) {
HEADERS +=embedded/qkbdtty_qws.h
@@ -166,15 +165,10 @@ embedded {
SOURCES +=embedded/qkbdum_qws.cpp
}
- contains( kbd-drivers, yopy ) {
- HEADERS +=embedded/qkbdyopy_qws.h
- SOURCES +=embedded/qkbdyopy_qws.cpp
- }
-
- contains( kbd-drivers, vr41xx ) {
- HEADERS +=embedded/qkbdvr41xx_qws.h
- SOURCES +=embedded/qkbdvr41xx_qws.cpp
- }
+ contains( kbd-drivers, qnx ) {
+ HEADERS += embedded/qkbdqnx_qws.h
+ SOURCES += embedded/qkbdqnx_qws.cpp
+ }
#
# Mouse drivers
@@ -189,29 +183,24 @@ embedded {
SOURCES +=embedded/qmousepc_qws.cpp
}
- contains( mouse-drivers, bus ) {
- HEADERS +=embedded/qmousebus_qws.h
- SOURCES +=embedded/qmousebus_qws.cpp
- }
-
contains( mouse-drivers, linuxtp ) {
HEADERS +=embedded/qmouselinuxtp_qws.h
SOURCES +=embedded/qmouselinuxtp_qws.cpp
}
- contains( mouse-drivers, vr41xx ) {
- HEADERS +=embedded/qmousevr41xx_qws.h
- SOURCES +=embedded/qmousevr41xx_qws.cpp
- }
-
- contains( mouse-drivers, yopy ) {
- HEADERS +=embedded/qmouseyopy_qws.h
- SOURCES +=embedded/qmouseyopy_qws.cpp
- }
-
contains( mouse-drivers, tslib ) {
LIBS += -lts
HEADERS +=embedded/qmousetslib_qws.h
SOURCES +=embedded/qmousetslib_qws.cpp
}
+
+ contains( mouse-drivers, linuxinput ) {
+ HEADERS +=embedded/qmouselinuxinput_qws.h
+ SOURCES +=embedded/qmouselinuxinput_qws.cpp
+ }
+
+ contains( mouse-drivers, qnx ) {
+ HEADERS += embedded/qmouseqnx_qws.h
+ SOURCES += embedded/qmouseqnx_qws.cpp
+ }
}
diff --git a/src/gui/embedded/qdirectpainter_qws.cpp b/src/gui/embedded/qdirectpainter_qws.cpp
index e97367c..b3dff06 100644
--- a/src/gui/embedded/qdirectpainter_qws.cpp
+++ b/src/gui/embedded/qdirectpainter_qws.cpp
@@ -150,14 +150,14 @@ QT_BEGIN_NAMESPACE
\value ReservedSynchronous The allocated region will never change and
each function that changes the allocated region will be blocking.
- \sa reservedRegion(), allocatedRegion()
+ \sa allocatedRegion()
*/
/*!
\fn QRegion QDirectPainter::region()
\obsolete
- Use QDirectPainter::reservedRegion() instead.
+ Use QDirectPainter::allocatedRegion() instead.
*/
static inline QScreen *getPrimaryScreen()
@@ -346,7 +346,7 @@ void QDirectPainter::setRegion(const QRegion &region)
returned by the allocatedRegion() function. Otherwise they might
differ (see \l {Dynamic Allocation} for details).
- \sa geometry(), setRegion()
+ \sa geometry(), setRegion(), allocatedRegion()
*/
QRegion QDirectPainter::requestedRegion() const
{
@@ -540,7 +540,7 @@ void QDirectPainter::lower()
any. If not released explicitly, the region will be released on
application exit.
- \sa reservedRegion(), {Static Allocation}
+ \sa allocatedRegion(), {Static Allocation}
\obsolete
diff --git a/src/gui/embedded/qdirectpainter_qws.h b/src/gui/embedded/qdirectpainter_qws.h
index a7f82f1..eddde10 100644
--- a/src/gui/embedded/qdirectpainter_qws.h
+++ b/src/gui/embedded/qdirectpainter_qws.h
@@ -57,7 +57,7 @@ class QWSEmbedEvent;
class Q_GUI_EXPORT QDirectPainter : public QObject {
Q_OBJECT
- Q_DECLARE_SCOPED_PRIVATE(QDirectPainter)
+ Q_DECLARE_PRIVATE(QDirectPainter)
public:
enum SurfaceFlag { NonReserved = 0,
diff --git a/src/gui/embedded/qkbd_qws.cpp b/src/gui/embedded/qkbd_qws.cpp
index 7799339..756a398 100644
--- a/src/gui/embedded/qkbd_qws.cpp
+++ b/src/gui/embedded/qkbd_qws.cpp
@@ -453,8 +453,9 @@ void QWSKeyboardHandler::endAutoRepeat()
Maps \a keycode according to a keymap and sends that key event to the
\l{Qt for Embedded Linux} server application.
- Please see the QWS_KEYBOARD documentation for a description on how to
- create and use keymap files.
+ Please see the \l{Qt for Embedded Linux Character Input} and the \l
+ {kmap2qmap} documentations for a description on how to create and use
+ keymap files.
The key event is identified by its \a keycode value and the \a isPress
and \a autoRepeat parameters.
@@ -475,9 +476,6 @@ void QWSKeyboardHandler::endAutoRepeat()
implementation needs to take care of a special action, like console
switching or LED handling.
- Standard Linux console keymaps can be found at the
- \l {http://lct.sourceforege.net}{LCT project}
-
If standard Linux console keymaps are used, \a keycode must be one of the
standardized values defined in \c /usr/include/linux/input.h
diff --git a/src/gui/embedded/qkbddriverfactory_qws.cpp b/src/gui/embedded/qkbddriverfactory_qws.cpp
index c599396..fb10030 100644
--- a/src/gui/embedded/qkbddriverfactory_qws.cpp
+++ b/src/gui/embedded/qkbddriverfactory_qws.cpp
@@ -47,10 +47,8 @@
#include "qkbdtty_qws.h"
#include "qkbdlinuxinput_qws.h"
#include "qkbdum_qws.h"
-#include "qkbdsl5000_qws.h"
#include "qkbdvfb_qws.h"
-#include "qkbdyopy_qws.h"
-#include "qkbdvr41xx_qws.h"
+#include "qkbdqnx_qws.h"
#include <stdlib.h>
#include "private/qfactoryloader_p.h"
#include "qkbddriverplugin_qws.h"
@@ -104,17 +102,9 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
QWSKeyboardHandler *QKbdDriverFactory::create(const QString& key, const QString& device)
{
QString driver = key.toLower();
-#ifndef QT_NO_QWS_KBD_SL5000
- if (driver == QLatin1String("sl5000") || driver.isEmpty())
- return new QWSSL5000KeyboardHandler(device);
-#endif
-#ifndef QT_NO_QWS_KBD_YOPY
- if (driver == QLatin1String("yopy") || driver.isEmpty())
- return new QWSYopyKeyboardHandler(device);
-#endif
-#ifndef QT_NO_QWS_KBD_VR41XX
- if (driver == QLatin1String("vr41xx") || driver.isEmpty())
- return new QWSVr41xxKeyboardHandler(device);
+#if defined(Q_OS_QNX) && !defined(QT_NO_QWS_KBD_QNX)
+ if (driver == QLatin1String("qnx") || driver.isEmpty())
+ return new QWSQnxKeyboardHandler(device);
#endif
#ifndef QT_NO_QWS_KEYBOARD
# ifndef QT_NO_QWS_KBD_TTY
@@ -158,14 +148,8 @@ QStringList QKbdDriverFactory::keys()
{
QStringList list;
-#ifndef QT_NO_QWS_KBD_SL5000
- list << QLatin1String("SL5000");
-#endif
-#ifndef QT_NO_QWS_KBD_YOPY
- list << QLatin1String("YOPY");
-#endif
-#ifndef QT_NO_QWS_KBD_VR41XX
- list << QLatin1String("VR41xx");
+#if defined(Q_OS_QNX) && !defined(QT_NO_QWS_KBD_QNX)
+ list << QLatin1String("QNX");
#endif
#ifndef QT_NO_QWS_KBD_TTY
list << QLatin1String("TTY");
diff --git a/src/gui/embedded/qkbdlinuxinput_qws.cpp b/src/gui/embedded/qkbdlinuxinput_qws.cpp
index d5720f7..6aa6633 100644
--- a/src/gui/embedded/qkbdlinuxinput_qws.cpp
+++ b/src/gui/embedded/qkbdlinuxinput_qws.cpp
@@ -47,6 +47,7 @@
#include <QStringList>
#include <qplatformdefs.h>
+#include <private/qcore_unix_p.h> // overrides QT_OPEN
#include <errno.h>
#include <termios.h>
@@ -75,6 +76,7 @@ private:
int m_fd;
int m_tty_fd;
struct termios m_tty_attr;
+ int m_orig_kbmode;
};
QWSLinuxInputKeyboardHandler::QWSLinuxInputKeyboardHandler(const QString &device)
@@ -94,8 +96,7 @@ bool QWSLinuxInputKeyboardHandler::filterInputEvent(quint16 &, qint32 &)
}
QWSLinuxInputKbPrivate::QWSLinuxInputKbPrivate(QWSLinuxInputKeyboardHandler *h, const QString &device)
- : m_handler(h), m_fd(-1), m_tty_fd(-1)
-
+ : m_handler(h), m_fd(-1), m_tty_fd(-1), m_orig_kbmode(K_XLATE)
{
setObjectName(QLatin1String("LinuxInputSubsystem Keyboard Handler"));
@@ -134,7 +135,10 @@ QWSLinuxInputKbPrivate::QWSLinuxInputKbPrivate(QWSLinuxInputKeyboardHandler *h,
struct ::termios termdata;
tcgetattr(m_tty_fd, &termdata);
- // setting this tranlation mode is also needed in INPUT mode to prevent
+ // record the original mode so we can restore it again in the destructor.
+ ::ioctl(m_tty_fd, KDGKBMODE, &m_orig_kbmode);
+
+ // setting this tranlation mode is even needed in INPUT mode to prevent
// the shell from also interpreting codes, if the process has a tty
// attached: e.g. Ctrl+C wouldn't copy, but kill the application.
::ioctl(m_tty_fd, KDSKBMODE, K_MEDIUMRAW);
@@ -151,7 +155,7 @@ QWSLinuxInputKbPrivate::QWSLinuxInputKbPrivate(QWSLinuxInputKeyboardHandler *h,
tcsetattr(m_tty_fd, TCSANOW, &termdata);
}
} else {
- qWarning("Cannot open input device '%s': %s", qPrintable(dev), strerror(errno));
+ qWarning("Cannot open keyboard input device '%s': %s", qPrintable(dev), strerror(errno));
return;
}
}
@@ -159,7 +163,7 @@ QWSLinuxInputKbPrivate::QWSLinuxInputKbPrivate(QWSLinuxInputKeyboardHandler *h,
QWSLinuxInputKbPrivate::~QWSLinuxInputKbPrivate()
{
if (m_tty_fd >= 0) {
- ::ioctl(m_tty_fd, KDSKBMODE, K_XLATE);
+ ::ioctl(m_tty_fd, KDSKBMODE, m_orig_kbmode);
tcsetattr(m_tty_fd, TCSANOW, &m_tty_attr);
}
if (m_fd >= 0)
diff --git a/src/gui/embedded/qkbdqnx_qws.cpp b/src/gui/embedded/qkbdqnx_qws.cpp
new file mode 100644
index 0000000..089b868
--- /dev/null
+++ b/src/gui/embedded/qkbdqnx_qws.cpp
@@ -0,0 +1,231 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qkbdqnx_qws.h"
+#include "QtCore/qsocketnotifier.h"
+#include "QtCore/qdebug.h"
+
+#include <sys/dcmd_input.h>
+#include <photon/keycodes.h>
+
+#include "qplatformdefs.h"
+#include <errno.h>
+
+/*!
+ \class QWSQnxKeyboardHandler
+ \preliminary
+ \ingroup qws
+ \since 4.6
+ \internal
+
+ \brief The QWSQnxKeyboardHandler class implements a keyboard driver
+ for the QNX \c{devi-hid} input manager.
+
+ To be able to compile this mouse handler, \l{Qt for Embedded Linux}
+ must be configured with the \c -qt-kbd-qnx option, see the
+ \l{Qt for Embedded Linux Character Input} documentation for details.
+
+ In order to use this keyboard handler, the \c{devi-hid} input manager
+ must be set up and run with the resource manager interface (option \c{-r}).
+ Also, Photon must not be running.
+
+ Example invocation from command line: \c{/usr/photon/bin/devi-hid -Pr kbd mouse}
+ Note that after running \c{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 \c{devi-hid}.
+
+ To make \l{Qt for Embedded Linux} explicitly choose the qnx keyboard
+ handler, set the QWS_KEYBOARD environment variable to \c{qnx}. By default,
+ the first keyboard device (\c{/dev/devi/keyboard0}) is used. To override, pass a device
+ name as the first and only parameter, for example
+ \c{QWS_KEYBOARD=qnx:/dev/devi/keyboard1; export QWS_KEYBOARD}.
+
+ \sa {Qt for Embedded Linux Character Input}, {Qt for Embedded Linux}
+*/
+
+/*!
+ Constructs a keyboard handler for the specified \a device, defaulting to
+ \c{/dev/devi/keyboard0}.
+
+ Note that you should never instanciate this class, instead let QKbdDriverFactory
+ handle the keyboard handlers.
+
+ \sa QKbdDriverFactory
+ */
+QWSQnxKeyboardHandler::QWSQnxKeyboardHandler(const QString &device)
+{
+ // open the keyboard device
+ keyboardFD = QT_OPEN(device.isEmpty() ? "/dev/devi/keyboard0" : device.toLatin1().constData(),
+ QT_OPEN_RDONLY);
+ if (keyboardFD == -1) {
+ qErrnoWarning(errno, "QWSQnxKeyboardHandler: Unable to open device");
+ return;
+ }
+
+ // create a socket notifier so we'll wake up whenever keyboard input is detected.
+ QSocketNotifier *notifier = new QSocketNotifier(keyboardFD, QSocketNotifier::Read, this);
+ connect(notifier, SIGNAL(activated(int)), SLOT(socketActivated()));
+
+ qDebug() << "QWSQnxKeyboardHandler: connected.";
+
+}
+
+/*!
+ Destroys this keyboard handler and closes the connection to the keyboard device.
+ */
+QWSQnxKeyboardHandler::~QWSQnxKeyboardHandler()
+{
+ QT_CLOSE(keyboardFD);
+}
+
+/*! \internal
+ Translates the QNX keyboard events to Qt keyboard events
+ */
+void QWSQnxKeyboardHandler::socketActivated()
+{
+ _keyboard_packet packet;
+
+ // read one keyboard event
+ int bytesRead = QT_READ(keyboardFD, &packet, sizeof(_keyboard_packet));
+ if (bytesRead == -1) {
+ qErrnoWarning(errno, "QWSQnxKeyboardHandler::socketActivated(): Unable to read data.");
+ return;
+ }
+
+ // the bytes read must be the size of a keyboard packet
+ Q_ASSERT(bytesRead == sizeof(_keyboard_packet));
+
+#if 0
+ qDebug() << "keyboard got scancode"
+ << hex << packet.data.modifiers
+ << packet.data.flags
+ << packet.data.key_cap
+ << packet.data.key_sym
+ << packet.data.key_scan;
+#endif
+
+ // QNX is nice enough to translate the raw keyboard data into a QNX data structure
+ // Now we just have to translate it into a format Qt understands.
+
+ // figure out whether it's a press
+ bool isPress = packet.data.key_cap & KEY_DOWN;
+ // figure out wheter the key is still pressed and the key event is repeated
+ bool isRepeat = packet.data.key_cap & KEY_REPEAT;
+
+ Qt::Key key = Qt::Key_unknown;
+ int unicode = 0xffff;
+
+ // TODO - this switch is not complete!
+ switch (packet.data.key_scan) {
+ case KEYCODE_SPACE: key = Qt::Key_Space; unicode = 0x20; break;
+ case KEYCODE_F1: key = Qt::Key_F1; break;
+ case KEYCODE_F2: key = Qt::Key_F2; break;
+ case KEYCODE_F3: key = Qt::Key_F3; break;
+ case KEYCODE_F4: key = Qt::Key_F4; break;
+ case KEYCODE_F5: key = Qt::Key_F5; break;
+ case KEYCODE_F6: key = Qt::Key_F6; break;
+ case KEYCODE_F7: key = Qt::Key_F7; break;
+ case KEYCODE_F8: key = Qt::Key_F8; break;
+ case KEYCODE_F9: key = Qt::Key_F9; break;
+ case KEYCODE_F10: key = Qt::Key_F10; break;
+ case KEYCODE_F11: key = Qt::Key_F11; break;
+ case KEYCODE_F12: key = Qt::Key_F12; break;
+ case KEYCODE_BACKSPACE: key = Qt::Key_Backspace; break;
+ case KEYCODE_TAB: key = Qt::Key_Tab; break;
+ case KEYCODE_RETURN: key = Qt::Key_Return; break;
+ case KEYCODE_KP_ENTER: key = Qt::Key_Enter; break;
+ case KEYCODE_UP:
+ case KEYCODE_KP_UP:
+ key = Qt::Key_Up; break;
+ case KEYCODE_DOWN:
+ case KEYCODE_KP_DOWN:
+ key = Qt::Key_Down; break;
+ case KEYCODE_LEFT:
+ case KEYCODE_KP_LEFT:
+ key = Qt::Key_Left; break;
+ case KEYCODE_RIGHT:
+ case KEYCODE_KP_RIGHT:
+ key = Qt::Key_Right; break;
+ case KEYCODE_HOME:
+ case KEYCODE_KP_HOME:
+ key = Qt::Key_Home; break;
+ case KEYCODE_END:
+ case KEYCODE_KP_END:
+ key = Qt::Key_End; break;
+ case KEYCODE_PG_UP:
+ case KEYCODE_KP_PG_UP:
+ key = Qt::Key_PageUp; break;
+ case KEYCODE_PG_DOWN:
+ case KEYCODE_KP_PG_DOWN:
+ key = Qt::Key_PageDown; break;
+ case KEYCODE_INSERT:
+ case KEYCODE_KP_INSERT:
+ key = Qt::Key_Insert; break;
+ case KEYCODE_DELETE:
+ case KEYCODE_KP_DELETE:
+ key = Qt::Key_Delete; break;
+ case KEYCODE_ESCAPE:
+ key = Qt::Key_Escape; break;
+ default: // none of the above, try the key_scan directly
+ unicode = packet.data.key_scan;
+ break;
+ }
+
+ // figure out the modifiers that are currently pressed
+ Qt::KeyboardModifiers modifiers = Qt::NoModifier;
+ if (packet.data.flags & KEYMOD_SHIFT)
+ modifiers |= Qt::ShiftModifier;
+ if (packet.data.flags & KEYMOD_CTRL)
+ modifiers |= Qt::ControlModifier;
+ if (packet.data.flags & KEYMOD_ALT)
+ modifiers |= Qt::AltModifier;
+
+ // if the unicode value is not ascii, we ignore it.
+ // TODO - do a complete mapping between all QNX scan codes and Qt codes
+ if (unicode != 0xffff && !isascii(unicode))
+ return; // unprintable character
+
+ // call processKeyEvent. This is where all the magic happens to insert a
+ // key event into Qt's event loop.
+ // Note that for repeated key events, isPress must be true
+ // (on QNX, isPress is not set when the key event is repeated).
+ processKeyEvent(unicode, key, modifiers, isPress || isRepeat, isRepeat);
+}
diff --git a/src/gui/embedded/qkbdyopy_qws.h b/src/gui/embedded/qkbdqnx_qws.h
index b4e45bd..fa3ae56 100644
--- a/src/gui/embedded/qkbdyopy_qws.h
+++ b/src/gui/embedded/qkbdqnx_qws.h
@@ -39,9 +39,10 @@
**
****************************************************************************/
-#ifndef QKBDYOPY_QWS_H
-#define QKBDYOPY_QWS_H
+#ifndef QKBDQNX_QWS_H
+#define QKBDQNX_QWS_H
+#include <QtGui/qapplication.h>
#include <QtGui/qkbd_qws.h>
QT_BEGIN_HEADER
@@ -50,24 +51,26 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Gui)
-#ifndef QT_NO_QWS_KBD_YOPY
+#if !defined(QT_NO_QWS_KEYBOARD) && !defined(QT_NO_QWS_KBD_QNX)
-class QWSYopyKbPrivate;
-
-class QWSYopyKeyboardHandler : public QWSKeyboardHandler
+class Q_GUI_EXPORT QWSQnxKeyboardHandler : public QObject, public QWSKeyboardHandler
{
+ Q_OBJECT
public:
- explicit QWSYopyKeyboardHandler(const QString&);
- virtual ~QWSYopyKeyboardHandler();
+ QWSQnxKeyboardHandler(const QString &device);
+ ~QWSQnxKeyboardHandler();
+
+private Q_SLOTS:
+ void socketActivated();
private:
- QWSYopyKbPrivate *d;
+ int keyboardFD;
};
-#endif // QT_NO_QWS_KBD_YOPY
+#endif // QT_NO_QWS_KEYBOARD
QT_END_NAMESPACE
QT_END_HEADER
-#endif // QKBDYOPY_QWS_H
+#endif // QKBDQNX_QWS_H
diff --git a/src/gui/embedded/qkbdsl5000_qws.cpp b/src/gui/embedded/qkbdsl5000_qws.cpp
deleted file mode 100644
index 36cb903..0000000
--- a/src/gui/embedded/qkbdsl5000_qws.cpp
+++ /dev/null
@@ -1,365 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qkbdsl5000_qws.h"
-
-#ifndef QT_NO_QWS_KBD_SL5000
-
-#include "qwindowsystem_qws.h"
-#include "qwsutils_qws.h"
-#include "qscreen_qws.h"
-
-#include "qapplication.h"
-#include "qnamespace.h"
-#include "qtimer.h"
-
-#include <unistd.h>
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <signal.h>
-
-#include <asm/sharp_char.h>
-
-#include <string.h>
-
-QT_BEGIN_NAMESPACE
-
-static const QWSKeyMap sl5000KeyMap[] = {
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 00
- { Qt::Key_A, 'a' , 'A' , 'A'-64 }, // 01
- { Qt::Key_B, 'b' , 'B' , 'B'-64 }, // 02
- { Qt::Key_C, 'c' , 'C' , 'C'-64 }, // 03
- { Qt::Key_D, 'd' , 'D' , 'D'-64 }, // 04
- { Qt::Key_E, 'e' , 'E' , 'E'-64 }, // 05
- { Qt::Key_F, 'f' , 'F' , 'F'-64 }, // 06
- { Qt::Key_G, 'g' , 'G' , 'G'-64 }, // 07
- { Qt::Key_H, 'h' , 'H' , 'H'-64 }, // 08
- { Qt::Key_I, 'i' , 'I' , 'I'-64 }, // 09
- { Qt::Key_J, 'j' , 'J' , 'J'-64 }, // 0a 10
- { Qt::Key_K, 'k' , 'K' , 'K'-64 }, // 0b
- { Qt::Key_L, 'l' , 'L' , 'L'-64 }, // 0c
- { Qt::Key_M, 'm' , 'M' , 'M'-64 }, // 0d
- { Qt::Key_N, 'n' , 'N' , 'N'-64 }, // 0e
- { Qt::Key_O, 'o' , 'O' , 'O'-64 }, // 0f
- { Qt::Key_P, 'p' , 'P' , 'P'-64 }, // 10
- { Qt::Key_Q, 'q' , 'Q' , 'Q'-64 }, // 11
- { Qt::Key_R, 'r' , 'R' , 'R'-64 }, // 12
- { Qt::Key_S, 's' , 'S' , 'S'-64 }, // 13
- { Qt::Key_T, 't' , 'T' , 'T'-64 }, // 14 20
- { Qt::Key_U, 'u' , 'U' , 'U'-64 }, // 15
- { Qt::Key_V, 'v' , 'V' , 'V'-64 }, // 16
- { Qt::Key_W, 'w' , 'W' , 'W'-64 }, // 17
- { Qt::Key_X, 'x' , 'X' , 'X'-64 }, // 18
- { Qt::Key_Y, 'y' , 'Y' , 'Y'-64 }, // 19
- { Qt::Key_Z, 'z' , 'Z' , 'Z'-64 }, // 1a
- { Qt::Key_Shift, 0xffff , 0xffff , 0xffff }, // 1b
- { Qt::Key_Return, 13 , 13 , 0xffff }, // 1c
- { Qt::Key_F11, 0xffff , 0xffff , 0xffff }, // 1d todo
- { Qt::Key_F22, 0xffff , 0xffff , 0xffff }, // 1e 30
- { Qt::Key_Backspace, 8 , 8 , 0xffff }, // 1f
- { Qt::Key_F31, 0xffff , 0xffff , 0xffff }, // 20
- { Qt::Key_F35, 0xffff , 0xffff , 0xffff }, // 21 light
- { Qt::Key_Escape, 0xffff , 0xffff , 0xffff }, // 22
-
- // Direction key code are for *UNROTATED* display.
- { Qt::Key_Up, 0xffff , 0xffff , 0xffff }, // 23
- { Qt::Key_Right, 0xffff , 0xffff , 0xffff }, // 24
- { Qt::Key_Left, 0xffff , 0xffff , 0xffff }, // 25
- { Qt::Key_Down, 0xffff , 0xffff , 0xffff }, // 26
-
- { Qt::Key_F33, 0xffff , 0xffff , 0xffff }, // 27 OK
- { Qt::Key_F12, 0xffff , 0xffff , 0xffff }, // 28 40 home
- { Qt::Key_1, '1' , 'q' , 'Q'-64 }, // 29
- { Qt::Key_2, '2' , 'w' , 'W'-64 }, // 2a
- { Qt::Key_3, '3' , 'e' , 'E'-64 }, // 2b
- { Qt::Key_4, '4' , 'r' , 'R'-64 }, // 2c
- { Qt::Key_5, '5' , 't' , 'T'-64 }, // 2d
- { Qt::Key_6, '6' , 'y' , 'Y'-64 }, // 2e
- { Qt::Key_7, '7' , 'u' , 'U'-64 }, // 2f
- { Qt::Key_8, '8' , 'i' , 'I'-64 }, // 30
- { Qt::Key_9, '9' , 'o' , 'O'-64 }, // 31
- { Qt::Key_0, '0' , 'p' , 'P'-64 }, // 32 50
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 33
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 34
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 35
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 36
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 37
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 38
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 39
- { Qt::Key_Minus, '-' , 'b' , 'B'-64 }, // 3a
- { Qt::Key_Plus, '+' , 'n' , 'N'-64 }, // 3b
- { Qt::Key_CapsLock, 0xffff , 0xffff , 0xffff }, // 3c 60
- { Qt::Key_At, '@' , 's' , 'S'-64 }, // 3d
- { Qt::Key_Question, '?' , '?' , 0xffff }, // 3e
- { Qt::Key_Comma, ',' , ',' , 0xffff }, // 3f
- { Qt::Key_Period, '.' , '.' , 0xffff }, // 40
- { Qt::Key_Tab, 9 , '\\' , 0xffff }, // 41
- { Qt::Key_X, 0xffff , 'x' , 'X'-64 }, // 42
- { Qt::Key_C, 0xffff , 'c' , 'C'-64 }, // 43
- { Qt::Key_V, 0xffff , 'v' , 'V'-64 }, // 44
- { Qt::Key_Slash, '/' , '/' , 0xffff }, // 45
- { Qt::Key_Apostrophe, '\'' , '\'' , 0xffff }, // 46 70
- { Qt::Key_Semicolon, ';' , ';' , 0xffff }, // 47
- { Qt::Key_QuoteDbl, '\"' , '\"' , 0xffff }, // 48
- { Qt::Key_Colon, ':' , ':' , 0xffff }, // 49
- { Qt::Key_NumberSign, '#' , 'd' , 'D'-64 }, // 4a
- { Qt::Key_Dollar, '$' , 'f' , 'F'-64 }, // 4b
- { Qt::Key_Percent, '%' , 'g' , 'G'-64 }, // 4c
- { Qt::Key_Underscore, '_' , 'h' , 'H'-64 }, // 4d
- { Qt::Key_Ampersand, '&' , 'j' , 'J'-64 }, // 4e
- { Qt::Key_Asterisk, '*' , 'k' , 'K'-64 }, // 4f
- { Qt::Key_ParenLeft, '(' , 'l' , 'L'-64 }, // 50 80
- { Qt::Key_Delete, '[' , '[' , '[' }, // 51
- { Qt::Key_Z, 0xffff , 'z' , 'Z'-64 }, // 52
- { Qt::Key_Equal, '=' , 'm' , 'M'-64 }, // 53
- { Qt::Key_ParenRight, ')' , ']' , ']' }, // 54
- { Qt::Key_AsciiTilde, '~' , '^' , '^' }, // 55
- { Qt::Key_Less, '<' , '{' , '{' }, // 56
- { Qt::Key_Greater, '>' , '}' , '}' }, // 57
- { Qt::Key_F9, 0xffff , 0xffff , 0xffff }, // 58 datebook
- { Qt::Key_F10, 0xffff , 0xffff , 0xffff }, // 59 address
- { Qt::Key_F13, 0xffff , 0xffff , 0xffff }, // 5a 90 email
- { Qt::Key_F30, ' ' , ' ' , 0xffff }, // 5b select
- { Qt::Key_Space, ' ' , '|' , '`' }, // 5c
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 5d
- { Qt::Key_Exclam, '!' , 'a' , 'A'-64 }, // 5e
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 5f
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 60
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 61
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 62
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 63
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 64
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 65
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 66
- { Qt::Key_Meta, 0xffff , 0xffff , 0xffff }, // 67
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 68
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 69
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 6a
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 6b
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 6c
- { Qt::Key_F34, 0xffff , 0xffff , 0xffff }, // 6d power
- { Qt::Key_F13, 0xffff , 0xffff , 0xffff }, // 6e mail long
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 6f
- { Qt::Key_NumLock, 0xffff , 0xffff , 0xffff }, // 70
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 71
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 72
- { 0x20ac, 0xffff , 0x20ac , 0x20ac }, // 73 Euro sign
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 74
- { Qt::Key_F32, 0xffff , 0xffff , 0xffff }, // 75 Sync
- { 0, 0xffff , 0xffff , 0xffff }
-};
-
-static const int keyMSize = sizeof(sl5000KeyMap)/sizeof(QWSKeyMap)-1;
-
-QWSSL5000KeyboardHandler::QWSSL5000KeyboardHandler(const QString &device)
- : QWSTtyKeyboardHandler(device)
-{
- shift = false;
- alt = false;
- ctrl = false;
- extended = 0;
- prevuni = 0;
- prevkey = 0;
- caps = false;
- meta = false;
- fn = false;
- numLock = false;
-
- sharp_kbdctl_modifstat st;
- int dev = ::open(device.isEmpty()?"/dev/sharp_kbdctl":device.toLocal8Bit().constData(), O_RDWR);
- if (dev >= 0) {
- memset(&st, 0, sizeof(st));
- st.which = 3;
- int ret = ioctl(dev, SHARP_KBDCTL_GETMODIFSTAT, (char*)&st);
- if(!ret)
- numLock = (bool)st.stat;
- ::close(dev);
- }
-}
-
-QWSSL5000KeyboardHandler::~QWSSL5000KeyboardHandler()
-{
-}
-
-const QWSKeyMap *QWSSL5000KeyboardHandler::keyMap() const
-{
- return sl5000KeyMap;
-}
-
-bool QWSSL5000KeyboardHandler::filterKeycode(char &code)
-{
- int keyCode = Qt::Key_unknown;
- bool release = false;
-
- if (code & 0x80) {
- release = true;
- code &= 0x7f;
- }
-
- if (fn && !meta && (code >= 0x42 && code <= 0x52)) {
- ushort unicode=0;
- int scan=0;
- if (code == 0x42) { unicode='X'-'@'; scan=Qt::Key_X; } // Cut
- else if (code == 0x43) { unicode='C'-'@'; scan=Qt::Key_C; } // Copy
- else if (code == 0x44) { unicode='V'-'@'; scan=Qt::Key_V; } // Paste
- else if (code == 0x52) { unicode='Z'-'@'; scan=Qt::Key_Z; } // Undo
- if (scan) {
- processKeyEvent(unicode, scan, Qt::ControlModifier, !release, false);
- return true;
- }
- }
-
- if (code < keyMSize) {
- keyCode = keyMap()[int(code)].key_code;
- }
-
- bool repeatable = true;
-
- if (release && (keyCode == Qt::Key_F34 || keyCode == Qt::Key_F35))
- return true; // no release for power and light keys
- if ((keyCode >= Qt::Key_F1 && keyCode <= Qt::Key_F35)
- || keyCode == Qt::Key_Escape || keyCode == Qt::Key_Home
- || keyCode == Qt::Key_Shift || keyCode == Qt::Key_Meta)
- repeatable = false;
-
- if (qt_screen->isTransformed()
- && keyCode >= Qt::Key_Left && keyCode <= Qt::Key_Down)
- {
- keyCode = transformDirKey(keyCode);
- }
-
- // Ctrl-Alt-Delete exits qws
- if (ctrl && alt && keyCode == Qt::Key_Delete) {
- qApp->quit();
- }
-
- if (keyCode == Qt::Key_F22) { /* Fn key */
- fn = !release;
- } else if (keyCode == Qt::Key_NumLock) {
- if (release)
- numLock = !numLock;
- } else if (keyCode == Qt::AltModifier) {
- alt = !release;
- } else if (keyCode == Qt::ControlModifier) {
- ctrl = !release;
- } else if (keyCode == Qt::ShiftModifier) {
- shift = !release;
- } else if (keyCode == Qt::MetaModifier) {
- meta = !release;
- } else if (keyCode == Qt::Key_CapsLock && release) {
- caps = !caps;
- }
- if (keyCode != Qt::Key_unknown) {
- bool bAlt = alt;
- bool bCtrl = ctrl;
- bool bShift = shift;
- int unicode = 0;
- if (code < keyMSize) {
- bool bCaps = caps ^ shift;
- if (fn) {
- if (shift) {
- bCaps = bShift = false;
- bCtrl = true;
- }
- if (meta) {
- bCaps = bShift = true;
- bAlt = true;
- }
- } else if (meta) {
- bCaps = bShift = true;
- }
- if (code > 40 && caps) {
- // fn-keys should only react to shift, not caps
- bCaps = bShift = shift;
- }
- if (numLock) {
- if (keyCode != Qt::Key_Space && keyCode != Qt::Key_Tab)
- bCaps = bShift = false;
- }
- if (keyCode == Qt::Key_Delete && (bAlt || bCtrl)) {
- keyCode = Qt::Key_BraceLeft;
- unicode = '[';
- bCaps = bShift = bAlt = bCtrl = false;
- } else if (keyCode == Qt::Key_F31 && bCtrl) {
- keyCode = Qt::Key_QuoteLeft;
- unicode = '`';
- } else if (bCtrl)
- unicode = keyMap()[int(code)].ctrl_unicode ? keyMap()[int(code)].ctrl_unicode : 0xffff;
- else if (bCaps)
- unicode = keyMap()[int(code)].shift_unicode ? keyMap()[int(code)].shift_unicode : 0xffff;
- else
- unicode = keyMap()[int(code)].unicode ? keyMap()[int(code)].unicode : 0xffff;
- }
-
- modifiers = 0;
- if (bAlt) modifiers |= Qt::AltModifier;
- if (bCtrl) modifiers |= Qt::ControlModifier;
- if (bShift) modifiers |= Qt::ShiftModifier;
-
- // looks wrong -- WWA
- bool repeat = false;
- if (prevuni == unicode && prevkey == keyCode && !release)
- repeat = true;
-
- processKeyEvent(unicode, keyCode, modifiers, !release, repeat);
-
- if (!release) {
- prevuni = unicode;
- prevkey = keyCode;
- } else {
- prevkey = prevuni = 0;
- }
- }
-
- if (repeatable && !release)
- beginAutoRepeat(prevuni, prevkey, modifiers);
- else
- endAutoRepeat();
-
- return true;
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_QWS_KBD_SL5000
diff --git a/src/gui/embedded/qkbdsl5000_qws.h b/src/gui/embedded/qkbdsl5000_qws.h
deleted file mode 100644
index 42afbe1..0000000
--- a/src/gui/embedded/qkbdsl5000_qws.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QKBDSL5000_QWS_H
-#define QKBDSL5000_QWS_H
-
-#include <QtGui/qkbdtty_qws.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_QWS_KBD_SL5000
-
-struct QWSKeyMap {
- uint key_code;
- ushort unicode;
- ushort shift_unicode;
- ushort ctrl_unicode;
-};
-
-
-class QWSSL5000KeyboardHandler : public QWSTtyKeyboardHandler
-{
-public:
- explicit QWSSL5000KeyboardHandler(const QString&);
- virtual ~QWSSL5000KeyboardHandler();
-
- bool filterKeycode(char &keycode);
- virtual const QWSKeyMap *keyMap() const;
-
-private:
- bool shift;
- bool alt;
- bool ctrl;
- bool caps;
- uint extended:2;
- Qt::KeyboardModifiers modifiers;
- int prevuni;
- int prevkey;
- bool meta;
- bool fn;
- bool numLock;
-};
-
-#endif // QT_NO_QWS_KBD_SL5000
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QKBDSL5000_QWS_H
diff --git a/src/gui/embedded/qkbdtty_qws.cpp b/src/gui/embedded/qkbdtty_qws.cpp
index 33777eb..f107567 100644
--- a/src/gui/embedded/qkbdtty_qws.cpp
+++ b/src/gui/embedded/qkbdtty_qws.cpp
@@ -47,6 +47,7 @@
#include <QStringList>
#include <qplatformdefs.h>
+#include <private/qcore_unix_p.h> // overrides QT_OPEN
#include <errno.h>
#include <termios.h>
@@ -89,7 +90,7 @@ private:
struct termios m_tty_attr;
char m_last_keycode;
int m_vt_qws;
- int m_originalKbdMode;
+ int m_orig_kbmode;
};
@@ -110,7 +111,7 @@ bool QWSTtyKeyboardHandler::filterKeycode(char &)
}
QWSTtyKbPrivate::QWSTtyKbPrivate(QWSTtyKeyboardHandler *h, const QString &device)
- : m_handler(h), m_tty_fd(-1), m_last_keycode(0), m_vt_qws(0)
+ : m_handler(h), m_tty_fd(-1), m_last_keycode(0), m_vt_qws(0), m_orig_kbmode(K_XLATE)
{
setObjectName(QLatin1String("TTY Keyboard Handler"));
#ifndef QT_NO_QWS_SIGNALHANDLER
@@ -151,15 +152,15 @@ QWSTtyKbPrivate::QWSTtyKbPrivate(QWSTtyKeyboardHandler *h, const QString &device
tcgetattr(m_tty_fd, &termdata);
#if defined(Q_OS_LINUX)
- // record the original mode so we can restore it again in the constructor
- ::ioctl(m_tty_fd, KDGKBMODE, m_originalKbdMode);
+ // record the original mode so we can restore it again in the destructor.
+ ::ioctl(m_tty_fd, KDGKBMODE, &m_orig_kbmode);
// PLEASE NOTE:
- // The tty keycode interface can only report keycodes 0x01 .. 0x7f
+ // the tty keycode interface can only report keycodes 0x01 .. 0x7f
// KEY_MAX is however defined to 0x1ff. In practice this is sufficient
// for a PC style keyboard though.
- // we don't support K_RAW anymore - if you need, you habe to add a
- // scan- to keycode converter.
+ // we don't support K_RAW anymore - if you need that, you have to add
+ // a scan- to keycode converter yourself.
::ioctl(m_tty_fd, KDSKBMODE, K_MEDIUMRAW);
#endif
@@ -210,9 +211,10 @@ QWSTtyKbPrivate::~QWSTtyKbPrivate()
{
if (m_tty_fd >= 0) {
#if defined(Q_OS_LINUX)
- ::ioctl(m_tty_fd, KDSKBMODE, m_originalKbdMode);
+ ::ioctl(m_tty_fd, KDSKBMODE, m_orig_kbmode);
#endif
tcsetattr(m_tty_fd, TCSANOW, &m_tty_attr);
+ QT_CLOSE(m_tty_fd);
}
}
diff --git a/src/gui/embedded/qkbdvfb_qws.cpp b/src/gui/embedded/qkbdvfb_qws.cpp
index 082aac1..a44183b 100644
--- a/src/gui/embedded/qkbdvfb_qws.cpp
+++ b/src/gui/embedded/qkbdvfb_qws.cpp
@@ -55,6 +55,7 @@
#include <qwindowsystem_qws.h>
#include <qsocketnotifier.h>
#include <qapplication.h>
+#include <private/qcore_unix_p.h> // overrides QT_OPEN
QT_BEGIN_NAMESPACE
@@ -69,13 +70,13 @@ QVFbKeyboardHandler::QVFbKeyboardHandler(const QString &device)
kbdBufferLen = sizeof(QVFbKeyData) * 5;
kbdBuffer = new unsigned char [kbdBufferLen];
- if ((kbdFD = open(terminalName.toLatin1().constData(), O_RDONLY | O_NDELAY)) < 0) {
+ if ((kbdFD = QT_OPEN(terminalName.toLatin1().constData(), O_RDONLY | O_NDELAY)) < 0) {
qWarning("Cannot open %s (%s)", terminalName.toLatin1().constData(),
strerror(errno));
} else {
// Clear pending input
char buf[2];
- while (read(kbdFD, buf, 1) > 0) { }
+ while (QT_READ(kbdFD, buf, 1) > 0) { }
notifier = new QSocketNotifier(kbdFD, QSocketNotifier::Read, this);
connect(notifier, SIGNAL(activated(int)),this, SLOT(readKeyboardData()));
@@ -85,7 +86,7 @@ QVFbKeyboardHandler::QVFbKeyboardHandler(const QString &device)
QVFbKeyboardHandler::~QVFbKeyboardHandler()
{
if (kbdFD >= 0)
- close(kbdFD);
+ QT_CLOSE(kbdFD);
delete [] kbdBuffer;
}
@@ -94,7 +95,7 @@ void QVFbKeyboardHandler::readKeyboardData()
{
int n;
do {
- n = read(kbdFD, kbdBuffer+kbdIdx, kbdBufferLen - kbdIdx);
+ n = QT_READ(kbdFD, kbdBuffer+kbdIdx, kbdBufferLen - kbdIdx);
if (n > 0)
kbdIdx += n;
} while (n > 0);
diff --git a/src/gui/embedded/qkbdvr41xx_qws.cpp b/src/gui/embedded/qkbdvr41xx_qws.cpp
deleted file mode 100644
index 03c2a67..0000000
--- a/src/gui/embedded/qkbdvr41xx_qws.cpp
+++ /dev/null
@@ -1,185 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qkbdvr41xx_qws.h"
-
-#if !defined(QT_NO_QWS_KEYBOARD) && !defined(QT_NO_QWS_KBD_VR41XX)
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/ioctl.h>
-#include <fcntl.h>
-#include <termios.h>
-#include <unistd.h>
-#include <errno.h>
-
-#include <qsocketnotifier.h>
-
-QT_BEGIN_NAMESPACE
-
-class QWSVr41xxKbPrivate : public QObject
-{
- Q_OBJECT
-public:
- QWSVr41xxKbPrivate(QWSVr41xxKeyboardHandler *h, const QString&);
- virtual ~QWSVr41xxKbPrivate();
-
- bool isOpen() { return buttonFD > 0; }
-
-private slots:
- void readKeyboardData();
-
-private:
- QString terminalName;
- int buttonFD;
- int kbdIdx;
- int kbdBufferLen;
- unsigned char *kbdBuffer;
- QSocketNotifier *notifier;
- QWSVr41xxKeyboardHandler *handler;
-};
-
-QWSVr41xxKeyboardHandler::QWSVr41xxKeyboardHandler(const QString &device)
-{
- d = new QWSVr41xxKbPrivate(this, device);
-}
-
-QWSVr41xxKeyboardHandler::~QWSVr41xxKeyboardHandler()
-{
- delete d;
-}
-
-QWSVr41xxKbPrivate::QWSVr41xxKbPrivate(QWSVr41xxKeyboardHandler *h, const QString &device) : handler(h)
-{
- terminalName = device;
- if (terminalName.isEmpty())
- terminalName = QLatin1String("/dev/buttons");
- buttonFD = -1;
- notifier = 0;
-
- buttonFD = open(terminalName.toLatin1().constData(), O_RDWR | O_NDELAY, 0);;
- if (buttonFD < 0) {
- qWarning("Cannot open %s\n", qPrintable(terminalName));
- return;
- }
-
- if (buttonFD >= 0) {
- notifier = new QSocketNotifier(buttonFD, QSocketNotifier::Read, this);
- connect(notifier, SIGNAL(activated(int)),this,
- SLOT(readKeyboardData()));
- }
-
- kbdBufferLen = 80;
- kbdBuffer = new unsigned char [kbdBufferLen];
- kbdIdx = 0;
-}
-
-QWSVr41xxKbPrivate::~QWSVr41xxKbPrivate()
-{
- if (buttonFD > 0) {
- ::close(buttonFD);
- buttonFD = -1;
- }
- delete notifier;
- notifier = 0;
- delete [] kbdBuffer;
-}
-
-void QWSVr41xxKbPrivate::readKeyboardData()
-{
- int n = 0;
- do {
- n = read(buttonFD, kbdBuffer+kbdIdx, kbdBufferLen - kbdIdx);
- if (n > 0)
- kbdIdx += n;
- } while (n > 0);
-
- int idx = 0;
- while (kbdIdx - idx >= 2) {
- unsigned char *next = kbdBuffer + idx;
- unsigned short *code = (unsigned short *)next;
- int keycode = Qt::Key_unknown;
- switch ((*code) & 0x0fff) {
- case 0x7:
- keycode = Qt::Key_Up;
- break;
- case 0x9:
- keycode = Qt::Key_Right;
- break;
- case 0x8:
- keycode = Qt::Key_Down;
- break;
- case 0xa:
- keycode = Qt::Key_Left;
- break;
- case 0x3:
- keycode = Qt::Key_Up;
- break;
- case 0x4:
- keycode = Qt::Key_Down;
- break;
- case 0x1:
- keycode = Qt::Key_Return;
- break;
- case 0x2:
- keycode = Qt::Key_F4;
- break;
- default:
- qDebug("Unrecognised key sequence %d", *code);
- }
- if ((*code) & 0x8000)
- handler->processKeyEvent(0, keycode, 0, false, false);
- else
- handler->processKeyEvent(0, keycode, 0, true, false);
- idx += 2;
- }
-
- int surplus = kbdIdx - idx;
- for (int i = 0; i < surplus; i++)
- kbdBuffer[i] = kbdBuffer[idx+i];
- kbdIdx = surplus;
-}
-
-QT_END_NAMESPACE
-
-#include "qkbdvr41xx_qws.moc"
-
-#endif // QT_NO_QWS_KBD_VR41XX
diff --git a/src/gui/embedded/qkbdyopy_qws.cpp b/src/gui/embedded/qkbdyopy_qws.cpp
deleted file mode 100644
index 5c9d28d..0000000
--- a/src/gui/embedded/qkbdyopy_qws.cpp
+++ /dev/null
@@ -1,209 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*
- * YOPY buttons driver
- * Contributed by Ron Victorelli (victorrj at icubed.com)
- */
-
-#include "qkbdyopy_qws.h"
-
-#ifndef QT_NO_QWS_KBD_YOPY
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/ioctl.h>
-#include <fcntl.h>
-#include <termios.h>
-#include <unistd.h>
-#include <errno.h>
-
-#include <linux/kd.h>
-#include <linux/fb.h>
-#include <linux/yopy_button.h>
-
-extern "C" {
- int getpgid(int);
-}
-
-#include <qwidget.h>
-#include <qsocketnotifier.h>
-
-QT_BEGIN_NAMESPACE
-
-class QWSYopyKbPrivate : public QObject
-{
- Q_OBJECT
-public:
- QWSYopyKbPrivate(QWSYopyKeyboardHandler *h, const QString&);
- virtual ~QWSYopyKbPrivate();
-
- bool isOpen() { return buttonFD > 0; }
-
-private slots:
- void readKeyboardData();
-
-private:
- QString terminalName;
- int buttonFD;
- struct termios newT, oldT;
- QSocketNotifier *notifier;
- QWSYopyKeyboardHandler *handler;
-};
-
-QWSYopyKeyboardHandler::QWSYopyKeyboardHandler(const QString &device)
-{
- d = new QWSYopyKbPrivate(this, device);
-}
-
-QWSYopyKeyboardHandler::~QWSYopyKeyboardHandler()
-{
- delete d;
-}
-
-QWSYopyKbPrivate::QWSYopyKbPrivate(QWSYopyKeyboardHandler *h, const QString &device) : handler(h)
-{
- terminalName = device.isEmpty()?"/dev/tty1":device.toLatin1().constData();
- buttonFD = -1;
- notifier = 0;
-
- buttonFD = ::open(terminalName.toLatin1().constData(), O_RDWR | O_NDELAY, 0);
- if (buttonFD < 0) {
- qWarning("Cannot open %s\n", qPrintable(terminalName));
- return;
- } else {
-
- tcsetpgrp(buttonFD, getpgid(0));
-
- /* put tty into "straight through" mode.
- */
- if (tcgetattr(buttonFD, &oldT) < 0) {
- qFatal("Linux-kbd: tcgetattr failed");
- }
-
- newT = oldT;
- newT.c_lflag &= ~(ICANON | ECHO | ISIG);
- newT.c_iflag &= ~(ISTRIP | IGNCR | ICRNL | INLCR | IXOFF | IXON);
- newT.c_iflag |= IGNBRK;
- newT.c_cc[VMIN] = 0;
- newT.c_cc[VTIME] = 0;
-
-
- if (tcsetattr(buttonFD, TCSANOW, &newT) < 0) {
- qFatal("Linux-kbd: TCSANOW tcsetattr failed");
- }
-
- if (ioctl(buttonFD, KDSKBMODE, K_MEDIUMRAW) < 0) {
- qFatal("Linux-kbd: KDSKBMODE tcsetattr failed");
- }
-
- notifier = new QSocketNotifier(buttonFD, QSocketNotifier::Read, this);
- connect(notifier, SIGNAL(activated(int)),this,
- SLOT(readKeyboardData()));
- }
-}
-
-QWSYopyKbPrivate::~QWSYopyKbPrivate()
-{
- if (buttonFD > 0) {
- ::close(buttonFD);
- buttonFD = -1;
- }
-}
-
-void QWSYopyKbPrivate::readKeyboardData()
-{
- uchar buf[1];
- char c='1';
- int fd;
-
- int n=read(buttonFD,buf,1);
- if (n<0) {
- qDebug("Keyboard read error %s",strerror(errno));
- } else {
- uint code = buf[0]&YPBUTTON_CODE_MASK;
- bool press = !(buf[0]&0x80);
- // printf("Key=%d/%d/%d\n",buf[1],code,press);
- int k=(-1);
- switch(code) {
- case 39: k=Qt::Key_Up; break;
- case 44: k=Qt::Key_Down; break;
- case 41: k=Qt::Key_Left; break;
- case 42: k=Qt::Key_Right; break;
- case 56: k=Qt::Key_F1; break; //windows
- case 29: k=Qt::Key_F2; break; //cycle
- case 24: k=Qt::Key_F3; break; //record
- case 23: k=Qt::Key_F4; break; //mp3
- case 4: k=Qt::Key_F5; break; // PIMS
- case 1: k=Qt::Key_Escape; break; // Escape
- case 40: k=Qt::Key_Up; break; // prev
- case 45: k=Qt::Key_Down; break; // next
- case 35: if(!press) {
- fd = open("/proc/sys/pm/sleep",O_RDWR,0);
- if(fd >= 0) {
- write(fd,&c,sizeof(c));
- close(fd);
- //
- // Updates all widgets.
- //
- QWidgetList list = QApplication::allWidgets();
- for (int i = 0; i < list.size(); ++i) {
- QWidget *w = list.at(i);
- w->update();
- }
- }
- }
- break;
-
- default: k=(-1); break;
- }
-
- if (k >= 0) {
- handler->processKeyEvent(0, k, 0, press, false);
- }
- }
-}
-
-QT_END_NAMESPACE
-
-#include "qkbdyopy_qws.moc"
-
-#endif // QT_NO_QWS_KBD_YOPY
diff --git a/src/gui/embedded/qlock.cpp b/src/gui/embedded/qlock.cpp
index c23608f..9592a4d 100644
--- a/src/gui/embedded/qlock.cpp
+++ b/src/gui/embedded/qlock.cpp
@@ -41,9 +41,46 @@
#include "qlock_p.h"
-#ifndef QT_NO_QWS_MULTIPROCESS
+QT_BEGIN_NAMESPACE
+
+#ifdef QT_NO_QWS_MULTIPROCESS
+
+/* no multiprocess - use a dummy */
+
+QLock::QLock(const QString & /*filename*/, char /*id*/, bool /*create*/)
+ : type(Read), data(0)
+{
+}
+
+QLock::~QLock()
+{
+}
+
+bool QLock::isValid() const
+{
+ return true;
+}
+
+void QLock::lock(Type t)
+{
+ data = (QLockData *)-1;
+ type = t;
+}
+
+void QLock::unlock()
+{
+ data = 0;
+}
+
+bool QLock::locked() const
+{
+ return data;
+}
+
+#else // QT_NO_QWS_MULTIPROCESS
#include "qwssignalhandler_p.h"
+
#include <unistd.h>
#include <sys/types.h>
#if defined(Q_OS_DARWIN)
@@ -71,14 +108,10 @@ union semun {
#include <qdebug.h>
#include <signal.h>
-#endif // QT_NO_QWS_MULTIPROCESS
+#include <private/qcore_unix_p.h> // overrides QT_OPEN
#define MAX_LOCKS 200 // maximum simultaneous read locks
-QT_BEGIN_NAMESPACE
-
-
-#ifndef QT_NO_QWS_MULTIPROCESS
class QLockData
{
public:
@@ -89,7 +122,6 @@ public:
int count;
bool owned;
};
-#endif // QT_NO_QWS_MULTIPROCESS
/*!
\class QLock
@@ -124,17 +156,12 @@ public:
QLock::QLock(const QString &filename, char id, bool create)
{
-#ifdef QT_NO_QWS_MULTIPROCESS
- Q_UNUSED(filename);
- Q_UNUSED(id);
- Q_UNUSED(create);
-#else
data = new QLockData;
data->count = 0;
#ifdef Q_NO_SEMAPHORE
data->file = QString(filename+id).toLocal8Bit().constData();
for(int x = 0; x < 2; x++) {
- data->id = open(data->file, O_RDWR | (x ? O_CREAT : 0), S_IRWXU);
+ data->id = QT_OPEN(data->file, O_RDWR | (x ? O_CREAT : 0), S_IRWXU);
if(data->id != -1 || !create) {
data->owned = x;
break;
@@ -161,7 +188,6 @@ QLock::QLock(const QString &filename, char id, bool create)
qPrintable(filename), id);
qDebug() << "Error" << eno << strerror(eno);
}
-#endif
}
/*!
@@ -172,12 +198,11 @@ QLock::QLock(const QString &filename, char id, bool create)
QLock::~QLock()
{
-#ifndef QT_NO_QWS_MULTIPROCESS
if (locked())
unlock();
#ifdef Q_NO_SEMAPHORE
if(isValid()) {
- close(data->id);
+ QT_CLOSE(data->id);
if(data->owned)
unlink(data->file);
}
@@ -186,7 +211,6 @@ QLock::~QLock()
QWSSignalHandler::instance()->removeSemaphore(data->id);
#endif
delete data;
-#endif
}
/*!
@@ -198,11 +222,7 @@ QLock::~QLock()
bool QLock::isValid() const
{
-#ifndef QT_NO_QWS_MULTIPROCESS
return (data->id != -1);
-#else
- return true;
-#endif
}
/*!
@@ -219,9 +239,6 @@ bool QLock::isValid() const
void QLock::lock(Type t)
{
-#ifdef QT_NO_QWS_MULTIPROCESS
- Q_UNUSED(t);
-#else
if (!data->count) {
#ifdef Q_NO_SEMAPHORE
int op = LOCK_SH;
@@ -254,7 +271,6 @@ void QLock::lock(Type t)
#endif
}
data->count++;
-#endif
}
/*!
@@ -267,7 +283,6 @@ void QLock::lock(Type t)
void QLock::unlock()
{
-#ifndef QT_NO_QWS_MULTIPROCESS
if(data->count) {
data->count--;
if(!data->count) {
@@ -296,7 +311,6 @@ void QLock::unlock()
} else {
qDebug("Unlock without corresponding lock");
}
-#endif
}
/*!
@@ -308,11 +322,9 @@ void QLock::unlock()
bool QLock::locked() const
{
-#ifndef QT_NO_QWS_MULTIPROCESS
return (data->count > 0);
-#else
- return false;
-#endif
}
+#endif // QT_NO_QWS_MULTIPROCESS
+
QT_END_NAMESPACE
diff --git a/src/gui/embedded/qmousebus_qws.cpp b/src/gui/embedded/qmousebus_qws.cpp
deleted file mode 100644
index a88ca5b..0000000
--- a/src/gui/embedded/qmousebus_qws.cpp
+++ /dev/null
@@ -1,238 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmousebus_qws.h"
-
-#ifndef QT_NO_QWS_MOUSE_BUS
-
-#include "qwindowsystem_qws.h"
-#include "qsocketnotifier.h"
-
-#include "qapplication.h"
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <termios.h>
-
-QT_BEGIN_NAMESPACE
-
-/*
- * bus mouse driver (a.k.a. Logitech busmouse)
- */
-
-class QWSBusMouseHandlerPrivate : public QObject
-{
- Q_OBJECT
-public:
- QWSBusMouseHandlerPrivate(QWSBusMouseHandler *h, const QString &driver, const QString &device);
- ~QWSBusMouseHandlerPrivate();
-
- void suspend();
- void resume();
-
-private slots:
- void readMouseData();
-
-protected:
- enum { mouseBufSize = 128 };
- QWSBusMouseHandler *handler;
- QSocketNotifier *mouseNotifier;
- int mouseFD;
- int mouseIdx;
- int obstate;
- uchar mouseBuf[mouseBufSize];
-};
-
-QWSBusMouseHandler::QWSBusMouseHandler(const QString &driver, const QString &device)
- : QWSMouseHandler(driver, device)
-{
- d = new QWSBusMouseHandlerPrivate(this, driver, device);
-}
-
-QWSBusMouseHandler::~QWSBusMouseHandler()
-{
- delete d;
-}
-
-void QWSBusMouseHandler::suspend()
-{
- d->suspend();
-}
-
-void QWSBusMouseHandler::resume()
-{
- d->resume();
-}
-
-
-QWSBusMouseHandlerPrivate::QWSBusMouseHandlerPrivate(QWSBusMouseHandler *h,
- const QString &, const QString &device)
- : handler(h)
-
-{
- QString mouseDev = device;
- if (mouseDev.isEmpty())
- mouseDev = QLatin1String("/dev/mouse");
- obstate = -1;
- mouseFD = -1;
- mouseFD = open(mouseDev.toLocal8Bit(), O_RDWR | O_NDELAY);
- if (mouseFD < 0)
- mouseFD = open(mouseDev.toLocal8Bit(), O_RDONLY | O_NDELAY);
- if (mouseFD < 0)
- qDebug("Cannot open %s (%s)", qPrintable(mouseDev), strerror(errno));
-
- // Clear pending input
- tcflush(mouseFD,TCIFLUSH);
- usleep(50000);
-
- char buf[100]; // busmouse driver will not read if bufsize < 3, YYD
- while (read(mouseFD, buf, 100) > 0) { } // eat unwanted replies
-
- mouseIdx = 0;
-
- mouseNotifier = new QSocketNotifier(mouseFD, QSocketNotifier::Read, this);
- connect(mouseNotifier, SIGNAL(activated(int)),this, SLOT(readMouseData()));
-}
-
-QWSBusMouseHandlerPrivate::~QWSBusMouseHandlerPrivate()
-{
- if (mouseFD >= 0) {
- tcflush(mouseFD,TCIFLUSH); // yyd.
- close(mouseFD);
- }
-}
-
-
-void QWSBusMouseHandlerPrivate::suspend()
-{
- mouseNotifier->setEnabled(false);
-}
-
-
-void QWSBusMouseHandlerPrivate::resume()
-{
- mouseIdx = 0;
- obstate = -1;
- mouseNotifier->setEnabled(true);
-}
-
-void QWSBusMouseHandlerPrivate::readMouseData()
-{
- int n;
- // It'll only read 3 bytes a time and return all other buffer zeroed, thus cause protocol errors
- for (;;) {
- if (mouseBufSize - mouseIdx < 3)
- break;
- n = read(mouseFD, mouseBuf+mouseIdx, 3);
- if (n != 3)
- break;
- mouseIdx += 3;
- }
-
- static const int accel_limit = 5;
- static const int accel = 2;
-
- int idx = 0;
- int bstate = 0;
- int dx = 0, dy = 0;
- bool sendEvent = false;
- int tdx = 0, tdy = 0;
-
- while (mouseIdx-idx >= 3) {
-#if 0 // debug
- qDebug("Got mouse data");
-#endif
- uchar *mb = mouseBuf+idx;
- bstate = 0;
- dx = 0;
- dy = 0;
- sendEvent = false;
- if (((mb[0] & 0x04)))
- bstate |= Qt::LeftButton;
- if (((mb[0] & 0x01)))
- bstate |= Qt::RightButton;
-
- dx=(signed char)mb[1];
- dy=(signed char)mb[2];
- sendEvent=true;
-
- if (sendEvent) {
- if (qAbs(dx) > accel_limit || qAbs(dy) > accel_limit) {
- dx *= accel;
- dy *= accel;
- }
- tdx += dx;
- tdy += dy;
- if (bstate != obstate) {
- QPoint pos = handler->pos() + QPoint(tdx,-tdy);
- handler->limitToScreen(pos);
- handler->mouseChanged(pos,bstate);
- sendEvent = false;
- tdx = 0;
- tdy = 0;
- obstate = bstate;
- }
- }
- idx += 3;
- }
- if (sendEvent) {
- QPoint pos = handler->pos() + QPoint(tdx,-tdy);
- handler->limitToScreen(pos);
- handler->mouseChanged(pos,bstate);
- }
-
- int surplus = mouseIdx - idx;
- for (int i = 0; i < surplus; i++)
- mouseBuf[i] = mouseBuf[idx+i];
- mouseIdx = surplus;
-}
-
-QT_END_NAMESPACE
-
-#include "qmousebus_qws.moc"
-
-#endif // QT_NO_QWS_MOUSE_BUS
diff --git a/src/gui/embedded/qmousedriverfactory_qws.cpp b/src/gui/embedded/qmousedriverfactory_qws.cpp
index 7e51818..6d71750 100644
--- a/src/gui/embedded/qmousedriverfactory_qws.cpp
+++ b/src/gui/embedded/qmousedriverfactory_qws.cpp
@@ -43,12 +43,11 @@
#include "qapplication.h"
#include "qmousepc_qws.h"
-#include "qmousebus_qws.h"
-#include "qmousevr41xx_qws.h"
-#include "qmouseyopy_qws.h"
#include "qmouselinuxtp_qws.h"
+#include "qmouselinuxinput_qws.h"
#include "qmousevfb_qws.h"
#include "qmousetslib_qws.h"
+#include "qmouseqnx_qws.h"
#include <stdlib.h>
#include "private/qfactoryloader_p.h"
#include "qmousedriverplugin_qws.h"
@@ -104,18 +103,14 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
QWSMouseHandler *QMouseDriverFactory::create(const QString& key, const QString &device)
{
QString driver = key.toLower();
+#if defined(Q_OS_QNX) && !defined(QT_NO_QWS_MOUSE_QNX)
+ if (driver == QLatin1String("qnx") || driver.isEmpty())
+ return new QQnxMouseHandler(key, device);
+#endif
#ifndef QT_NO_QWS_MOUSE_LINUXTP
if (driver == QLatin1String("linuxtp") || driver.isEmpty())
return new QWSLinuxTPMouseHandler(key, device);
#endif
-#ifndef QT_NO_QWS_MOUSE_YOPY
- if (driver == QLatin1String("yopy") || driver.isEmpty())
- return new QWSYopyMouseHandler(key, device);
-#endif
-#ifndef QT_NO_QWS_MOUSE_VR41XX
- if (driver == QLatin1String("vr41xx") || driver.isEmpty())
- return new QWSVr41xxMouseHandler(key, device);
-#endif
#ifndef QT_NO_QWS_MOUSE_PC
if (driver == QLatin1String("auto")
|| driver == QLatin1String("intellimouse")
@@ -126,14 +121,16 @@ QWSMouseHandler *QMouseDriverFactory::create(const QString& key, const QString &
return new QWSPcMouseHandler(key, device);
}
#endif
-#ifndef QT_NO_QWS_MOUSE_BUS
- if (driver == QLatin1String("bus"))
- return new QWSBusMouseHandler(key, device);
-#endif
#ifndef QT_NO_QWS_MOUSE_TSLIB
if (driver == QLatin1String("tslib") || driver.isEmpty())
return new QWSTslibMouseHandler(key, device);
#endif
+# ifndef QT_NO_QWS_MOUSE_LINUXINPUT
+ if (driver == QLatin1String("linuxinput") || \
+ driver == QLatin1String("usb") || \
+ driver == QLatin1String("linuxis"))
+ return new QWSLinuxInputMouseHandler(device);
+# endif
#ifndef QT_NO_QWS_MOUSE_QVFB
if (driver == QLatin1String("qvfbmouse") || driver == QLatin1String("qvfb"))
return new QVFbMouseHandler(key, device);
@@ -157,15 +154,12 @@ QStringList QMouseDriverFactory::keys()
{
QStringList list;
+#if defined(Q_OS_QNX) && !defined(QT_NO_QWS_MOUSE_QNX)
+ list << QLatin1String("QNX");
+#endif
#ifndef QT_NO_QWS_MOUSE_LINUXTP
list << QLatin1String("LinuxTP");
#endif
-#ifndef QT_NO_QWS_MOUSE_YOPY
- list << QLatin1String("Yopy");
-#endif
-#ifndef QT_NO_QWS_MOUSE_VR41XX
- list << QLatin1String("VR41xx");
-#endif
#ifndef QT_NO_QWS_MOUSE_PC
list << QLatin1String("Auto")
<< QLatin1String("IntelliMouse")
@@ -173,12 +167,12 @@ QStringList QMouseDriverFactory::keys()
<< QLatin1String("MouseSystems")
<< QLatin1String("MouseMan");
#endif
-#ifndef QT_NO_QWS_MOUSE_BUS
- list << QLatin1String("Bus");
-#endif
#ifndef QT_NO_QWS_MOUSE_TSLIB
list << QLatin1String("Tslib");
#endif
+#ifndef QT_NO_QWS_MOUSE_LINUXINPUT
+ list << QLatin1String("LinuxInput");
+#endif
#if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL)
#ifndef QT_NO_LIBRARY
diff --git a/src/gui/embedded/qmouselinuxinput_qws.cpp b/src/gui/embedded/qmouselinuxinput_qws.cpp
new file mode 100644
index 0000000..6ea8807
--- /dev/null
+++ b/src/gui/embedded/qmouselinuxinput_qws.cpp
@@ -0,0 +1,205 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmouselinuxinput_qws.h"
+
+#include <QScreen>
+#include <QSocketNotifier>
+
+#include <qplatformdefs.h>
+#include <private/qcore_unix_p.h> // overrides QT_OPEN
+
+#include <errno.h>
+
+#include <linux/input.h>
+
+QT_BEGIN_NAMESPACE
+
+
+class QWSLinuxInputMousePrivate : public QObject
+{
+ Q_OBJECT
+public:
+ QWSLinuxInputMousePrivate(QWSLinuxInputMouseHandler *, const QString &);
+ ~QWSLinuxInputMousePrivate();
+
+ void enable(bool on);
+
+private Q_SLOTS:
+ void readMouseData();
+
+private:
+ QWSLinuxInputMouseHandler *m_handler;
+ QSocketNotifier * m_notify;
+ int m_fd;
+ int m_x, m_y;
+ int m_buttons;
+};
+
+QWSLinuxInputMouseHandler::QWSLinuxInputMouseHandler(const QString &device)
+ : QWSCalibratedMouseHandler(device)
+{
+ d = new QWSLinuxInputMousePrivate(this, device);
+}
+
+QWSLinuxInputMouseHandler::~QWSLinuxInputMouseHandler()
+{
+ delete d;
+}
+
+void QWSLinuxInputMouseHandler::suspend()
+{
+ d->enable(false);
+}
+
+void QWSLinuxInputMouseHandler::resume()
+{
+ d->enable(true);
+}
+
+QWSLinuxInputMousePrivate::QWSLinuxInputMousePrivate(QWSLinuxInputMouseHandler *h, const QString &device)
+ : m_handler(h), m_notify(0), m_x(0), m_y(0), m_buttons(0)
+{
+ setObjectName(QLatin1String("LinuxInputSubsystem Mouse Handler"));
+
+ QString dev = QLatin1String("/dev/input/event0");
+ if (device.startsWith(QLatin1String("/dev/")))
+ dev = device;
+
+ m_fd = QT_OPEN(dev.toLocal8Bit().constData(), O_RDONLY | O_NDELAY, 0);
+ if (m_fd >= 0) {
+ m_notify = new QSocketNotifier(m_fd, QSocketNotifier::Read, this);
+ connect(m_notify, SIGNAL(activated(int)), this, SLOT(readMouseData()));
+ } else {
+ qWarning("Cannot open mouse input device '%s': %s", qPrintable(dev), strerror(errno));
+ return;
+ }
+}
+
+QWSLinuxInputMousePrivate::~QWSLinuxInputMousePrivate()
+{
+ if (m_fd >= 0)
+ QT_CLOSE(m_fd);
+}
+
+void QWSLinuxInputMousePrivate::enable(bool on)
+{
+ if (m_notify)
+ m_notify->setEnabled(on);
+}
+
+void QWSLinuxInputMousePrivate::readMouseData()
+{
+ if (!qt_screen)
+ return;
+
+ struct ::input_event buffer[32];
+ int n = 0;
+
+ forever {
+ n = QT_READ(m_fd, reinterpret_cast<char *>(buffer) + n, sizeof(buffer) - n);
+
+ if (n == 0) {
+ qWarning("Got EOF from the input device.");
+ return;
+ } else if (n < 0 && (errno != EINTR && errno != EAGAIN)) {
+ qWarning("Could not read from input device: %s", strerror(errno));
+ return;
+ } else if (n % sizeof(buffer[0]) == 0) {
+ break;
+ }
+ }
+
+ n /= sizeof(buffer[0]);
+
+ for (int i = 0; i < n; ++i) {
+ struct ::input_event *data = &buffer[i];
+
+ bool unknown = false;
+ if (data->type == EV_ABS) {
+ if (data->code == ABS_X) {
+ m_x = data->value;
+ } else if (data->code == ABS_Y) {
+ m_y = data->value;
+ } else {
+ unknown = true;
+ }
+ } else if (data->type == EV_REL) {
+ if (data->code == REL_X) {
+ m_x += data->value;
+ } else if (data->code == REL_Y) {
+ m_y += data->value;
+ } else {
+ unknown = true;
+ }
+ } else if (data->type == EV_KEY && data->code == BTN_TOUCH) {
+ m_buttons = data->value ? Qt::LeftButton : 0;
+ } else if (data->type == EV_KEY) {
+ int button = 0;
+ switch (data->code) {
+ case BTN_LEFT: button = Qt::LeftButton; break;
+ case BTN_MIDDLE: button = Qt::MidButton; break;
+ case BTN_RIGHT: button = Qt::RightButton; break;
+ }
+ if (data->value)
+ m_buttons |= button;
+ else
+ m_buttons &= ~button;
+ } else if (data->type == EV_SYN && data->code == SYN_REPORT) {
+ QPoint pos(m_x, m_y);
+ pos = m_handler->transform(pos);
+ m_handler->limitToScreen(pos);
+ m_handler->mouseChanged(pos, m_buttons);
+ } else if (data->type == EV_MSC && data->code == MSC_SCAN) {
+ // kernel encountered an unmapped key - just ignore it
+ continue;
+ } else {
+ unknown = true;
+ }
+ if (unknown) {
+ qWarning("unknown mouse event type=%x, code=%x, value=%x", data->type, data->code, data->value);
+ }
+ }
+}
+
+QT_END_NAMESPACE
+
+#include "qmouselinuxinput_qws.moc"
diff --git a/src/gui/embedded/qmousevr41xx_qws.h b/src/gui/embedded/qmouselinuxinput_qws.h
index 46d07e0..25e351f 100644
--- a/src/gui/embedded/qmousevr41xx_qws.h
+++ b/src/gui/embedded/qmouselinuxinput_qws.h
@@ -3,7 +3,7 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the QtGui module of the Qt Toolkit.
+** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -39,10 +39,10 @@
**
****************************************************************************/
-#ifndef QMOUSEVR41XX_QWS_H
-#define QMOUSEVR41XX_QWS_H
+#ifndef QMOUSELINUXINPUT_QWS_H
+#define QMOUSELINUXINPUT_QWS_H
-#include <QtGui/qmouse_qws.h>
+#include <QtGui/QWSCalibratedMouseHandler>
QT_BEGIN_HEADER
@@ -50,31 +50,29 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Gui)
-#ifndef QT_NO_QWS_MOUSE_VR41XX
+#ifndef QT_NO_QWS_MOUSE_LINUXINPUT
-class QWSVr41xxMouseHandlerPrivate;
+class QWSLinuxInputMousePrivate;
-class QWSVr41xxMouseHandler : public QWSCalibratedMouseHandler
+class QWSLinuxInputMouseHandler : public QWSCalibratedMouseHandler
{
public:
- explicit QWSVr41xxMouseHandler(const QString & = QString(),
- const QString & = QString());
- ~QWSVr41xxMouseHandler();
+ QWSLinuxInputMouseHandler(const QString &);
+ ~QWSLinuxInputMouseHandler();
- void resume();
void suspend();
-
-protected:
- QWSVr41xxMouseHandlerPrivate *d;
+ void resume();
private:
- friend class QWSVr41xxMouseHandlerPrivate;
+ QWSLinuxInputMousePrivate *d;
+
+ friend class QWSLinuxInputMousePrivate;
};
-#endif // QT_NO_QWS_MOUSE_VR41XX
+#endif // QT_NO_QWS_MOUSE_LINUXINPUT
QT_END_NAMESPACE
QT_END_HEADER
-#endif // QMOUSEVR41XX_QWS_H
+#endif // QMOUSELINUXINPUT_QWS_H
diff --git a/src/gui/embedded/qmouselinuxtp_qws.cpp b/src/gui/embedded/qmouselinuxtp_qws.cpp
index 1b4d96e..e64407e 100644
--- a/src/gui/embedded/qmouselinuxtp_qws.cpp
+++ b/src/gui/embedded/qmouselinuxtp_qws.cpp
@@ -47,6 +47,7 @@
#include "qtimer.h"
#include "qapplication.h"
#include "qscreen_qws.h"
+#include <private/qcore_unix_p.h> // overrides QT_OPEN
#include <unistd.h>
#include <stdlib.h>
@@ -190,7 +191,7 @@ QWSLinuxTPMouseHandlerPrivate::QWSLinuxTPMouseHandlerPrivate(QWSLinuxTPMouseHand
} else {
mousedev = device;
}
- if ((mouseFD = open(mousedev.toLatin1().constData(), O_RDONLY | O_NDELAY)) < 0) {
+ if ((mouseFD = QT_OPEN(mousedev.toLatin1().constData(), O_RDONLY | O_NDELAY)) < 0) {
qWarning("Cannot open %s (%s)", qPrintable(mousedev), strerror(errno));
return;
}
@@ -205,7 +206,7 @@ QWSLinuxTPMouseHandlerPrivate::QWSLinuxTPMouseHandlerPrivate(QWSLinuxTPMouseHand
QWSLinuxTPMouseHandlerPrivate::~QWSLinuxTPMouseHandlerPrivate()
{
if (mouseFD >= 0)
- close(mouseFD);
+ QT_CLOSE(mouseFD);
}
void QWSLinuxTPMouseHandlerPrivate::suspend()
@@ -233,7 +234,7 @@ void QWSLinuxTPMouseHandlerPrivate::readMouseData()
int n;
do {
- n = read(mouseFD, mouseBuf+mouseIdx, mouseBufSize-mouseIdx);
+ n = QT_READ(mouseFD, mouseBuf+mouseIdx, mouseBufSize-mouseIdx);
if (n > 0)
mouseIdx += n;
} while (n > 0 && mouseIdx < mouseBufSize);
diff --git a/src/gui/embedded/qmousepc_qws.cpp b/src/gui/embedded/qmousepc_qws.cpp
index a9f2bc8..2d62772 100644
--- a/src/gui/embedded/qmousepc_qws.cpp
+++ b/src/gui/embedded/qmousepc_qws.cpp
@@ -55,6 +55,7 @@
#include "qfile.h"
#include "qtextstream.h"
#include "qstringlist.h"
+#include <private/qcore_unix_p.h> // overrides QT_OPEN
#include <unistd.h>
#include <stdlib.h>
@@ -107,7 +108,7 @@ public:
{
if (fd != f) {
f = fd;
- close(fd);
+ QT_CLOSE(fd);
}
}
@@ -170,7 +171,7 @@ public:
}
static const uchar initseq[] = { 243, 200, 243, 100, 243, 80 };
static const uchar query[] = { 0xf2 };
- if (write(fd, initseq, sizeof(initseq))!=sizeof(initseq)) {
+ if (QT_WRITE(fd, initseq, sizeof(initseq))!=sizeof(initseq)) {
badness = 100;
return;
}
@@ -180,12 +181,12 @@ public:
perror("QWSPcMouseSubHandler_intellimouse: post-init tcflush");
#endif
}
- if (write(fd, query, sizeof(query))!=sizeof(query)) {
+ if (QT_WRITE(fd, query, sizeof(query))!=sizeof(query)) {
badness = 100;
return;
}
usleep(10000);
- n = read(fd, reply, 20);
+ n = QT_READ(fd, reply, 20);
if (n > 0) {
goodness = 10;
switch (reply[n-1]) {
@@ -256,13 +257,13 @@ public:
perror("QWSPcMouseSubHandler_mouseman: initial tcflush");
#endif
}
- write(fd,"",1);
+ QT_WRITE(fd,"",1);
usleep(50000);
- write(fd,"@EeI!",5);
+ QT_WRITE(fd,"@EeI!",5);
usleep(10000);
static const char ibuf[] = { 246, 244 };
- write(fd,ibuf,1);
- write(fd,ibuf+1,1);
+ QT_WRITE(fd,ibuf,1);
+ QT_WRITE(fd,ibuf+1,1);
if (tcflush(fd,TCIOFLUSH) == -1) {
#ifdef QWS_MOUSE_DEBUG
perror("QWSPcMouseSubHandler_mouseman: tcflush");
@@ -271,7 +272,7 @@ public:
usleep(10000);
char buf[100];
- while (read(fd, buf, 100) > 0) { } // eat unwanted replies
+ while (QT_READ(fd, buf, 100) > 0) { } // eat unwanted replies
}
int tryData()
@@ -331,7 +332,7 @@ protected:
tty.c_oflag = 0;
tty.c_lflag = 0;
tty.c_cflag = f | CREAD | CLOCAL | HUPCL;
-#if !defined(Q_OS_DARWIN) && !defined(Q_OS_SOLARIS) && !defined(Q_OS_INTEGRITY)
+#ifdef Q_OS_LINUX
tty.c_line = 0;
#endif
tty.c_cc[VTIME] = 0;
@@ -350,7 +351,7 @@ private:
for (int n = 0; n < 4; n++) {
setflags(CSTOPB | speed[n]);
- write(fd, "*q", 2);
+ QT_WRITE(fd, "*q", 2);
usleep(10000);
}
}
@@ -369,7 +370,7 @@ public:
{
setflags(B1200|CS8|CSTOPB);
// 60Hz
- if (write(fd, "R", 1)!=1) {
+ if (QT_WRITE(fd, "R", 1)!=1) {
badness = 100;
return;
}
@@ -418,7 +419,7 @@ public:
{
setflags(B1200|CS7);
// 60Hz
- if (write(fd, "R", 1)!=1) {
+ if (QT_WRITE(fd, "R", 1)!=1) {
badness = 100;
return;
}
@@ -648,25 +649,25 @@ void QWSPcMouseHandlerPrivate::openDevices()
if (drv == QLatin1String("intellimouse")) {
if (dev.isEmpty())
dev = "/dev/psaux";
- fd = open(dev, O_RDWR | O_NDELAY);
+ fd = QT_OPEN(dev, O_RDWR | O_NDELAY);
if (fd >= 0)
sub[nsub++] = new QWSPcMouseSubHandler_intellimouse(fd);
} else if (drv == QLatin1String("microsoft")) {
if (dev.isEmpty())
dev = "/dev/ttyS0";
- fd = open(dev, O_RDWR | O_NDELAY);
+ fd = QT_OPEN(dev, O_RDWR | O_NDELAY);
if (fd >= 0)
sub[nsub++] = new QWSPcMouseSubHandler_ms(fd);
} else if (drv == QLatin1String("mousesystems")) {
if (dev.isEmpty())
dev = "/dev/ttyS0";
- fd = open(dev, O_RDWR | O_NDELAY);
+ fd = QT_OPEN(dev, O_RDWR | O_NDELAY);
if (fd >= 0)
sub[nsub++] = new QWSPcMouseSubHandler_mousesystems(fd);
} else if (drv == QLatin1String("mouseman")) {
if (dev.isEmpty())
dev = "/dev/psaux";
- fd = open(dev, O_RDWR | O_NDELAY);
+ fd = QT_OPEN(dev, O_RDWR | O_NDELAY);
if (fd >= 0)
sub[nsub++] = new QWSPcMouseSubHandler_mouseman(fd);
}
@@ -677,12 +678,12 @@ void QWSPcMouseHandlerPrivate::openDevices()
dev.constData(), strerror(errno));
} else {
// Try automatically
- fd = open("/dev/psaux", O_RDWR | O_NDELAY);
+ fd = QT_OPEN("/dev/psaux", O_RDWR | O_NDELAY);
if (fd >= 0) {
sub[nsub++] = new QWSPcMouseSubHandler_intellimouse(fd);
notify(fd);
}
- fd = open("/dev/input/mice", O_RDWR | O_NDELAY);
+ fd = QT_OPEN("/dev/input/mice", O_RDWR | O_NDELAY);
if (fd >= 0) {
sub[nsub++] = new QWSPcMouseSubHandler_intellimouse(fd);
notify(fd);
@@ -694,7 +695,7 @@ void QWSPcMouseHandlerPrivate::openDevices()
#if 0
const char fn[4][11] = { "/dev/ttyS0", "/dev/ttyS1", "/dev/ttyS2", "/dev/ttyS3" };
for (int ch = 0; ch < 4; ++ch) {
- fd = open(fn[ch], O_RDWR | O_NDELAY);
+ fd = QT_OPEN(fn[ch], O_RDWR | O_NDELAY);
if (fd >= 0) {
//sub[nsub++] = new QWSPcMouseSubHandler_intellimouse(fd);
sub[nsub++] = new QWSPcMouseSubHandler_mousesystems(fd);
diff --git a/src/gui/embedded/qmouseqnx_qws.cpp b/src/gui/embedded/qmouseqnx_qws.cpp
new file mode 100644
index 0000000..59cd5be
--- /dev/null
+++ b/src/gui/embedded/qmouseqnx_qws.cpp
@@ -0,0 +1,190 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qplatformdefs.h"
+#include "qmouseqnx_qws.h"
+
+#include "qsocketnotifier.h"
+#include "qdebug.h"
+
+#include <sys/dcmd_input.h>
+
+#include <errno.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QQnxMouseHandler
+ \preliminary
+ \ingroup qws
+ \internal
+ \since 4.6
+
+ \brief The QQnxMouseHandler class implements a mouse driver
+ for the QNX \c{devi-hid} input manager.
+
+ To be able to compile this mouse handler, \l{Qt for Embedded Linux}
+ must be configured with the \c -qt-mouse-qnx option, see the
+ \l{Qt for Embedded Linux Pointer Handling}{Pointer Handling} documentation for details.
+
+ In order to use this mouse handler, the \c{devi-hid} input manager
+ must be set up and run with the resource manager interface (option \c{-r}).
+ Also, Photon must not be running.
+
+ Example invocation from command line: \c{/usr/photon/bin/devi-hid -Pr kbd mouse}
+ Note that after running \c{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 \c{devi-hid}.
+
+ To make \l{Qt for Embedded Linux} explicitly choose the qnx mouse
+ handler, set the QWS_MOUSE_PROTO environment variable to \c{qnx}. By default,
+ the first mouse device (\c{/dev/devi/mouse0}) is used. To override, pass a device
+ name as the first and only parameter, for example
+ \c{QWS_MOUSE_PROTO=qnx:/dev/devi/mouse1; export QWS_MOUSE_PROTO}.
+
+ \sa {Qt for Embedded Linux Pointer Handling}{Pointer Handling}, {Qt for Embedded Linux}
+*/
+
+/*!
+ Constructs a mouse handler for the specified \a device, defaulting to \c{/dev/devi/mouse0}.
+ The \a driver parameter must be \c{"qnx"}.
+
+ Note that you should never instanciate this class, instead let QMouseDriverFactory
+ handle the mouse handlers.
+
+ \sa QMouseDriverFactory
+ */
+QQnxMouseHandler::QQnxMouseHandler(const QString & /*driver*/, const QString &device)
+{
+ // open the mouse device with O_NONBLOCK so reading won't block when there's no data
+ mouseFD = QT_OPEN(device.isEmpty() ? "/dev/devi/mouse0" : device.toLatin1().constData(),
+ QT_OPEN_RDONLY | O_NONBLOCK);
+ if (mouseFD == -1) {
+ qErrnoWarning(errno, "QQnxMouseHandler: Unable to open mouse device");
+ return;
+ }
+
+ // register a socket notifier on the file descriptor so we'll wake up whenever
+ // there's a mouse move waiting for us.
+ mouseNotifier = new QSocketNotifier(mouseFD, QSocketNotifier::Read, this);
+ connect(mouseNotifier, SIGNAL(activated(int)), SLOT(socketActivated()));
+
+ qDebug() << "QQnxMouseHandler: connected.";
+}
+
+/*!
+ Destroys this mouse handler and closes the connection to the mouse device.
+ */
+QQnxMouseHandler::~QQnxMouseHandler()
+{
+ QT_CLOSE(mouseFD);
+}
+
+/*! \reimp */
+void QQnxMouseHandler::resume()
+{
+ if (mouseNotifier)
+ mouseNotifier->setEnabled(true);
+}
+
+/*! \reimp */
+void QQnxMouseHandler::suspend()
+{
+ if (mouseNotifier)
+ mouseNotifier->setEnabled(false);
+}
+
+/*! \internal
+
+ This function is called whenever there is activity on the mouse device.
+ By default, it reads up to 10 mouse move packets and calls mouseChanged()
+ for each of them.
+*/
+void QQnxMouseHandler::socketActivated()
+{
+ // _mouse_packet is a QNX structure. devi-hid is nice enough to translate
+ // the raw byte data from mouse devices into generic format for us.
+ _mouse_packet packet;
+
+ int iteration = 0;
+
+ // read mouse events in batches of 10. Since we're getting quite a lot
+ // of mouse events, it's better to do them in batches than to return to the
+ // event loop every time.
+ do {
+ int bytesRead = QT_READ(mouseFD, &packet, sizeof(packet));
+ if (bytesRead == -1) {
+ // EAGAIN means that there are no more mouse events to read
+ if (errno != EAGAIN)
+ qErrnoWarning(errno, "QQnxMouseHandler: Unable to read from socket");
+ return;
+ }
+
+ // bytes read should always be equal to the size of a packet.
+ Q_ASSERT(bytesRead == sizeof(packet));
+
+ // translate the coordinates from the QNX data structure to Qt coordinates
+ // note the swapped y axis
+ QPoint pos = mousePos;
+ pos += QPoint(packet.dx, -packet.dy);
+
+ // QNX only tells us relative mouse movements, not absolute ones, so limit the
+ // cursor position manually to the screen
+ limitToScreen(pos);
+
+ // translate the QNX mouse button bitmask to Qt buttons
+ int buttons = Qt::NoButton;
+
+ if (packet.hdr.buttons & _POINTER_BUTTON_LEFT)
+ buttons |= Qt::LeftButton;
+ if (packet.hdr.buttons & _POINTER_BUTTON_MIDDLE)
+ buttons |= Qt::MidButton;
+ if (packet.hdr.buttons & _POINTER_BUTTON_RIGHT)
+ buttons |= Qt::RightButton;
+
+ // call mouseChanged() - this does all the magic to actually move the on-screen
+ // mouse cursor.
+ mouseChanged(pos, buttons, 0);
+ } while (++iteration < 11);
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/gui/embedded/qmousebus_qws.h b/src/gui/embedded/qmouseqnx_qws.h
index 407da98..f8cad4a 100644
--- a/src/gui/embedded/qmousebus_qws.h
+++ b/src/gui/embedded/qmouseqnx_qws.h
@@ -39,9 +39,10 @@
**
****************************************************************************/
-#ifndef QMOUSEBUS_QWS_H
-#define QMOUSEBUS_QWS_H
+#ifndef QMOUSE_QNX_H
+#define QMOUSE_QNX_H
+#include <QtCore/qobject.h>
#include <QtGui/qmouse_qws.h>
QT_BEGIN_HEADER
@@ -50,27 +51,29 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Gui)
-#ifndef QT_NO_QWS_MOUSE_BUS
+class QSocketNotifier;
-class QWSBusMouseHandlerPrivate;
-
-class QWSBusMouseHandler : public QWSMouseHandler
+class Q_GUI_EXPORT QQnxMouseHandler : public QObject, public QWSMouseHandler
{
+ Q_OBJECT
public:
- explicit QWSBusMouseHandler(const QString & = QString(),
- const QString & = QString());
- ~QWSBusMouseHandler();
+ explicit QQnxMouseHandler(const QString &driver = QString(),
+ const QString &device = QString());
+ ~QQnxMouseHandler();
- void suspend();
void resume();
-protected:
- QWSBusMouseHandlerPrivate *d;
-};
+ void suspend();
+
+private Q_SLOTS:
+ void socketActivated();
-#endif // QT_NO_QWS_MOUSE_BUS
+private:
+ QSocketNotifier *mouseNotifier;
+ int mouseFD;
+};
QT_END_NAMESPACE
QT_END_HEADER
-#endif // QMOUSEBUS_QWS_H
+#endif // QMOUSE_QWS_H
diff --git a/src/gui/embedded/qmousevfb_qws.cpp b/src/gui/embedded/qmousevfb_qws.cpp
index 17d051f..dd553bc 100644
--- a/src/gui/embedded/qmousevfb_qws.cpp
+++ b/src/gui/embedded/qmousevfb_qws.cpp
@@ -54,6 +54,7 @@
#include <qsocketnotifier.h>
#include <qapplication.h>
#include <qtimer.h>
+#include <private/qcore_unix_p.h> // overrides QT_OPEN
QT_BEGIN_NAMESPACE
@@ -64,7 +65,7 @@ QVFbMouseHandler::QVFbMouseHandler(const QString &driver, const QString &device)
if (device.isEmpty())
mouseDev = QLatin1String("/dev/vmouse");
- mouseFD = open(mouseDev.toLatin1().constData(), O_RDWR | O_NDELAY);
+ mouseFD = QT_OPEN(mouseDev.toLatin1().constData(), O_RDWR | O_NDELAY);
if (mouseFD == -1) {
perror("QVFbMouseHandler::QVFbMouseHandler");
qWarning("QVFbMouseHander: Unable to open device %s",
@@ -74,7 +75,7 @@ QVFbMouseHandler::QVFbMouseHandler(const QString &driver, const QString &device)
// Clear pending input
char buf[2];
- while (read(mouseFD, buf, 1) > 0) { }
+ while (QT_READ(mouseFD, buf, 1) > 0) { }
mouseIdx = 0;
@@ -85,7 +86,7 @@ QVFbMouseHandler::QVFbMouseHandler(const QString &driver, const QString &device)
QVFbMouseHandler::~QVFbMouseHandler()
{
if (mouseFD >= 0)
- close(mouseFD);
+ QT_CLOSE(mouseFD);
}
void QVFbMouseHandler::resume()
@@ -102,7 +103,7 @@ void QVFbMouseHandler::readMouseData()
{
int n;
do {
- n = read(mouseFD, mouseBuf+mouseIdx, mouseBufSize-mouseIdx);
+ n = QT_READ(mouseFD, mouseBuf+mouseIdx, mouseBufSize-mouseIdx);
if (n > 0)
mouseIdx += n;
} while (n > 0);
diff --git a/src/gui/embedded/qmousevr41xx_qws.cpp b/src/gui/embedded/qmousevr41xx_qws.cpp
deleted file mode 100644
index 8748055..0000000
--- a/src/gui/embedded/qmousevr41xx_qws.cpp
+++ /dev/null
@@ -1,250 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmousevr41xx_qws.h"
-
-#ifndef QT_NO_QWS_MOUSE_VR41XX
-#include "qwindowsystem_qws.h"
-#include "qsocketnotifier.h"
-#include "qtimer.h"
-#include "qapplication.h"
-#include "qscreen_qws.h"
-#include <qstringlist.h>
-#include <qvarlengtharray.h>
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <termios.h>
-
-QT_BEGIN_NAMESPACE
-
-static const int defaultFilterSize = 3;
-
-class QWSVr41xxMouseHandlerPrivate : public QObject
-{
- Q_OBJECT
-public:
- QWSVr41xxMouseHandlerPrivate(QWSVr41xxMouseHandler *, const QString &, const QString &);
- ~QWSVr41xxMouseHandlerPrivate();
-
- void resume();
- void suspend();
-
-private slots:
- void sendRelease();
- void readMouseData();
-
-private:
- bool getSample();
- ushort currSample[6];
- uint currLength;
-
- int mouseFD;
- int mouseIdx;
- QTimer *rtimer;
- QSocketNotifier *mouseNotifier;
- QWSVr41xxMouseHandler *handler;
- QPoint lastPos;
- bool isPressed;
- int filterSize;
- int pressLimit;
-};
-
-QWSVr41xxMouseHandler::QWSVr41xxMouseHandler(const QString &drv, const QString &dev)
- : QWSCalibratedMouseHandler(drv, dev)
-{
- d = new QWSVr41xxMouseHandlerPrivate(this, drv, dev);
-}
-
-QWSVr41xxMouseHandler::~QWSVr41xxMouseHandler()
-{
- delete d;
-}
-
-void QWSVr41xxMouseHandler::resume()
-{
- d->resume();
-}
-
-void QWSVr41xxMouseHandler::suspend()
-{
- d->suspend();
-}
-
-QWSVr41xxMouseHandlerPrivate::QWSVr41xxMouseHandlerPrivate(QWSVr41xxMouseHandler *h, const QString &, const QString &device)
- : currLength(0), handler(h)
-{
- QStringList options = device.split(QLatin1String(":"));
- int index = -1;
-
- filterSize = defaultFilterSize;
- QRegExp filterRegExp(QLatin1String("filter=(\\d+)"));
- index = options.indexOf(filterRegExp);
- if (index != -1) {
- filterSize = qMax(1, filterRegExp.cap(1).toInt());
- options.removeAt(index);
- }
- handler->setFilterSize(filterSize);
-
- pressLimit = 750;
- QRegExp pressRegExp(QLatin1String("press=(\\d+)"));
- index = options.indexOf(pressRegExp);
- if (index != -1) {
- pressLimit = filterRegExp.cap(1).toInt();
- options.removeAt(index);
- }
-
- QString dev;
- if (options.isEmpty())
- dev = QLatin1String("/dev/vrtpanel");
- else
- dev = options.first();
-
- if ((mouseFD = open(dev.toLocal8Bit().constData(), O_RDONLY)) < 0) {
- qWarning("Cannot open %s (%s)", qPrintable(dev), strerror(errno));
- return;
- }
- sleep(1);
-
- if (fcntl(mouseFD, F_SETFL, O_NONBLOCK) < 0) {
- qWarning("Error initializing touch panel.");
- return;
- }
-
- mouseNotifier = new QSocketNotifier(mouseFD, QSocketNotifier::Read, this);
- connect(mouseNotifier, SIGNAL(activated(int)),this, SLOT(readMouseData()));
-
- rtimer = new QTimer(this);
- rtimer->setSingleShot(true);
- connect(rtimer, SIGNAL(timeout()), this, SLOT(sendRelease()));
- mouseIdx = 0;
-}
-
-QWSVr41xxMouseHandlerPrivate::~QWSVr41xxMouseHandlerPrivate()
-{
- if (mouseFD >= 0)
- close(mouseFD);
-}
-
-void QWSVr41xxMouseHandlerPrivate::suspend()
-{
- mouseNotifier->setEnabled(false);
-}
-
-
-void QWSVr41xxMouseHandlerPrivate::resume()
-{
- mouseIdx = 0;
- mouseNotifier->setEnabled(true);
-}
-
-void QWSVr41xxMouseHandlerPrivate::sendRelease()
-{
- handler->sendFiltered(lastPos, Qt::NoButton);
- isPressed = false;
-}
-
-bool QWSVr41xxMouseHandlerPrivate::getSample()
-{
- const int n = read(mouseFD,
- reinterpret_cast<uchar*>(currSample) + currLength,
- sizeof(currSample) - currLength);
-
- if (n > 0)
- currLength += n;
-
- if (currLength < sizeof(currSample))
- return false;
-
- currLength = 0;
- return true;
-}
-
-void QWSVr41xxMouseHandlerPrivate::readMouseData()
-{
- const int sampleLength = sizeof(currSample) / sizeof(ushort);
- QVarLengthArray<ushort, sampleLength * defaultFilterSize> samples(sampleLength * filterSize);
-
- // Only return last 'filterSize' samples
- int head = 0;
- int tail = 0;
- int nSamples = 0;
- while (getSample()) {
- if (!(currSample[0] & 0x8000) || (currSample[5] < pressLimit))
- continue;
-
- ushort *data = samples.data() + head * sampleLength;
- memcpy(data, currSample, sizeof(currSample));
- ++nSamples;
- head = (head + 1) % filterSize;
- if (nSamples >= filterSize)
- tail = (tail + 1) % filterSize;
- }
-
- if (nSamples == 0)
- return;
-
- // send mouse events
- while (tail != head || filterSize == 1) {
- const ushort *data = samples.data() + tail * sampleLength;
- lastPos = QPoint(data[3] - data[4], data[2] - data[1]);
- handler->sendFiltered(lastPos, Qt::LeftButton);
- isPressed = true;
- tail = (tail + 1) % filterSize;
- if (filterSize == 1)
- break;
- }
-
- if (isPressed)
- rtimer->start(50); // release unreliable
-}
-
-QT_END_NAMESPACE
-
-#include "qmousevr41xx_qws.moc"
-
-#endif //QT_NO_QWS_MOUSE_VR41
diff --git a/src/gui/embedded/qmouseyopy_qws.cpp b/src/gui/embedded/qmouseyopy_qws.cpp
deleted file mode 100644
index 7b1141a..0000000
--- a/src/gui/embedded/qmouseyopy_qws.cpp
+++ /dev/null
@@ -1,184 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmouseyopy_qws.h"
-
-#ifndef QT_NO_QWS_MOUSE_YOPY
-#include "qwindowsystem_qws.h"
-#include "qsocketnotifier.h"
-#include "qapplication.h"
-#include "qscreen_qws.h"
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <termios.h>
-
-QT_BEGIN_NAMESPACE
-
-class QWSYopyMouseHandlerPrivate : public QObject
-{
- Q_OBJECT
-public:
- QWSYopyMouseHandlerPrivate(QWSYopyMouseHandler *h);
- ~QWSYopyMouseHandlerPrivate();
-
- void suspend();
- void resume();
-
-private slots:
- void readMouseData();
-
-private:
- int mouseFD;
- int prevstate;
- QSocketNotifier *mouseNotifier;
- QWSYopyMouseHandler *handler;
-};
-
-QWSYopyMouseHandler::QWSYopyMouseHandler(const QString &driver, const QString &device)
- : QWSMouseHandler(driver, device)
-{
- d = new QWSYopyMouseHandlerPrivate(this);
-}
-
-QWSYopyMouseHandler::~QWSYopyMouseHandler()
-{
- delete d;
-}
-
-void QWSYopyMouseHandler::resume()
-{
- d->resume();
-}
-
-void QWSYopyMouseHandler::suspend()
-{
- d->suspend();
-}
-
-QWSYopyMouseHandlerPrivate::QWSYopyMouseHandlerPrivate(QWSYopyMouseHandler *h)
- : handler(h)
-{
- if ((mouseFD = open("/dev/ts", O_RDONLY)) < 0) {
- qWarning("Cannot open /dev/ts (%s)", strerror(errno));
- return;
- } else {
- sleep(1);
- }
- prevstate=0;
- mouseNotifier = new QSocketNotifier(mouseFD, QSocketNotifier::Read,
- this);
- connect(mouseNotifier, SIGNAL(activated(int)),this, SLOT(readMouseData()));
-}
-
-QWSYopyMouseHandlerPrivate::~QWSYopyMouseHandlerPrivate()
-{
- if (mouseFD >= 0)
- close(mouseFD);
-}
-
-#define YOPY_XPOS(d) (d[1]&0x3FF)
-#define YOPY_YPOS(d) (d[2]&0x3FF)
-#define YOPY_PRES(d) (d[0]&0xFF)
-#define YOPY_STAT(d) (d[3]&0x01)
-
-struct YopyTPdata {
-
- unsigned char status;
- unsigned short xpos;
- unsigned short ypos;
-
-};
-
-void QWSYopyMouseHandlerPrivate::suspend()
-{
- mouseNotifier->setEnabled(false);
-}
-
-
-void QWSYopyMouseHandlerPrivate::resume()
-{
- prevstate = 0;
- mouseNotifier->setEnabled(true);
-}
-
-void QWSYopyMouseHandlerPrivate::readMouseData()
-{
- if(!qt_screen)
- return;
- YopyTPdata data;
-
- unsigned int yopDat[4];
-
- int ret;
-
- ret=read(mouseFD,&yopDat,sizeof(yopDat));
-
- if(ret) {
- data.status= (YOPY_PRES(yopDat)) ? 1 : 0;
- data.xpos=YOPY_XPOS(yopDat);
- data.ypos=YOPY_YPOS(yopDat);
- QPoint q;
- q.setX(data.xpos);
- q.setY(data.ypos);
- if (data.status && !prevstate) {
- handler->mouseChanged(q,Qt::LeftButton);
- } else if(!data.status && prevstate) {
- handler->mouseChanged(q,0);
- }
- prevstate = data.status;
- }
- if(ret<0) {
- qDebug("Error %s",strerror(errno));
- }
-}
-
-QT_END_NAMESPACE
-
-#include "qmouseyopy_qws.moc"
-
-#endif //QT_NO_QWS_MOUSE_YOPY
diff --git a/src/gui/embedded/qmouseyopy_qws.h b/src/gui/embedded/qmouseyopy_qws.h
deleted file mode 100644
index 0d24a8f..0000000
--- a/src/gui/embedded/qmouseyopy_qws.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMOUSEYOPY_QWS_H
-#define QMOUSEYOPY_QWS_H
-
-#include <QtGui/qmouse_qws.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_QWS_MOUSE_YOPY
-
-// YOPY touch panel support based on changes contributed by Ron Victorelli
-// (victorrj at icubed.com) to Custom TP driver.
-
-class QWSYopyMouseHandlerPrivate;
-
-class QWSYopyMouseHandler : public QWSMouseHandler
-{
-public:
- explicit QWSYopyMouseHandler(const QString & = QString(),
- const QString & = QString());
- ~QWSYopyMouseHandler();
-
- void resume();
- void suspend();
-
-protected:
- QWSYopyMouseHandlerPrivate *d;
-};
-
-#endif // QT_NO_QWS_MOUSE_YOPY
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMOUSEYOPY_QWS_H
diff --git a/src/gui/embedded/qscreendriverfactory_qws.cpp b/src/gui/embedded/qscreendriverfactory_qws.cpp
index 2290627..b531798 100644
--- a/src/gui/embedded/qscreendriverfactory_qws.cpp
+++ b/src/gui/embedded/qscreendriverfactory_qws.cpp
@@ -47,6 +47,7 @@
#include "qscreentransformed_qws.h"
#include "qscreenvfb_qws.h"
#include "qscreenmulti_qws_p.h"
+#include "qscreenqnx_qws.h"
#include <stdlib.h>
#include "private/qfactoryloader_p.h"
#include "qscreendriverplugin_qws.h"
@@ -105,6 +106,10 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
QScreen *QScreenDriverFactory::create(const QString& key, int displayId)
{
QString driver = key.toLower();
+#if defined(Q_OS_QNX) && !defined(QT_NO_QWS_QNX)
+ if (driver == QLatin1String("qnx") || driver.isEmpty())
+ return new QQnxScreen(displayId);
+#endif
#ifndef QT_NO_QWS_QVFB
if (driver == QLatin1String("qvfb") || driver.isEmpty())
return new QVFbScreen(displayId);
@@ -146,6 +151,9 @@ QStringList QScreenDriverFactory::keys()
{
QStringList list;
+#if defined(Q_OS_QNX) && !defined(QT_NO_QWS_QNX)
+ list << QLatin1String("QNX");
+#endif
#ifndef QT_NO_QWS_QVFB
list << QLatin1String("QVFb");
#endif
diff --git a/src/gui/embedded/qscreenlinuxfb_qws.cpp b/src/gui/embedded/qscreenlinuxfb_qws.cpp
index 42c4fcd..2845842 100644
--- a/src/gui/embedded/qscreenlinuxfb_qws.cpp
+++ b/src/gui/embedded/qscreenlinuxfb_qws.cpp
@@ -46,6 +46,7 @@
#include "qwsdisplay_qws.h"
#include "qpixmap.h"
#include <private/qwssignalhandler_p.h>
+#include <private/qcore_unix_p.h> // overrides QT_OPEN
#include <unistd.h>
#include <stdlib.h>
@@ -122,12 +123,12 @@ void QLinuxFbScreenPrivate::openTty()
if (ttyDevice.isEmpty()) {
for (const char * const *dev = devs; *dev; ++dev) {
- ttyfd = ::open(*dev, O_RDWR);
+ ttyfd = QT_OPEN(*dev, O_RDWR);
if (ttyfd != -1)
break;
}
} else {
- ttyfd = ::open(ttyDevice.toAscii().constData(), O_RDWR);
+ ttyfd = QT_OPEN(ttyDevice.toAscii().constData(), O_RDWR);
}
if (ttyfd == -1)
@@ -144,7 +145,7 @@ void QLinuxFbScreenPrivate::openTty()
// No blankin' screen, no blinkin' cursor!, no cursor!
const char termctl[] = "\033[9;0]\033[?33l\033[?25l\033[?1c";
- ::write(ttyfd, termctl, sizeof(termctl));
+ QT_WRITE(ttyfd, termctl, sizeof(termctl));
}
void QLinuxFbScreenPrivate::closeTty()
@@ -157,9 +158,9 @@ void QLinuxFbScreenPrivate::closeTty()
// Blankin' screen, blinkin' cursor!
const char termctl[] = "\033[9;15]\033[?33h\033[?25h\033[?0c";
- ::write(ttyfd, termctl, sizeof(termctl));
+ QT_WRITE(ttyfd, termctl, sizeof(termctl));
- ::close(ttyfd);
+ QT_CLOSE(ttyfd);
ttyfd = -1;
}
@@ -281,7 +282,7 @@ bool QLinuxFbScreen::connect(const QString &displaySpec)
dev = QLatin1String("/dev/fb0");
if (access(dev.toLatin1().constData(), R_OK|W_OK) == 0)
- d_ptr->fd = open(dev.toLatin1().constData(), O_RDWR);
+ d_ptr->fd = QT_OPEN(dev.toLatin1().constData(), O_RDWR);
if (d_ptr->fd == -1) {
if (QApplication::type() == QApplication::GuiServer) {
perror("QScreenLinuxFb::connect");
@@ -289,7 +290,7 @@ bool QLinuxFbScreen::connect(const QString &displaySpec)
return false;
}
if (access(dev.toLatin1().constData(), R_OK) == 0)
- d_ptr->fd = open(dev.toLatin1().constData(), O_RDONLY);
+ d_ptr->fd = QT_OPEN(dev.toLatin1().constData(), O_RDONLY);
}
fb_fix_screeninfo finfo;
@@ -681,7 +682,7 @@ bool QLinuxFbScreen::initDevice()
#ifdef __i386__
// Now init mtrr
if(!::getenv("QWS_NOMTRR")) {
- int mfd=open("/proc/mtrr",O_WRONLY,0);
+ int mfd=QT_OPEN("/proc/mtrr",O_WRONLY,0);
// MTRR entry goes away when file is closed - i.e.
// hopefully when QWS is killed
if(mfd != -1) {
@@ -702,6 +703,9 @@ bool QLinuxFbScreen::initDevice()
//sentry.base,sentry.size,strerror(errno));
}
}
+
+ // Should we close mfd here?
+ //QT_CLOSE(mfd);
}
#endif
if ((vinfo.bits_per_pixel==8) || (vinfo.bits_per_pixel==4) || (finfo.visual==FB_VISUAL_DIRECTCOLOR))
diff --git a/src/gui/embedded/qscreenproxy_qws.cpp b/src/gui/embedded/qscreenproxy_qws.cpp
index ade16ca..3d7451b 100644
--- a/src/gui/embedded/qscreenproxy_qws.cpp
+++ b/src/gui/embedded/qscreenproxy_qws.cpp
@@ -537,7 +537,7 @@ int QProxyScreen::transformOrientation() const
}
/*!
-\reimp
+\internal
*/
int QProxyScreen::memoryNeeded(const QString &str)
{
@@ -548,7 +548,7 @@ int QProxyScreen::memoryNeeded(const QString &str)
}
/*!
-\reimp
+\internal
*/
int QProxyScreen::sharedRamSize(void *ptr)
{
@@ -559,7 +559,7 @@ int QProxyScreen::sharedRamSize(void *ptr)
}
/*!
-\reimp
+\internal
*/
void QProxyScreen::haltUpdates()
{
@@ -568,7 +568,7 @@ void QProxyScreen::haltUpdates()
}
/*!
-\reimp
+\internal
*/
void QProxyScreen::resumeUpdates()
{
diff --git a/src/gui/embedded/qscreenqnx_qws.cpp b/src/gui/embedded/qscreenqnx_qws.cpp
new file mode 100644
index 0000000..c79ee59
--- /dev/null
+++ b/src/gui/embedded/qscreenqnx_qws.cpp
@@ -0,0 +1,447 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qscreenqnx_qws.h"
+#include "qdebug.h"
+
+#include <gf/gf.h>
+
+// This struct holds all the pointers to QNX's internals
+struct QQnxScreenContext
+{
+ inline QQnxScreenContext()
+ : device(0), display(0), layer(0), hwSurface(0), memSurface(0), context(0)
+ {}
+
+ gf_dev_t device;
+ gf_dev_info_t deviceInfo;
+ gf_display_t display;
+ gf_display_info_t displayInfo;
+ gf_layer_t layer;
+ gf_surface_t hwSurface;
+ gf_surface_t memSurface;
+ gf_surface_info_t memSurfaceInfo;
+ gf_context_t context;
+};
+
+/*!
+ \class QQnxScreen
+ \preliminary
+ \ingroup qws
+ \since 4.6
+ \internal
+
+ \brief The QQnxScreen class implements a screen driver
+ for QNX io-display based devices.
+
+ Note - you never have to instanciate this class, the QScreenDriverFactory
+ does that for us based on the \c{QWS_DISPLAY} environment variable.
+
+ To activate this driver, set \c{QWS_DISPLAY} to \c{qnx}.
+
+ Example:
+ \c{QWS_DISPLAY=qnx; export QWS_DISPLAY}
+
+ By default, the main layer of the first display of the first device is used.
+ If you have multiple graphic cards, multiple displays or multiple layers and
+ don't want to connect to the default, you can override that with setting
+ the corresponding options \c{device}, \c{display} or \c{layer} in the \c{QWS_DISPLAY} variable:
+
+ \c{QWS_DISPLAY=qnx:device=3:display=4:layer=5}
+
+ In addition, it is suggested to set the physical width and height of the display.
+ QQnxScreen will use that information to compute the dots per inch (DPI) in order to render
+ fonts correctly. If this informaiton is omitted, QQnxScreen defaults to 72 dpi.
+
+ \c{QWS_DISPLAY=qnx:mmWidth=120:mmHeight=80}
+
+ \c{mmWidth} and \c{mmHeight} are the physical width/height of the screen in millimeters.
+
+ \sa QScreen, QScreenDriverPlugin, {Running Qt for Embedded Linux Applications}{Running Applications}
+*/
+
+/*!
+ Constructs a QQnxScreen object. The \a display_id argument
+ identifies the Qt for Embedded Linux server to connect to.
+*/
+QQnxScreen::QQnxScreen(int display_id)
+ : QScreen(display_id), d(new QQnxScreenContext)
+{
+}
+
+/*!
+ Destroys this QQnxScreen object.
+*/
+QQnxScreen::~QQnxScreen()
+{
+ delete d;
+}
+
+/*! \reimp
+*/
+bool QQnxScreen::initDevice()
+{
+ // implement this if you have multiple processes that want to access the display
+ // (not required if QT_NO_QWS_MULTIPROCESS is set)
+ return true;
+}
+
+/*! \internal
+ Attaches to the named device \a name.
+*/
+static bool attachDevice(QQnxScreenContext * const d, const char *name)
+{
+ int ret = gf_dev_attach(&d->device, name, &d->deviceInfo);
+ if (ret != GF_ERR_OK) {
+ qWarning("QQnxScreen: gf_dev_attach(%s) failed with error code %d", name, ret);
+ return false;
+ }
+ return true;
+}
+
+/*! \internal
+ Attaches to the display at index \a displayIndex.
+ */
+static bool attachDisplay(QQnxScreenContext * const d, int displayIndex)
+{
+ int ret = gf_display_attach(&d->display, d->device, displayIndex, &d->displayInfo);
+ if (ret != GF_ERR_OK) {
+ qWarning("QQnxScreen: gf_display_attach(%d) failed with error code %d",
+ displayIndex, ret);
+ return false;
+ }
+ return true;
+}
+
+/*! \internal
+ Attaches to the layer \a layerIndex.
+ */
+static bool attachLayer(QQnxScreenContext * const d, int layerIndex)
+{
+ int ret = gf_layer_attach(&d->layer, d->display, layerIndex, 0);
+ if (ret != GF_ERR_OK) {
+ qWarning("QQnxScreen: gf_layer_attach(%d) failed with error code %d", layerIndex,
+ ret);
+ return false;
+ }
+ gf_layer_enable(d->layer);
+
+ return true;
+}
+
+/*! \internal
+ Creates a new hardware surface (usually on the Gfx card memory) with the dimensions \a w * \a h.
+ */
+static bool createHwSurface(QQnxScreenContext * const d, int w, int h)
+{
+ int ret = gf_surface_create_layer(&d->hwSurface, &d->layer, 1, 0,
+ w, h, GF_FORMAT_ARGB8888, 0, 0);
+ if (ret != GF_ERR_OK) {
+ qWarning("QQnxScreen: gf_surface_create_layer(%dx%d) failed with error code %d",
+ w, h, ret);
+ return false;
+ }
+
+ gf_layer_set_surfaces(d->layer, &d->hwSurface, 1);
+
+ ret = gf_layer_update(d->layer, 0);
+ if (ret != GF_ERR_OK) {
+ qWarning("QQnxScreen: gf_layer_update() failed with error code %d\n", ret);
+ return false;
+ }
+
+ return true;
+}
+
+/*! \internal
+ Creates an in-memory, linear accessible surface of dimensions \a w * \a h.
+ This is the main surface that QWS blits to.
+ */
+static bool createMemSurface(QQnxScreenContext * const d, int w, int h)
+{
+ // Note: gf_surface_attach() could also be used, so we'll create the buffer
+ // and let the surface point to it. Here, we use surface_create instead.
+
+ int ret = gf_surface_create(&d->memSurface, d->device, w, h,
+ GF_FORMAT_ARGB8888, 0,
+ GF_SURFACE_CREATE_CPU_FAST_ACCESS | GF_SURFACE_CREATE_CPU_LINEAR_ACCESSIBLE
+ | GF_SURFACE_PHYS_CONTIG);
+ if (ret != GF_ERR_OK) {
+ qWarning("QQnxScreen: gf_surface_create(%dx%d) failed with error code %d",
+ w, h, ret);
+ return false;
+ }
+
+ gf_surface_get_info(d->memSurface, &d->memSurfaceInfo);
+
+ if (d->memSurfaceInfo.sid == unsigned(GF_SID_INVALID)) {
+ qWarning("QQnxScreen: gf_surface_get_info() failed.");
+ return false;
+ }
+
+ return true;
+}
+
+/* \internal
+ Creates a QNX gf context and sets our memory surface on it.
+ */
+static bool createContext(QQnxScreenContext * const d)
+{
+ int ret = gf_context_create(&d->context);
+ if (ret != GF_ERR_OK) {
+ qWarning("QQnxScreen: gf_context_create() failed with error code %d", ret);
+ return false;
+ }
+
+ ret = gf_context_set_surface(d->context, d->memSurface);
+ if (ret != GF_ERR_OK) {
+ qWarning("QQnxScreen: gf_context_set_surface() failed with error code %d", ret);
+ return false;
+ }
+
+ return true;
+}
+
+/*! \reimp
+ Connects to QNX's io-display based device based on the \a displaySpec parameters
+ from the \c{QWS_DISPLAY} environment variable. See the QQnxScreen class documentation
+ for possible parameters.
+
+ \sa QQnxScreen
+ */
+bool QQnxScreen::connect(const QString &displaySpec)
+{
+ const QStringList params = displaySpec.split(QLatin1Char(':'), QString::SkipEmptyParts);
+
+ bool isOk = false;
+ QRegExp deviceRegExp(QLatin1String("^device=(.+)$"));
+ if (params.indexOf(deviceRegExp) != -1) {
+ isOk = attachDevice(d, deviceRegExp.cap(1).toLocal8Bit().constData());
+ } else {
+ // no device specified - attach to device 0 (the default)
+ isOk = attachDevice(d, GF_DEVICE_INDEX(0));
+ }
+
+ if (!isOk)
+ return false;
+
+ qDebug("QQnxScreen: Attached to Device, number of displays: %d", d->deviceInfo.ndisplays);
+
+ // default to display 0
+ int displayIndex = 0;
+ QRegExp displayRegexp(QLatin1String("^display=(\\d+)$"));
+ if (params.indexOf(displayRegexp) != -1) {
+ displayIndex = displayRegexp.cap(1).toInt();
+ }
+
+ if (!attachDisplay(d, displayIndex))
+ return false;
+
+ qDebug("QQnxScreen: Attached to Display %d, resolution %dx%d, refresh %d Hz",
+ displayIndex, d->displayInfo.xres, d->displayInfo.yres,
+ d->displayInfo.refresh);
+
+
+ // default to main_layer_index from the displayInfo struct
+ int layerIndex = 0;
+ QRegExp layerRegexp(QLatin1String("^layer=(\\d+)$"));
+ if (params.indexOf(layerRegexp) != -1) {
+ layerIndex = layerRegexp.cap(1).toInt();
+ } else {
+ layerIndex = d->displayInfo.main_layer_index;
+ }
+
+ if (!attachLayer(d, layerIndex))
+ return false;
+
+ // tell QWSDisplay the width and height of the display
+ w = dw = d->displayInfo.xres;
+ h = dh = d->displayInfo.yres;
+
+ // we only support 32 bit displays for now.
+ QScreen::d = 32;
+
+ // assume 72 dpi as default, to calculate the physical dimensions if not specified
+ const int defaultDpi = 72;
+
+ // Handle display physical size spec.
+ QRegExp mmWidthRegexp(QLatin1String("^mmWidth=(\\d+)$"));
+ if (params.indexOf(mmWidthRegexp) == -1) {
+ physWidth = qRound(dw * 25.4 / defaultDpi);
+ } else {
+ physWidth = mmWidthRegexp.cap(1).toInt();
+ }
+
+ QRegExp mmHeightRegexp(QLatin1String("^mmHeight=(\\d+)$"));
+ if (params.indexOf(mmHeightRegexp) == -1) {
+ physHeight = qRound(dh * 25.4 / defaultDpi);
+ } else {
+ physHeight = mmHeightRegexp.cap(1).toInt();
+ }
+
+ // create a hardware surface with our dimensions. In the old days, it was possible
+ // to get a pointer directly to the hw surface, so we could blit directly. Now, we
+ // have to use one indirection more, because it's not guaranteed that the hw surface
+ // is mappable into our process.
+ if (!createHwSurface(d, w, h))
+ return false;
+
+ // create an in-memory linear surface that is used by QWS. QWS will blit directly in here.
+ if (!createMemSurface(d, w, h))
+ return false;
+
+ // set the address of the in-memory buffer that QWS is blitting to
+ data = d->memSurfaceInfo.vaddr;
+ // set the line stepping
+ lstep = d->memSurfaceInfo.stride;
+
+ // the overall size of the in-memory buffer is linestep * height
+ size = mapsize = lstep * h;
+
+ // create a QNX drawing context
+ if (!createContext(d))
+ return false;
+
+ // we're always using a software cursor for now. Initialize it here.
+ QScreenCursor::initSoftwareCursor();
+
+ // done, the driver should be connected to the display now.
+ return true;
+}
+
+/*! \reimp
+ */
+void QQnxScreen::disconnect()
+{
+ if (d->context)
+ gf_context_free(d->context);
+
+ if (d->memSurface)
+ gf_surface_free(d->memSurface);
+
+ if (d->hwSurface)
+ gf_surface_free(d->hwSurface);
+
+ if (d->layer)
+ gf_layer_detach(d->layer);
+
+ if (d->display)
+ gf_display_detach(d->display);
+
+ if (d->device)
+ gf_dev_detach(d->device);
+
+ d->memSurface = 0;
+ d->hwSurface = 0;
+ d->context = 0;
+ d->layer = 0;
+ d->display = 0;
+ d->device = 0;
+}
+
+/*! \reimp
+ */
+void QQnxScreen::shutdownDevice()
+{
+}
+
+
+/*! \reimp
+ QQnxScreen doesn't support setting the mode, use io-display instead.
+ */
+void QQnxScreen::setMode(int,int,int)
+{
+ qWarning("QQnxScreen: Unable to change mode, use io-display instead.");
+}
+
+/*! \reimp
+ */
+bool QQnxScreen::supportsDepth(int depth) const
+{
+ // only 32-bit for the moment
+ return depth == 32;
+}
+
+/*! \reimp
+ */
+void QQnxScreen::exposeRegion(QRegion r, int changing)
+{
+ // here is where the actual magic happens. QWS will call exposeRegion whenever
+ // a region on the screen is dirty and needs to be updated on the actual screen.
+
+ // first, call the parent implementation. The parent implementation will update
+ // the region on our in-memory surface
+ QScreen::exposeRegion(r, changing);
+
+ // now our in-memory surface should be up to date with the latest changes.
+ // the code below copies the region from the in-memory surface to the hardware.
+
+ // just get the bounding rectangle of the region. Most screen updates are rectangular
+ // anyways. Code could be optimized to blit each and every member of the region
+ // individually, but in real life, the speed-up is neglectable
+ const QRect br = r.boundingRect();
+ if (br.isEmpty())
+ return; // ignore empty regions because gf_draw_blit2 doesn't like 0x0 dimensions
+
+ // start drawing.
+ int ret = gf_draw_begin(d->context);
+ if (ret != GF_ERR_OK) {
+ qWarning("QQnxScreen: gf_draw_begin() failed with error code %d", ret);
+ return;
+ }
+
+ // blit the changed region from the memory surface to the hardware surface
+ ret = gf_draw_blit2(d->context, d->memSurface, d->hwSurface,
+ br.x(), br.y(), br.right(), br.bottom(), br.x(), br.y());
+ if (ret != GF_ERR_OK) {
+ qWarning("QQnxScreen: gf_draw_blit2() failed with error code %d", ret);
+ }
+
+ // flush all drawing commands (in our case, a single blit)
+ ret = gf_draw_flush(d->context);
+ if (ret != GF_ERR_OK) {
+ qWarning("QQnxScreen: gf_draw_flush() failed with error code %d", ret);
+ }
+
+ // tell QNX that we're done drawing.
+ gf_draw_end(d->context);
+}
+
diff --git a/src/gui/embedded/qkbdvr41xx_qws.h b/src/gui/embedded/qscreenqnx_qws.h
index 1a657b9..30312fe 100644
--- a/src/gui/embedded/qkbdvr41xx_qws.h
+++ b/src/gui/embedded/qscreenqnx_qws.h
@@ -39,10 +39,12 @@
**
****************************************************************************/
-#ifndef QKBDVR41XX_QWS_H
-#define QKBDVR41XX_QWS_H
+#ifndef QSCREENQNX_QWS_H
+#define QSCREENQNX_QWS_H
-#include <QtGui/qkbd_qws.h>
+#include <QtGui/qscreen_qws.h>
+
+#ifndef QT_NO_QWS_QNX
QT_BEGIN_HEADER
@@ -50,24 +52,31 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Gui)
-#if !defined(QT_NO_QWS_KEYBOARD) && !defined(QT_NO_QWS_KBD_VR41XX)
-
-class QWSVr41xxKbPrivate;
+struct QQnxScreenContext;
-class QWSVr41xxKeyboardHandler : public QWSKeyboardHandler
+class QQnxScreen : public QScreen
{
public:
- explicit QWSVr41xxKeyboardHandler(const QString&);
- virtual ~QWSVr41xxKeyboardHandler();
+ explicit QQnxScreen(int display_id);
+ ~QQnxScreen();
+
+ bool initDevice();
+ bool connect(const QString &displaySpec);
+ void disconnect();
+ void shutdownDevice();
+ void setMode(int,int,int);
+ bool supportsDepth(int) const;
+
+ void exposeRegion(QRegion r, int changing);
private:
- QWSVr41xxKbPrivate *d;
+ QQnxScreenContext * const d;
};
-#endif // QT_NO_QWS_KBD_VR41XX
-
QT_END_NAMESPACE
QT_END_HEADER
-#endif // QKBDVR41XX_QWS_H
+#endif // QT_NO_QWS_QNX
+
+#endif
diff --git a/src/gui/embedded/qsoundqss_qws.cpp b/src/gui/embedded/qsoundqss_qws.cpp
index 4355eff..e239e14 100644
--- a/src/gui/embedded/qsoundqss_qws.cpp
+++ b/src/gui/embedded/qsoundqss_qws.cpp
@@ -53,6 +53,7 @@
#include <qtimer.h>
#include <qpointer.h>
#include <qendian.h>
+#include <private/qcore_unix_p.h> // overrides QT_OPEN
#include <unistd.h>
#include <stdlib.h>
@@ -1141,7 +1142,7 @@ void QWSSoundServerPrivate::sendCompletedSignals()
int QWSSoundServerPrivate::openFile(int wid, int sid, const QString& filename)
{
stopFile(wid, sid); // close and re-open.
- int f = ::open(QFile::encodeName(filename), O_RDONLY|O_NONBLOCK);
+ int f = QT_OPEN(QFile::encodeName(filename), O_RDONLY|O_NONBLOCK);
if (f == -1) {
// XXX check ferror, check reason.
qDebug("Failed opening \"%s\"",filename.toLatin1().data());
@@ -1161,7 +1162,7 @@ bool QWSSoundServerPrivate::openDevice()
{
if (fd < 0) {
if( silent ) {
- fd = ::open( "/dev/null", O_WRONLY );
+ fd = QT_OPEN( "/dev/null", O_WRONLY );
// Emulate write to audio device
int delay = 1000*(sound_buffer_size>>(sound_stereo+sound_16bit))/sound_speed/2;
timerId = startTimer(delay);
@@ -1172,7 +1173,7 @@ bool QWSSoundServerPrivate::openDevice()
// Don't block open right away.
//
bool openOkay = false;
- if ((fd = ::open("/dev/dsp", O_WRONLY|O_NONBLOCK)) != -1) {
+ if ((fd = QT_OPEN("/dev/dsp", O_WRONLY|O_NONBLOCK)) != -1) {
int flags = fcntl(fd, F_GETFL);
flags &= ~O_NONBLOCK;
openOkay = (fcntl(fd, F_SETFL, flags) == 0);
@@ -1226,7 +1227,7 @@ bool QWSSoundServerPrivate::openDevice()
//
// Check system volume
//
- int mixerHandle = ::open( "/dev/mixer", O_RDWR|O_NONBLOCK );
+ int mixerHandle = QT_OPEN( "/dev/mixer", O_RDWR|O_NONBLOCK );
if ( mixerHandle >= 0 ) {
int volume;
ioctl( mixerHandle, MIXER_READ(0), &volume );
diff --git a/src/gui/embedded/qtransportauth_qws.cpp b/src/gui/embedded/qtransportauth_qws.cpp
index 05dce11..8523e27 100644
--- a/src/gui/embedded/qtransportauth_qws.cpp
+++ b/src/gui/embedded/qtransportauth_qws.cpp
@@ -56,6 +56,7 @@
#include "qlibraryinfo.h"
#include "qfile.h"
#include "qdebug.h"
+#include <private/qcore_unix_p.h> // overrides QT_OPEN
#include <syslog.h>
#include <unistd.h>
@@ -572,7 +573,7 @@ bool QTransportAuth::authorizeRequest( QTransportAuth::Data &d, const QString &r
//get cmdline from proc/pid/cmdline
snprintf( cmdlinePath, BUF_SIZE, "/proc/%d/cmdline", d.processId );
- int cmdlineFd = open( cmdlinePath, O_RDONLY );
+ int cmdlineFd = QT_OPEN( cmdlinePath, O_RDONLY );
if ( cmdlineFd == -1 )
{
qWarning( "SXE:- Error encountered in opening /proc/%u/cmdline: %s",
@@ -581,13 +582,13 @@ bool QTransportAuth::authorizeRequest( QTransportAuth::Data &d, const QString &r
}
else
{
- if ( -1 == ::read(cmdlineFd, cmdline, BUF_SIZE - 1 ) )
+ if ( -1 == QT_READ(cmdlineFd, cmdline, BUF_SIZE - 1 ) )
{
qWarning( "SXE:- Error encountered in reading /proc/%u/cmdline : %s",
d.processId, strerror(errno) );
snprintf( cmdline, BUF_SIZE, "%s", "Unknown" );
}
- close( cmdlineFd );
+ QT_CLOSE( cmdlineFd );
}
syslog( LOG_ERR | LOG_LOCAL6, "%s // PID:%u // ProgId:%u // Exe:%s // Request:%s // Cmdline:%s",
diff --git a/src/gui/embedded/qtransportauth_qws.h b/src/gui/embedded/qtransportauth_qws.h
index e633a90..d8753fe 100644
--- a/src/gui/embedded/qtransportauth_qws.h
+++ b/src/gui/embedded/qtransportauth_qws.h
@@ -169,7 +169,7 @@ private:
~QTransportAuth();
friend class QAuthDevice;
- Q_DECLARE_SCOPED_PRIVATE(QTransportAuth)
+ Q_DECLARE_PRIVATE(QTransportAuth)
};
class Q_GUI_EXPORT RequestAnalyzer
diff --git a/src/gui/embedded/qunixsocket.cpp b/src/gui/embedded/qunixsocket.cpp
index 070d3cf..57a4a11 100644
--- a/src/gui/embedded/qunixsocket.cpp
+++ b/src/gui/embedded/qunixsocket.cpp
@@ -46,6 +46,7 @@
#include <QtCore/qsocketnotifier.h>
#include <QtCore/qqueue.h>
#include <QtCore/qdatetime.h>
+#include "private/qcore_unix_p.h" // overrides QT_OPEN
#ifdef QUNIXSOCKET_DEBUG
#include <QtCore/qdebug.h>
@@ -131,7 +132,7 @@ struct QUnixSocketRightsPrivate : public QSharedData
#ifdef QUNIXSOCKET_DEBUG
int closerv =
#endif
- ::close(fd);
+ QT_CLOSE(fd);
#ifdef QUNIXSOCKET_DEBUG
if(0 != closerv) {
qDebug() << "QUnixSocketRightsPrivate: Unable to close managed"
@@ -162,7 +163,7 @@ QUnixSocketRights::QUnixSocketRights(int fd)
if(-1 == fd) {
d->fd = -1;
} else {
- d->fd = ::dup(fd);
+ d->fd = qt_safe_dup(fd);
#ifdef QUNIXSOCKET_DEBUG
if(-1 == d->fd) {
qDebug() << "QUnixSocketRights: Unable to duplicate fd "
@@ -232,7 +233,7 @@ int QUnixSocketRights::dupFd() const
{
if(-1 == d->fd) return -1;
- int rv = ::dup(d->fd);
+ int rv = qt_safe_dup(d->fd);
#ifdef QUNIXSOCKET_DEBUG
if(-1 == rv)
@@ -825,7 +826,7 @@ public:
int numFds = (h->cmsg_len - CMSG_LEN(0)) / sizeof(int);
for(int ii = 0; ii < numFds; ++ii)
- ::close(fds[ii]);
+ QT_CLOSE(fds[ii]);
}
h = (::cmsghdr *)CMSG_NXTHDR(&(message), h);
@@ -1017,7 +1018,7 @@ connect_error: // Cleanup failed connection
#ifdef QUNIXSOCKET_DEBUG
int closerv =
#endif
- ::close(d->fd);
+ QT_CLOSE(d->fd);
#ifdef QUNIXSOCKET_DEBUG
if(0 != closerv) {
qDebug() << "QUnixSocket: Unable to close file descriptor after "
@@ -1762,7 +1763,12 @@ void QUnixSocketPrivate::readActivated()
message.msg_controllen = ancillaryBufferCapacity();
message.msg_control = ancillaryBuffer;
- int recvrv = ::recvmsg(fd, &message, 0);
+ int flags = 0;
+#ifdef MSG_CMSG_CLOEXEC
+ flags = MSG_CMSG_CLOEXEC;
+#endif
+
+ int recvrv = ::recvmsg(fd, &message, flags);
#ifdef QUNIXSOCKET_DEBUG
qDebug() << "QUnixSocket: Received message (" << recvrv << ')';
#endif
diff --git a/src/gui/embedded/qwindowsystem_qws.cpp b/src/gui/embedded/qwindowsystem_qws.cpp
index dfc1e76..7384817 100644
--- a/src/gui/embedded/qwindowsystem_qws.cpp
+++ b/src/gui/embedded/qwindowsystem_qws.cpp
@@ -39,6 +39,8 @@
**
****************************************************************************/
+#include "qplatformdefs.h"
+
#include "qwindowsystem_qws.h"
#include "qwsevent_qws.h"
#include "qwscommand_qws_p.h"
@@ -71,24 +73,26 @@
#include <qdebug.h>
-#include <unistd.h>
+#include "qkbddriverfactory_qws.h"
+#include "qmousedriverfactory_qws.h"
+
+#include <qbuffer.h>
+#include <qdir.h>
+
+#include <private/qwindowsurface_qws_p.h>
+#include <private/qfontengine_qpf_p.h>
+
+#include "qwindowsystem_p.h"
+
+
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#ifndef QT_NO_QWS_MULTIPROCESS
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#ifndef Q_OS_DARWIN
-# include <sys/sem.h>
-#endif
#include <sys/param.h>
#include <sys/mount.h>
#endif
-#include <signal.h>
-#include <fcntl.h>
#if !defined(QT_NO_SOUND) && !defined(Q_OS_DARWIN)
#ifdef QT_USE_OLD_QWS_SOUND
@@ -101,17 +105,6 @@
#endif
#endif
-#include "qkbddriverfactory_qws.h"
-#include "qmousedriverfactory_qws.h"
-
-#include <qbuffer.h>
-#include <qdir.h>
-
-#include <private/qwindowsurface_qws_p.h>
-#include <private/qfontengine_qpf_p.h>
-
-#include "qwindowsystem_p.h"
-
//#define QWS_DEBUG_FONTCLEANUP
QT_BEGIN_NAMESPACE
@@ -1406,7 +1399,7 @@ void QWSServerPrivate::initServer(int flags)
#ifndef QT_NO_QWS_MULTIPROCESS
if (!geteuid()) {
-#if !defined(Q_OS_FREEBSD) && !defined(Q_OS_SOLARIS) && !defined(Q_OS_DARWIN) && !defined(QT_LINUXBASE)
+#if defined(Q_OS_LINUX) && !defined(QT_LINUXBASE)
if(mount(0,"/var/shm", "shm", 0, 0)) {
/* This just confuses people with 2.2 kernels
if (errno != EBUSY)
diff --git a/src/gui/embedded/qwindowsystem_qws.h b/src/gui/embedded/qwindowsystem_qws.h
index 04cd756..3cda9f6 100644
--- a/src/gui/embedded/qwindowsystem_qws.h
+++ b/src/gui/embedded/qwindowsystem_qws.h
@@ -214,7 +214,7 @@ class Q_GUI_EXPORT QWSServer : public QObject
friend class QWSDisplay;
friend class QWSInputMethod;
Q_OBJECT
- Q_DECLARE_SCOPED_PRIVATE(QWSServer)
+ Q_DECLARE_PRIVATE(QWSServer)
public:
explicit QWSServer(int flags = 0, QObject *parent=0);
#ifdef QT3_SUPPORT
@@ -443,7 +443,7 @@ class QWSConvertSelectionCommand;
class Q_GUI_EXPORT QWSClient : public QObject
{
Q_OBJECT
- Q_DECLARE_SCOPED_PRIVATE(QWSClient)
+ Q_DECLARE_PRIVATE(QWSClient)
public:
QWSClient(QObject* parent, QWS_SOCK_BASE *, int id);
~QWSClient();
diff --git a/src/gui/embedded/qwsembedwidget.h b/src/gui/embedded/qwsembedwidget.h
index d880454..8313c38 100644
--- a/src/gui/embedded/qwsembedwidget.h
+++ b/src/gui/embedded/qwsembedwidget.h
@@ -71,7 +71,7 @@ protected:
void showEvent(QShowEvent *event);
private:
- Q_DECLARE_SCOPED_PRIVATE(QWSEmbedWidget)
+ Q_DECLARE_PRIVATE(QWSEmbedWidget)
};
QT_END_NAMESPACE
diff --git a/src/gui/embedded/qwsmanager_qws.h b/src/gui/embedded/qwsmanager_qws.h
index 86aadc9..5a4312c 100644
--- a/src/gui/embedded/qwsmanager_qws.h
+++ b/src/gui/embedded/qwsmanager_qws.h
@@ -66,7 +66,7 @@ class QWSManagerPrivate;
class Q_GUI_EXPORT QWSManager : public QObject
{
Q_OBJECT
- Q_DECLARE_SCOPED_PRIVATE(QWSManager)
+ Q_DECLARE_PRIVATE(QWSManager)
public:
explicit QWSManager(QWidget *);
~QWSManager();