summaryrefslogtreecommitdiffstats
path: root/src/plugins/generic/linuxinput/qlinuxinput.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/generic/linuxinput/qlinuxinput.cpp')
-rw-r--r--src/plugins/generic/linuxinput/qlinuxinput.cpp192
1 files changed, 0 insertions, 192 deletions
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 <QPoint>
#include <QWindowSystemInterface>
-#include <qkbd_qws.h>
-
-
#include <qplatformdefs.h>
#include <private/qcore_unix_p.h> // 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<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) {
- 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;
- }
- }
-}
-
-