evdev: Cleanup mouse and keyboard plugins
Remove fallback event0 device usage. All available devices should be detected automatically from DeviceDiscovery either through udev or the static fallback discovery method. This also removes the never used 'key' argument, which was pulled over from Qt4. Change-Id: Iffe8bd80f0770664024019a220cbbc6f98843340 Reviewed-by: Girish Ramakrishnan <girish.1.ramakrishnan@nokia.com>bb10
parent
a530ffd6de
commit
e6a4d6054d
|
|
@ -62,8 +62,8 @@ QT_BEGIN_NAMESPACE
|
|||
// simple builtin US keymap
|
||||
#include "qevdevkeyboard_defaultmap.h"
|
||||
|
||||
QEvdevKeyboardHandler::QEvdevKeyboardHandler(int deviceDescriptor, bool disableZap, bool enableCompose, const QString &keymapFile)
|
||||
: m_fd(deviceDescriptor),
|
||||
QEvdevKeyboardHandler::QEvdevKeyboardHandler(const QString &device, int fd, bool disableZap, bool enableCompose, const QString &keymapFile)
|
||||
: m_device(device), m_fd(fd),
|
||||
m_modifiers(0), m_composing(0), m_dead_unicode(0xffff),
|
||||
m_no_zap(disableZap), m_do_compose(enableCompose),
|
||||
m_keymap(0), m_keymap_size(0), m_keycompose(0), m_keycompose_size(0)
|
||||
|
|
@ -93,16 +93,13 @@ QEvdevKeyboardHandler::~QEvdevKeyboardHandler()
|
|||
qt_safe_close(m_fd);
|
||||
}
|
||||
|
||||
QEvdevKeyboardHandler *QEvdevKeyboardHandler::createLinuxInputKeyboardHandler(const QString &key, const QString &specification)
|
||||
QEvdevKeyboardHandler *QEvdevKeyboardHandler::create(const QString &device, const QString &specification)
|
||||
{
|
||||
#ifdef QT_QPA_KEYMAP_DEBUG
|
||||
qWarning() << "Try to create keyboard handler with" << key << specification;
|
||||
#else
|
||||
Q_UNUSED(key)
|
||||
qWarning() << "Try to create keyboard handler for" << device << specification;
|
||||
#endif
|
||||
|
||||
QString keymapFile;
|
||||
QString device = QLatin1String("/dev/input/event0");
|
||||
int repeatDelay = 400;
|
||||
int repeatRate = 80;
|
||||
bool disableZap = false;
|
||||
|
|
@ -120,8 +117,6 @@ QEvdevKeyboardHandler *QEvdevKeyboardHandler::createLinuxInputKeyboardHandler(co
|
|||
repeatDelay = arg.mid(13).toInt();
|
||||
else if (arg.startsWith(QLatin1String("repeat-rate=")))
|
||||
repeatRate = arg.mid(12).toInt();
|
||||
else if (arg.startsWith(QLatin1String("/dev/")))
|
||||
device = arg;
|
||||
}
|
||||
|
||||
#ifdef QT_QPA_KEYMAP_DEBUG
|
||||
|
|
@ -136,7 +131,7 @@ QEvdevKeyboardHandler *QEvdevKeyboardHandler::createLinuxInputKeyboardHandler(co
|
|||
::ioctl(fd, EVIOCSREP, kbdrep);
|
||||
}
|
||||
|
||||
return new QEvdevKeyboardHandler(fd, disableZap, enableCompose, keymapFile);
|
||||
return new QEvdevKeyboardHandler(device, fd, disableZap, enableCompose, keymapFile);
|
||||
} else {
|
||||
qWarning("Cannot open keyboard input device '%s': %s", qPrintable(device), strerror(errno));
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ class QEvdevKeyboardHandler : public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QEvdevKeyboardHandler(int deviceDescriptor, bool disableZap, bool enableCompose, const QString &keymapFile);
|
||||
QEvdevKeyboardHandler(const QString &device, int fd, bool disableZap, bool enableCompose, const QString &keymapFile);
|
||||
~QEvdevKeyboardHandler();
|
||||
|
||||
enum KeycodeAction {
|
||||
|
|
@ -147,7 +147,7 @@ public:
|
|||
SwitchConsoleMask = 0x0000007f
|
||||
};
|
||||
|
||||
static QEvdevKeyboardHandler *createLinuxInputKeyboardHandler(const QString &key, const QString &specification);
|
||||
static QEvdevKeyboardHandler *create(const QString &device, const QString &specification);
|
||||
|
||||
static Qt::KeyboardModifiers toQtModifiers(quint8 mod)
|
||||
{
|
||||
|
|
@ -173,6 +173,7 @@ private:
|
|||
void processKeyEvent(int unicode, int keycode, Qt::KeyboardModifiers modifiers, bool isPress, bool autoRepeat);
|
||||
void switchLed(int, bool);
|
||||
|
||||
QString m_device;
|
||||
int m_fd;
|
||||
|
||||
// keymap handling
|
||||
|
|
|
|||
|
|
@ -105,15 +105,8 @@ void QEvdevKeyboardManager::addKeyboard(const QString &deviceNode)
|
|||
qWarning() << "Adding keyboard at" << deviceNode;
|
||||
#endif
|
||||
|
||||
QString specification = m_spec;
|
||||
|
||||
if (!deviceNode.isEmpty()) {
|
||||
specification.append(QLatin1Char(':'));
|
||||
specification.append(deviceNode);
|
||||
}
|
||||
|
||||
QEvdevKeyboardHandler *keyboard;
|
||||
keyboard = QEvdevKeyboardHandler::createLinuxInputKeyboardHandler(QLatin1String("EvdevKeyboard"), specification);
|
||||
keyboard = QEvdevKeyboardHandler::create(deviceNode, m_spec);
|
||||
if (keyboard)
|
||||
m_keyboards.insert(deviceNode, keyboard);
|
||||
else
|
||||
|
|
|
|||
|
|
@ -62,15 +62,12 @@
|
|||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QEvdevMouseHandler *QEvdevMouseHandler::createLinuxInputMouseHandler(const QString &key, const QString &specification)
|
||||
QEvdevMouseHandler *QEvdevMouseHandler::create(const QString &device, const QString &specification)
|
||||
{
|
||||
#ifdef QT_QPA_MOUSE_HANDLER_DEBUG
|
||||
qWarning() << "Try to create mouse handler with" << key << specification;
|
||||
#else
|
||||
Q_UNUSED(key)
|
||||
qWarning() << "Try to create mouse handler for" << device << specification;
|
||||
#endif
|
||||
|
||||
QString device = "/dev/input/event0";
|
||||
bool compression = true;
|
||||
int jitterLimit = 0;
|
||||
|
||||
|
|
@ -80,28 +77,21 @@ QEvdevMouseHandler *QEvdevMouseHandler::createLinuxInputMouseHandler(const QStri
|
|||
compression = false;
|
||||
else if (arg.startsWith("dejitter="))
|
||||
jitterLimit = arg.mid(9).toInt();
|
||||
else if (arg.startsWith(QLatin1String("/dev/")))
|
||||
device = arg;
|
||||
}
|
||||
|
||||
#ifdef QT_QPA_MOUSE_HANDLER_DEBUG
|
||||
qDebug("evdevmouse: Using device %s", qPrintable(device));
|
||||
#endif
|
||||
|
||||
int fd;
|
||||
fd = qt_safe_open(device.toLocal8Bit().constData(), O_RDONLY | O_NDELAY, 0);
|
||||
if (fd >= 0) {
|
||||
return new QEvdevMouseHandler(fd, compression, jitterLimit);
|
||||
return new QEvdevMouseHandler(device, fd, compression, jitterLimit);
|
||||
} else {
|
||||
qWarning("Cannot open mouse input device '%s': %s", qPrintable(device), strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
QEvdevMouseHandler::QEvdevMouseHandler(int deviceDescriptor, bool compression, int jitterLimit)
|
||||
: m_notify(0), m_x(0), m_y(0), m_prevx(0), m_prevy(0),
|
||||
m_fd(deviceDescriptor), m_compression(compression),
|
||||
m_buttons(0)
|
||||
QEvdevMouseHandler::QEvdevMouseHandler(const QString &device, int fd, bool compression, int jitterLimit)
|
||||
: m_device(device), m_fd(fd), m_notify(0), m_x(0), m_y(0), m_prevx(0), m_prevy(0),
|
||||
m_compression(compression), m_buttons(0)
|
||||
{
|
||||
setObjectName(QLatin1String("Evdev Mouse Handler"));
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class QEvdevMouseHandler : public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static QEvdevMouseHandler *createLinuxInputMouseHandler(const QString &key, const QString &specification);
|
||||
static QEvdevMouseHandler *create(const QString &device, const QString &specification);
|
||||
~QEvdevMouseHandler();
|
||||
|
||||
signals:
|
||||
|
|
@ -65,14 +65,15 @@ private slots:
|
|||
void readMouseData();
|
||||
|
||||
private:
|
||||
QEvdevMouseHandler(int deviceDescriptor, bool compression, int jitterLimit);
|
||||
QEvdevMouseHandler(const QString &device, int fd, bool compression, int jitterLimit);
|
||||
|
||||
void sendMouseEvent();
|
||||
|
||||
QString m_device;
|
||||
int m_fd;
|
||||
QSocketNotifier *m_notify;
|
||||
int m_x, m_y;
|
||||
int m_prevx, m_prevy;
|
||||
int m_fd;
|
||||
bool m_compression;
|
||||
Qt::MouseButtons m_buttons;
|
||||
int m_jitterLimitSquared;
|
||||
|
|
|
|||
|
|
@ -138,15 +138,8 @@ void QEvdevMouseManager::addMouse(const QString &deviceNode)
|
|||
qWarning() << "Adding mouse at" << deviceNode;
|
||||
#endif
|
||||
|
||||
QString specification = m_spec;
|
||||
|
||||
if (!deviceNode.isEmpty()) {
|
||||
specification.append(":");
|
||||
specification.append(deviceNode);
|
||||
}
|
||||
|
||||
QEvdevMouseHandler *handler;
|
||||
handler = QEvdevMouseHandler::createLinuxInputMouseHandler("EvdevMouse", specification);
|
||||
handler = QEvdevMouseHandler::create(deviceNode, m_spec);
|
||||
if (handler) {
|
||||
connect(handler, SIGNAL(handleMouseEvent(int, int, Qt::MouseButtons)), this, SLOT(handleMouseEvent(int, int, Qt::MouseButtons)));
|
||||
m_mice.insert(deviceNode, handler);
|
||||
|
|
|
|||
Loading…
Reference in New Issue