27 QString spec = qEnvironmentVariable(
"QT_QPA_EVDEV_MOUSE_PARAMETERS");
32 auto parsed = QEvdevUtil::parseSpecification(spec);
33 m_spec = std::move(parsed.spec);
35 for (
const auto &arg : std::as_const(parsed.args)) {
36 if (arg.startsWith(
"xoffset="_L1)) {
37 m_xoffset = arg.mid(8).toInt();
38 }
else if (arg.startsWith(
"yoffset="_L1)) {
39 m_yoffset = arg.mid(8).toInt();
44 for (
const QString &device : std::as_const(parsed.devices))
47 if (parsed.devices.isEmpty()) {
48 qCDebug(qLcEvdevMouse,
"evdevmouse: Using device discovery");
49 if (
auto deviceDiscovery = QDeviceDiscovery::create(QDeviceDiscovery::Device_Mouse | QDeviceDiscovery::Device_Touchpad,
this)) {
51 const QStringList devices = deviceDiscovery->scanConnectedDevices();
52 for (
const QString &device : devices)
55 connect(deviceDiscovery, &QDeviceDiscovery::deviceDetected,
56 this, &QEvdevMouseManager::addMouse);
57 connect(deviceDiscovery, &QDeviceDiscovery::deviceRemoved,
58 this, &QEvdevMouseManager::removeMouse);
62 QInputDeviceManager *manager = QGuiApplicationPrivate::inputDeviceManager();
63 connect(manager, &QInputDeviceManager::cursorPositionChangeRequested,
this, [
this](
const QPoint &pos) {
91 Qt::MouseButton button, QEvent::Type type)
104 QPoint pos(m_x + m_xoffset, m_y + m_yoffset);
107 QWindowSystemInterface::handleMouseEvent(0, pos, pos, buttons, button, type, QGuiApplicationPrivate::inputDeviceManager()->keyboardModifiers());
118 qCDebug(qLcEvdevMouse,
"Adding mouse at %ls", qUtf16Printable(deviceNode));
119 auto handler = QEvdevMouseHandler::create(deviceNode, m_spec);
121 connect(handler.get(), &QEvdevMouseHandler::handleMouseEvent,
122 this, &QEvdevMouseManager::handleMouseEvent);
123 connect(handler.get(), &QEvdevMouseHandler::handleWheelEvent,
124 this, &QEvdevMouseManager::handleWheelEvent);
125 m_mice.add(deviceNode, std::move(handler));
128 qWarning(
"evdevmouse: Failed to open mouse device %ls", qUtf16Printable(deviceNode));