]> git.localhorst.tv Git - l2e.git/blobdiff - src/app/Application.cpp
added Input class for handling user input
[l2e.git] / src / app / Application.cpp
index e06e231d785535488554f9b09975410f8942f667..d3b00a1efaf125aa38f62561979b5c8a0bdd038c 100644 (file)
@@ -88,6 +88,7 @@ void Application::Loop(void) {
 
 void Application::HandleEvents(void) {
        if (!CurrentState()) return;
+       input.ResetInteractiveState();
        SDL_Event event;
        while (SDL_PollEvent(&event)) {
                switch (event.type) {
@@ -98,11 +99,16 @@ void Application::HandleEvents(void) {
                                screen->Resize(event.resize.w, event.resize.h);
                                CurrentState()->Resize(event.resize.w, event.resize.h);
                                break;
+                       case SDL_KEYDOWN:
+                       case SDL_KEYUP:
+                               input.HandleKeyboardEvent(event.key);
+                               break;
                        default:
-                               CurrentState()->HandleEvent(event);
+                               // skip event
                                break;
                }
        }
+       CurrentState()->HandleInput(input);
 }
 
 void Application::UpdateWorld(Uint32 deltaT) {