#include "inputManager.h"
#include "../debug.h"
+#include <SDL/SDL.h>
+
#include "../config/keys.h"
/// ***** Public Methods *****
+const Uint32 eventMask = -1; // ALL events
+
void input::update()
{
SDL_Event event;
keyState[i] = isP;
}
- while(SDL_PollEvent(&event))
+ while(0 < SDL_PeepEvents(&event, 1, SDL_GETEVENT, eventMask))
{
switch(event.type)
{
case SDL_QUIT:
keyState[key::end] = wasR;
break;
+ default:
+ break;
}
}
}
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;
}
#include <SDL/SDL.h>
#include "../Vector2.h"
-
/// ***** Header Methods *****
namespace input
bool mouseLeft();
bool mouseRight();
- bool isPressed(SDLKey);
- bool isReleased(SDLKey);
+ bool isPressed(const SDLKey&);
+ bool isReleased(const SDLKey&);
- bool wasPressed(SDLKey);
- bool wasReleased(SDLKey);
+ bool wasPressed(const SDLKey&);
+ bool wasReleased(const SDLKey&);
}
#endif // INPUT_H