// 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)
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;
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
::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;
{
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 {
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)
{
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
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
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;
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"));
{
Q_OBJECT
public:
- static QEvdevMouseHandler *createLinuxInputMouseHandler(const QString &key, const QString &specification);
+ static QEvdevMouseHandler *create(const QString &device, const QString &specification);
~QEvdevMouseHandler();
signals:
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;
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);