GamepadInput.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #pragma once
  2. //##########################################################################
  3. //# #
  4. //# CLOUDCOMPARE #
  5. //# #
  6. //# This program is free software; you can redistribute it and/or modify #
  7. //# it under the terms of the GNU General Public License as published by #
  8. //# the Free Software Foundation; version 2 or later of the License. #
  9. //# #
  10. //# This program is distributed in the hope that it will be useful, #
  11. //# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  12. //# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  13. //# GNU General Public License for more details. #
  14. //# #
  15. //# COPYRIGHT: Daniel Girardeau-Montaut #
  16. //# #
  17. //##########################################################################
  18. #include "CCAppCommon.h"
  19. //CCCoreLib
  20. #include <CCConst.h>
  21. //qCC_db
  22. #include <ccGLMatrix.h>
  23. //Qt
  24. #include <QGamepad>
  25. #include <QTimer>
  26. class ccGLWindowInterface;
  27. //! Gaempad handler
  28. class CCAPPCOMMON_LIB_API GamepadInput : public QGamepad
  29. {
  30. Q_OBJECT
  31. public:
  32. //! Default constructor
  33. explicit GamepadInput(QObject* parent = nullptr);
  34. //! Destructor
  35. virtual ~GamepadInput();
  36. void start();
  37. void stop();
  38. //! Updates a window with the current gamepad state
  39. void update(ccGLWindowInterface* win);
  40. Q_SIGNALS:
  41. void updated();
  42. protected:
  43. void updateInternalState();
  44. private:
  45. //! Timer to poll the gamepad state
  46. QTimer m_timer;
  47. //! Last state
  48. CCVector3 m_panning;
  49. bool m_hasPanning;
  50. CCVector3 m_translation;
  51. bool m_hasTranslation;
  52. ccGLMatrixd m_rotation;
  53. bool m_hasRotation;
  54. float m_zoom;
  55. };