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 KWIN_LIBINPUT_DEVICE_H 10 #define KWIN_LIBINPUT_DEVICE_H 11 12 #include <libinput.h> 13 14 #include <KConfigGroup> 15 16 #include <QObject> 17 #include <QMatrix4x4> 18 #include <QSizeF> 19 #include <QVector> 20 #include "kwin_export.h" 21 22 struct libinput_device; 23 24 namespace KWin 25 { 26 namespace LibInput 27 { 28 enum class ConfigKey; 29 30 class KWIN_EXPORT Device : public QObject 31 { 32 Q_OBJECT 33 Q_CLASSINFO("D-Bus Interface", "org.kde.KWin.InputDevice") 34 // 35 // general 36 Q_PROPERTY(bool keyboard READ isKeyboard CONSTANT) 37 Q_PROPERTY(bool alphaNumericKeyboard READ isAlphaNumericKeyboard CONSTANT) 38 Q_PROPERTY(bool pointer READ isPointer CONSTANT) 39 Q_PROPERTY(bool touchpad READ isTouchpad CONSTANT) 40 Q_PROPERTY(bool touch READ isTouch CONSTANT) 41 Q_PROPERTY(bool tabletTool READ isTabletTool CONSTANT) 42 Q_PROPERTY(bool tabletPad READ isTabletPad CONSTANT) 43 Q_PROPERTY(bool gestureSupport READ supportsGesture CONSTANT) 44 Q_PROPERTY(QString name READ name CONSTANT) 45 Q_PROPERTY(QString sysName READ sysName CONSTANT) 46 Q_PROPERTY(QString outputName READ outputName CONSTANT) 47 Q_PROPERTY(QSizeF size READ size CONSTANT) 48 Q_PROPERTY(quint32 product READ product CONSTANT) 49 Q_PROPERTY(quint32 vendor READ vendor CONSTANT) 50 Q_PROPERTY(bool supportsDisableEvents READ supportsDisableEvents CONSTANT) 51 Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged) 52 // 53 // advanced 54 Q_PROPERTY(int supportedButtons READ supportedButtons CONSTANT) 55 Q_PROPERTY(bool supportsCalibrationMatrix READ supportsCalibrationMatrix CONSTANT) 56 57 Q_PROPERTY(bool supportsLeftHanded READ supportsLeftHanded CONSTANT) 58 Q_PROPERTY(bool leftHandedEnabledByDefault READ leftHandedEnabledByDefault CONSTANT) 59 Q_PROPERTY(bool leftHanded READ isLeftHanded WRITE setLeftHanded NOTIFY leftHandedChanged) 60 61 Q_PROPERTY(bool supportsDisableEventsOnExternalMouse READ supportsDisableEventsOnExternalMouse CONSTANT) 62 63 Q_PROPERTY(bool supportsDisableWhileTyping READ supportsDisableWhileTyping CONSTANT) 64 Q_PROPERTY(bool disableWhileTypingEnabledByDefault READ disableWhileTypingEnabledByDefault CONSTANT) 65 Q_PROPERTY(bool disableWhileTyping READ isDisableWhileTyping WRITE setDisableWhileTyping NOTIFY disableWhileTypingChanged) 66 // 67 // acceleration speed and profile 68 Q_PROPERTY(bool supportsPointerAcceleration READ supportsPointerAcceleration CONSTANT) 69 Q_PROPERTY(qreal defaultPointerAcceleration READ defaultPointerAcceleration CONSTANT) 70 Q_PROPERTY(qreal pointerAcceleration READ pointerAcceleration WRITE setPointerAcceleration NOTIFY pointerAccelerationChanged) 71 72 Q_PROPERTY(bool supportsPointerAccelerationProfileFlat READ supportsPointerAccelerationProfileFlat CONSTANT) 73 Q_PROPERTY(bool defaultPointerAccelerationProfileFlat READ defaultPointerAccelerationProfileFlat CONSTANT) 74 Q_PROPERTY(bool pointerAccelerationProfileFlat READ pointerAccelerationProfileFlat WRITE setPointerAccelerationProfileFlat NOTIFY pointerAccelerationProfileChanged) 75 76 Q_PROPERTY(bool supportsPointerAccelerationProfileAdaptive READ supportsPointerAccelerationProfileAdaptive CONSTANT) 77 Q_PROPERTY(bool defaultPointerAccelerationProfileAdaptive READ defaultPointerAccelerationProfileAdaptive CONSTANT) 78 Q_PROPERTY(bool pointerAccelerationProfileAdaptive READ pointerAccelerationProfileAdaptive WRITE setPointerAccelerationProfileAdaptive NOTIFY pointerAccelerationProfileChanged) 79 // 80 // tapping 81 Q_PROPERTY(int tapFingerCount READ tapFingerCount CONSTANT) 82 Q_PROPERTY(bool tapToClickEnabledByDefault READ tapToClickEnabledByDefault CONSTANT) 83 Q_PROPERTY(bool tapToClick READ isTapToClick WRITE setTapToClick NOTIFY tapToClickChanged) 84 85 Q_PROPERTY(bool supportsLmrTapButtonMap READ supportsLmrTapButtonMap CONSTANT) 86 Q_PROPERTY(bool lmrTapButtonMapEnabledByDefault READ lmrTapButtonMapEnabledByDefault CONSTANT) 87 Q_PROPERTY(bool lmrTapButtonMap READ lmrTapButtonMap WRITE setLmrTapButtonMap NOTIFY tapButtonMapChanged) 88 89 Q_PROPERTY(bool tapAndDragEnabledByDefault READ tapAndDragEnabledByDefault CONSTANT) 90 Q_PROPERTY(bool tapAndDrag READ isTapAndDrag WRITE setTapAndDrag NOTIFY tapAndDragChanged) 91 Q_PROPERTY(bool tapDragLockEnabledByDefault READ tapDragLockEnabledByDefault CONSTANT) 92 Q_PROPERTY(bool tapDragLock READ isTapDragLock WRITE setTapDragLock NOTIFY tapDragLockChanged) 93 94 Q_PROPERTY(bool supportsMiddleEmulation READ supportsMiddleEmulation CONSTANT) 95 Q_PROPERTY(bool middleEmulationEnabledByDefault READ middleEmulationEnabledByDefault CONSTANT) 96 Q_PROPERTY(bool middleEmulation READ isMiddleEmulation WRITE setMiddleEmulation NOTIFY middleEmulationChanged) 97 // 98 // scrolling 99 Q_PROPERTY(bool supportsNaturalScroll READ supportsNaturalScroll CONSTANT) 100 Q_PROPERTY(bool naturalScrollEnabledByDefault READ naturalScrollEnabledByDefault CONSTANT) 101 Q_PROPERTY(bool naturalScroll READ isNaturalScroll WRITE setNaturalScroll NOTIFY naturalScrollChanged) 102 103 Q_PROPERTY(bool supportsScrollTwoFinger READ supportsScrollTwoFinger CONSTANT) 104 Q_PROPERTY(bool scrollTwoFingerEnabledByDefault READ scrollTwoFingerEnabledByDefault CONSTANT) 105 Q_PROPERTY(bool scrollTwoFinger READ isScrollTwoFinger WRITE setScrollTwoFinger NOTIFY scrollMethodChanged) 106 107 Q_PROPERTY(bool supportsScrollEdge READ supportsScrollEdge CONSTANT) 108 Q_PROPERTY(bool scrollEdgeEnabledByDefault READ scrollEdgeEnabledByDefault CONSTANT) 109 Q_PROPERTY(bool scrollEdge READ isScrollEdge WRITE setScrollEdge NOTIFY scrollMethodChanged) 110 111 Q_PROPERTY(bool supportsScrollOnButtonDown READ supportsScrollOnButtonDown CONSTANT) 112 Q_PROPERTY(bool scrollOnButtonDownEnabledByDefault READ scrollOnButtonDownEnabledByDefault CONSTANT) 113 Q_PROPERTY(quint32 defaultScrollButton READ defaultScrollButton CONSTANT) 114 Q_PROPERTY(bool scrollOnButtonDown READ isScrollOnButtonDown WRITE setScrollOnButtonDown NOTIFY scrollMethodChanged) 115 Q_PROPERTY(quint32 scrollButton READ scrollButton WRITE setScrollButton NOTIFY scrollButtonChanged) 116 117 Q_PROPERTY(qreal scrollFactor READ scrollFactor WRITE setScrollFactor NOTIFY scrollFactorChanged) 118 119 // switches 120 Q_PROPERTY(bool switchDevice READ isSwitch CONSTANT) 121 Q_PROPERTY(bool lidSwitch READ isLidSwitch CONSTANT) 122 Q_PROPERTY(bool tabletModeSwitch READ isTabletModeSwitch CONSTANT) 123 124 // Click Methods 125 Q_PROPERTY(bool supportsClickMethodAreas READ supportsClickMethodAreas CONSTANT) 126 Q_PROPERTY(bool defaultClickMethodAreas READ defaultClickMethodAreas CONSTANT) 127 Q_PROPERTY(bool clickMethodAreas READ isClickMethodAreas WRITE setClickMethodAreas NOTIFY clickMethodChanged) 128 129 Q_PROPERTY(bool supportsClickMethodClickfinger READ supportsClickMethodClickfinger CONSTANT) 130 Q_PROPERTY(bool defaultClickMethodClickfinger READ defaultClickMethodClickfinger CONSTANT) 131 Q_PROPERTY(bool clickMethodClickfinger READ isClickMethodClickfinger WRITE setClickMethodClickfinger NOTIFY clickMethodChanged) 132 133 public: 134 explicit Device(libinput_device *device, QObject *parent = nullptr); 135 ~Device() override; 136 isKeyboard()137 bool isKeyboard() const { 138 return m_keyboard; 139 } isAlphaNumericKeyboard()140 bool isAlphaNumericKeyboard() const { 141 return m_alphaNumericKeyboard; 142 } isPointer()143 bool isPointer() const { 144 return m_pointer; 145 } isTouchpad()146 bool isTouchpad() const{ 147 return m_pointer && 148 // ignore all combined devices. E.g. a touchpad on a keyboard we don't want to toggle 149 // as that would result in the keyboard going off as well 150 !(m_keyboard || m_touch || m_tabletPad || m_tabletTool) && 151 // is this a touch pad? We don't really know, let's do some assumptions 152 (m_tapFingerCount > 0 || m_supportsDisableWhileTyping || m_supportsDisableEventsOnExternalMouse); 153 } isTouch()154 bool isTouch() const { 155 return m_touch; 156 } isTabletTool()157 bool isTabletTool() const { 158 return m_tabletTool; 159 } isTabletPad()160 bool isTabletPad() const { 161 return m_tabletPad; 162 } supportsGesture()163 bool supportsGesture() const { 164 return m_supportsGesture; 165 } name()166 QString name() const { 167 return m_name; 168 } sysName()169 QString sysName() const { 170 return m_sysName; 171 } outputName()172 QString outputName() const { 173 return m_outputName; 174 } size()175 QSizeF size() const { 176 return m_size; 177 } product()178 quint32 product() const { 179 return m_product; 180 } vendor()181 quint32 vendor() const { 182 return m_vendor; 183 } supportedButtons()184 Qt::MouseButtons supportedButtons() const { 185 return m_supportedButtons; 186 } tapFingerCount()187 int tapFingerCount() const { 188 return m_tapFingerCount; 189 } tapToClickEnabledByDefault()190 bool tapToClickEnabledByDefault() const { 191 return m_tapToClickEnabledByDefault; 192 } isTapToClick()193 bool isTapToClick() const { 194 return m_tapToClick; 195 } 196 /** 197 * Set the Device to tap to click if @p set is @c true. 198 */ 199 void setTapToClick(bool set); tapAndDragEnabledByDefault()200 bool tapAndDragEnabledByDefault() const { 201 return m_tapAndDragEnabledByDefault; 202 } isTapAndDrag()203 bool isTapAndDrag() const { 204 return m_tapAndDrag; 205 } 206 void setTapAndDrag(bool set); tapDragLockEnabledByDefault()207 bool tapDragLockEnabledByDefault() const { 208 return m_tapDragLockEnabledByDefault; 209 } isTapDragLock()210 bool isTapDragLock() const { 211 return m_tapDragLock; 212 } 213 void setTapDragLock(bool set); supportsDisableWhileTyping()214 bool supportsDisableWhileTyping() const { 215 return m_supportsDisableWhileTyping; 216 } disableWhileTypingEnabledByDefault()217 bool disableWhileTypingEnabledByDefault() const { 218 return m_disableWhileTypingEnabledByDefault; 219 } supportsPointerAcceleration()220 bool supportsPointerAcceleration() const { 221 return m_supportsPointerAcceleration; 222 } supportsLeftHanded()223 bool supportsLeftHanded() const { 224 return m_supportsLeftHanded; 225 } supportsCalibrationMatrix()226 bool supportsCalibrationMatrix() const { 227 return m_supportsCalibrationMatrix; 228 } supportsDisableEvents()229 bool supportsDisableEvents() const { 230 return m_supportsDisableEvents; 231 } supportsDisableEventsOnExternalMouse()232 bool supportsDisableEventsOnExternalMouse() const { 233 return m_supportsDisableEventsOnExternalMouse; 234 } supportsMiddleEmulation()235 bool supportsMiddleEmulation() const { 236 return m_supportsMiddleEmulation; 237 } supportsNaturalScroll()238 bool supportsNaturalScroll() const { 239 return m_supportsNaturalScroll; 240 } supportsScrollTwoFinger()241 bool supportsScrollTwoFinger() const { 242 return (m_supportedScrollMethods & LIBINPUT_CONFIG_SCROLL_2FG); 243 } supportsScrollEdge()244 bool supportsScrollEdge() const { 245 return (m_supportedScrollMethods & LIBINPUT_CONFIG_SCROLL_EDGE); 246 } supportsScrollOnButtonDown()247 bool supportsScrollOnButtonDown() const { 248 return (m_supportedScrollMethods & LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN); 249 } leftHandedEnabledByDefault()250 bool leftHandedEnabledByDefault() const { 251 return m_leftHandedEnabledByDefault; 252 } middleEmulationEnabledByDefault()253 bool middleEmulationEnabledByDefault() const { 254 return m_middleEmulationEnabledByDefault; 255 } naturalScrollEnabledByDefault()256 bool naturalScrollEnabledByDefault() const { 257 return m_naturalScrollEnabledByDefault; 258 } defaultScrollMethod()259 enum libinput_config_scroll_method defaultScrollMethod() const { 260 return m_defaultScrollMethod; 261 } defaultScrollMethodToInt()262 quint32 defaultScrollMethodToInt() const { 263 return (quint32) m_defaultScrollMethod; 264 } scrollTwoFingerEnabledByDefault()265 bool scrollTwoFingerEnabledByDefault() const { 266 return m_defaultScrollMethod == LIBINPUT_CONFIG_SCROLL_2FG; 267 } scrollEdgeEnabledByDefault()268 bool scrollEdgeEnabledByDefault() const { 269 return m_defaultScrollMethod == LIBINPUT_CONFIG_SCROLL_EDGE; 270 } scrollOnButtonDownEnabledByDefault()271 bool scrollOnButtonDownEnabledByDefault() const { 272 return m_defaultScrollMethod == LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN; 273 } supportsLmrTapButtonMap()274 bool supportsLmrTapButtonMap() const { 275 return m_tapFingerCount > 1; 276 } lmrTapButtonMapEnabledByDefault()277 bool lmrTapButtonMapEnabledByDefault() const { 278 return m_defaultTapButtonMap == LIBINPUT_CONFIG_TAP_MAP_LMR; 279 } 280 281 void setLmrTapButtonMap(bool set); lmrTapButtonMap()282 bool lmrTapButtonMap() const { 283 return m_tapButtonMap & LIBINPUT_CONFIG_TAP_MAP_LMR; 284 } 285 defaultScrollButton()286 quint32 defaultScrollButton() const { 287 return m_defaultScrollButton; 288 } isMiddleEmulation()289 bool isMiddleEmulation() const { 290 return m_middleEmulation; 291 } 292 void setMiddleEmulation(bool set); isNaturalScroll()293 bool isNaturalScroll() const { 294 return m_naturalScroll; 295 } 296 void setNaturalScroll(bool set); 297 void setScrollMethod(bool set, enum libinput_config_scroll_method method); isScrollTwoFinger()298 bool isScrollTwoFinger() const { 299 return m_scrollMethod & LIBINPUT_CONFIG_SCROLL_2FG; 300 } setScrollTwoFinger(bool set)301 void setScrollTwoFinger(bool set) { 302 setScrollMethod(set, LIBINPUT_CONFIG_SCROLL_2FG); 303 } isScrollEdge()304 bool isScrollEdge() const { 305 return m_scrollMethod & LIBINPUT_CONFIG_SCROLL_EDGE; 306 } setScrollEdge(bool set)307 void setScrollEdge(bool set) { 308 setScrollMethod(set, LIBINPUT_CONFIG_SCROLL_EDGE); 309 } isScrollOnButtonDown()310 bool isScrollOnButtonDown() const { 311 return m_scrollMethod & LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN; 312 } setScrollOnButtonDown(bool set)313 void setScrollOnButtonDown(bool set) { 314 setScrollMethod(set, LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN); 315 } activateScrollMethodFromInt(quint32 method)316 void activateScrollMethodFromInt(quint32 method) { 317 setScrollMethod(true, (libinput_config_scroll_method) method); 318 } scrollButton()319 quint32 scrollButton() const { 320 return m_scrollButton; 321 } 322 void setScrollButton(quint32 button); 323 scrollFactorDefault()324 qreal scrollFactorDefault() const { 325 return 1.0; 326 } scrollFactor()327 qreal scrollFactor() const { 328 return m_scrollFactor; 329 } 330 void setScrollFactor(qreal factor); 331 332 void setDisableWhileTyping(bool set); isDisableWhileTyping()333 bool isDisableWhileTyping() const { 334 return m_disableWhileTyping; 335 } isLeftHanded()336 bool isLeftHanded() const { 337 return m_leftHanded; 338 } 339 /** 340 * Sets the Device to left handed mode if @p set is @c true. 341 * If @p set is @c false the device is set to right handed mode 342 */ 343 void setLeftHanded(bool set); 344 defaultPointerAcceleration()345 qreal defaultPointerAcceleration() const { 346 return m_defaultPointerAcceleration; 347 } pointerAcceleration()348 qreal pointerAcceleration() const { 349 return m_pointerAcceleration; 350 } 351 /** 352 * @param acceleration mapped to range [-1,1] with -1 being the slowest, 1 being the fastest supported acceleration. 353 */ 354 void setPointerAcceleration(qreal acceleration); setPointerAccelerationFromString(QString acceleration)355 void setPointerAccelerationFromString(QString acceleration) { 356 setPointerAcceleration(acceleration.toDouble()); 357 } defaultPointerAccelerationToString()358 QString defaultPointerAccelerationToString() const { 359 return QString::number(m_pointerAcceleration, 'f', 3); 360 } supportsPointerAccelerationProfileFlat()361 bool supportsPointerAccelerationProfileFlat() const { 362 return (m_supportedPointerAccelerationProfiles & LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT); 363 } supportsPointerAccelerationProfileAdaptive()364 bool supportsPointerAccelerationProfileAdaptive() const { 365 return (m_supportedPointerAccelerationProfiles & LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE); 366 } defaultPointerAccelerationProfileFlat()367 bool defaultPointerAccelerationProfileFlat() const { 368 return (m_defaultPointerAccelerationProfile & LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT); 369 } defaultPointerAccelerationProfileAdaptive()370 bool defaultPointerAccelerationProfileAdaptive() const { 371 return (m_defaultPointerAccelerationProfile & LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE); 372 } pointerAccelerationProfileFlat()373 bool pointerAccelerationProfileFlat() const { 374 return (m_pointerAccelerationProfile & LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT); 375 } pointerAccelerationProfileAdaptive()376 bool pointerAccelerationProfileAdaptive() const { 377 return (m_pointerAccelerationProfile & LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE); 378 } 379 void setPointerAccelerationProfile(bool set, enum libinput_config_accel_profile profile); setPointerAccelerationProfileFlat(bool set)380 void setPointerAccelerationProfileFlat(bool set) { 381 setPointerAccelerationProfile(set, LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT); 382 } setPointerAccelerationProfileAdaptive(bool set)383 void setPointerAccelerationProfileAdaptive(bool set) { 384 setPointerAccelerationProfile(set, LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE); 385 } setPointerAccelerationProfileFromInt(quint32 profile)386 void setPointerAccelerationProfileFromInt(quint32 profile) { 387 setPointerAccelerationProfile(true, (libinput_config_accel_profile) profile); 388 } defaultPointerAccelerationProfileToInt()389 quint32 defaultPointerAccelerationProfileToInt() const { 390 return (quint32) m_defaultPointerAccelerationProfile; 391 } supportsClickMethodAreas()392 bool supportsClickMethodAreas() const { 393 return (m_supportedClickMethods & LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS); 394 } defaultClickMethodAreas()395 bool defaultClickMethodAreas() const { 396 return (m_defaultClickMethod == LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS); 397 } isClickMethodAreas()398 bool isClickMethodAreas() const { 399 return (m_clickMethod == LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS); 400 } supportsClickMethodClickfinger()401 bool supportsClickMethodClickfinger() const { 402 return (m_supportedClickMethods & LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER); 403 } defaultClickMethodClickfinger()404 bool defaultClickMethodClickfinger() const { 405 return (m_defaultClickMethod == LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER); 406 } isClickMethodClickfinger()407 bool isClickMethodClickfinger() const { 408 return (m_clickMethod == LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER); 409 } 410 void setClickMethod(bool set, enum libinput_config_click_method method); setClickMethodAreas(bool set)411 void setClickMethodAreas(bool set) { 412 setClickMethod(set, LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS); 413 } setClickMethodClickfinger(bool set)414 void setClickMethodClickfinger(bool set) { 415 setClickMethod(set, LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER); 416 } setClickMethodFromInt(quint32 method)417 void setClickMethodFromInt(quint32 method) { 418 setClickMethod(true, (libinput_config_click_method) method); 419 } defaultClickMethodToInt()420 quint32 defaultClickMethodToInt() const { 421 return (quint32) m_defaultClickMethod; 422 } 423 isEnabled()424 bool isEnabled() const { 425 return m_enabled; 426 } 427 void setEnabled(bool enabled); 428 device()429 libinput_device *device() const { 430 return m_device; 431 } 432 433 /** 434 * Sets the @p config to load the Device configuration from and to store each 435 * successful Device configuration. 436 */ setConfig(const KConfigGroup & config)437 void setConfig(const KConfigGroup &config) { 438 m_config = config; 439 } 440 441 /** 442 * The id of the screen in KWin identifiers. Set from KWin through setScreenId. 443 */ screenId()444 int screenId() const { 445 return m_screenId; 446 } 447 448 /** 449 * Sets the KWin screen id for the device 450 */ setScreenId(int screenId)451 void setScreenId(int screenId) { 452 m_screenId = screenId; 453 } 454 455 void setOrientation(Qt::ScreenOrientation orientation); 456 457 /** 458 * Loads the configuration and applies it to the Device 459 */ 460 void loadConfiguration(); 461 isSwitch()462 bool isSwitch() const { 463 return m_switch; 464 } 465 isLidSwitch()466 bool isLidSwitch() const { 467 return m_lidSwitch; 468 } 469 isTabletModeSwitch()470 bool isTabletModeSwitch() const { 471 return m_tabletSwitch; 472 } 473 474 int stripsCount() const; 475 int ringsCount() const; 476 477 void *groupUserData() const; 478 479 /** 480 * All created Devices 481 */ devices()482 static QVector<Device*> devices() { 483 return s_devices; 484 } 485 /** 486 * Gets the Device for @p native. @c null if there is no Device for @p native. 487 */ 488 static Device *getDevice(libinput_device *native); 489 490 Q_SIGNALS: 491 void tapButtonMapChanged(); 492 void leftHandedChanged(); 493 void disableWhileTypingChanged(); 494 void pointerAccelerationChanged(); 495 void pointerAccelerationProfileChanged(); 496 void enabledChanged(); 497 void tapToClickChanged(); 498 void tapAndDragChanged(); 499 void tapDragLockChanged(); 500 void middleEmulationChanged(); 501 void naturalScrollChanged(); 502 void scrollMethodChanged(); 503 void scrollButtonChanged(); 504 void scrollFactorChanged(); 505 void clickMethodChanged(); 506 507 private: 508 template <typename T> 509 void writeEntry(const ConfigKey &key, const T &value); 510 template <typename T, typename Setter> 511 void readEntry(const QByteArray &key, const Setter &s, const T &defaultValue = T()); 512 libinput_device *m_device; 513 bool m_keyboard; 514 bool m_alphaNumericKeyboard = false; 515 bool m_pointer; 516 bool m_touch; 517 bool m_tabletTool; 518 bool m_tabletPad; 519 bool m_supportsGesture; 520 bool m_switch = false; 521 bool m_lidSwitch = false; 522 bool m_tabletSwitch = false; 523 QString m_name; 524 QString m_sysName; 525 QString m_outputName; 526 QSizeF m_size; 527 quint32 m_product; 528 quint32 m_vendor; 529 Qt::MouseButtons m_supportedButtons = Qt::NoButton; 530 int m_tapFingerCount; 531 enum libinput_config_tap_button_map m_defaultTapButtonMap; 532 enum libinput_config_tap_button_map m_tapButtonMap; 533 bool m_tapToClickEnabledByDefault; 534 bool m_tapToClick; 535 bool m_tapAndDragEnabledByDefault; 536 bool m_tapAndDrag; 537 bool m_tapDragLockEnabledByDefault; 538 bool m_tapDragLock; 539 bool m_supportsDisableWhileTyping; 540 bool m_supportsPointerAcceleration; 541 bool m_supportsLeftHanded; 542 bool m_supportsCalibrationMatrix; 543 bool m_supportsDisableEvents; 544 bool m_supportsDisableEventsOnExternalMouse; 545 bool m_supportsMiddleEmulation; 546 bool m_supportsNaturalScroll; 547 quint32 m_supportedScrollMethods; 548 bool m_supportsScrollEdge; 549 bool m_supportsScrollOnButtonDown; 550 bool m_leftHandedEnabledByDefault; 551 bool m_middleEmulationEnabledByDefault; 552 bool m_naturalScrollEnabledByDefault; 553 enum libinput_config_scroll_method m_defaultScrollMethod; 554 quint32 m_defaultScrollButton; 555 bool m_disableWhileTypingEnabledByDefault; 556 bool m_disableWhileTyping; 557 bool m_middleEmulation; 558 bool m_leftHanded; 559 bool m_naturalScroll; 560 enum libinput_config_scroll_method m_scrollMethod; 561 quint32 m_scrollButton; 562 qreal m_defaultPointerAcceleration; 563 qreal m_pointerAcceleration; 564 qreal m_scrollFactor; 565 quint32 m_supportedPointerAccelerationProfiles; 566 enum libinput_config_accel_profile m_defaultPointerAccelerationProfile; 567 enum libinput_config_accel_profile m_pointerAccelerationProfile; 568 bool m_enabled; 569 570 KConfigGroup m_config; 571 bool m_loading = false; 572 573 int m_screenId = 0; 574 Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation; 575 QMatrix4x4 m_defaultCalibrationMatrix; 576 quint32 m_supportedClickMethods; 577 enum libinput_config_click_method m_defaultClickMethod; 578 enum libinput_config_click_method m_clickMethod; 579 580 static QVector<Device*> s_devices; 581 }; 582 583 } 584 } 585 586 Q_DECLARE_METATYPE(KWin::LibInput::Device*) 587 588 #endif 589