From 1d6a7bb467d28898da5eb1270a6e8dabf958fa42 Mon Sep 17 00:00:00 2001 From: Ekaitz Zarraga Date: Tue, 28 Dec 2021 12:39:47 +0100 Subject: Huge rewrite, this is not how I'm supposed to use git but whatever --- src/keyboard.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'src/keyboard.cpp') diff --git a/src/keyboard.cpp b/src/keyboard.cpp index b3efada..1eff1d1 100644 --- a/src/keyboard.cpp +++ b/src/keyboard.cpp @@ -2,9 +2,13 @@ Keyboard::Keyboard(){ nop = new Nop; + pressedDown = new KeyboardDownPressed; + releasedDown = new KeyboardDownReleased; } Keyboard::~Keyboard(){ delete nop; + delete pressedDown; + delete releasedDown; } Command* Keyboard::handleEvent( SDL_Event e ){ @@ -19,11 +23,19 @@ Command* Keyboard::handleEvent( SDL_Event e ){ } Command* Keyboard::pressed( SDL_Keycode k, Uint16 mod ){ - // TODO - return nop; + switch(k){ + case SDLK_DOWN: + return pressedDown; + default: + return nop; + } } Command* Keyboard::released( SDL_Keycode k, Uint16 mod ){ - // TODO - return nop; + switch(k){ + case SDLK_DOWN: + return releasedDown; + default: + return nop; + } } -- cgit v1.2.3