| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||
| 3 | extern "C" { | - | ||||||||||||||||||||||||
| 4 | } | - | ||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||
| 6 | - | |||||||||||||||||||||||||
| 7 | - | |||||||||||||||||||||||||
| 8 | - | |||||||||||||||||||||||||
| 9 | const QLoggingCategory &qLcEvdevTouch() { static const QLoggingCategory category("qt.qpa.input"); return never executed: category;return category;never executed: }return category; | 0 | ||||||||||||||||||||||||
| 10 | class QEvdevTouchScreenData | - | ||||||||||||||||||||||||
| 11 | { | - | ||||||||||||||||||||||||
| 12 | public: | - | ||||||||||||||||||||||||
| 13 | QEvdevTouchScreenData(QEvdevTouchScreenHandler *q_ptr, const QStringList &args); | - | ||||||||||||||||||||||||
| 14 | - | |||||||||||||||||||||||||
| 15 | void processInputEvent(input_event *data); | - | ||||||||||||||||||||||||
| 16 | void assignIds(); | - | ||||||||||||||||||||||||
| 17 | - | |||||||||||||||||||||||||
| 18 | QEvdevTouchScreenHandler *q; | - | ||||||||||||||||||||||||
| 19 | int m_lastEventType; | - | ||||||||||||||||||||||||
| 20 | QList<QWindowSystemInterface::TouchPoint> m_touchPoints; | - | ||||||||||||||||||||||||
| 21 | - | |||||||||||||||||||||||||
| 22 | struct Contact { | - | ||||||||||||||||||||||||
| 23 | int trackingId; | - | ||||||||||||||||||||||||
| 24 | int x; | - | ||||||||||||||||||||||||
| 25 | int y; | - | ||||||||||||||||||||||||
| 26 | int maj; | - | ||||||||||||||||||||||||
| 27 | int pressure; | - | ||||||||||||||||||||||||
| 28 | Qt::TouchPointState state; | - | ||||||||||||||||||||||||
| 29 | QTouchEvent::TouchPoint::InfoFlags flags; | - | ||||||||||||||||||||||||
| 30 | Contact() : trackingId(-1), | - | ||||||||||||||||||||||||
| 31 | x(0), y(0), maj(-1), pressure(0), | - | ||||||||||||||||||||||||
| 32 | state(Qt::TouchPointPressed), flags(0) { } never executed: end of block | 0 | ||||||||||||||||||||||||
| 33 | }; | - | ||||||||||||||||||||||||
| 34 | QHash<int, Contact> m_contacts; | - | ||||||||||||||||||||||||
| 35 | QHash<int, Contact> m_lastContacts; | - | ||||||||||||||||||||||||
| 36 | Contact m_currentData; | - | ||||||||||||||||||||||||
| 37 | int m_currentSlot; | - | ||||||||||||||||||||||||
| 38 | - | |||||||||||||||||||||||||
| 39 | int findClosestContact(const QHash<int, Contact> &contacts, int x, int y, int *dist); | - | ||||||||||||||||||||||||
| 40 | void addTouchPoint(const Contact &contact, Qt::TouchPointStates *combinedStates); | - | ||||||||||||||||||||||||
| 41 | void reportPoints(); | - | ||||||||||||||||||||||||
| 42 | - | |||||||||||||||||||||||||
| 43 | int hw_range_x_min; | - | ||||||||||||||||||||||||
| 44 | int hw_range_x_max; | - | ||||||||||||||||||||||||
| 45 | int hw_range_y_min; | - | ||||||||||||||||||||||||
| 46 | int hw_range_y_max; | - | ||||||||||||||||||||||||
| 47 | int hw_pressure_min; | - | ||||||||||||||||||||||||
| 48 | int hw_pressure_max; | - | ||||||||||||||||||||||||
| 49 | QString hw_name; | - | ||||||||||||||||||||||||
| 50 | bool m_forceToActiveWindow; | - | ||||||||||||||||||||||||
| 51 | bool m_typeB; | - | ||||||||||||||||||||||||
| 52 | QTransform m_rotate; | - | ||||||||||||||||||||||||
| 53 | bool m_singleTouch; | - | ||||||||||||||||||||||||
| 54 | }; | - | ||||||||||||||||||||||||
| 55 | - | |||||||||||||||||||||||||
| 56 | QEvdevTouchScreenData::QEvdevTouchScreenData(QEvdevTouchScreenHandler *q_ptr, const QStringList &args) | - | ||||||||||||||||||||||||
| 57 | : q(q_ptr), | - | ||||||||||||||||||||||||
| 58 | m_lastEventType(-1), | - | ||||||||||||||||||||||||
| 59 | m_currentSlot(0), | - | ||||||||||||||||||||||||
| 60 | hw_range_x_min(0), hw_range_x_max(0), | - | ||||||||||||||||||||||||
| 61 | hw_range_y_min(0), hw_range_y_max(0), | - | ||||||||||||||||||||||||
| 62 | hw_pressure_min(0), hw_pressure_max(0), | - | ||||||||||||||||||||||||
| 63 | m_typeB(false), m_singleTouch(false) | - | ||||||||||||||||||||||||
| 64 | { | - | ||||||||||||||||||||||||
| 65 | m_forceToActiveWindow = args.contains(QLatin1String("force_window")); | - | ||||||||||||||||||||||||
| 66 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 67 | QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &device, const QString &spec, QObject *parent) | - | ||||||||||||||||||||||||
| 68 | : QObject(parent), m_notify(nullptr), m_fd(-1), d(nullptr), m_device(nullptr) | - | ||||||||||||||||||||||||
| 69 | - | |||||||||||||||||||||||||
| 70 | , m_mtdev(nullptr) | - | ||||||||||||||||||||||||
| 71 | - | |||||||||||||||||||||||||
| 72 | { | - | ||||||||||||||||||||||||
| 73 | setObjectName(QLatin1String("Evdev Touch Handler")); | - | ||||||||||||||||||||||||
| 74 | - | |||||||||||||||||||||||||
| 75 | const QStringList args = spec.split(QLatin1Char(':')); | - | ||||||||||||||||||||||||
| 76 | int rotationAngle = 0; | - | ||||||||||||||||||||||||
| 77 | bool invertx = false; | - | ||||||||||||||||||||||||
| 78 | bool inverty = false; | - | ||||||||||||||||||||||||
| 79 | for (int i = 0; i < args.count()
| 0 | ||||||||||||||||||||||||
| 80 | if (args.at(i).startsWith(QLatin1String("rotate"))
| 0 | ||||||||||||||||||||||||
| 81 | QString rotateArg = args.at(i).section(QLatin1Char('='), 1, 1); | - | ||||||||||||||||||||||||
| 82 | bool ok; | - | ||||||||||||||||||||||||
| 83 | uint argValue = rotateArg.toUInt(&ok); | - | ||||||||||||||||||||||||
| 84 | if (ok
| 0 | ||||||||||||||||||||||||
| 85 | switch (argValue) { | - | ||||||||||||||||||||||||
| 86 | case never executed: 90:case 90:never executed: case 90: | 0 | ||||||||||||||||||||||||
| 87 | case never executed: 180:case 180:never executed: case 180: | 0 | ||||||||||||||||||||||||
| 88 | case never executed: 270:case 270:never executed: case 270: | 0 | ||||||||||||||||||||||||
| 89 | rotationAngle = argValue; | - | ||||||||||||||||||||||||
| 90 | default never executed: :default:never executed: default:code before this statement never executed: default: | 0 | ||||||||||||||||||||||||
| 91 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 92 | } | - | ||||||||||||||||||||||||
| 93 | } | - | ||||||||||||||||||||||||
| 94 | } never executed: else if (args.at(i) == QLatin1String("invertx")end of block
| 0 | ||||||||||||||||||||||||
| 95 | invertx = true; | - | ||||||||||||||||||||||||
| 96 | } never executed: else if (args.at(i) == QLatin1String("inverty")end of block
| 0 | ||||||||||||||||||||||||
| 97 | inverty = true; | - | ||||||||||||||||||||||||
| 98 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 99 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 100 | - | |||||||||||||||||||||||||
| 101 | for (bool qt_category_enabled = qLcEvdevTouch().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 182, __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug("evdevtouch: Using device %s", QString(device).toLocal8Bit().constData()); | 0 | ||||||||||||||||||||||||
| 102 | - | |||||||||||||||||||||||||
| 103 | m_fd = qt_safe_open(device.toLocal8Bit().constData(), 00 | 04000, 0); | - | ||||||||||||||||||||||||
| 104 | - | |||||||||||||||||||||||||
| 105 | if (m_fd >= 0
| 0 | ||||||||||||||||||||||||
| 106 | m_notify = new QSocketNotifier(m_fd, QSocketNotifier::Read, this); | - | ||||||||||||||||||||||||
| 107 | connect(m_notify, qFlagLocation("2""activated(int)" "\0" __FILE__ ":" "188"), this, qFlagLocation("1""readData()" "\0" __FILE__ ":" "188")); | - | ||||||||||||||||||||||||
| 108 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 109 | qErrnoWarning((*__errno_location ()), "evdevtouch: Cannot open input device %s", QString(device).toLocal8Bit().constData()); | - | ||||||||||||||||||||||||
| 110 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 111 | } | - | ||||||||||||||||||||||||
| 112 | - | |||||||||||||||||||||||||
| 113 | - | |||||||||||||||||||||||||
| 114 | m_mtdev = static_cast<mtdev *>(calloc(1, sizeof(mtdev))); | - | ||||||||||||||||||||||||
| 115 | int mtdeverr = mtdev_open(m_mtdev, m_fd); | - | ||||||||||||||||||||||||
| 116 | if (mtdeverr
| 0 | ||||||||||||||||||||||||
| 117 | QMessageLogger(__FILE__, 198, __PRETTY_FUNCTION__).warning("evdevtouch: mtdev_open failed: %d", mtdeverr); | - | ||||||||||||||||||||||||
| 118 | qt_safe_close(m_fd); | - | ||||||||||||||||||||||||
| 119 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 120 | } | - | ||||||||||||||||||||||||
| 121 | - | |||||||||||||||||||||||||
| 122 | - | |||||||||||||||||||||||||
| 123 | d = new QEvdevTouchScreenData(this, args); | - | ||||||||||||||||||||||||
| 124 | - | |||||||||||||||||||||||||
| 125 | - | |||||||||||||||||||||||||
| 126 | const char *mtdevStr = "(mtdev)"; | - | ||||||||||||||||||||||||
| 127 | d->m_typeB = true; | - | ||||||||||||||||||||||||
| 128 | for (bool qt_category_enabled = qLcEvdevTouch().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger( __FILE__ , 219 , __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug("evdevtouch: %s: Protocol type %c %s (%s)", QString(device).toLocal8Bit().constData(), d->m_typeB ? 'B' : 'A', mtdevStr, d->m_singleTouch ? "single" : "multi") ; | 0 | ||||||||||||||||||||||||
| 129 | __FILE__ never executed: QMessageLogger( __FILE__ , 219 , __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug("evdevtouch: %s: Protocol type %c %s (%s)", QString(device).toLocal8Bit().constData(), d->m_typeB ? 'B' : 'A', mtdevStr, d->m_singleTouch ? "single" : "multi") ; | 0 | ||||||||||||||||||||||||
| 130 | , never executed: QMessageLogger( __FILE__ , 219 , __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug("evdevtouch: %s: Protocol type %c %s (%s)", QString(device).toLocal8Bit().constData(), d->m_typeB ? 'B' : 'A', mtdevStr, d->m_singleTouch ? "single" : "multi") ; | 0 | ||||||||||||||||||||||||
| 131 | 219 never executed: QMessageLogger( __FILE__ , 219 , __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug("evdevtouch: %s: Protocol type %c %s (%s)", QString(device).toLocal8Bit().constData(), d->m_typeB ? 'B' : 'A', mtdevStr, d->m_singleTouch ? "single" : "multi") ; | 0 | ||||||||||||||||||||||||
| 132 | , __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug("evdevtouch: %s: Protocol type %c %s (%s)", QString(device).toLocal8Bit().constData(), d->m_typeB ? 'B' : 'A', mtdevStr, d->m_singleTouch ? "single" : "multi") never executed: QMessageLogger( __FILE__ , 219 , __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug("evdevtouch: %s: Protocol type %c %s (%s)", QString(device).toLocal8Bit().constData(), d->m_typeB ? 'B' : 'A', mtdevStr, d->m_singleTouch ? "single" : "multi") ; | 0 | ||||||||||||||||||||||||
| 133 | ; never executed: QMessageLogger( __FILE__ , 219 , __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug("evdevtouch: %s: Protocol type %c %s (%s)", QString(device).toLocal8Bit().constData(), d->m_typeB ? 'B' : 'A', mtdevStr, d->m_singleTouch ? "single" : "multi") ; | 0 | ||||||||||||||||||||||||
| 134 | - | |||||||||||||||||||||||||
| 135 | input_absinfo absInfo; | - | ||||||||||||||||||||||||
| 136 | memset(&absInfo, 0, sizeof(input_absinfo)); | - | ||||||||||||||||||||||||
| 137 | bool has_x_range = false, has_y_range = false; | - | ||||||||||||||||||||||||
| 138 | - | |||||||||||||||||||||||||
| 139 | if (ioctl(m_fd, (((2U) << (((0 +8)+8)+14)) | ((('E')) << (0 +8)) | (((0x40 + ((d->m_singleTouch ? 0x00 : 0x35)))) << 0) | ((((sizeof(struct input_absinfo)))) << ((0 +8)+8))), &absInfo) >= 0
| 0 | ||||||||||||||||||||||||
| 140 | for (bool qt_category_enabled = qLcEvdevTouch().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger( __FILE__ , 227 , __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug("evdevtouch: %s: min X: %d max X: %d", QString(device).toLocal8Bit().constData(), absInfo.minimum, absInfo.maximum) ; | 0 | ||||||||||||||||||||||||
| 141 | __FILE__ never executed: QMessageLogger( __FILE__ , 227 , __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug("evdevtouch: %s: min X: %d max X: %d", QString(device).toLocal8Bit().constData(), absInfo.minimum, absInfo.maximum) ; | 0 | ||||||||||||||||||||||||
| 142 | , never executed: QMessageLogger( __FILE__ , 227 , __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug("evdevtouch: %s: min X: %d max X: %d", QString(device).toLocal8Bit().constData(), absInfo.minimum, absInfo.maximum) ; | 0 | ||||||||||||||||||||||||
| 143 | 227 never executed: QMessageLogger( __FILE__ , 227 , __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug("evdevtouch: %s: min X: %d max X: %d", QString(device).toLocal8Bit().constData(), absInfo.minimum, absInfo.maximum) ; | 0 | ||||||||||||||||||||||||
| 144 | , __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug("evdevtouch: %s: min X: %d max X: %d", QString(device).toLocal8Bit().constData(), absInfo.minimum, absInfo.maximum) never executed: QMessageLogger( __FILE__ , 227 , __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug("evdevtouch: %s: min X: %d max X: %d", QString(device).toLocal8Bit().constData(), absInfo.minimum, absInfo.maximum) ; | 0 | ||||||||||||||||||||||||
| 145 | ; never executed: QMessageLogger( __FILE__ , 227 , __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug("evdevtouch: %s: min X: %d max X: %d", QString(device).toLocal8Bit().constData(), absInfo.minimum, absInfo.maximum) ; | 0 | ||||||||||||||||||||||||
| 146 | d->hw_range_x_min = absInfo.minimum; | - | ||||||||||||||||||||||||
| 147 | d->hw_range_x_max = absInfo.maximum; | - | ||||||||||||||||||||||||
| 148 | has_x_range = true; | - | ||||||||||||||||||||||||
| 149 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 150 | - | |||||||||||||||||||||||||
| 151 | if (ioctl(m_fd, (((2U) << (((0 +8)+8)+14)) | ((('E')) << (0 +8)) | (((0x40 + ((d->m_singleTouch ? 0x01 : 0x36)))) << 0) | ((((sizeof(struct input_absinfo)))) << ((0 +8)+8))), &absInfo) >= 0
| 0 | ||||||||||||||||||||||||
| 152 | for (bool qt_category_enabled = qLcEvdevTouch().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger( __FILE__ , 235 , __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug("evdevtouch: %s: min Y: %d max Y: %d", QString(device).toLocal8Bit().constData(), absInfo.minimum, absInfo.maximum) ; | 0 | ||||||||||||||||||||||||
| 153 | __FILE__ never executed: QMessageLogger( __FILE__ , 235 , __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug("evdevtouch: %s: min Y: %d max Y: %d", QString(device).toLocal8Bit().constData(), absInfo.minimum, absInfo.maximum) ; | 0 | ||||||||||||||||||||||||
| 154 | , never executed: QMessageLogger( __FILE__ , 235 , __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug("evdevtouch: %s: min Y: %d max Y: %d", QString(device).toLocal8Bit().constData(), absInfo.minimum, absInfo.maximum) ; | 0 | ||||||||||||||||||||||||
| 155 | 235 never executed: QMessageLogger( __FILE__ , 235 , __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug("evdevtouch: %s: min Y: %d max Y: %d", QString(device).toLocal8Bit().constData(), absInfo.minimum, absInfo.maximum) ; | 0 | ||||||||||||||||||||||||
| 156 | , __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug("evdevtouch: %s: min Y: %d max Y: %d", QString(device).toLocal8Bit().constData(), absInfo.minimum, absInfo.maximum) never executed: QMessageLogger( __FILE__ , 235 , __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug("evdevtouch: %s: min Y: %d max Y: %d", QString(device).toLocal8Bit().constData(), absInfo.minimum, absInfo.maximum) ; | 0 | ||||||||||||||||||||||||
| 157 | ; never executed: QMessageLogger( __FILE__ , 235 , __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug("evdevtouch: %s: min Y: %d max Y: %d", QString(device).toLocal8Bit().constData(), absInfo.minimum, absInfo.maximum) ; | 0 | ||||||||||||||||||||||||
| 158 | d->hw_range_y_min = absInfo.minimum; | - | ||||||||||||||||||||||||
| 159 | d->hw_range_y_max = absInfo.maximum; | - | ||||||||||||||||||||||||
| 160 | has_y_range = true; | - | ||||||||||||||||||||||||
| 161 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 162 | - | |||||||||||||||||||||||||
| 163 | if (!has_x_range
| 0 | ||||||||||||||||||||||||
| 164 | QMessageLogger(__FILE__, 242, __PRETTY_FUNCTION__).warning("evdevtouch: %s: Invalid ABS limits, behavior unspecified", QString(device).toLocal8Bit().constData()); never executed: QMessageLogger(__FILE__, 242, __PRETTY_FUNCTION__).warning("evdevtouch: %s: Invalid ABS limits, behavior unspecified", QString(device).toLocal8Bit().constData()); | 0 | ||||||||||||||||||||||||
| 165 | - | |||||||||||||||||||||||||
| 166 | if (ioctl(m_fd, (((2U) << (((0 +8)+8)+14)) | ((('E')) << (0 +8)) | (((0x40 + (0x18))) << 0) | ((((sizeof(struct input_absinfo)))) << ((0 +8)+8))), &absInfo) >= 0
| 0 | ||||||||||||||||||||||||
| 167 | for (bool qt_category_enabled = qLcEvdevTouch().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger( __FILE__ , 246 , __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug("evdevtouch: %s: min pressure: %d max pressure: %d", QString(device).toLocal8Bit().constData(), absInfo.minimum, absInfo.maximum) ; | 0 | ||||||||||||||||||||||||
| 168 | __FILE__ never executed: QMessageLogger( __FILE__ , 246 , __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug("evdevtouch: %s: min pressure: %d max pressure: %d", QString(device).toLocal8Bit().constData(), absInfo.minimum, absInfo.maximum) ; | 0 | ||||||||||||||||||||||||
| 169 | , never executed: QMessageLogger( __FILE__ , 246 , __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug("evdevtouch: %s: min pressure: %d max pressure: %d", QString(device).toLocal8Bit().constData(), absInfo.minimum, absInfo.maximum) ; | 0 | ||||||||||||||||||||||||
| 170 | 246 never executed: QMessageLogger( __FILE__ , 246 , __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug("evdevtouch: %s: min pressure: %d max pressure: %d", QString(device).toLocal8Bit().constData(), absInfo.minimum, absInfo.maximum) ; | 0 | ||||||||||||||||||||||||
| 171 | , __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug("evdevtouch: %s: min pressure: %d max pressure: %d", QString(device).toLocal8Bit().constData(), absInfo.minimum, absInfo.maximum) never executed: QMessageLogger( __FILE__ , 246 , __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug("evdevtouch: %s: min pressure: %d max pressure: %d", QString(device).toLocal8Bit().constData(), absInfo.minimum, absInfo.maximum) ; | 0 | ||||||||||||||||||||||||
| 172 | ; never executed: QMessageLogger( __FILE__ , 246 , __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug("evdevtouch: %s: min pressure: %d max pressure: %d", QString(device).toLocal8Bit().constData(), absInfo.minimum, absInfo.maximum) ; | 0 | ||||||||||||||||||||||||
| 173 | if (absInfo.maximum > absInfo.minimum
| 0 | ||||||||||||||||||||||||
| 174 | d->hw_pressure_min = absInfo.minimum; | - | ||||||||||||||||||||||||
| 175 | d->hw_pressure_max = absInfo.maximum; | - | ||||||||||||||||||||||||
| 176 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 177 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 178 | - | |||||||||||||||||||||||||
| 179 | char name[1024]; | - | ||||||||||||||||||||||||
| 180 | if (ioctl(m_fd, (((2U) << (((0 +8)+8)+14)) | (('E') << (0 +8)) | ((0x06) << 0) | ((sizeof(name) - 1) << ((0 +8)+8))), name) >= 0
| 0 | ||||||||||||||||||||||||
| 181 | d->hw_name = QString::fromLocal8Bit(name); | - | ||||||||||||||||||||||||
| 182 | for (bool qt_category_enabled = qLcEvdevTouch().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 256, __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug("evdevtouch: %s: device name: %s", QString(device).toLocal8Bit().constData(), name); | 0 | ||||||||||||||||||||||||
| 183 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 184 | - | |||||||||||||||||||||||||
| 185 | - | |||||||||||||||||||||||||
| 186 | if (d->hw_name == QLatin1String("ti-tsc")
| 0 | ||||||||||||||||||||||||
| 187 | if (d->hw_range_x_min == 0
| 0 | ||||||||||||||||||||||||
| 188 | d->hw_range_x_min = 165; | - | ||||||||||||||||||||||||
| 189 | d->hw_range_x_max = 4016; | - | ||||||||||||||||||||||||
| 190 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 191 | if (d->hw_range_y_min == 0
| 0 | ||||||||||||||||||||||||
| 192 | d->hw_range_y_min = 220; | - | ||||||||||||||||||||||||
| 193 | d->hw_range_y_max = 3907; | - | ||||||||||||||||||||||||
| 194 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 195 | for (bool qt_category_enabled = qLcEvdevTouch().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger( __FILE__ , 270 , __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug("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) ; | 0 | ||||||||||||||||||||||||
| 196 | __FILE__ never executed: QMessageLogger( __FILE__ , 270 , __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug("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) ; | 0 | ||||||||||||||||||||||||
| 197 | , never executed: QMessageLogger( __FILE__ , 270 , __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug("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) ; | 0 | ||||||||||||||||||||||||
| 198 | 270 never executed: QMessageLogger( __FILE__ , 270 , __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug("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) ; | 0 | ||||||||||||||||||||||||
| 199 | , __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug("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) never executed: QMessageLogger( __FILE__ , 270 , __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug("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) ; | 0 | ||||||||||||||||||||||||
| 200 | ; never executed: QMessageLogger( __FILE__ , 270 , __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug("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) ; | 0 | ||||||||||||||||||||||||
| 201 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 202 | - | |||||||||||||||||||||||||
| 203 | bool grabSuccess = !ioctl(m_fd, (((1U) << (((0 +8)+8)+14)) | ((('E')) << (0 +8)) | (((0x90)) << 0) | ((((sizeof(int)))) << ((0 +8)+8))), (void *) 1); | - | ||||||||||||||||||||||||
| 204 | if (grabSuccess
| 0 | ||||||||||||||||||||||||
| 205 | ioctl(m_fd, (((1U) << (((0 +8)+8)+14)) | ((('E')) << (0 +8)) | (((0x90)) << 0) | ((((sizeof(int)))) << ((0 +8)+8))), (void *) 0); never executed: ioctl(m_fd, (((1U) << (((0 +8)+8)+14)) | ((('E')) << (0 +8)) | (((0x90)) << 0) | ((((sizeof(int)))) << ((0 +8)+8))), (void *) 0); | 0 | ||||||||||||||||||||||||
| 206 | else | - | ||||||||||||||||||||||||
| 207 | QMessageLogger(__FILE__, 277, __PRETTY_FUNCTION__).warning("evdevtouch: The device is grabbed by another process. No events will be read."); never executed: QMessageLogger(__FILE__, 277, __PRETTY_FUNCTION__).warning("evdevtouch: The device is grabbed by another process. No events will be read."); | 0 | ||||||||||||||||||||||||
| 208 | - | |||||||||||||||||||||||||
| 209 | if (rotationAngle
| 0 | ||||||||||||||||||||||||
| 210 | d->m_rotate = QTransform::fromTranslate(0.5, 0.5).rotate(rotationAngle).translate(-0.5, -0.5); never executed: d->m_rotate = QTransform::fromTranslate(0.5, 0.5).rotate(rotationAngle).translate(-0.5, -0.5); | 0 | ||||||||||||||||||||||||
| 211 | - | |||||||||||||||||||||||||
| 212 | if (invertx
| 0 | ||||||||||||||||||||||||
| 213 | d->m_rotate *= QTransform::fromTranslate(0.5, 0.5).scale(-1.0, 1.0).translate(-0.5, -0.5); never executed: d->m_rotate *= QTransform::fromTranslate(0.5, 0.5).scale(-1.0, 1.0).translate(-0.5, -0.5); | 0 | ||||||||||||||||||||||||
| 214 | - | |||||||||||||||||||||||||
| 215 | if (inverty
| 0 | ||||||||||||||||||||||||
| 216 | d->m_rotate *= QTransform::fromTranslate(0.5, 0.5).scale(1.0, -1.0).translate(-0.5, -0.5); never executed: d->m_rotate *= QTransform::fromTranslate(0.5, 0.5).scale(1.0, -1.0).translate(-0.5, -0.5); | 0 | ||||||||||||||||||||||||
| 217 | - | |||||||||||||||||||||||||
| 218 | registerTouchDevice(); | - | ||||||||||||||||||||||||
| 219 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 220 | - | |||||||||||||||||||||||||
| 221 | QEvdevTouchScreenHandler::~QEvdevTouchScreenHandler() | - | ||||||||||||||||||||||||
| 222 | { | - | ||||||||||||||||||||||||
| 223 | - | |||||||||||||||||||||||||
| 224 | if (m_mtdev
| 0 | ||||||||||||||||||||||||
| 225 | mtdev_close(m_mtdev); | - | ||||||||||||||||||||||||
| 226 | free(m_mtdev); | - | ||||||||||||||||||||||||
| 227 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 228 | - | |||||||||||||||||||||||||
| 229 | - | |||||||||||||||||||||||||
| 230 | if (m_fd >= 0
| 0 | ||||||||||||||||||||||||
| 231 | qt_safe_close(m_fd); never executed: qt_safe_close(m_fd); | 0 | ||||||||||||||||||||||||
| 232 | - | |||||||||||||||||||||||||
| 233 | delete d; | - | ||||||||||||||||||||||||
| 234 | - | |||||||||||||||||||||||||
| 235 | unregisterTouchDevice(); | - | ||||||||||||||||||||||||
| 236 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 237 | - | |||||||||||||||||||||||||
| 238 | QTouchDevice *QEvdevTouchScreenHandler::touchDevice() const | - | ||||||||||||||||||||||||
| 239 | { | - | ||||||||||||||||||||||||
| 240 | return never executed: m_device;return m_device;never executed: return m_device; | 0 | ||||||||||||||||||||||||
| 241 | } | - | ||||||||||||||||||||||||
| 242 | - | |||||||||||||||||||||||||
| 243 | void QEvdevTouchScreenHandler::readData() | - | ||||||||||||||||||||||||
| 244 | { | - | ||||||||||||||||||||||||
| 245 | ::input_event buffer[32]; | - | ||||||||||||||||||||||||
| 246 | int events = 0; | - | ||||||||||||||||||||||||
| 247 | - | |||||||||||||||||||||||||
| 248 | - | |||||||||||||||||||||||||
| 249 | for(;;) { | - | ||||||||||||||||||||||||
| 250 | do { | - | ||||||||||||||||||||||||
| 251 | events = mtdev_get(m_mtdev, m_fd, buffer, sizeof(buffer) / sizeof(::input_event)); | - | ||||||||||||||||||||||||
| 252 | - | |||||||||||||||||||||||||
| 253 | - | |||||||||||||||||||||||||
| 254 | - | |||||||||||||||||||||||||
| 255 | } never executed: while (events == -1end of block
| 0 | ||||||||||||||||||||||||
| 256 | - | |||||||||||||||||||||||||
| 257 | - | |||||||||||||||||||||||||
| 258 | if (events <= 0
| 0 | ||||||||||||||||||||||||
| 259 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 260 | - | |||||||||||||||||||||||||
| 261 | - | |||||||||||||||||||||||||
| 262 | for (int i = 0; i < events
| 0 | ||||||||||||||||||||||||
| 263 | d->processInputEvent(&buffer[i]); never executed: d->processInputEvent(&buffer[i]); | 0 | ||||||||||||||||||||||||
| 264 | - | |||||||||||||||||||||||||
| 265 | - | |||||||||||||||||||||||||
| 266 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 267 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 268 | - | |||||||||||||||||||||||||
| 269 | err: | - | ||||||||||||||||||||||||
| 270 | if (!events
| 0 | ||||||||||||||||||||||||
| 271 | QMessageLogger(__FILE__, 357, __PRETTY_FUNCTION__).warning("evdevtouch: Got EOF from input device"); | - | ||||||||||||||||||||||||
| 272 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 273 | } else if (events < 0
| 0 | ||||||||||||||||||||||||
| 274 | if ((*
| 0 | ||||||||||||||||||||||||
| 275 | qErrnoWarning((*__errno_location ()), "evdevtouch: Could not read from input device"); | - | ||||||||||||||||||||||||
| 276 | if ((*
| 0 | ||||||||||||||||||||||||
| 277 | delete m_notify; | - | ||||||||||||||||||||||||
| 278 | m_notify = nullptr; | - | ||||||||||||||||||||||||
| 279 | - | |||||||||||||||||||||||||
| 280 | qt_safe_close(m_fd); | - | ||||||||||||||||||||||||
| 281 | m_fd = -1; | - | ||||||||||||||||||||||||
| 282 | - | |||||||||||||||||||||||||
| 283 | unregisterTouchDevice(); | - | ||||||||||||||||||||||||
| 284 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 285 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 286 | } | - | ||||||||||||||||||||||||
| 287 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 288 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 289 | - | |||||||||||||||||||||||||
| 290 | void QEvdevTouchScreenHandler::registerTouchDevice() | - | ||||||||||||||||||||||||
| 291 | { | - | ||||||||||||||||||||||||
| 292 | if (m_device
| 0 | ||||||||||||||||||||||||
| 293 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 294 | - | |||||||||||||||||||||||||
| 295 | m_device = new QTouchDevice; | - | ||||||||||||||||||||||||
| 296 | m_device->setName(d->hw_name); | - | ||||||||||||||||||||||||
| 297 | m_device->setType(QTouchDevice::TouchScreen); | - | ||||||||||||||||||||||||
| 298 | m_device->setCapabilities(QTouchDevice::Position | QTouchDevice::Area); | - | ||||||||||||||||||||||||
| 299 | if (d->hw_pressure_max > d->hw_pressure_min
| 0 | ||||||||||||||||||||||||
| 300 | m_device->setCapabilities(m_device->capabilities() | QTouchDevice::Pressure); never executed: m_device->setCapabilities(m_device->capabilities() | QTouchDevice::Pressure); | 0 | ||||||||||||||||||||||||
| 301 | - | |||||||||||||||||||||||||
| 302 | QWindowSystemInterface::registerTouchDevice(m_device); | - | ||||||||||||||||||||||||
| 303 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 304 | - | |||||||||||||||||||||||||
| 305 | void QEvdevTouchScreenHandler::unregisterTouchDevice() | - | ||||||||||||||||||||||||
| 306 | { | - | ||||||||||||||||||||||||
| 307 | if (!m_device
| 0 | ||||||||||||||||||||||||
| 308 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 309 | - | |||||||||||||||||||||||||
| 310 | - | |||||||||||||||||||||||||
| 311 | - | |||||||||||||||||||||||||
| 312 | if (QWindowSystemInterface::isTouchDeviceRegistered(m_device)
| 0 | ||||||||||||||||||||||||
| 313 | QWindowSystemInterface::unregisterTouchDevice(m_device); | - | ||||||||||||||||||||||||
| 314 | delete m_device; | - | ||||||||||||||||||||||||
| 315 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 316 | - | |||||||||||||||||||||||||
| 317 | m_device = nullptr; | - | ||||||||||||||||||||||||
| 318 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 319 | - | |||||||||||||||||||||||||
| 320 | void QEvdevTouchScreenData::addTouchPoint(const Contact &contact, Qt::TouchPointStates *combinedStates) | - | ||||||||||||||||||||||||
| 321 | { | - | ||||||||||||||||||||||||
| 322 | QWindowSystemInterface::TouchPoint tp; | - | ||||||||||||||||||||||||
| 323 | tp.id = contact.trackingId; | - | ||||||||||||||||||||||||
| 324 | tp.flags = contact.flags; | - | ||||||||||||||||||||||||
| 325 | tp.state = contact.state; | - | ||||||||||||||||||||||||
| 326 | *combinedStates |= tp.state; | - | ||||||||||||||||||||||||
| 327 | - | |||||||||||||||||||||||||
| 328 | - | |||||||||||||||||||||||||
| 329 | tp.area = QRectF(0, 0, contact.maj, contact.maj); | - | ||||||||||||||||||||||||
| 330 | tp.area.moveCenter(QPoint(contact.x, contact.y)); | - | ||||||||||||||||||||||||
| 331 | tp.pressure = contact.pressure; | - | ||||||||||||||||||||||||
| 332 | - | |||||||||||||||||||||||||
| 333 | - | |||||||||||||||||||||||||
| 334 | tp.normalPosition = QPointF((contact.x - hw_range_x_min) / qreal(hw_range_x_max - hw_range_x_min), | - | ||||||||||||||||||||||||
| 335 | (contact.y - hw_range_y_min) / qreal(hw_range_y_max - hw_range_y_min)); | - | ||||||||||||||||||||||||
| 336 | - | |||||||||||||||||||||||||
| 337 | if (!m_rotate.isIdentity()
| 0 | ||||||||||||||||||||||||
| 338 | tp.normalPosition = m_rotate.map(tp.normalPosition); never executed: tp.normalPosition = m_rotate.map(tp.normalPosition); | 0 | ||||||||||||||||||||||||
| 339 | - | |||||||||||||||||||||||||
| 340 | tp.rawPositions.append(QPointF(contact.x, contact.y)); | - | ||||||||||||||||||||||||
| 341 | - | |||||||||||||||||||||||||
| 342 | m_touchPoints.append(tp); | - | ||||||||||||||||||||||||
| 343 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 344 | - | |||||||||||||||||||||||||
| 345 | void QEvdevTouchScreenData::processInputEvent(input_event *data) | - | ||||||||||||||||||||||||
| 346 | { | - | ||||||||||||||||||||||||
| 347 | if (data->type == 0x03
| 0 | ||||||||||||||||||||||||
| 348 | - | |||||||||||||||||||||||||
| 349 | if (data->code == 0x35
| 0 | ||||||||||||||||||||||||
| 350 | m_currentData.x = qBound(hw_range_x_min, data->value, hw_range_x_max); | - | ||||||||||||||||||||||||
| 351 | if (m_singleTouch
| 0 | ||||||||||||||||||||||||
| 352 | m_contacts[m_currentSlot].x = m_currentData.x; never executed: m_contacts[m_currentSlot].x = m_currentData.x; | 0 | ||||||||||||||||||||||||
| 353 | if (m_typeB
| 0 | ||||||||||||||||||||||||
| 354 | m_contacts[m_currentSlot].x = m_currentData.x; | - | ||||||||||||||||||||||||
| 355 | if (m_contacts[m_currentSlot].state == Qt::TouchPointStationary
| 0 | ||||||||||||||||||||||||
| 356 | m_contacts[m_currentSlot].state = Qt::TouchPointMoved; never executed: m_contacts[m_currentSlot].state = Qt::TouchPointMoved; | 0 | ||||||||||||||||||||||||
| 357 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 358 | } never executed: else if (data->code == 0x36end of block
| 0 | ||||||||||||||||||||||||
| 359 | m_currentData.y = qBound(hw_range_y_min, data->value, hw_range_y_max); | - | ||||||||||||||||||||||||
| 360 | if (m_singleTouch
| 0 | ||||||||||||||||||||||||
| 361 | m_contacts[m_currentSlot].y = m_currentData.y; never executed: m_contacts[m_currentSlot].y = m_currentData.y; | 0 | ||||||||||||||||||||||||
| 362 | if (m_typeB
| 0 | ||||||||||||||||||||||||
| 363 | m_contacts[m_currentSlot].y = m_currentData.y; | - | ||||||||||||||||||||||||
| 364 | if (m_contacts[m_currentSlot].state == Qt::TouchPointStationary
| 0 | ||||||||||||||||||||||||
| 365 | m_contacts[m_currentSlot].state = Qt::TouchPointMoved; never executed: m_contacts[m_currentSlot].state = Qt::TouchPointMoved; | 0 | ||||||||||||||||||||||||
| 366 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 367 | } never executed: else if (data->code == 0x39end of block
| 0 | ||||||||||||||||||||||||
| 368 | m_currentData.trackingId = data->value; | - | ||||||||||||||||||||||||
| 369 | if (m_typeB
| 0 | ||||||||||||||||||||||||
| 370 | if (m_currentData.trackingId == -1
| 0 | ||||||||||||||||||||||||
| 371 | m_contacts[m_currentSlot].state = Qt::TouchPointReleased; | - | ||||||||||||||||||||||||
| 372 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 373 | m_contacts[m_currentSlot].state = Qt::TouchPointPressed; | - | ||||||||||||||||||||||||
| 374 | m_contacts[m_currentSlot].trackingId = m_currentData.trackingId; | - | ||||||||||||||||||||||||
| 375 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 376 | } | - | ||||||||||||||||||||||||
| 377 | } never executed: else if (data->code == 0x30end of block
| 0 | ||||||||||||||||||||||||
| 378 | m_currentData.maj = data->value; | - | ||||||||||||||||||||||||
| 379 | if (data->value == 0
| 0 | ||||||||||||||||||||||||
| 380 | m_currentData.state = Qt::TouchPointReleased; never executed: m_currentData.state = Qt::TouchPointReleased; | 0 | ||||||||||||||||||||||||
| 381 | if (m_typeB
| 0 | ||||||||||||||||||||||||
| 382 | m_contacts[m_currentSlot].maj = m_currentData.maj; never executed: m_contacts[m_currentSlot].maj = m_currentData.maj; | 0 | ||||||||||||||||||||||||
| 383 | } never executed: else if (data->code == 0x18end of block
| 0 | ||||||||||||||||||||||||
| 384 | m_currentData.pressure = qBound(hw_pressure_min, data->value, hw_pressure_max); | - | ||||||||||||||||||||||||
| 385 | if (m_typeB
| 0 | ||||||||||||||||||||||||
| 386 | m_contacts[m_currentSlot].pressure = m_currentData.pressure; never executed: m_contacts[m_currentSlot].pressure = m_currentData.pressure; | 0 | ||||||||||||||||||||||||
| 387 | } never executed: else if (data->code == 0x2fend of block
| 0 | ||||||||||||||||||||||||
| 388 | m_currentSlot = data->value; | - | ||||||||||||||||||||||||
| 389 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 390 | - | |||||||||||||||||||||||||
| 391 | } never executed: else if (data->type == 0x01end of block
| 0 | ||||||||||||||||||||||||
| 392 | if (data->code == 0x14a
| 0 | ||||||||||||||||||||||||
| 393 | m_contacts[m_currentSlot].state = Qt::TouchPointReleased; never executed: m_contacts[m_currentSlot].state = Qt::TouchPointReleased; | 0 | ||||||||||||||||||||||||
| 394 | } never executed: else if (data->type == 0x00end of block
| 0 | ||||||||||||||||||||||||
| 395 | - | |||||||||||||||||||||||||
| 396 | - | |||||||||||||||||||||||||
| 397 | - | |||||||||||||||||||||||||
| 398 | int key = m_currentData.trackingId; | - | ||||||||||||||||||||||||
| 399 | if (key == -1
| 0 | ||||||||||||||||||||||||
| 400 | key = m_contacts.count(); never executed: key = m_contacts.count(); | 0 | ||||||||||||||||||||||||
| 401 | - | |||||||||||||||||||||||||
| 402 | m_contacts.insert(key, m_currentData); | - | ||||||||||||||||||||||||
| 403 | m_currentData = Contact(); | - | ||||||||||||||||||||||||
| 404 | - | |||||||||||||||||||||||||
| 405 | } never executed: else if (data->type == 0x00end of block
| 0 | ||||||||||||||||||||||||
| 406 | - | |||||||||||||||||||||||||
| 407 | - | |||||||||||||||||||||||||
| 408 | if (!m_contacts.isEmpty()
| 0 | ||||||||||||||||||||||||
| 409 | assignIds(); never executed: assignIds(); | 0 | ||||||||||||||||||||||||
| 410 | - | |||||||||||||||||||||||||
| 411 | m_touchPoints.clear(); | - | ||||||||||||||||||||||||
| 412 | Qt::TouchPointStates combinedStates; | - | ||||||||||||||||||||||||
| 413 | - | |||||||||||||||||||||||||
| 414 | QMutableHashIterator<int, Contact> it(m_contacts); | - | ||||||||||||||||||||||||
| 415 | while (it.hasNext()
| 0 | ||||||||||||||||||||||||
| 416 | it.next(); | - | ||||||||||||||||||||||||
| 417 | Contact &contact(it.value()); | - | ||||||||||||||||||||||||
| 418 | - | |||||||||||||||||||||||||
| 419 | if (!contact.state
| 0 | ||||||||||||||||||||||||
| 420 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 421 | - | |||||||||||||||||||||||||
| 422 | int key = m_typeB
| 0 | ||||||||||||||||||||||||
| 423 | if (!m_typeB
| 0 | ||||||||||||||||||||||||
| 424 | const Contact &prev(m_lastContacts.value(key)); | - | ||||||||||||||||||||||||
| 425 | if (contact.state == Qt::TouchPointReleased
| 0 | ||||||||||||||||||||||||
| 426 | - | |||||||||||||||||||||||||
| 427 | contact.x = prev.x; | - | ||||||||||||||||||||||||
| 428 | contact.y = prev.y; | - | ||||||||||||||||||||||||
| 429 | contact.maj = prev.maj; | - | ||||||||||||||||||||||||
| 430 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 431 | contact.state = (prev.x == contact.x
| 0 | ||||||||||||||||||||||||
| 432 | ? Qt::TouchPointStationary : Qt::TouchPointMoved; | - | ||||||||||||||||||||||||
| 433 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 434 | } | - | ||||||||||||||||||||||||
| 435 | - | |||||||||||||||||||||||||
| 436 | - | |||||||||||||||||||||||||
| 437 | if (!m_typeB
| 0 | ||||||||||||||||||||||||
| 438 | && !m_lastContacts.contains(key)
| 0 | ||||||||||||||||||||||||
| 439 | it.remove(); | - | ||||||||||||||||||||||||
| 440 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 441 | } | - | ||||||||||||||||||||||||
| 442 | - | |||||||||||||||||||||||||
| 443 | addTouchPoint(contact, &combinedStates); | - | ||||||||||||||||||||||||
| 444 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 445 | - | |||||||||||||||||||||||||
| 446 | - | |||||||||||||||||||||||||
| 447 | it = m_lastContacts; | - | ||||||||||||||||||||||||
| 448 | while (it.hasNext()
| 0 | ||||||||||||||||||||||||
| 449 | it.next(); | - | ||||||||||||||||||||||||
| 450 | Contact &contact(it.value()); | - | ||||||||||||||||||||||||
| 451 | int key = m_typeB
| 0 | ||||||||||||||||||||||||
| 452 | if (m_typeB
| 0 | ||||||||||||||||||||||||
| 453 | if (contact.trackingId != m_contacts[key].trackingId
| 0 | ||||||||||||||||||||||||
| 454 | contact.state = Qt::TouchPointReleased; | - | ||||||||||||||||||||||||
| 455 | addTouchPoint(contact, &combinedStates); | - | ||||||||||||||||||||||||
| 456 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 457 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 458 | if (!m_contacts.contains(key)
| 0 | ||||||||||||||||||||||||
| 459 | contact.state = Qt::TouchPointReleased; | - | ||||||||||||||||||||||||
| 460 | addTouchPoint(contact, &combinedStates); | - | ||||||||||||||||||||||||
| 461 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 462 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 463 | } | - | ||||||||||||||||||||||||
| 464 | - | |||||||||||||||||||||||||
| 465 | - | |||||||||||||||||||||||||
| 466 | it = m_contacts; | - | ||||||||||||||||||||||||
| 467 | while (it.hasNext()
| 0 | ||||||||||||||||||||||||
| 468 | it.next(); | - | ||||||||||||||||||||||||
| 469 | Contact &contact(it.value()); | - | ||||||||||||||||||||||||
| 470 | - | |||||||||||||||||||||||||
| 471 | if (!contact.state
| 0 | ||||||||||||||||||||||||
| 472 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 473 | - | |||||||||||||||||||||||||
| 474 | if (contact.state == Qt::TouchPointReleased
| 0 | ||||||||||||||||||||||||
| 475 | if (m_typeB
| 0 | ||||||||||||||||||||||||
| 476 | contact.state = static_cast<Qt::TouchPointState>(0); never executed: contact.state = static_cast<Qt::TouchPointState>(0); | 0 | ||||||||||||||||||||||||
| 477 | else | - | ||||||||||||||||||||||||
| 478 | it.remove(); never executed: it.remove(); | 0 | ||||||||||||||||||||||||
| 479 | } else { | - | ||||||||||||||||||||||||
| 480 | contact.state = Qt::TouchPointStationary; | - | ||||||||||||||||||||||||
| 481 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 482 | } | - | ||||||||||||||||||||||||
| 483 | - | |||||||||||||||||||||||||
| 484 | m_lastContacts = m_contacts; | - | ||||||||||||||||||||||||
| 485 | if (!m_typeB
| 0 | ||||||||||||||||||||||||
| 486 | m_contacts.clear(); never executed: m_contacts.clear(); | 0 | ||||||||||||||||||||||||
| 487 | - | |||||||||||||||||||||||||
| 488 | if (!m_touchPoints.isEmpty()
| 0 | ||||||||||||||||||||||||
| 489 | reportPoints(); never executed: reportPoints(); | 0 | ||||||||||||||||||||||||
| 490 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 491 | - | |||||||||||||||||||||||||
| 492 | m_lastEventType = data->type; | - | ||||||||||||||||||||||||
| 493 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 494 | - | |||||||||||||||||||||||||
| 495 | int QEvdevTouchScreenData::findClosestContact(const QHash<int, Contact> &contacts, int x, int y, int *dist) | - | ||||||||||||||||||||||||
| 496 | { | - | ||||||||||||||||||||||||
| 497 | int minDist = -1, id = -1; | - | ||||||||||||||||||||||||
| 498 | for (QHash<int, Contact>::const_iterator it = contacts.constBegin(), ite = contacts.constEnd(); | - | ||||||||||||||||||||||||
| 499 | it != ite
| 0 | ||||||||||||||||||||||||
| 500 | const Contact &contact(it.value()); | - | ||||||||||||||||||||||||
| 501 | int dx = x - contact.x; | - | ||||||||||||||||||||||||
| 502 | int dy = y - contact.y; | - | ||||||||||||||||||||||||
| 503 | int dist = dx * dx + dy * dy; | - | ||||||||||||||||||||||||
| 504 | if (minDist == -1
| 0 | ||||||||||||||||||||||||
| 505 | minDist = dist; | - | ||||||||||||||||||||||||
| 506 | id = contact.trackingId; | - | ||||||||||||||||||||||||
| 507 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 508 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 509 | if (dist
| 0 | ||||||||||||||||||||||||
| 510 | * never executed: dist = minDist;*dist = minDist;never executed: *dist = minDist; | 0 | ||||||||||||||||||||||||
| 511 | return never executed: id;return id;never executed: return id; | 0 | ||||||||||||||||||||||||
| 512 | } | - | ||||||||||||||||||||||||
| 513 | - | |||||||||||||||||||||||||
| 514 | void QEvdevTouchScreenData::assignIds() | - | ||||||||||||||||||||||||
| 515 | { | - | ||||||||||||||||||||||||
| 516 | QHash<int, Contact> candidates = m_lastContacts, pending = m_contacts, newContacts; | - | ||||||||||||||||||||||||
| 517 | int maxId = -1; | - | ||||||||||||||||||||||||
| 518 | QHash<int, Contact>::iterator it, ite, bestMatch; | - | ||||||||||||||||||||||||
| 519 | while (!pending.isEmpty()
| 0 | ||||||||||||||||||||||||
| 520 | int bestDist = -1, bestId = 0; | - | ||||||||||||||||||||||||
| 521 | for (it = pending.begin(), ite = pending.end(); it != ite
| 0 | ||||||||||||||||||||||||
| 522 | int dist; | - | ||||||||||||||||||||||||
| 523 | int id = findClosestContact(candidates, it->x, it->y, &dist); | - | ||||||||||||||||||||||||
| 524 | if (id >= 0
| 0 | ||||||||||||||||||||||||
| 525 | bestDist = dist; | - | ||||||||||||||||||||||||
| 526 | bestId = id; | - | ||||||||||||||||||||||||
| 527 | bestMatch = it; | - | ||||||||||||||||||||||||
| 528 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 529 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 530 | if (bestDist >= 0
| 0 | ||||||||||||||||||||||||
| 531 | bestMatch->trackingId = bestId; | - | ||||||||||||||||||||||||
| 532 | newContacts.insert(bestId, *bestMatch); | - | ||||||||||||||||||||||||
| 533 | candidates.remove(bestId); | - | ||||||||||||||||||||||||
| 534 | pending.erase(bestMatch); | - | ||||||||||||||||||||||||
| 535 | if (bestId > maxId
| 0 | ||||||||||||||||||||||||
| 536 | maxId = bestId; never executed: maxId = bestId; | 0 | ||||||||||||||||||||||||
| 537 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 538 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 539 | if (candidates.isEmpty()
| 0 | ||||||||||||||||||||||||
| 540 | for (it = pending.begin(), ite = pending.end(); it != ite
| 0 | ||||||||||||||||||||||||
| 541 | it->trackingId = ++maxId; | - | ||||||||||||||||||||||||
| 542 | newContacts.insert(it->trackingId, *it); | - | ||||||||||||||||||||||||
| 543 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 544 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 545 | m_contacts = newContacts; | - | ||||||||||||||||||||||||
| 546 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 547 | - | |||||||||||||||||||||||||
| 548 | void QEvdevTouchScreenData::reportPoints() | - | ||||||||||||||||||||||||
| 549 | { | - | ||||||||||||||||||||||||
| 550 | QRect winRect; | - | ||||||||||||||||||||||||
| 551 | if (m_forceToActiveWindow
| 0 | ||||||||||||||||||||||||
| 552 | QWindow *win = QGuiApplication::focusWindow(); | - | ||||||||||||||||||||||||
| 553 | if (!win
| 0 | ||||||||||||||||||||||||
| 554 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 555 | winRect = QHighDpi::toNativePixels(win->geometry(), win); | - | ||||||||||||||||||||||||
| 556 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 557 | QScreen *primary = QGuiApplication::primaryScreen(); | - | ||||||||||||||||||||||||
| 558 | winRect = QHighDpi::toNativePixels(primary->geometry(), primary); | - | ||||||||||||||||||||||||
| 559 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 560 | - | |||||||||||||||||||||||||
| 561 | const int hw_w = hw_range_x_max - hw_range_x_min; | - | ||||||||||||||||||||||||
| 562 | const int hw_h = hw_range_y_max - hw_range_y_min; | - | ||||||||||||||||||||||||
| 563 | - | |||||||||||||||||||||||||
| 564 | - | |||||||||||||||||||||||||
| 565 | - | |||||||||||||||||||||||||
| 566 | const int pointCount = m_touchPoints.count(); | - | ||||||||||||||||||||||||
| 567 | for (int i = 0; i < pointCount
| 0 | ||||||||||||||||||||||||
| 568 | QWindowSystemInterface::TouchPoint &tp(m_touchPoints[i]); | - | ||||||||||||||||||||||||
| 569 | - | |||||||||||||||||||||||||
| 570 | - | |||||||||||||||||||||||||
| 571 | - | |||||||||||||||||||||||||
| 572 | - | |||||||||||||||||||||||||
| 573 | const qreal wx = winRect.left() + tp.normalPosition.x() * (winRect.width() - 1); | - | ||||||||||||||||||||||||
| 574 | const qreal wy = winRect.top() + tp.normalPosition.y() * (winRect.height() - 1); | - | ||||||||||||||||||||||||
| 575 | const qreal sizeRatio = (winRect.width() + winRect.height()) / qreal(hw_w + hw_h); | - | ||||||||||||||||||||||||
| 576 | if (tp.area.width() == -1
| 0 | ||||||||||||||||||||||||
| 577 | tp.area = QRectF(0, 0, 8, 8); never executed: tp.area = QRectF(0, 0, 8, 8); | 0 | ||||||||||||||||||||||||
| 578 | else | - | ||||||||||||||||||||||||
| 579 | tp.area = QRectF(0, 0, tp.area.width() * sizeRatio, tp.area.height() * sizeRatio); never executed: tp.area = QRectF(0, 0, tp.area.width() * sizeRatio, tp.area.height() * sizeRatio); | 0 | ||||||||||||||||||||||||
| 580 | tp.area.moveCenter(QPointF(wx, wy)); | - | ||||||||||||||||||||||||
| 581 | - | |||||||||||||||||||||||||
| 582 | - | |||||||||||||||||||||||||
| 583 | if (!hw_pressure_min
| 0 | ||||||||||||||||||||||||
| 584 | tp.pressure = tp.state == Qt::TouchPointReleased
never executed: tp.pressure = tp.state == Qt::TouchPointReleased ? 0 : 1; | 0 | ||||||||||||||||||||||||
| 585 | else | - | ||||||||||||||||||||||||
| 586 | tp.pressure = (tp.pressure - hw_pressure_min) / qreal(hw_pressure_max - hw_pressure_min); never executed: tp.pressure = (tp.pressure - hw_pressure_min) / qreal(hw_pressure_max - hw_pressure_min); | 0 | ||||||||||||||||||||||||
| 587 | } | - | ||||||||||||||||||||||||
| 588 | - | |||||||||||||||||||||||||
| 589 | QWindowSystemInterface::handleTouchEvent(nullptr, q->touchDevice(), m_touchPoints); | - | ||||||||||||||||||||||||
| 590 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 591 | - | |||||||||||||||||||||||||
| 592 | - | |||||||||||||||||||||||||
| 593 | QEvdevTouchScreenHandlerThread::QEvdevTouchScreenHandlerThread(const QString &device, const QString &spec, QObject *parent) | - | ||||||||||||||||||||||||
| 594 | : QDaemonThread(parent), m_device(device), m_spec(spec), m_handler(nullptr), m_touchDeviceRegistered(false) | - | ||||||||||||||||||||||||
| 595 | { | - | ||||||||||||||||||||||||
| 596 | start(); | - | ||||||||||||||||||||||||
| 597 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 598 | - | |||||||||||||||||||||||||
| 599 | QEvdevTouchScreenHandlerThread::~QEvdevTouchScreenHandlerThread() | - | ||||||||||||||||||||||||
| 600 | { | - | ||||||||||||||||||||||||
| 601 | quit(); | - | ||||||||||||||||||||||||
| 602 | wait(); | - | ||||||||||||||||||||||||
| 603 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 604 | - | |||||||||||||||||||||||||
| 605 | void QEvdevTouchScreenHandlerThread::run() | - | ||||||||||||||||||||||||
| 606 | { | - | ||||||||||||||||||||||||
| 607 | m_handler = new QEvdevTouchScreenHandler(m_device, m_spec); | - | ||||||||||||||||||||||||
| 608 | - | |||||||||||||||||||||||||
| 609 | QMetaObject::invokeMethod(this, "notifyTouchDeviceRegistered", Qt::QueuedConnection); | - | ||||||||||||||||||||||||
| 610 | - | |||||||||||||||||||||||||
| 611 | exec(); | - | ||||||||||||||||||||||||
| 612 | - | |||||||||||||||||||||||||
| 613 | delete m_handler; | - | ||||||||||||||||||||||||
| 614 | m_handler = nullptr; | - | ||||||||||||||||||||||||
| 615 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 616 | - | |||||||||||||||||||||||||
| 617 | bool QEvdevTouchScreenHandlerThread::isTouchDeviceRegistered() const | - | ||||||||||||||||||||||||
| 618 | { | - | ||||||||||||||||||||||||
| 619 | return never executed: m_touchDeviceRegistered;return m_touchDeviceRegistered;never executed: return m_touchDeviceRegistered; | 0 | ||||||||||||||||||||||||
| 620 | } | - | ||||||||||||||||||||||||
| 621 | - | |||||||||||||||||||||||||
| 622 | void QEvdevTouchScreenHandlerThread::notifyTouchDeviceRegistered() | - | ||||||||||||||||||||||||
| 623 | { | - | ||||||||||||||||||||||||
| 624 | m_touchDeviceRegistered = true; | - | ||||||||||||||||||||||||
| 625 | touchDeviceRegistered(); | - | ||||||||||||||||||||||||
| 626 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 627 | - | |||||||||||||||||||||||||
| 628 | - | |||||||||||||||||||||||||
| 629 | - | |||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |