X-Git-Url: http://gitweb.pgornicz.com/gitweb.cgi?a=blobdiff_plain;f=src%2Finput%2FinputManager.cpp;h=21934c4c137769acdf76aeeb4c78497d947e7ad4;hb=e616366d12163fd5947cc87433e2dd51746e6846;hp=a8491b141561a778fd29930dd2ef89afcb3a41a4;hpb=e68f847b245153427266841ae724d602ca434c29;p=physics.git diff --git a/src/input/inputManager.cpp b/src/input/inputManager.cpp index a8491b1..21934c4 100644 --- a/src/input/inputManager.cpp +++ b/src/input/inputManager.cpp @@ -18,6 +18,8 @@ #include "inputManager.h" #include "../debug.h" +#include "../config/keys.h" + /// ***** Private Variables ***** @@ -68,24 +70,48 @@ void input::update() case SDL_KEYDOWN: keyState[event.key.keysym.sym] = wasP; break; + case SDL_QUIT: + keyState[key::end] = wasR; + break; } } } -bool input::isPressed(Uint8 key) +Vector2 input::mousePosition() +{ + int x,y; + SDL_GetMouseState(&x, &y); + + return Vector2(x,y); +} + +bool input::mouseLeft() +{ + Uint8 state = SDL_GetMouseState(NULL, NULL); + + return state & SDL_BUTTON(1); +} +bool input::mouseRight() +{ + Uint8 state = SDL_GetMouseState(NULL, NULL); + + return state & SDL_BUTTON(3); +} + +bool input::isPressed(SDLKey key) { return keyState[key] == isP || keyState[key] == wasP; } -bool input::isReleased(Uint8 key) +bool input::isReleased(SDLKey key) { return keyState[key] == isR || keyState[key] == wasR; } -bool input::wasPressed(Uint8 key) +bool input::wasPressed(SDLKey key) { return keyState[key] == wasP; } -bool input::wasReleased(Uint8 key) +bool input::wasReleased(SDLKey key) { return keyState[key] == wasR; }