12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- #ifndef DEF_INPUT
- #define DEF_INPUT
- ///Jovian
- ///Centralisation du traitement d'évènement
- // Include
- #include <set>
- #include <SDL.h>
- #define MOUSE_LEFT 1
- #define MOUSE_MIDDLE 2
- #define MOUSE_RIGHT 3
- #define MOUSE_ANNEX_A 4
- #define MOUSE_ANNEX_B 5
- class Input {
- /// Methods
- public:
- Input();
- virtual ~Input();
- virtual void updateEvents();
- protected: // Deal with an event, return true if caught
- bool catchKeyBoardEvents(const SDL_Event &event);
- bool catchMouseEvents(const SDL_Event &event);
- bool catchWindowEvents(const SDL_Event &event);
- public:
- bool isFinished() const;
- void showCursor(bool flag) const;
- void capPtr(bool flag);
- bool getKey(const SDL_Scancode key) const;
- bool getInstantKey(const SDL_Scancode key) const;
- bool getMouseKey(const Uint8 key) const;
- bool isMouseMoving() const;
- int getX() const;
- int getY() const;
- int getXFromCenter();
- int getYFromCenter();
- int getXRel() const;
- int getYRel() const;
- void setWindow(SDL_Window *activWindow);
- /// Variables
- protected:
- SDL_Event m_event;
- bool m_keys[SDL_NUM_SCANCODES];
- std::set<SDL_Scancode> m_instantKeys;
- bool m_mouseKeys[8];
- int m_x;
- int m_y;
- int m_xRel;
- int m_yRel;
- bool m_finished;
- bool m_relativeMouse;
- SDL_Window *m_window;
- int m_windowHalfHeight;
- int m_windowHalfWidth;
- };
- #endif
|