#include "keyboard.h" Keyboard::Keyboard(){ nop = new Nop; pressedDown = new KeyboardDownPressed; releasedDown = new KeyboardDownReleased; pressedLeft = new KeyboardLeftPressed; pressedRight = new KeyboardRightPressed; } Keyboard::~Keyboard(){ delete nop; delete pressedDown; delete releasedDown; delete pressedLeft; delete pressedRight; } Command* Keyboard::handleEvent( SDL_Event e ){ switch( e.type ){ case SDL_KEYDOWN: return pressed( e.key.keysym.sym, e.key.keysym.mod ); case SDL_KEYUP: return released( e.key.keysym.sym, e.key.keysym.mod ); default: return nop; } } Command* Keyboard::pressed( SDL_Keycode k, Uint16 mod ){ switch(k){ case SDLK_DOWN: return pressedDown; case SDLK_LEFT: return pressedLeft; case SDLK_RIGHT: return pressedRight; default: return nop; } } Command* Keyboard::released( SDL_Keycode k, Uint16 mod ){ switch(k){ case SDLK_DOWN: return releasedDown; default: return nop; } }