From 46bf3d71e58457afcc8177a68243ac71308534db Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 3 Mar 2017 09:00:23 +0100 Subject: xcb: stringify enums for tablet qt.qpa.input.events qCDebug It's a bit easier to read, not having to look up TabletDevice and PointerType enum values manually. Change-Id: I53353be4dcea3e2cb875f04250502ffe802fc971 Reviewed-by: Andy Shaw --- src/plugins/platforms/xcb/qxcbconnection_xi2.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'src/plugins/platforms/xcb') diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index 73a7e97716..4a30f7b7bc 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -42,6 +42,7 @@ #include "qxcbscreen.h" #include "qxcbwindow.h" #include "qtouchdevice.h" +#include "QtCore/qmetaobject.h" #include #include #include @@ -1065,6 +1066,18 @@ static QTabletEvent::TabletDevice toolIdToTabletDevice(quint32 toolId) { return QTabletEvent::Stylus; // Safe default assumption if nonzero } +static const char *toolName(QTabletEvent::TabletDevice tool) { + static const QMetaObject *metaObject = qt_getEnumMetaObject(tool); + static const QMetaEnum me = metaObject->enumerator(metaObject->indexOfEnumerator(qt_getEnumName(tool))); + return me.valueToKey(tool); +} + +static const char *pointerTypeName(QTabletEvent::PointerType ptype) { + static const QMetaObject *metaObject = qt_getEnumMetaObject(ptype); + static const QMetaEnum me = metaObject->enumerator(metaObject->indexOfEnumerator(qt_getEnumName(ptype))); + return me.valueToKey(ptype); +} + bool QXcbConnection::xi2HandleTabletEvent(const void *event, TabletData *tabletData) { bool handled = true; @@ -1138,9 +1151,9 @@ bool QXcbConnection::xi2HandleTabletEvent(const void *event, TabletData *tabletD // TODO maybe have a hash of tabletData->deviceId to device data so we can // look up the tablet name here, and distinguish multiple tablets if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled())) - qCDebug(lcQpaXInputEvents, "XI2 proximity change on tablet %d (USB %x): last tool: %x id %x current tool: %x id %x TabletDevice %d", + qCDebug(lcQpaXInputEvents, "XI2 proximity change on tablet %d (USB %x): last tool: %x id %x current tool: %x id %x %s", tabletData->deviceId, ptr[_WACSER_USB_ID], ptr[_WACSER_LAST_TOOL_SERIAL], ptr[_WACSER_LAST_TOOL_ID], - ptr[_WACSER_TOOL_SERIAL], ptr[_WACSER_TOOL_ID], tabletData->tool); + ptr[_WACSER_TOOL_SERIAL], ptr[_WACSER_TOOL_ID], toolName(tabletData->tool)); } XFree(data); } @@ -1203,9 +1216,10 @@ void QXcbConnection::xi2ReportTabletEvent(const void *event, TabletData *tabletD } if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled())) - qCDebug(lcQpaXInputEvents, "XI2 event on tablet %d with tool %d type %d seq %d detail %d time %d " + qCDebug(lcQpaXInputEvents, "XI2 event on tablet %d with tool %s type %s seq %d detail %d time %d " "pos %6.1f, %6.1f root pos %6.1f, %6.1f buttons 0x%x pressure %4.2lf tilt %d, %d rotation %6.2lf", - tabletData->deviceId, tabletData->tool, ev->evtype, ev->sequenceNumber, ev->detail, ev->time, + tabletData->deviceId, toolName(tabletData->tool), pointerTypeName(tabletData->pointerType), + ev->sequenceNumber, ev->detail, ev->time, fixed1616ToReal(ev->event_x), fixed1616ToReal(ev->event_y), fixed1616ToReal(ev->root_x), fixed1616ToReal(ev->root_y), (int)tabletData->buttons, pressure, xTilt, yTilt, rotation); -- cgit v1.2.3