X-Git-Url: http://gitweb.pgornicz.com/gitweb.cgi?a=blobdiff_plain;f=src%2Finput%2FinputManager.cpp;h=5a42b2cebc1d87cf0b99d91fdbf73322f8ae3669;hb=3d1f081343dc603a3292538eeb9bd794b255deb6;hp=3ecb477866776500da716639413053c3b178a70e;hpb=d6ce2baff0c3bfe8dce98d9b9325f84add6a2e72;p=physics.git diff --git a/src/input/inputManager.cpp b/src/input/inputManager.cpp index 3ecb477..5a42b2c 100644 --- a/src/input/inputManager.cpp +++ b/src/input/inputManager.cpp @@ -16,7 +16,11 @@ */ #include "inputManager.h" -#include "../debug.h" +#include "debug.h" + +#include + +#include "config/keys.h" /// ***** Private Variables ***** @@ -46,6 +50,8 @@ void input::clean() /// ***** Public Methods ***** +const Uint32 eventMask = -1; // ALL events + void input::update() { SDL_Event event; @@ -58,7 +64,7 @@ void input::update() keyState[i] = isP; } - while(SDL_PollEvent(&event)) + while(0 < SDL_PeepEvents(&event, 1, SDL_GETEVENT, eventMask)) { switch(event.type) { @@ -68,6 +74,11 @@ void input::update() case SDL_KEYDOWN: keyState[event.key.keysym.sym] = wasP; break; + case SDL_QUIT: + keyState[key::end] = wasR; + break; + default: + break; } } } @@ -93,20 +104,20 @@ bool input::mouseRight() return state & SDL_BUTTON(3); } -bool input::isPressed(SDLKey key) +bool input::isPressed(const SDLKey& key) { return keyState[key] == isP || keyState[key] == wasP; } -bool input::isReleased(SDLKey key) +bool input::isReleased(const SDLKey& key) { return keyState[key] == isR || keyState[key] == wasR; } -bool input::wasPressed(SDLKey key) +bool input::wasPressed(const SDLKey& key) { return keyState[key] == wasP; } -bool input::wasReleased(SDLKey key) +bool input::wasReleased(const SDLKey& key) { return keyState[key] == wasR; }