You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

150 lines
6.3 KiB

8 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2015 The Qt Company Ltd.
  4. ** Contact: http://www.qt.io/licensing/
  5. **
  6. ** This file is part of the Qt Gamepad module
  7. **
  8. ** $QT_BEGIN_LICENSE:LGPL3$
  9. ** Commercial License Usage
  10. ** Licensees holding valid commercial Qt licenses may use this file in
  11. ** accordance with the commercial license agreement provided with the
  12. ** Software or, alternatively, in accordance with the terms contained in
  13. ** a written agreement between you and The Qt Company. For licensing terms
  14. ** and conditions see http://www.qt.io/terms-conditions. For further
  15. ** information use the contact form at http://www.qt.io/contact-us.
  16. **
  17. ** GNU Lesser General Public License Usage
  18. ** Alternatively, this file may be used under the terms of the GNU Lesser
  19. ** General Public License version 3 as published by the Free Software
  20. ** Foundation and appearing in the file LICENSE.LGPLv3 included in the
  21. ** packaging of this file. Please review the following information to
  22. ** ensure the GNU Lesser General Public License version 3 requirements
  23. ** will be met: https://www.gnu.org/licenses/lgpl.html.
  24. **
  25. ** GNU General Public License Usage
  26. ** Alternatively, this file may be used under the terms of the GNU
  27. ** General Public License version 2.0 or later as published by the Free
  28. ** Software Foundation and appearing in the file LICENSE.GPL included in
  29. ** the packaging of this file. Please review the following information to
  30. ** ensure the GNU General Public License version 2.0 requirements will be
  31. ** met: http://www.gnu.org/licenses/gpl-2.0.html.
  32. **
  33. ** $QT_END_LICENSE$
  34. **
  35. ****************************************************************************/
  36. #ifndef QGAMEPADKEYNAVIGATION_H
  37. #define QGAMEPADKEYNAVIGATION_H
  38. #include <QtCore/QObject>
  39. #include <QtCore/QMap>
  40. #include "qtgamepadglobal.h"
  41. #include "qgamepadmanager.h"
  42. QT_BEGIN_NAMESPACE
  43. class QKeyEvent;
  44. class QGamepad;
  45. class QGamepadKeyNavigationPrivate;
  46. class Q_GAMEPAD_EXPORT QGamepadKeyNavigation : public QObject
  47. {
  48. Q_OBJECT
  49. Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged)
  50. Q_PROPERTY(QGamepad *gamepad READ gamepad WRITE setGamepad NOTIFY gamepadChanged)
  51. Q_PROPERTY(Qt::Key upKey READ upKey WRITE setUpKey NOTIFY upKeyChanged)
  52. Q_PROPERTY(Qt::Key downKey READ downKey WRITE setDownKey NOTIFY downKeyChanged)
  53. Q_PROPERTY(Qt::Key leftKey READ leftKey WRITE setLeftKey NOTIFY leftKeyChanged)
  54. Q_PROPERTY(Qt::Key rightKey READ rightKey WRITE setRightKey NOTIFY rightKeyChanged)
  55. Q_PROPERTY(Qt::Key buttonAKey READ buttonAKey WRITE setButtonAKey NOTIFY buttonAKeyChanged)
  56. Q_PROPERTY(Qt::Key buttonBKey READ buttonBKey WRITE setButtonBKey NOTIFY buttonBKeyChanged)
  57. Q_PROPERTY(Qt::Key buttonXKey READ buttonXKey WRITE setButtonXKey NOTIFY buttonXKeyChanged)
  58. Q_PROPERTY(Qt::Key buttonYKey READ buttonYKey WRITE setButtonYKey NOTIFY buttonYKeyChanged)
  59. Q_PROPERTY(Qt::Key buttonSelectKey READ buttonSelectKey WRITE setButtonSelectKey NOTIFY buttonSelectKeyChanged)
  60. Q_PROPERTY(Qt::Key buttonStartKey READ buttonStartKey WRITE setButtonStartKey NOTIFY buttonStartKeyChanged)
  61. Q_PROPERTY(Qt::Key buttonGuideKey READ buttonGuideKey WRITE setButtonGuideKey NOTIFY buttonGuideKeyChanged)
  62. Q_PROPERTY(Qt::Key buttonL1Key READ buttonL1Key WRITE setButtonL1Key NOTIFY buttonL1KeyChanged)
  63. Q_PROPERTY(Qt::Key buttonR1Key READ buttonR1Key WRITE setButtonR1Key NOTIFY buttonR1KeyChanged)
  64. Q_PROPERTY(Qt::Key buttonL2Key READ buttonL2Key WRITE setButtonL2Key NOTIFY buttonL2KeyChanged)
  65. Q_PROPERTY(Qt::Key buttonR2Key READ buttonR2Key WRITE setButtonR2Key NOTIFY buttonR2KeyChanged)
  66. Q_PROPERTY(Qt::Key buttonL3Key READ buttonL3Key WRITE setButtonL3Key NOTIFY buttonL3KeyChanged)
  67. Q_PROPERTY(Qt::Key buttonR3Key READ buttonR3Key WRITE setButtonR3Key NOTIFY buttonR3KeyChanged)
  68. public:
  69. explicit QGamepadKeyNavigation(QObject *parent = nullptr);
  70. bool active() const;
  71. QGamepad *gamepad() const;
  72. Qt::Key upKey() const;
  73. Qt::Key downKey() const;
  74. Qt::Key leftKey() const;
  75. Qt::Key rightKey() const;
  76. Qt::Key buttonAKey() const;
  77. Qt::Key buttonBKey() const;
  78. Qt::Key buttonXKey() const;
  79. Qt::Key buttonYKey() const;
  80. Qt::Key buttonSelectKey() const;
  81. Qt::Key buttonStartKey() const;
  82. Qt::Key buttonGuideKey() const;
  83. Qt::Key buttonL1Key() const;
  84. Qt::Key buttonR1Key() const;
  85. Qt::Key buttonL2Key() const;
  86. Qt::Key buttonR2Key() const;
  87. Qt::Key buttonL3Key() const;
  88. Qt::Key buttonR3Key() const;
  89. Q_SIGNALS:
  90. void activeChanged(bool isActive);
  91. void gamepadChanged(QGamepad *gamepad);
  92. void upKeyChanged(Qt::Key key);
  93. void downKeyChanged(Qt::Key key);
  94. void leftKeyChanged(Qt::Key key);
  95. void rightKeyChanged(Qt::Key key);
  96. void buttonAKeyChanged(Qt::Key key);
  97. void buttonBKeyChanged(Qt::Key key);
  98. void buttonXKeyChanged(Qt::Key key);
  99. void buttonYKeyChanged(Qt::Key key);
  100. void buttonSelectKeyChanged(Qt::Key key);
  101. void buttonStartKeyChanged(Qt::Key key);
  102. void buttonGuideKeyChanged(Qt::Key key);
  103. void buttonL1KeyChanged(Qt::Key key);
  104. void buttonR1KeyChanged(Qt::Key key);
  105. void buttonL2KeyChanged(Qt::Key key);
  106. void buttonR2KeyChanged(Qt::Key key);
  107. void buttonL3KeyChanged(Qt::Key key);
  108. void buttonR3KeyChanged(Qt::Key key);
  109. public Q_SLOTS:
  110. void setActive(bool isActive);
  111. void setGamepad(QGamepad *gamepad);
  112. void setUpKey(Qt::Key key);
  113. void setDownKey(Qt::Key key);
  114. void setLeftKey(Qt::Key key);
  115. void setRightKey(Qt::Key key);
  116. void setButtonAKey(Qt::Key key);
  117. void setButtonBKey(Qt::Key key);
  118. void setButtonXKey(Qt::Key key);
  119. void setButtonYKey(Qt::Key key);
  120. void setButtonSelectKey(Qt::Key key);
  121. void setButtonStartKey(Qt::Key key);
  122. void setButtonGuideKey(Qt::Key key);
  123. void setButtonL1Key(Qt::Key key);
  124. void setButtonR1Key(Qt::Key key);
  125. void setButtonL2Key(Qt::Key key);
  126. void setButtonR2Key(Qt::Key key);
  127. void setButtonL3Key(Qt::Key key);
  128. void setButtonR3Key(Qt::Key key);
  129. private:
  130. Q_DECLARE_PRIVATE(QGamepadKeyNavigation)
  131. Q_DISABLE_COPY(QGamepadKeyNavigation)
  132. Q_PRIVATE_SLOT(d_func(), void _q_processGamepadButtonPressEvent(int, QGamepadManager::GamepadButton, double))
  133. Q_PRIVATE_SLOT(d_func(), void _q_processGamepadButtonReleaseEvent(int, QGamepadManager::GamepadButton))
  134. };
  135. QT_END_NAMESPACE
  136. #endif // QGAMEPADKEYNAVIGATION_H