23void QLibInputPointer::processButton(libinput_event_pointer *e)
25 const uint32_t b = libinput_event_pointer_get_button(e);
26 const bool pressed = libinput_event_pointer_get_button_state(e) == LIBINPUT_BUTTON_STATE_PRESSED;
28 Qt::MouseButton button = Qt::NoButton;
30 case 0x110: button = Qt::LeftButton;
break;
31 case 0x111: button = Qt::RightButton;
break;
32 case 0x112: button = Qt::MiddleButton;
break;
33 case 0x113: button = Qt::ExtraButton1;
break;
34 case 0x114: button = Qt::ExtraButton2;
break;
35 case 0x115: button = Qt::ExtraButton3;
break;
36 case 0x116: button = Qt::ExtraButton4;
break;
37 case 0x117: button = Qt::ExtraButton5;
break;
38 case 0x118: button = Qt::ExtraButton6;
break;
39 case 0x119: button = Qt::ExtraButton7;
break;
40 case 0x11a: button = Qt::ExtraButton8;
break;
41 case 0x11b: button = Qt::ExtraButton9;
break;
42 case 0x11c: button = Qt::ExtraButton10;
break;
43 case 0x11d: button = Qt::ExtraButton11;
break;
44 case 0x11e: button = Qt::ExtraButton12;
break;
45 case 0x11f: button = Qt::ExtraButton13;
break;
48 m_buttons.setFlag(button, pressed);
50 QEvent::Type type = pressed ? QEvent::MouseButtonPress : QEvent::MouseButtonRelease;
51 Qt::KeyboardModifiers mods = QGuiApplicationPrivate::inputDeviceManager()->keyboardModifiers();
53 qCDebug(qLcLibInputMouse) <<
"processButton" << type << button << m_buttons << m_pos << mods;
54 QWindowSystemInterface::handleMouseEvent(
nullptr, m_pos, m_pos, m_buttons, button, type, mods);
57void QLibInputPointer::processMotion(libinput_event_pointer *e)
59 const double dx = libinput_event_pointer_get_dx(e);
60 const double dy = libinput_event_pointer_get_dy(e);
61 QScreen *
const primaryScreen = QGuiApplication::primaryScreen();
62 const QRect g = QHighDpi::toNativePixels(primaryScreen->virtualGeometry(), primaryScreen);
64 m_pos.setX(qBound(g.left(), qRound(m_pos.x() + dx), g.right()));
65 m_pos.setY(qBound(g.top(), qRound(m_pos.y() + dy), g.bottom()));
67 Qt::KeyboardModifiers mods = QGuiApplicationPrivate::inputDeviceManager()->keyboardModifiers();
69 qCDebug(qLcLibInputMouse) <<
"processMotion" << m_pos << mods;
70 QWindowSystemInterface::handleMouseEvent(
nullptr, m_pos, m_pos, m_buttons,
71 Qt::NoButton, QEvent::MouseMove, mods);
74void QLibInputPointer::processAbsMotion(libinput_event_pointer *e)
76 QScreen *
const primaryScreen = QGuiApplication::primaryScreen();
77 const QRect g = QHighDpi::toNativePixels(primaryScreen->virtualGeometry(), primaryScreen);
79 const double x = libinput_event_pointer_get_absolute_x_transformed(e, g.width());
80 const double y = libinput_event_pointer_get_absolute_y_transformed(e, g.height());
82 m_pos.setX(qBound(g.left(), qRound(g.left() + x), g.right()));
83 m_pos.setY(qBound(g.top(), qRound(g.top() + y), g.bottom()));
85 Qt::KeyboardModifiers mods = QGuiApplicationPrivate::inputDeviceManager()->keyboardModifiers();
87 qCDebug(qLcLibInputMouse) <<
"processAbsMotion" << m_pos << mods;
88 QWindowSystemInterface::handleMouseEvent(
nullptr, m_pos, m_pos, m_buttons,
89 Qt::NoButton, QEvent::MouseMove, mods);
93void QLibInputPointer::processAxis(libinput_event_pointer *e)
97#if !QT_CONFIG(libinput_axis_api)
98 value = libinput_event_pointer_get_axis_value(e);
99 if (libinput_event_pointer_get_axis(e) == LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL)
100 angleDelta.setY(qRound(value));
102 angleDelta.setX(qRound(value));
104 if (libinput_event_pointer_has_axis(e, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL)) {
105#if QT_CONFIG(libinput_hires_wheel_support)
106 value = libinput_event_pointer_get_scroll_value_v120(e, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL);
108 value = libinput_event_pointer_get_axis_value(e, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL);
110 angleDelta.setY(qRound(value));
112 if (libinput_event_pointer_has_axis(e, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL)) {
113#if QT_CONFIG(libinput_hires_wheel_support)
114 value = libinput_event_pointer_get_scroll_value_v120(e, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL);
116 value = libinput_event_pointer_get_axis_value(e, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL);
118 angleDelta.setX(qRound(value));
121#if QT_CONFIG(libinput_hires_wheel_support)
122 const int factor = -1;
124 const int factor = -8;
126 angleDelta *= factor;
127 Qt::KeyboardModifiers mods = QGuiApplicationPrivate::inputDeviceManager()->keyboardModifiers();
128 qCDebug(qLcLibInputMouse) <<
"processAxis" << angleDelta << m_pos << mods;
129 QWindowSystemInterface::handleWheelEvent(
nullptr, m_pos, m_pos, QPoint(), angleDelta, mods);
132void QLibInputPointer::setPos(
const QPoint &pos)
134 QScreen *
const primaryScreen = QGuiApplication::primaryScreen();
135 const QRect g = QHighDpi::toNativePixels(primaryScreen->virtualGeometry(), primaryScreen);
137 m_pos.setX(qBound(g.left(), pos.x(), g.right()));
138 m_pos.setY(qBound(g.top(), pos.y(), g.bottom()));
139 qCDebug(qLcLibInputMouse) <<
"setPos" << pos <<
"bounded:" << m_pos;