summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@digia.com>2014-10-13 15:32:29 +0200
committerLaszlo Agocs <laszlo.agocs@digia.com>2014-10-16 13:08:14 +0200
commitdae22ebfe48ea769fe55f5330411ca71e0a98542 (patch)
tree72b58d9965305d891fb01ac4efbce56805db4a9c
parentcf046ccec0e9a2f174e6dc47f23cc8c4d5c1a935 (diff)
Switch to categorized logging in all the input handlers
Use the rule qt.qpa.input (similarly to xcb). In addition, evdevkeyboard supports qt.qpa.input.keymap to enable keymap debug messages. For compatibility, evdevtouch retains the QT_QPA_EVDEV_DEBUG environment variable, this will simply turn on the associated logging rule. Change-Id: Ia038beb827346d2573ca9a2b69b8dcc53adcf0eb Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com> Reviewed-by: Risto Avila <risto.avila@digia.com> Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
-rw-r--r--src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp72
-rw-r--r--src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp25
-rw-r--r--src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp28
-rw-r--r--src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp33
-rw-r--r--src/platformsupport/input/evdevtablet/qevdevtablet.cpp16
-rw-r--r--src/platformsupport/input/evdevtouch/qevdevtouch.cpp35
6 files changed, 72 insertions, 137 deletions
diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp
index 27d15dfafa..9ce97cf373 100644
--- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp
+++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp
@@ -37,20 +37,18 @@
#include <QSocketNotifier>
#include <QStringList>
-#include <qpa/qwindowsysteminterface.h>
#include <QCoreApplication>
+#include <QLoggingCategory>
+#include <qpa/qwindowsysteminterface.h>
#include <private/qcore_unix_p.h>
#include <linux/input.h>
-//#define QT_QPA_KEYMAP_DEBUG
-
-#ifdef QT_QPA_KEYMAP_DEBUG
-#include <qdebug.h>
-#endif
-
QT_BEGIN_NAMESPACE
+Q_LOGGING_CATEGORY(qLcEvdevKey, "qt.qpa.input")
+Q_LOGGING_CATEGORY(qLcEvdevKeyMap, "qt.qpa.input.keymap")
+
// simple builtin US keymap
#include "qevdevkeyboard_defaultmap_p.h"
@@ -60,9 +58,7 @@ QEvdevKeyboardHandler::QEvdevKeyboardHandler(const QString &device, int fd, bool
m_no_zap(disableZap), m_do_compose(enableCompose),
m_keymap(0), m_keymap_size(0), m_keycompose(0), m_keycompose_size(0)
{
-#ifdef QT_QPA_KEYMAP_DEBUG
- qWarning() << "Create keyboard handler with for device" << device;
-#endif
+ qCDebug(qLcEvdevKey) << "Create keyboard handler with for device" << device;
setObjectName(QLatin1String("LinuxInput Keyboard Handler"));
@@ -89,9 +85,7 @@ QEvdevKeyboardHandler *QEvdevKeyboardHandler::create(const QString &device,
const QString &specification,
const QString &defaultKeymapFile)
{
-#ifdef QT_QPA_KEYMAP_DEBUG
- qWarning() << "Try to create keyboard handler for" << device << specification;
-#endif
+ qCDebug(qLcEvdevKey) << "Try to create keyboard handler for" << device << specification;
QString keymapFile = defaultKeymapFile;
int repeatDelay = 400;
@@ -116,9 +110,7 @@ QEvdevKeyboardHandler *QEvdevKeyboardHandler::create(const QString &device,
grab = arg.mid(5).toInt();
}
-#ifdef QT_QPA_KEYMAP_DEBUG
- qWarning() << "Opening keyboard at" << device;
-#endif
+ qCDebug(qLcEvdevKey) << "Opening keyboard at" << device;
int fd;
fd = qt_safe_open(device.toLocal8Bit().constData(), O_RDONLY | O_NDELAY, 0);
@@ -138,9 +130,7 @@ QEvdevKeyboardHandler *QEvdevKeyboardHandler::create(const QString &device,
void QEvdevKeyboardHandler::switchLed(int led, bool state)
{
-#ifdef QT_QPA_KEYMAP_DEBUG
- qWarning() << "switchLed" << led << state;
-#endif
+ qCDebug(qLcEvdevKey) << "switchLed" << led << state;
struct ::input_event led_ie;
::gettimeofday(&led_ie.time, 0);
@@ -153,10 +143,6 @@ void QEvdevKeyboardHandler::switchLed(int led, bool state)
void QEvdevKeyboardHandler::readKeycode()
{
-#ifdef QT_QPA_KEYMAP_DEBUG
- qWarning() << "Read new keycode on" << m_device;
-#endif
-
struct ::input_event buffer[32];
int n = 0;
@@ -164,11 +150,11 @@ void QEvdevKeyboardHandler::readKeycode()
int result = qt_safe_read(m_fd, reinterpret_cast<char *>(buffer) + n, sizeof(buffer) - n);
if (result == 0) {
- qWarning("Got EOF from the input device.");
+ qWarning("evdevkeyboard: Got EOF from the input device");
return;
} else if (result < 0) {
if (errno != EINTR && errno != EAGAIN) {
- qWarning("Could not read from input device: %s", strerror(errno));
+ qErrnoWarning(errno, "evdevkeyboard: Could not read from input device");
return;
}
} else {
@@ -249,21 +235,17 @@ QEvdevKeyboardHandler::KeycodeAction QEvdevKeyboardHandler::processKeycode(quint
if (m_locks[0] /*CapsLock*/ && map_withmod && (map_withmod->flags & QEvdevKeyboardMap::IsLetter))
modifiers ^= QEvdevKeyboardMap::ModShift;
-#ifdef QT_QPA_KEYMAP_DEBUG
- qWarning("Processing key event: keycode=%3d, modifiers=%02x pressed=%d, autorepeat=%d | plain=%d, withmod=%d, size=%d", \
- keycode, modifiers, pressed ? 1 : 0, autorepeat ? 1 : 0, \
- map_plain ? map_plain - m_keymap : -1, \
- map_withmod ? map_withmod - m_keymap : -1, \
- m_keymap_size);
-#endif
+ qCDebug(qLcEvdevKeyMap, "Processing key event: keycode=%3d, modifiers=%02x pressed=%d, autorepeat=%d | plain=%d, withmod=%d, size=%d",
+ keycode, modifiers, pressed ? 1 : 0, autorepeat ? 1 : 0,
+ int(map_plain ? map_plain - m_keymap : -1),
+ int(map_withmod ? map_withmod - m_keymap : -1),
+ m_keymap_size);
const QEvdevKeyboardMap::Mapping *it = map_withmod ? map_withmod : map_plain;
if (!it) {
-#ifdef QT_QPA_KEYMAP_DEBUG
// we couldn't even find a plain mapping
- qWarning("Could not find a suitable mapping for keycode: %3d, modifiers: %02x", keycode, modifiers);
-#endif
+ qCDebug(qLcEvdevKeyMap, "Could not find a suitable mapping for keycode: %3d, modifiers: %02x", keycode, modifiers);
return result;
}
@@ -397,9 +379,7 @@ QEvdevKeyboardHandler::KeycodeAction QEvdevKeyboardHandler::processKeycode(quint
}
if (!skip) {
-#ifdef QT_QPA_KEYMAP_DEBUG
- qWarning("Processing: uni=%04x, qt=%08x, qtmod=%08x", unicode, qtcode & ~modmask, (qtcode & modmask));
-#endif
+ qCDebug(qLcEvdevKeyMap, "Processing: uni=%04x, qt=%08x, qtmod=%08x", unicode, qtcode & ~modmask, (qtcode & modmask));
//If NumLockOff and keypad key pressed remap event sent
if (!m_locks[1] &&
(qtcode & Qt::KeypadModifier) &&
@@ -457,9 +437,7 @@ QEvdevKeyboardHandler::KeycodeAction QEvdevKeyboardHandler::processKeycode(quint
void QEvdevKeyboardHandler::unloadKeymap()
{
-#ifdef QT_QPA_KEYMAP_DEBUG
- qWarning() << "Unload current keymap and restore built-in";
-#endif
+ qCDebug(qLcEvdevKey) << "Unload current keymap and restore built-in";
if (m_keymap && m_keymap != s_keymap_default)
delete [] m_keymap;
@@ -481,7 +459,7 @@ void QEvdevKeyboardHandler::unloadKeymap()
quint16 ledbits[1];
memset(ledbits, 0, sizeof(ledbits));
if (::ioctl(m_fd, EVIOCGLED(sizeof(ledbits)), ledbits) < 0) {
- qWarning("Failed to query led states. Settings numlock & capslock off");
+ qWarning("evdevkeyboard: Failed to query led states");
switchLed(LED_NUML,false);
switchLed(LED_CAPSL, false);
switchLed(LED_SCROLLL,false);
@@ -495,17 +473,13 @@ void QEvdevKeyboardHandler::unloadKeymap()
//Scrollock
if ((ledbits[0]&0x04) > 0)
m_locks[2] = 1;
-#ifdef QT_QPA_KEYMAP_DEBUG
- qWarning("numlock=%d , capslock=%d, scrolllock=%d",m_locks[1],m_locks[0],m_locks[2]);
-#endif
+ qCDebug(qLcEvdevKey, "numlock=%d , capslock=%d, scrolllock=%d", m_locks[1], m_locks[0], m_locks[2]);
}
}
bool QEvdevKeyboardHandler::loadKeymap(const QString &file)
{
-#ifdef QT_QPA_KEYMAP_DEBUG
- qWarning() << "Load keymap" << file;
-#endif
+ qCDebug(qLcEvdevKey) << "Loading keymap" << file;
QFile f(file);
@@ -529,7 +503,7 @@ bool QEvdevKeyboardHandler::loadKeymap(const QString &file)
ds >> qmap_magic >> qmap_version >> qmap_keymap_size >> qmap_keycompose_size;
if (ds.status() != QDataStream::Ok || qmap_magic != QEvdevKeyboardMap::FileMagic || qmap_version != 1 || qmap_keymap_size == 0) {
- qWarning("'%s' is ot a valid.qmap keymap file.", qPrintable(file));
+ qWarning("'%s' is not a valid .qmap keymap file", qPrintable(file));
return false;
}
diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp
index 3f8eb1bcd5..4614fbd499 100644
--- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp
+++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp
@@ -35,15 +35,12 @@
#include <QStringList>
#include <QCoreApplication>
-
-//#define QT_QPA_KEYMAP_DEBUG
-
-#ifdef QT_QPA_KEYMAP_DEBUG
-#include <QDebug>
-#endif
+#include <QLoggingCategory>
QT_BEGIN_NAMESPACE
+Q_DECLARE_LOGGING_CATEGORY(qLcEvdevKey)
+
QEvdevKeyboardManager::QEvdevKeyboardManager(const QString &key, const QString &specification, QObject *parent)
: QObject(parent)
{
@@ -74,10 +71,7 @@ QEvdevKeyboardManager::QEvdevKeyboardManager(const QString &key, const QString &
addKeyboard(device);
if (devices.isEmpty()) {
-#ifdef QT_QPA_KEYMAP_DEBUG
- qWarning() << "Use device discovery";
-#endif
-
+ qCDebug(qLcEvdevKey) << "evdevkeyboard: Using device discovery";
m_deviceDiscovery = QDeviceDiscovery::create(QDeviceDiscovery::Device_Keyboard, this);
if (m_deviceDiscovery) {
// scan and add already connected keyboards
@@ -100,24 +94,19 @@ QEvdevKeyboardManager::~QEvdevKeyboardManager()
void QEvdevKeyboardManager::addKeyboard(const QString &deviceNode)
{
-#ifdef QT_QPA_KEYMAP_DEBUG
- qWarning() << "Adding keyboard at" << deviceNode;
-#endif
-
+ qCDebug(qLcEvdevKey) << "Adding keyboard at" << deviceNode;
QEvdevKeyboardHandler *keyboard;
keyboard = QEvdevKeyboardHandler::create(deviceNode, m_spec, m_defaultKeymapFile);
if (keyboard)
m_keyboards.insert(deviceNode, keyboard);
else
- qWarning("Failed to open keyboard");
+ qWarning("Failed to open keyboard device %s", qPrintable(deviceNode));
}
void QEvdevKeyboardManager::removeKeyboard(const QString &deviceNode)
{
if (m_keyboards.contains(deviceNode)) {
-#ifdef QT_QPA_KEYMAP_DEBUG
- qWarning() << "Removing keyboard at" << deviceNode;
-#endif
+ qCDebug(qLcEvdevKey) << "Removing keyboard at" << deviceNode;
QEvdevKeyboardHandler *keyboard = m_keyboards.value(deviceNode);
m_keyboards.remove(deviceNode);
delete keyboard;
diff --git a/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp b/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp
index 11db06680a..eddf180e4a 100644
--- a/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp
+++ b/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp
@@ -38,6 +38,7 @@
#include <QPoint>
#include <QGuiApplication>
#include <QScreen>
+#include <QLoggingCategory>
#include <qpa/qwindowsysteminterface.h>
#include <qplatformdefs.h>
@@ -48,19 +49,15 @@
#include <linux/kd.h>
#include <linux/input.h>
-#include <qdebug.h>
-
-//#define QT_QPA_MOUSE_HANDLER_DEBUG
-
#define TEST_BIT(array, bit) (array[bit/8] & (1<<(bit%8)))
QT_BEGIN_NAMESPACE
+Q_LOGGING_CATEGORY(qLcEvdevMouse, "qt.qpa.input")
+
QEvdevMouseHandler *QEvdevMouseHandler::create(const QString &device, const QString &specification)
{
-#ifdef QT_QPA_MOUSE_HANDLER_DEBUG
- qWarning() << "Try to create mouse handler for" << device << specification;
-#endif
+ qCDebug(qLcEvdevMouse) << "create mouse handler for" << device << specification;
bool compression = true;
int jitterLimit = 0;
@@ -85,7 +82,7 @@ QEvdevMouseHandler *QEvdevMouseHandler::create(const QString &device, const QStr
::ioctl(fd, EVIOCGRAB, grab);
return new QEvdevMouseHandler(device, fd, abs, compression, jitterLimit);
} else {
- qWarning("Cannot open mouse input device '%s': %s", qPrintable(device), strerror(errno));
+ qErrnoWarning(errno, "Cannot open mouse input device %s", qPrintable(device));
return 0;
}
}
@@ -148,12 +145,10 @@ bool QEvdevMouseHandler::getHardwareMaximum()
m_hardwareScalerX = static_cast<qreal>(m_hardwareWidth) / (g.right() - g.left());
m_hardwareScalerY = static_cast<qreal>(m_hardwareHeight) / (g.bottom() - g.top());
-#ifdef QT_QPA_MOUSE_HANDLER_DEBUG
- qDebug() << "Absolute pointing device";
- qDebug() << "hardware max x" << m_hardwareWidth;
- qDebug() << "hardware max y" << m_hardwareHeight;
- qDebug() << "hardware scalers x" << m_hardwareScalerX << "y" << m_hardwareScalerY;
-#endif
+ qCDebug(qLcEvdevMouse) << "Absolute pointing device"
+ << "hardware max x" << m_hardwareWidth
+ << "hardware max y" << m_hardwareHeight
+ << "hardware scalers x" << m_hardwareScalerX << "y" << m_hardwareScalerY;
return true;
}
@@ -194,11 +189,11 @@ void QEvdevMouseHandler::readMouseData()
int result = QT_READ(m_fd, reinterpret_cast<char *>(buffer) + n, sizeof(buffer) - n);
if (result == 0) {
- qWarning("Got EOF from the input device.");
+ qWarning("evdevmouse: Got EOF from the input device");
return;
} else if (result < 0) {
if (errno != EINTR && errno != EAGAIN) {
- qWarning("Could not read from input device: %s", strerror(errno));
+ qErrnoWarning(errno, "evdevmouse: Could not read from input device");
return;
}
} else {
@@ -212,7 +207,6 @@ void QEvdevMouseHandler::readMouseData()
for (int i = 0; i < n; ++i) {
struct ::input_event *data = &buffer[i];
- //qDebug() << ">>" << hex << data->type << data->code << dec << data->value;
if (data->type == EV_ABS) {
// Touchpads: store the absolute position for now, will calculate a relative one later.
if (data->code == ABS_X && m_x != data->value) {
diff --git a/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp b/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp
index 2b52c4e995..a0c9c9f34d 100644
--- a/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp
+++ b/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp
@@ -36,16 +36,13 @@
#include <QStringList>
#include <QGuiApplication>
#include <QScreen>
+#include <QLoggingCategory>
#include <qpa/qwindowsysteminterface.h>
-//#define QT_QPA_MOUSEMANAGER_DEBUG
-
-#ifdef QT_QPA_MOUSEMANAGER_DEBUG
-#include <QDebug>
-#endif
-
QT_BEGIN_NAMESPACE
+Q_DECLARE_LOGGING_CATEGORY(qLcEvdevMouse)
+
QEvdevMouseManager::QEvdevMouseManager(const QString &key, const QString &specification, QObject *parent)
: QObject(parent), m_x(0), m_y(0), m_xoffset(0), m_yoffset(0)
{
@@ -79,10 +76,7 @@ QEvdevMouseManager::QEvdevMouseManager(const QString &key, const QString &specif
addMouse(device);
if (devices.isEmpty()) {
-#ifdef QT_QPA_MOUSEMANAGER_DEBUG
- qWarning() << "Use device discovery";
-#endif
-
+ qCDebug(qLcEvdevMouse) << "evdevmouse: Using device discovery";
m_deviceDiscovery = QDeviceDiscovery::create(QDeviceDiscovery::Device_Mouse | QDeviceDiscovery::Device_Touchpad, this);
if (m_deviceDiscovery) {
// scan and add already connected keyboards
@@ -130,28 +124,17 @@ void QEvdevMouseManager::handleMouseEvent(int x, int y, bool abs, Qt::MouseButto
// Cannot track the keyboard modifiers ourselves here. Instead, report the
// modifiers from the last key event that has been seen by QGuiApplication.
QWindowSystemInterface::handleMouseEvent(0, pos, pos, buttons, QGuiApplication::keyboardModifiers());
-
-#ifdef QT_QPA_MOUSEMANAGER_DEBUG
- qDebug("mouse event %d %d %d", pos.x(), pos.y(), int(buttons));
-#endif
}
void QEvdevMouseManager::handleWheelEvent(int delta, Qt::Orientation orientation)
{
QPoint pos(m_x + m_xoffset, m_y + m_yoffset);
QWindowSystemInterface::handleWheelEvent(0, pos, pos, delta, orientation, QGuiApplication::keyboardModifiers());
-
-#ifdef QT_QPA_MOUSEMANAGER_DEBUG
- qDebug("mouse wheel event %dx%d %d %d", pos.x(), pos.y(), delta, int(orientation));
-#endif
}
void QEvdevMouseManager::addMouse(const QString &deviceNode)
{
-#ifdef QT_QPA_MOUSEMANAGER_DEBUG
- qWarning() << "Adding mouse at" << deviceNode;
-#endif
-
+ qCDebug(qLcEvdevMouse) << "Adding mouse at" << deviceNode;
QEvdevMouseHandler *handler;
handler = QEvdevMouseHandler::create(deviceNode, m_spec);
if (handler) {
@@ -159,16 +142,14 @@ void QEvdevMouseManager::addMouse(const QString &deviceNode)
connect(handler, SIGNAL(handleWheelEvent(int,Qt::Orientation)), this, SLOT(handleWheelEvent(int,Qt::Orientation)));
m_mice.insert(deviceNode, handler);
} else {
- qWarning("Failed to open mouse");
+ qWarning("evdevmouse: Failed to open mouse device %s", qPrintable(deviceNode));
}
}
void QEvdevMouseManager::removeMouse(const QString &deviceNode)
{
if (m_mice.contains(deviceNode)) {
-#ifdef QT_QPA_MOUSEMANAGER_DEBUG
- qWarning() << "Removing mouse at" << deviceNode;
-#endif
+ qCDebug(qLcEvdevMouse) << "Removing mouse at" << deviceNode;
QEvdevMouseHandler *handler = m_mice.value(deviceNode);
m_mice.remove(deviceNode);
delete handler;
diff --git a/src/platformsupport/input/evdevtablet/qevdevtablet.cpp b/src/platformsupport/input/evdevtablet/qevdevtablet.cpp
index 8d91c49488..8dbf5832d9 100644
--- a/src/platformsupport/input/evdevtablet/qevdevtablet.cpp
+++ b/src/platformsupport/input/evdevtablet/qevdevtablet.cpp
@@ -36,13 +36,15 @@
#include <QStringList>
#include <QSocketNotifier>
#include <QGuiApplication>
-#include <QDebug>
+#include <QLoggingCategory>
#include <QtCore/private/qcore_unix_p.h>
#include <QtPlatformSupport/private/qdevicediscovery_p.h>
#include <linux/input.h>
QT_BEGIN_NAMESPACE
+Q_LOGGING_CATEGORY(qLcEvdevTablet, "qt.qpa.input")
+
class QEvdevTabletData
{
public:
@@ -87,28 +89,28 @@ bool QEvdevTabletData::queryLimits()
if (ok) {
minValues.x = absInfo.minimum;
maxValues.x = absInfo.maximum;
- qDebug("evdevtablet: min X: %d max X: %d", minValues.x, maxValues.x);
+ qCDebug(qLcEvdevTablet, "evdevtablet: min X: %d max X: %d", minValues.x, maxValues.x);
}
ok &= ioctl(fd, EVIOCGABS(ABS_Y), &absInfo) >= 0;
if (ok) {
minValues.y = absInfo.minimum;
maxValues.y = absInfo.maximum;
- qDebug("evdevtablet: min Y: %d max Y: %d", minValues.y, maxValues.y);
+ qCDebug(qLcEvdevTablet, "evdevtablet: min Y: %d max Y: %d", minValues.y, maxValues.y);
}
if (ioctl(fd, EVIOCGABS(ABS_PRESSURE), &absInfo) >= 0) {
minValues.p = absInfo.minimum;
maxValues.p = absInfo.maximum;
- qDebug("evdevtablet: min pressure: %d max pressure: %d", minValues.p, maxValues.p);
+ qCDebug(qLcEvdevTablet, "evdevtablet: min pressure: %d max pressure: %d", minValues.p, maxValues.p);
}
if (ioctl(fd, EVIOCGABS(ABS_DISTANCE), &absInfo) >= 0) {
minValues.d = absInfo.minimum;
maxValues.d = absInfo.maximum;
- qDebug("evdevtablet: min distance: %d max distance: %d", minValues.d, maxValues.d);
+ qCDebug(qLcEvdevTablet, "evdevtablet: min distance: %d max distance: %d", minValues.d, maxValues.d);
}
char name[128];
if (ioctl(fd, EVIOCGNAME(sizeof(name) - 1), name) >= 0) {
devName = QString::fromLocal8Bit(name);
- qDebug("evdevtablet: device name: %s", name);
+ qCDebug(qLcEvdevTablet, "evdevtablet: device name: %s", name);
}
return ok;
}
@@ -232,7 +234,7 @@ QEvdevTabletHandler::QEvdevTabletHandler(const QString &spec, QObject *parent)
}
}
if (!dev.isEmpty()) {
- qDebug("evdevtablet: using %s", qPrintable(dev));
+ qCDebug(qLcEvdevTablet, "evdevtablet: using %s", qPrintable(dev));
d->fd = QT_OPEN(dev.toLocal8Bit().constData(), O_RDONLY | O_NDELAY, 0);
if (d->fd >= 0) {
d->testGrab();
diff --git a/src/platformsupport/input/evdevtouch/qevdevtouch.cpp b/src/platformsupport/input/evdevtouch/qevdevtouch.cpp
index d3b8afea13..dd831c9e82 100644
--- a/src/platformsupport/input/evdevtouch/qevdevtouch.cpp
+++ b/src/platformsupport/input/evdevtouch/qevdevtouch.cpp
@@ -36,7 +36,7 @@
#include <QHash>
#include <QSocketNotifier>
#include <QGuiApplication>
-#include <QDebug>
+#include <QLoggingCategory>
#include <QtCore/private/qcore_unix_p.h>
#include <QtPlatformSupport/private/qdevicediscovery_p.h>
#include <linux/input.h>
@@ -49,6 +49,8 @@ extern "C" {
QT_BEGIN_NAMESPACE
+Q_LOGGING_CATEGORY(qLcEvdevTouch, "qt.qpa.input")
+
/* android (and perhaps some other linux-derived stuff) don't define everything
* in linux/input.h, so we'll need to do that ourselves.
*/
@@ -164,7 +166,8 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &specification,
{
setObjectName(QLatin1String("Evdev Touch Handler"));
- bool printDeviceInfo = qEnvironmentVariableIntValue("QT_QPA_EVDEV_DEBUG");
+ if (qEnvironmentVariableIsSet("QT_QPA_EVDEV_DEBUG"))
+ ((QLoggingCategory &) qLcEvdevTouch()).setEnabled(QtDebugMsg, true);
// only the first device argument is used for now
QString spec = QString::fromLocal8Bit(qgetenv("QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS"));
@@ -215,13 +218,11 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &specification,
}
if (dev.isEmpty()) {
- if (printDeviceInfo)
- qDebug("evdevtouch: No touch devices found");
+ qCDebug(qLcEvdevTouch, "evdevtouch: No touch devices found");
return;
}
- if (printDeviceInfo)
- qDebug("evdevtouch: Using device %s", qPrintable(dev));
+ qCDebug(qLcEvdevTouch, "evdevtouch: Using device %s", qPrintable(dev));
m_fd = QT_OPEN(dev.toLocal8Bit().constData(), O_RDONLY | O_NDELAY, 0);
@@ -257,25 +258,22 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &specification,
}
#endif
- if (printDeviceInfo)
- qDebug("evdevtouch: Protocol type %c %s (%s)", d->m_typeB ? 'B' : 'A',
- mtdevStr, d->m_singleTouch ? "single" : "multi");
+ qCDebug(qLcEvdevTouch, "evdevtouch: Protocol type %c %s (%s)", d->m_typeB ? 'B' : 'A',
+ mtdevStr, d->m_singleTouch ? "single" : "multi");
input_absinfo absInfo;
memset(&absInfo, 0, sizeof(input_absinfo));
bool has_x_range = false, has_y_range = false;
if (ioctl(m_fd, EVIOCGABS((d->m_singleTouch ? ABS_X : ABS_MT_POSITION_X)), &absInfo) >= 0) {
- if (printDeviceInfo)
- qDebug("evdevtouch: min X: %d max X: %d", absInfo.minimum, absInfo.maximum);
+ qCDebug(qLcEvdevTouch, "evdevtouch: min X: %d max X: %d", absInfo.minimum, absInfo.maximum);
d->hw_range_x_min = absInfo.minimum;
d->hw_range_x_max = absInfo.maximum;
has_x_range = true;
}
if (ioctl(m_fd, EVIOCGABS((d->m_singleTouch ? ABS_Y : ABS_MT_POSITION_Y)), &absInfo) >= 0) {
- if (printDeviceInfo)
- qDebug("evdevtouch: min Y: %d max Y: %d", absInfo.minimum, absInfo.maximum);
+ qCDebug(qLcEvdevTouch, "evdevtouch: min Y: %d max Y: %d", absInfo.minimum, absInfo.maximum);
d->hw_range_y_min = absInfo.minimum;
d->hw_range_y_max = absInfo.maximum;
has_y_range = true;
@@ -285,8 +283,7 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &specification,
qWarning("evdevtouch: Invalid ABS limits, behavior unspecified");
if (ioctl(m_fd, EVIOCGABS(ABS_PRESSURE), &absInfo) >= 0) {
- if (printDeviceInfo)
- qDebug("evdevtouch: min pressure: %d max pressure: %d", absInfo.minimum, absInfo.maximum);
+ qCDebug(qLcEvdevTouch, "evdevtouch: min pressure: %d max pressure: %d", absInfo.minimum, absInfo.maximum);
if (absInfo.maximum > absInfo.minimum) {
d->hw_pressure_min = absInfo.minimum;
d->hw_pressure_max = absInfo.maximum;
@@ -296,8 +293,7 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &specification,
char name[1024];
if (ioctl(m_fd, EVIOCGNAME(sizeof(name) - 1), name) >= 0) {
d->hw_name = QString::fromLocal8Bit(name);
- if (printDeviceInfo)
- qDebug("evdevtouch: device name: %s", name);
+ qCDebug(qLcEvdevTouch, "evdevtouch: device name: %s", name);
}
// Fix up the coordinate ranges for am335x in case the kernel driver does not have them fixed.
@@ -310,9 +306,8 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &specification,
d->hw_range_y_min = 220;
d->hw_range_y_max = 3907;
}
- if (printDeviceInfo)
- qDebug("evdevtouch: found ti-tsc, overriding: min X: %d max X: %d min Y: %d max Y: %d",
- d->hw_range_x_min, d->hw_range_x_max, d->hw_range_y_min, d->hw_range_y_max);
+ qCDebug(qLcEvdevTouch, "evdevtouch: found ti-tsc, overriding: min X: %d max X: %d min Y: %d max Y: %d",
+ d->hw_range_x_min, d->hw_range_x_max, d->hw_range_y_min, d->hw_range_y_max);
}
bool grabSuccess = !ioctl(m_fd, EVIOCGRAB, (void *) 1);