100 if (!state.lastReportTool && state.tool)
101 QWindowSystemInterface::handleTabletEnterProximityEvent(
int(QInputDevice::DeviceType::Stylus), state.tool, q->deviceId());
103 qreal nx = (state.x - minValues.x) / qreal(maxValues.x - minValues.x);
104 qreal ny = (state.y - minValues.y) / qreal(maxValues.y - minValues.y);
106 QRect winRect = QGuiApplication::primaryScreen()->geometry();
107 QPointF globalPos(nx * winRect.width(), ny * winRect.height());
108 int pointer = state.tool;
110 if (!state.down && state.lastReportDown) {
111 globalPos = state.lastReportPos;
112 pointer = state.lastReportTool;
115 int pressureRange = maxValues
.p - minValues
.p;
116 qreal pressure = pressureRange ? (state.p - minValues.p) / qreal(pressureRange) : qreal(1);
118 if (state.down || state.lastReportDown) {
119 QWindowSystemInterface::handleTabletEvent(0, QPointF(), globalPos,
120 int(QInputDevice::DeviceType::Stylus), pointer,
121 state.down ? Qt::LeftButton : Qt::NoButton,
122 pressure, 0, 0, 0, 0, 0, q->deviceId(),
123 qGuiApp->keyboardModifiers());
126 if (state.lastReportTool && !state.tool)
127 QWindowSystemInterface::handleTabletLeaveProximityEvent(
int(QInputDevice::DeviceType::Stylus), state.tool, q->deviceId());
129 state.lastReportDown = state.down;
130 state.lastReportTool = state.tool;
131 state.lastReportPos = globalPos;
140 setObjectName(
"Evdev Tablet Handler"_L1);
142 qCDebug(qLcEvdevTablet,
"evdevtablet: using %ls", qUtf16Printable(device));
144 m_fd = QT_OPEN(device.toLocal8Bit().constData(), O_RDONLY | O_NDELAY, 0);
146 qErrnoWarning(
"evdevtablet: Cannot open input device %ls", qUtf16Printable(device));
150 bool grabSuccess = !ioctl(m_fd, EVIOCGRAB, (
void *) 1);
152 ioctl(m_fd, EVIOCGRAB, (
void *) 0);
154 qWarning(
"evdevtablet: %ls: The device is grabbed by another process. No events will be read.", qUtf16Printable(device));
158 qWarning(
"evdevtablet: %ls: Unset or invalid ABS limits. Behavior will be unspecified.", qUtf16Printable(device));
160 m_notifier =
new QSocketNotifier(m_fd, QSocketNotifier::Read,
this);
161 connect(m_notifier, &QSocketNotifier::activated,
this, &QEvdevTabletHandler::readData);