Input.h 1.4 KB

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