From a7f23865ff7ffb57d35505bc0cf67507f1751ff2 Mon Sep 17 00:00:00 2001 From: Ekaitz Zarraga Date: Fri, 24 Dec 2021 20:16:41 +0100 Subject: Rename keyHandler to keyboard --- src/keyHandler.cpp | 29 ----------------------------- src/keyHandler.h | 21 --------------------- src/keyboard.cpp | 29 +++++++++++++++++++++++++++++ src/keyboard.h | 21 +++++++++++++++++++++ src/main.cpp | 4 ++-- 5 files changed, 52 insertions(+), 52 deletions(-) delete mode 100644 src/keyHandler.cpp delete mode 100644 src/keyHandler.h create mode 100644 src/keyboard.cpp create mode 100644 src/keyboard.h diff --git a/src/keyHandler.cpp b/src/keyHandler.cpp deleted file mode 100644 index e188992..0000000 --- a/src/keyHandler.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "keyHandler.h" - -KeyHandler::KeyHandler(){ - nop = new Nop; -} -KeyHandler::~KeyHandler(){ - delete nop; -} - -Command* KeyHandler::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* KeyHandler::pressed( SDL_Keycode k, Uint16 mod ){ - // TODO - return nop; -} - -Command* KeyHandler::released( SDL_Keycode k, Uint16 mod ){ - // TODO - return nop; -} diff --git a/src/keyHandler.h b/src/keyHandler.h deleted file mode 100644 index 5c2152c..0000000 --- a/src/keyHandler.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef KEYHANDLER_H -#define KEYHANDLER_H -#include -#include "command.h" - -class KeyHandler{ - - public: - KeyHandler(); - ~KeyHandler(); - Command* handleEvent( SDL_Event e ); - Command* pressed( SDL_Keycode k, Uint16 mod = 0); - Command* released( SDL_Keycode k, Uint16 mod = 0); - - // Modifiers: https://wiki.libsdl.org/SDL_Keymod - // Keycodes: https://wiki.libsdl.org/SDL_Keycode - private: - Command* nop; -}; - -#endif diff --git a/src/keyboard.cpp b/src/keyboard.cpp new file mode 100644 index 0000000..b3efada --- /dev/null +++ b/src/keyboard.cpp @@ -0,0 +1,29 @@ +#include "keyboard.h" + +Keyboard::Keyboard(){ + nop = new Nop; +} +Keyboard::~Keyboard(){ + delete nop; +} + +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 ){ + // TODO + return nop; +} + +Command* Keyboard::released( SDL_Keycode k, Uint16 mod ){ + // TODO + return nop; +} diff --git a/src/keyboard.h b/src/keyboard.h new file mode 100644 index 0000000..fd4680e --- /dev/null +++ b/src/keyboard.h @@ -0,0 +1,21 @@ +#ifndef KEYHANDLER_H +#define KEYHANDLER_H +#include +#include "command.h" + +class Keyboard{ + + public: + Keyboard(); + ~Keyboard(); + Command* handleEvent( SDL_Event e ); + Command* pressed( SDL_Keycode k, Uint16 mod = 0); + Command* released( SDL_Keycode k, Uint16 mod = 0); + + // Modifiers: https://wiki.libsdl.org/SDL_Keymod + // Keycodes: https://wiki.libsdl.org/SDL_Keycode + private: + Command* nop; +}; + +#endif diff --git a/src/main.cpp b/src/main.cpp index d059b75..fb4a6b5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,7 +5,7 @@ #include "renderer.h" #include "window.h" #include "timer.h" -#include "keyHandler.h" +#include "keyboard.h" #include #include @@ -99,7 +99,7 @@ main( int argc, char* args[] ) { timer.start(); GameState game; - KeyHandler keys; + Keyboard keys; while( true ) { -- cgit v1.2.3