X-Git-Url: http://gitweb.pgornicz.com/gitweb.cgi?a=blobdiff_plain;f=src%2Finput%2FinputManager.cpp;h=715213848cfd77162cf4634030e1961ab9643e3f;hb=b85b89ba9a2cb0373209e8117046fd308faf0202;hp=ebbd72e67071a804a7690bccd4dd7fd4f1ec7a14;hpb=10baa49bf3be2ad03b3adf5be5cb0fcf5f10fcfb;p=physics.git diff --git a/src/input/inputManager.cpp b/src/input/inputManager.cpp index ebbd72e..7152138 100644 --- a/src/input/inputManager.cpp +++ b/src/input/inputManager.cpp @@ -16,7 +16,13 @@ */ #include "inputManager.h" -#include "../debug.h" + +#include +using namespace pg; + +#include + +#include "config/keys.h" /// ***** Private Variables ***** @@ -46,6 +52,8 @@ void input::clean() /// ***** Public Methods ***** +const Uint32 eventMask = -1; // ALL events + void input::update() { SDL_Event event; @@ -58,7 +66,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 +76,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 +106,20 @@ bool input::mouseRight() return state & SDL_BUTTON(3); } -bool input::isPressed(Uint8 key) +bool input::isPressed(const SDLKey& key) { return keyState[key] == isP || keyState[key] == wasP; } -bool input::isReleased(Uint8 key) +bool input::isReleased(const SDLKey& key) { return keyState[key] == isR || keyState[key] == wasR; } -bool input::wasPressed(Uint8 key) +bool input::wasPressed(const SDLKey& key) { return keyState[key] == wasP; } -bool input::wasReleased(Uint8 key) +bool input::wasReleased(const SDLKey& key) { return keyState[key] == wasR; }