#include "Input.h" Input::Input(): m_x(0), m_y(0), m_xRel(0), m_yRel(0), m_continuer(true) { for(int i = 0;i<512;i++) m_touches[i] = R_RELACHER; for(int i = 0;i<8;i++) m_boutonsSouris[i] = R_RELACHER; } Input::~Input() { } void Input::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] = (m_touches[m_evenement.key.keysym.scancode] & R_RELACHER)?APPUYER:R_APPUYER; break; case SDL_KEYUP: m_touches[m_evenement.key.keysym.sym] = (m_touches[m_evenement.key.keysym.scancode] & R_APPUYER)?RELACHER:R_RELACHER; break; case SDL_MOUSEBUTTONDOWN: m_boutonsSouris[m_evenement.button.button] = (m_boutonsSouris[m_evenement.button.button] & R_RELACHER)?APPUYER:R_APPUYER; break; case SDL_MOUSEBUTTONUP: m_boutonsSouris[m_evenement.button.button] = (m_boutonsSouris[m_evenement.button.button] & R_APPUYER)?RELACHER:R_RELACHER; 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 Input::continuer() const { return m_continuer; } int Input::getTouches(const SDLKey touche) const { return m_touches[touche]; } int Input::getBoutonSouris(const Uint8 bouton) const { return m_boutonsSouris[bouton]; } bool Input::mouvementSouris() const { if(m_xRel == 0 && m_yRel == 0) return false; else return true; } int Input::getX() const { return m_x; } int Input::getY() const { return m_y; } int Input::getXRel() const { return m_xRel; } int Input::getYRel() const { return m_yRel; }