From f66065f28140c998a4c7ad2e9a1f8063f7361bd6 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Tue, 9 Aug 2011 09:19:22 +0200 Subject: Get linux input plugin compiling by removing keyboard support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I46ade27b5dde6c8d326a84e94abbbde1435889f8 Reviewed-on: http://codereview.qt.nokia.com/2765 Reviewed-by: Qt Sanity Bot Reviewed-by: Jørgen Lind --- src/plugins/generic/linuxinput/linuxinput.pro | 6 - src/plugins/generic/linuxinput/main.cpp | 5 +- src/plugins/generic/linuxinput/qlinuxinput.cpp | 192 ------------------------- src/plugins/generic/linuxinput/qlinuxinput.h | 25 ---- 4 files changed, 1 insertion(+), 227 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/generic/linuxinput/linuxinput.pro b/src/plugins/generic/linuxinput/linuxinput.pro index 18cb04e973..6ef5f0fb3a 100644 --- a/src/plugins/generic/linuxinput/linuxinput.pro +++ b/src/plugins/generic/linuxinput/linuxinput.pro @@ -5,8 +5,6 @@ DESTDIR = $$QT.gui.plugins/generic target.path = $$[QT_INSTALL_PLUGINS]/generic INSTALLS += target -DEFINES += QT_QWS_KBD_LINUXINPUT - HEADERS = qlinuxinput.h QT += core-private @@ -14,7 +12,3 @@ QT += core-private SOURCES = main.cpp \ qlinuxinput.cpp -HEADERS += $$QT_SOURCE_TREE/src/gui/embedded/qkbd_qws.h \ - $$QT_SOURCE_TREE/src/gui/embedded/qkbd_qws_p.h - -SOURCES += $$QT_SOURCE_TREE/src/gui/embedded/qkbd_qws.cpp diff --git a/src/plugins/generic/linuxinput/main.cpp b/src/plugins/generic/linuxinput/main.cpp index 9c38dba199..20391901bf 100644 --- a/src/plugins/generic/linuxinput/main.cpp +++ b/src/plugins/generic/linuxinput/main.cpp @@ -61,8 +61,7 @@ QLinuxInputPlugin::QLinuxInputPlugin() QStringList QLinuxInputPlugin::keys() const { return (QStringList() - << QLatin1String("LinuxInputMouse") - << QLatin1String("LinuxInputKeyboard")); + << QLatin1String("LinuxInputMouse")); } QObject* QLinuxInputPlugin::create(const QString &key, @@ -70,8 +69,6 @@ QObject* QLinuxInputPlugin::create(const QString &key, { if (!key.compare(QLatin1String("LinuxInputMouse"), Qt::CaseInsensitive)) return new QLinuxInputMouseHandler(key, specification); - if (!key.compare(QLatin1String("LinuxInputKeyboard"), Qt::CaseInsensitive)) - return new QLinuxInputKeyboardHandler(key, specification); return 0; } diff --git a/src/plugins/generic/linuxinput/qlinuxinput.cpp b/src/plugins/generic/linuxinput/qlinuxinput.cpp index 2316f089cc..943b213ce0 100644 --- a/src/plugins/generic/linuxinput/qlinuxinput.cpp +++ b/src/plugins/generic/linuxinput/qlinuxinput.cpp @@ -48,9 +48,6 @@ #include #include -#include - - #include #include // overrides QT_OPEN @@ -361,195 +358,6 @@ void QLinuxInputMouseHandler::readMouseData() -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -//Keyboard handler - - - - -class QWSLinuxInputKeyboardHandler : public QWSKeyboardHandler -{ -public: - QWSLinuxInputKeyboardHandler(const QString&); - ~QWSLinuxInputKeyboardHandler(); - - virtual bool filterInputEvent(quint16 &input_code, qint32 &input_value); - -//private: -// QWSLinuxInputKbPrivate *d; -}; - - -QWSLinuxInputKeyboardHandler::QWSLinuxInputKeyboardHandler(const QString &device) - : QWSKeyboardHandler(device) -{ -} - -QWSLinuxInputKeyboardHandler::~QWSLinuxInputKeyboardHandler() -{ -} - -bool QWSLinuxInputKeyboardHandler::filterInputEvent(quint16 &, qint32 &) -{ - return false; -} - - -QLinuxInputKeyboardHandler::QLinuxInputKeyboardHandler(const QString &key, const QString &specification) - : m_handler(0), m_fd(-1), m_tty_fd(-1), m_orig_kbmode(K_XLATE) -{ - setObjectName(QLatin1String("LinuxInputSubsystem Keyboard Handler")); - - QString dev = QLatin1String("/dev/input/event1"); - int repeat_delay = -1; - int repeat_rate = -1; - - bool ttymode = false; - - QStringList args = specification.split(QLatin1Char(':')); - foreach (const QString &arg, args) { - if (arg.startsWith(QLatin1String("repeat-delay="))) - repeat_delay = arg.mid(13).toInt(); - else if (arg.startsWith(QLatin1String("repeat-rate="))) - repeat_rate = arg.mid(12).toInt(); - else if (arg.startsWith(QLatin1String("ttymode"))) - ttymode = true; - else if (arg.startsWith(QLatin1String("/dev/"))) - dev = arg; - } - - m_handler = new QWSLinuxInputKeyboardHandler(dev); //This is a hack to avoid copying all the QWS code - - m_fd = QT_OPEN(dev.toLocal8Bit().constData(), O_RDWR, 0); - if (m_fd >= 0) { - if (repeat_delay > 0 && repeat_rate > 0) { - int kbdrep[2] = { repeat_delay, repeat_rate }; - ::ioctl(m_fd, EVIOCSREP, kbdrep); - } - - QSocketNotifier *notifier; - notifier = new QSocketNotifier(m_fd, QSocketNotifier::Read, this); - connect(notifier, SIGNAL(activated(int)), this, SLOT(readKeycode())); - - if (ttymode) { - // play nice in case we are started from a shell (e.g. for debugging) - m_tty_fd = isatty(0) ? 0 : -1; - - if (m_tty_fd >= 0) { - // save tty config for restore. - tcgetattr(m_tty_fd, &m_tty_attr); - - struct ::termios termdata; - tcgetattr(m_tty_fd, &termdata); - - // record the original mode so we can restore it again in the destructor. - ::ioctl(m_tty_fd, KDGKBMODE, &m_orig_kbmode); - - // setting this translation 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); - - // set the tty layer to pass-through - termdata.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP); - termdata.c_oflag = 0; - termdata.c_cflag = CREAD | CS8; - termdata.c_lflag = 0; - termdata.c_cc[VTIME]=0; - termdata.c_cc[VMIN]=1; - cfsetispeed(&termdata, 9600); - cfsetospeed(&termdata, 9600); - tcsetattr(m_tty_fd, TCSANOW, &termdata); - } - } - } else { - qWarning("Cannot open keyboard input device '%s': %s", qPrintable(dev), strerror(errno)); - return; - } -} - -QLinuxInputKeyboardHandler::~QLinuxInputKeyboardHandler() -{ - if (m_tty_fd >= 0) { - ::ioctl(m_tty_fd, KDSKBMODE, m_orig_kbmode); - tcsetattr(m_tty_fd, TCSANOW, &m_tty_attr); - } - if (m_fd >= 0) - QT_CLOSE(m_fd); - delete m_handler; -} - -void QLinuxInputKeyboardHandler::switchLed(int led, bool state) -{ - struct ::input_event led_ie; - ::gettimeofday(&led_ie.time, 0); - led_ie.type = EV_LED; - led_ie.code = led; - led_ie.value = state; - - QT_WRITE(m_fd, &led_ie, sizeof(led_ie)); -} - - - -void QLinuxInputKeyboardHandler::readKeycode() -{ - struct ::input_event buffer[32]; - int n = 0; - - forever { - n = QT_READ(m_fd, reinterpret_cast(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) { - if (buffer[i].type != EV_KEY) - continue; - - quint16 code = buffer[i].code; - qint32 value = buffer[i].value; - - if (m_handler->filterInputEvent(code, value)) - continue; - - QWSKeyboardHandler::KeycodeAction ka; - ka = m_handler->processKeycode(code, value != 0, value == 2); - - switch (ka) { - case QWSKeyboardHandler::CapsLockOn: - case QWSKeyboardHandler::CapsLockOff: - switchLed(LED_CAPSL, ka == QWSKeyboardHandler::CapsLockOn); - break; - - case QWSKeyboardHandler::NumLockOn: - case QWSKeyboardHandler::NumLockOff: - switchLed(LED_NUML, ka == QWSKeyboardHandler::NumLockOn); - break; - - case QWSKeyboardHandler::ScrollLockOn: - case QWSKeyboardHandler::ScrollLockOff: - switchLed(LED_SCROLLL, ka == QWSKeyboardHandler::ScrollLockOn); - break; - - default: - // ignore console switching and reboot - break; - } - } -} - - diff --git a/src/plugins/generic/linuxinput/qlinuxinput.h b/src/plugins/generic/linuxinput/qlinuxinput.h index 83b91d095d..b9475a1bf5 100644 --- a/src/plugins/generic/linuxinput/qlinuxinput.h +++ b/src/plugins/generic/linuxinput/qlinuxinput.h @@ -79,31 +79,6 @@ private: QLinuxInputMouseHandlerData *d; }; - -class QWSLinuxInputKeyboardHandler; - -class QLinuxInputKeyboardHandler : public QObject -{ - Q_OBJECT -public: - QLinuxInputKeyboardHandler(const QString &key, const QString &specification); - ~QLinuxInputKeyboardHandler(); - - -private: - void switchLed(int, bool); - -private slots: - void readKeycode(); - -private: - QWSLinuxInputKeyboardHandler *m_handler; - int m_fd; - int m_tty_fd; - struct termios m_tty_attr; - int m_orig_kbmode; -}; - QT_END_NAMESPACE QT_END_HEADER -- cgit v1.2.3