27 QString spec = QString::fromLocal8Bit(qgetenv(
"QT_QPA_VXEVDEV_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(qLcVxMouse,
"vxmouse: 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, &QVxMouseManager::addMouse);
57 connect(deviceDiscovery, &QDeviceDiscovery::deviceRemoved,
58 this, &QVxMouseManager::removeMouse);
62 QInputDeviceManager *manager = QGuiApplicationPrivate::inputDeviceManager();
63 connect(manager, &QInputDeviceManager::cursorPositionChangeRequested,
this, [
this](
const QPoint &pos) {
91 Qt::MouseButton button, QEvent::Type type)
98 QPoint pos(m_x + m_xoffset, m_y + m_yoffset);
101 QWindowSystemInterface::handleMouseEvent(0, pos, pos, buttons, button, type, QGuiApplicationPrivate::inputDeviceManager()->keyboardModifiers());
106 qCDebug(qLcVxMouse,
"Adding mouse at %ls", qUtf16Printable(deviceNode));
107 auto handler = QVxMouseHandler::create(deviceNode, m_spec);
109 connect(handler.get(), &QVxMouseHandler::handleMouseEvent,
110 this, &QVxMouseManager::handleMouseEvent);
111 m_mice.add(deviceNode, std::move(handler));
114 qWarning(
"vxmouse: Failed to open mouse device %ls", qUtf16Printable(deviceNode));