Input.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #ifndef DEF_INPUT
  2. #define DEF_INPUT
  3. ///Jovian
  4. ///Centralisation du traitement d'évènement
  5. // Include
  6. #include <set>
  7. #include <SDL.h>
  8. #define MOUSE_LEFT 1
  9. #define MOUSE_MIDDLE 2
  10. #define MOUSE_RIGHT 3
  11. #define MOUSE_ANNEX_A 4
  12. #define MOUSE_ANNEX_B 5
  13. class Input {
  14. /// Methods
  15. public:
  16. Input();
  17. virtual ~Input();
  18. virtual void updateEvents();
  19. protected: // Deal with an event, return true if caught
  20. bool catchKeyBoardEvents(const SDL_Event &event);
  21. bool catchMouseEvents(const SDL_Event &event);
  22. bool catchWindowEvents(const SDL_Event &event);
  23. public:
  24. bool isFinished() const;
  25. void showCursor(bool flag) const;
  26. void capPtr(bool flag);
  27. bool getKey(const SDL_Scancode key) const;
  28. bool getInstantKey(const SDL_Scancode key) const;
  29. bool getMouseKey(const Uint8 key) const;
  30. bool isMouseMoving() const;
  31. int getX() const;
  32. int getY() const;
  33. int getXFromCenter();
  34. int getYFromCenter();
  35. int getXRel() const;
  36. int getYRel() const;
  37. void setWindow(SDL_Window *activWindow);
  38. /// Variables
  39. protected:
  40. SDL_Event m_event;
  41. bool m_keys[SDL_NUM_SCANCODES];
  42. std::set<SDL_Scancode> m_instantKeys;
  43. bool m_mouseKeys[8];
  44. int m_x;
  45. int m_y;
  46. int m_xRel;
  47. int m_yRel;
  48. bool m_finished;
  49. bool m_relativeMouse;
  50. SDL_Window *m_window;
  51. int m_windowHalfHeight;
  52. int m_windowHalfWidth;
  53. };
  54. #endif