#ifndef INPUT_H_INCLUDED #define INPUT_H_INCLUDED #include #undef main class Input { public: Input(): m_x(0), m_y(0), m_xRel(0), m_yRel(0), m_continuer(true) { reset(); } ~Input() { } void updateEvenement() { m_xRel = 0; m_yRel = 0; while(SDL_PollEvent(&m_evenement)) { switch(m_evenement.type) { case SDL_QUIT: m_continuer = false; break; case SDL_KEYDOWN: m_touches[m_evenement.key.keysym.sym] = true; break; case SDL_KEYUP: m_touches[m_evenement.key.keysym.sym] = false; break; case SDL_MOUSEBUTTONDOWN: m_boutonsSouris[m_evenement.button.button] = true; break; case SDL_MOUSEBUTTONUP: m_boutonsSouris[m_evenement.button.button] = false; break; case SDL_MOUSEMOTION: m_x = m_evenement.motion.x; m_y = m_evenement.motion.y; m_xRel = m_evenement.motion.xrel; m_yRel = m_evenement.motion.yrel; break; default: break; } } } bool continuer() const { return m_continuer; } bool getTouches(const SDLKey touche) const { return m_touches[touche]; } bool getBoutonSouris(const Uint8 bouton) const { return m_boutonsSouris[bouton]; } bool mouvementSouris() const { if(m_xRel == 0 && m_yRel == 0) return false; else return true; } int getX() const { return m_x; } int getY() const { return m_y; } int getXRel() const { return m_xRel; } int getYRel() const { return m_yRel; } void afficherPointeur(bool reponse) const { if(reponse) SDL_ShowCursor(SDL_ENABLE); else SDL_ShowCursor(SDL_DISABLE); } void reset() { for(int i = 0;i<323;i++) m_touches[i] = false; for(int i = 0;i<8;i++) m_boutonsSouris[i] = false; } private: SDL_Event m_evenement; bool m_touches[323]; bool m_boutonsSouris[8]; int m_x, m_y; int m_xRel, m_yRel; bool m_continuer; }; #endif // INPUT_H_INCLUDED