diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboard_defaultmap_p.h b/src/platformsupport/input/evdevkeyboard/qevdevkeyboard_defaultmap_p.h index 02ed8463e34..5dd859eb16a 100644 --- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboard_defaultmap_p.h +++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboard_defaultmap_p.h @@ -19,7 +19,7 @@ #include "private/qglobal_p.h" #ifdef Q_OS_FREEBSD #include -#else +#elif !defined(Q_OS_VXWORKS) #include "linux/input.h" #endif @@ -613,6 +613,7 @@ const QEvdevKeyboardMap::Mapping QEvdevKeyboardHandler::s_keymap_default[] = { { 111, 0xffff, 0x01000000, 0x06, 0x08, 0x0200 }, { 111, 0xffff, 0x01000000, 0x0c, 0x08, 0x0200 }, +#ifndef Q_OS_VXWORKS // 113 -> 248 { KEY_MUTE, 0xffff, Qt::Key_VolumeMute, 0x00, 0x00, 0x0000 }, { KEY_VOLUMEDOWN, 0xffff, Qt::Key_VolumeDown, 0x00, 0x00, 0x0000 }, @@ -641,6 +642,7 @@ const QEvdevKeyboardMap::Mapping QEvdevKeyboardHandler::s_keymap_default[] = { { KEY_BLUE, 0xffff, Qt::Key_Blue, 0x00, 0x00, 0x0000 }, { KEY_CHANNELUP, 0xffff, Qt::Key_ChannelUp, 0x00, 0x00, 0x0000 }, { KEY_CHANNELDOWN, 0xffff, Qt::Key_ChannelDown, 0x00, 0x00, 0x0000 }, +#endif }; const QEvdevKeyboardMap::Composing QEvdevKeyboardHandler::s_keycompose_default[] = { diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp index 48fba799581..acace3e77b6 100644 --- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp +++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp @@ -19,6 +19,8 @@ #ifdef Q_OS_FREEBSD #include +#elif defined(Q_OS_VXWORKS) +#include #else #include #endif @@ -111,11 +113,22 @@ std::unique_ptr QEvdevKeyboardHandler::create(const QStri fd.reset(qt_safe_open(device.toLocal8Bit().constData(), O_RDONLY | O_NDELAY, 0)); } if (fd.get() >= 0) { +#if !defined(Q_OS_VXWORKS) ::ioctl(fd.get(), EVIOCGRAB, grab); if (repeatDelay > 0 && repeatRate > 0) { int kbdrep[2] = { repeatDelay, repeatRate }; ::ioctl(fd.get(), EVIOCSREP, kbdrep); } +#else + Q_UNUSED(repeatDelay) + Q_UNUSED(repeatRate) + Q_UNUSED(grab) + UINT32 kbdMode = EV_DEV_KBD_KEYCODE_MODE; + if (ERROR == ioctl (fd.get(), EV_DEV_IO_SET_KBD_MODE, (char *)&kbdMode)) { + qWarning("Cannot set keyboard mapping mode to KEYCODE mode '%s': %s", qPrintable(device), strerror(errno)); + return 0; + } +#endif return std::unique_ptr(new QEvdevKeyboardHandler(device, fd, disableZap, enableCompose, keymapFile)); } else { @@ -124,6 +137,7 @@ std::unique_ptr QEvdevKeyboardHandler::create(const QStri } } +#if !defined(Q_OS_VXWORKS) void QEvdevKeyboardHandler::switchLed(int led, bool state) { qCDebug(qLcEvdevKey, "switchLed %d %d", led, int(state)); @@ -139,9 +153,45 @@ void QEvdevKeyboardHandler::switchLed(int led, bool state) qt_safe_write(m_fd.get(), &led_ie, sizeof(led_ie)); } +#endif void QEvdevKeyboardHandler::readKeycode() { +#if defined(Q_OS_VXWORKS) + EV_DEV_EVENT ev; + int n = ERROR; + + while (n == ERROR) { + n = read(m_fd.get(), (char *)(&ev), sizeof(EV_DEV_EVENT)); + + if (n == 0) { + qWarning("evdevkeyboard: Got EOF from the input device"); + return; + } + + if (n == ERROR) { + if (errno == EINTR || errno == EAGAIN) + continue; + + qErrnoWarning("evdevkeyboard: Could not read from input device"); + if (errno == ENXIO) { + close(m_fd.get()); + delete m_notify; + m_notify = nullptr; + m_fd.reset(); + } + return; + } + } + + if (n < sizeof(EV_DEV_EVENT)) return; + if (ev.type != EV_DEV_KEY) return; + + quint16 code = ev.code; + qint32 value = ev.value; + + processKeycode(code, value != 0, value == 2); +#else struct ::input_event buffer[32]; int n = 0; @@ -203,6 +253,7 @@ void QEvdevKeyboardHandler::readKeycode() break; } } +#endif } void QEvdevKeyboardHandler::processKeyEvent(int nativecode, int unicode, int qtcode, @@ -478,6 +529,7 @@ void QEvdevKeyboardHandler::unloadKeymap() m_composing = 0; m_dead_unicode = 0xffff; +#if !defined(Q_OS_VXWORKS) //Set locks according to keyboard leds quint16 ledbits[1]; memset(ledbits, 0, sizeof(ledbits)); @@ -500,6 +552,7 @@ void QEvdevKeyboardHandler::unloadKeymap() } m_langLock = 0; +#endif } bool QEvdevKeyboardHandler::loadKeymap(const QString &file) diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h index 1d991e2ba51..c5e39b6b334 100644 --- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h +++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h @@ -165,7 +165,9 @@ public: private: void processKeyEvent(int nativecode, int unicode, int qtcode, Qt::KeyboardModifiers modifiers, bool isPress, bool autoRepeat); +#ifndef Q_OS_VXWORKS void switchLed(int, bool); +#endif QString m_device; QFdContainer m_fd;