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.

90 lines
3.2 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /***************************************************************************
  2. * Copyright (C) 2014 M Wellings *
  3. * info@openforeveryone.co.uk *
  4. * *
  5. * This program is free software; you can redistribute it and/or modify *
  6. * it under the terms of the GNU General Public License version 2 as *
  7. * published by the Free Software Foundation *
  8. * *
  9. * This program is distributed in the hope that it will be useful, *
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  12. * GNU General Public License for more details. *
  13. * *
  14. * You should have received a copy of the GNU General Public License *
  15. * along with this program; if not, write to the *
  16. * Free Software Foundation, Inc., *
  17. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
  18. ***************************************************************************/
  19. #ifndef QGameController_H
  20. #define QGameController_H
  21. #include <QtCore/QObject>
  22. #include "qgamecontroller-global.h"
  23. QT_BEGIN_NAMESPACE
  24. class QGameControllerPrivate;
  25. class QGameControllerEventPrivate;
  26. class QGameControllerAxisEventPrivate;
  27. class QGameControllerButtonEventPrivate;
  28. class QGAMECONTROLLER_EXPORT QGameControllerEvent
  29. {
  30. Q_DECLARE_PRIVATE(QGameControllerEvent)
  31. public:
  32. QGameControllerEvent(uint controllerId);
  33. uint controllerId();
  34. ~QGameControllerEvent();
  35. protected:
  36. QGameControllerEvent(uint controllerId, QGameControllerEventPrivate &d);
  37. QGameControllerEventPrivate* const d_ptr;
  38. };
  39. class QGAMECONTROLLER_EXPORT QGameControllerButtonEvent : public QGameControllerEvent
  40. {
  41. Q_DECLARE_PRIVATE(QGameControllerButtonEvent)
  42. public:
  43. QGameControllerButtonEvent(uint controllerId, uint button, bool pressed);
  44. uint button();
  45. bool pressed();
  46. };
  47. class QGAMECONTROLLER_EXPORT QGameControllerAxisEvent : public QGameControllerEvent
  48. {
  49. Q_DECLARE_PRIVATE(QGameControllerAxisEvent)
  50. public:
  51. QGameControllerAxisEvent(uint controllerId, uint axis, float value);
  52. uint axis();
  53. float value();
  54. };
  55. class QGAMECONTROLLER_EXPORT QGameController : public QObject
  56. {
  57. Q_OBJECT
  58. Q_DECLARE_PRIVATE(QGameController)
  59. public:
  60. explicit QGameController(uint id = 0, QObject *parent = 0);
  61. uint axisCount();
  62. uint buttonCount();
  63. float axisValue(uint axis);
  64. bool buttonValue(uint button);
  65. QString description();
  66. uint id();
  67. bool isValid();
  68. signals:
  69. public slots:
  70. void readGameController();
  71. signals:
  72. void gameControllerEvent(QGameControllerEvent *event);
  73. void gameControllerButtonEvent(QGameControllerButtonEvent *event);
  74. void gameControllerAxisEvent(QGameControllerAxisEvent *event);
  75. private:
  76. QGameControllerPrivate* const d_ptr;
  77. Q_DISABLE_COPY(QGameController)
  78. };
  79. QT_END_NAMESPACE
  80. #endif // QGameController_H