File indexing completed on 2025-02-16 05:02:36
0001 /* 0002 KWin - the KDE window manager 0003 This file is part of the KDE project. 0004 0005 SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org> 0006 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 #ifndef MOCK_LIBINPUT_H 0010 #define MOCK_LIBINPUT_H 0011 #include <libinput.h> 0012 0013 #include <QByteArray> 0014 #include <QList> 0015 #include <QPointF> 0016 #include <QSizeF> 0017 0018 #include <array> 0019 #include <chrono> 0020 0021 struct libinput_device 0022 { 0023 void *userData = nullptr; 0024 bool keyboard = false; 0025 bool pointer = false; 0026 bool touch = false; 0027 bool tabletTool = false; 0028 bool gestureSupported = false; 0029 bool switchDevice = false; 0030 QByteArray name; 0031 QByteArray sysName = QByteArrayLiteral("event0"); 0032 QByteArray outputName; 0033 quint32 product = 0; 0034 quint32 vendor = 0; 0035 int tapFingerCount = 0; 0036 QSizeF deviceSize; 0037 int deviceSizeReturnValue = 0; 0038 bool tapEnabledByDefault = false; 0039 bool tapToClick = false; 0040 bool tapAndDragEnabledByDefault = false; 0041 bool tapAndDrag = false; 0042 bool tapDragLockEnabledByDefault = false; 0043 bool tapDragLock = false; 0044 bool supportsDisableWhileTyping = false; 0045 bool supportsPointerAcceleration = false; 0046 bool supportsLeftHanded = false; 0047 bool supportsCalibrationMatrix = false; 0048 bool supportsDisableEvents = false; 0049 bool supportsDisableEventsOnExternalMouse = false; 0050 bool supportsMiddleEmulation = false; 0051 bool supportsNaturalScroll = false; 0052 quint32 supportedScrollMethods = 0; 0053 bool middleEmulationEnabledByDefault = false; 0054 bool middleEmulation = false; 0055 enum libinput_config_tap_button_map defaultTapButtonMap = LIBINPUT_CONFIG_TAP_MAP_LRM; 0056 enum libinput_config_tap_button_map tapButtonMap = LIBINPUT_CONFIG_TAP_MAP_LRM; 0057 int setTapButtonMapReturnValue = 0; 0058 enum libinput_config_dwt_state disableWhileTypingEnabledByDefault = LIBINPUT_CONFIG_DWT_DISABLED; 0059 enum libinput_config_dwt_state disableWhileTyping = LIBINPUT_CONFIG_DWT_DISABLED; 0060 int setDisableWhileTypingReturnValue = 0; 0061 qreal defaultPointerAcceleration = 0.0; 0062 qreal pointerAcceleration = 0.0; 0063 int setPointerAccelerationReturnValue = 0; 0064 bool leftHandedEnabledByDefault = false; 0065 bool leftHanded = false; 0066 int setLeftHandedReturnValue = 0; 0067 bool naturalScrollEnabledByDefault = false; 0068 bool naturalScroll = false; 0069 int setNaturalScrollReturnValue = 0; 0070 enum libinput_config_scroll_method defaultScrollMethod = LIBINPUT_CONFIG_SCROLL_NO_SCROLL; 0071 enum libinput_config_scroll_method scrollMethod = LIBINPUT_CONFIG_SCROLL_NO_SCROLL; 0072 int setScrollMethodReturnValue = 0; 0073 quint32 defaultScrollButton = 0; 0074 quint32 scrollButton = 0; 0075 int setScrollButtonReturnValue = 0; 0076 Qt::MouseButtons supportedButtons; 0077 QList<quint32> keys; 0078 bool enabled = true; 0079 int setEnableModeReturnValue = 0; 0080 int setTapToClickReturnValue = 0; 0081 int setTapAndDragReturnValue = 0; 0082 int setTapDragLockReturnValue = 0; 0083 int setMiddleEmulationReturnValue = 0; 0084 quint32 supportedPointerAccelerationProfiles = 0; 0085 enum libinput_config_accel_profile defaultPointerAccelerationProfile = LIBINPUT_CONFIG_ACCEL_PROFILE_NONE; 0086 enum libinput_config_accel_profile pointerAccelerationProfile = LIBINPUT_CONFIG_ACCEL_PROFILE_NONE; 0087 bool setPointerAccelerationProfileReturnValue = 0; 0088 std::array<float, 6> defaultCalibrationMatrix{{1.0f, 0.0f, 0.0f, 0089 0.0f, 1.0f, 0.0f}}; 0090 std::array<float, 6> calibrationMatrix{{1.0f, 0.0f, 0.0f, 0091 0.0f, 1.0f, 0.0f}}; 0092 bool defaultCalibrationMatrixIsIdentity = true; 0093 bool calibrationMatrixIsIdentity = true; 0094 0095 bool lidSwitch = false; 0096 bool tabletModeSwitch = false; 0097 quint32 supportedClickMethods = 0; 0098 enum libinput_config_click_method defaultClickMethod = LIBINPUT_CONFIG_CLICK_METHOD_NONE; 0099 enum libinput_config_click_method clickMethod = LIBINPUT_CONFIG_CLICK_METHOD_NONE; 0100 bool setClickMethodReturnValue = 0; 0101 uint32_t buttonCount = 0; 0102 uint32_t stripCount = 0; 0103 uint32_t ringCount = 0; 0104 }; 0105 0106 struct libinput_event 0107 { 0108 virtual ~libinput_event() 0109 { 0110 } 0111 libinput_device *device = nullptr; 0112 libinput_event_type type = LIBINPUT_EVENT_NONE; 0113 std::chrono::microseconds time = std::chrono::microseconds::zero(); 0114 }; 0115 0116 struct libinput_event_keyboard : libinput_event 0117 { 0118 libinput_event_keyboard() 0119 { 0120 type = LIBINPUT_EVENT_KEYBOARD_KEY; 0121 } 0122 libinput_key_state state = LIBINPUT_KEY_STATE_RELEASED; 0123 quint32 key = 0; 0124 }; 0125 0126 struct libinput_event_pointer : libinput_event 0127 { 0128 libinput_button_state buttonState = LIBINPUT_BUTTON_STATE_RELEASED; 0129 quint32 button = 0; 0130 bool verticalAxis = false; 0131 bool horizontalAxis = false; 0132 qreal horizontalScrollValue = 0.0; 0133 qreal verticalScrollValue = 0.0; 0134 qreal horizontalScrollValueV120 = 0.0; 0135 qreal verticalScrollValueV120 = 0.0; 0136 QPointF delta; 0137 QPointF absolutePos; 0138 }; 0139 0140 struct libinput_event_touch : libinput_event 0141 { 0142 qint32 slot = -1; 0143 QPointF absolutePos; 0144 }; 0145 0146 struct libinput_event_gesture : libinput_event 0147 { 0148 int fingerCount = 0; 0149 bool cancelled = false; 0150 QPointF delta = QPointF(0, 0); 0151 qreal scale = 0.0; 0152 qreal angleDelta = 0.0; 0153 }; 0154 0155 struct libinput_event_switch : libinput_event 0156 { 0157 enum class State { 0158 Off, 0159 On 0160 }; 0161 State state = State::Off; 0162 }; 0163 0164 struct libinput 0165 { 0166 int refCount = 1; 0167 QByteArray seat; 0168 int assignSeatRetVal = 0; 0169 }; 0170 0171 #endif