MouseManager.h 719 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #ifndef MOUSE_H
  2. #define MOUSE_H
  3. #include <GLFW/glfw3.h>
  4. class MouseManager
  5. {
  6. public:
  7. MouseManager();
  8. bool isDown(int mapping);
  9. bool isReleased(int mapping);
  10. unsigned int getDownTime(int mapping);
  11. void resetDownTime(int mapping);
  12. bool map(int mapping, int key);
  13. void tick();
  14. void press(int button);
  15. void release(int button);
  16. private:
  17. static const int NUMBER_OF_BUTTONS = GLFW_MOUSE_BUTTON_LAST + 1;
  18. bool isInRange(int i);
  19. struct Mouse
  20. {
  21. bool down = false;
  22. bool shouldRelease = false;
  23. unsigned int downTime = 0;
  24. };
  25. Mouse mouseArray[NUMBER_OF_BUTTONS];
  26. int mappingArray[NUMBER_OF_BUTTONS];
  27. };
  28. #endif