1 /* 2 KWin - the KDE window manager 3 This file is part of the KDE project. 4 5 SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org> 6 7 SPDX-License-Identifier: GPL-2.0-or-later 8 */ 9 #ifndef MOCK_LIBINPUT_H 10 #define MOCK_LIBINPUT_H 11 #include <libinput.h> 12 13 #include <QByteArray> 14 #include <QPointF> 15 #include <QSizeF> 16 #include <QVector> 17 18 #include <array> 19 20 struct libinput_device { 21 bool keyboard = false; 22 bool pointer = false; 23 bool touch = false; 24 bool tabletTool = false; 25 bool gestureSupported = false; 26 bool switchDevice = false; 27 QByteArray name; 28 QByteArray sysName = QByteArrayLiteral("event0"); 29 QByteArray outputName; 30 quint32 product = 0; 31 quint32 vendor = 0; 32 int tapFingerCount = 0; 33 QSizeF deviceSize; 34 int deviceSizeReturnValue = 0; 35 bool tapEnabledByDefault = false; 36 bool tapToClick = false; 37 bool tapAndDragEnabledByDefault = false; 38 bool tapAndDrag = false; 39 bool tapDragLockEnabledByDefault = false; 40 bool tapDragLock = false; 41 bool supportsDisableWhileTyping = false; 42 bool supportsPointerAcceleration = false; 43 bool supportsLeftHanded = false; 44 bool supportsCalibrationMatrix = false; 45 bool supportsDisableEvents = false; 46 bool supportsDisableEventsOnExternalMouse = false; 47 bool supportsMiddleEmulation = false; 48 bool supportsNaturalScroll = false; 49 quint32 supportedScrollMethods = 0; 50 bool middleEmulationEnabledByDefault = false; 51 bool middleEmulation = false; 52 enum libinput_config_tap_button_map defaultTapButtonMap = LIBINPUT_CONFIG_TAP_MAP_LRM; 53 enum libinput_config_tap_button_map tapButtonMap = LIBINPUT_CONFIG_TAP_MAP_LRM; 54 int setTapButtonMapReturnValue = 0; 55 enum libinput_config_dwt_state disableWhileTypingEnabledByDefault = LIBINPUT_CONFIG_DWT_DISABLED; 56 enum libinput_config_dwt_state disableWhileTyping = LIBINPUT_CONFIG_DWT_DISABLED; 57 int setDisableWhileTypingReturnValue = 0; 58 qreal defaultPointerAcceleration = 0.0; 59 qreal pointerAcceleration = 0.0; 60 int setPointerAccelerationReturnValue = 0; 61 bool leftHandedEnabledByDefault = false; 62 bool leftHanded = false; 63 int setLeftHandedReturnValue = 0; 64 bool naturalScrollEnabledByDefault = false; 65 bool naturalScroll = false; 66 int setNaturalScrollReturnValue = 0; 67 enum libinput_config_scroll_method defaultScrollMethod = LIBINPUT_CONFIG_SCROLL_NO_SCROLL; 68 enum libinput_config_scroll_method scrollMethod = LIBINPUT_CONFIG_SCROLL_NO_SCROLL; 69 int setScrollMethodReturnValue = 0; 70 quint32 defaultScrollButton = 0; 71 quint32 scrollButton = 0; 72 int setScrollButtonReturnValue = 0; 73 Qt::MouseButtons supportedButtons; 74 QVector<quint32> keys; 75 bool enabled = true; 76 int setEnableModeReturnValue = 0; 77 int setTapToClickReturnValue = 0; 78 int setTapAndDragReturnValue = 0; 79 int setTapDragLockReturnValue = 0; 80 int setMiddleEmulationReturnValue = 0; 81 quint32 supportedPointerAccelerationProfiles = 0; 82 enum libinput_config_accel_profile defaultPointerAccelerationProfile = LIBINPUT_CONFIG_ACCEL_PROFILE_NONE; 83 enum libinput_config_accel_profile pointerAccelerationProfile = LIBINPUT_CONFIG_ACCEL_PROFILE_NONE; 84 bool setPointerAccelerationProfileReturnValue = 0; 85 std::array<float, 6> defaultCalibrationMatrix{{1.0f, 0.0f, 0.0f, 86 0.0f, 1.0f, 0.0f}}; 87 std::array<float, 6> calibrationMatrix{{1.0f, 0.0f, 0.0f, 88 0.0f, 1.0f, 0.0f}}; 89 bool defaultCalibrationMatrixIsIdentity = true; 90 91 bool lidSwitch = false; 92 bool tabletModeSwitch = false; 93 quint32 supportedClickMethods = 0; 94 enum libinput_config_click_method defaultClickMethod = LIBINPUT_CONFIG_CLICK_METHOD_NONE; 95 enum libinput_config_click_method clickMethod = LIBINPUT_CONFIG_CLICK_METHOD_NONE; 96 bool setClickMethodReturnValue = 0; 97 uint32_t buttonCount = 0; 98 uint32_t stripCount = 0; 99 uint32_t ringCount = 0; 100 }; 101 102 struct libinput_event { ~libinput_eventlibinput_event103 virtual ~libinput_event() {} 104 libinput_device *device = nullptr; 105 libinput_event_type type = LIBINPUT_EVENT_NONE; 106 quint32 time = 0; 107 }; 108 109 struct libinput_event_keyboard : libinput_event { libinput_event_keyboardlibinput_event_keyboard110 libinput_event_keyboard() { 111 type = LIBINPUT_EVENT_KEYBOARD_KEY; 112 } 113 libinput_key_state state = LIBINPUT_KEY_STATE_RELEASED; 114 quint32 key = 0; 115 }; 116 117 struct libinput_event_pointer : libinput_event { 118 libinput_button_state buttonState = LIBINPUT_BUTTON_STATE_RELEASED; 119 quint32 button = 0; 120 bool verticalAxis = false; 121 bool horizontalAxis = false; 122 qreal horizontalAxisValue = 0.0; 123 qreal verticalAxisValue = 0.0; 124 qreal horizontalDiscreteAxisValue = 0.0; 125 qreal verticalDiscreteAxisValue = 0.0; 126 libinput_pointer_axis_source axisSource = {}; 127 QSizeF delta; 128 QPointF absolutePos; 129 }; 130 131 struct libinput_event_touch : libinput_event { 132 qint32 slot = -1; 133 QPointF absolutePos; 134 }; 135 136 struct libinput_event_gesture : libinput_event { 137 int fingerCount = 0; 138 bool cancelled = false; 139 QSizeF delta = QSizeF(0, 0); 140 qreal scale = 0.0; 141 qreal angleDelta = 0.0; 142 }; 143 144 struct libinput_event_switch : libinput_event { 145 enum class State { 146 Off, 147 On 148 }; 149 State state = State::Off; 150 quint64 timeMicroseconds = 0; 151 }; 152 153 struct libinput { 154 int refCount = 1; 155 QByteArray seat; 156 int assignSeatRetVal = 0; 157 }; 158 159 #endif 160