X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fapp%2FInput.h;fp=src%2Fapp%2FInput.h;h=ad5086920ac954119cb57ced60041d2fba956c75;hb=867fd5d9b79c3b9c1d0fb17ba9f55cfe971b93d5;hp=0000000000000000000000000000000000000000;hpb=2955f56fb11fab871a34db5700befe55737d81d7;p=l2e.git diff --git a/src/app/Input.h b/src/app/Input.h new file mode 100644 index 0000000..ad50869 --- /dev/null +++ b/src/app/Input.h @@ -0,0 +1,70 @@ +/* + * Input.h + * + * Created on: Aug 6, 2012 + * Author: holy + */ + +#ifndef APP_INPUT_H_ +#define APP_INPUT_H_ + +#include +#include + +namespace app { + +class Input { + +public: + enum Button { + PAD_UP = 1, + PAD_RIGHT = 2, + PAD_DOWN = 4, + PAD_LEFT = 8, + ACTION_A = 16, + ACTION_B = 32, + ACTION_X = 64, + ACTION_Y = 128, + START = 256, + SELECT = 512, + SHOULDER_RIGHT = 1024, + SHOULDER_LEFT = 2048 + }; + +public: + Input(); + +public: + bool IsDown(Button b) const { + return down & b; + } + bool JustPressed(Button b) const { + return pressed & b; + } + bool JustReleased(Button b) const { + return released & b; + } + +public: + void ResetInteractiveState() { + pressed = 0; + released = 0; + } + void HandleKeyboardEvent(const SDL_KeyboardEvent &); + +public: + void MapKey(SDLKey k, Button b) { + mapping[k] = b; + } + +private: + std::map mapping; + Uint16 down; + Uint16 pressed; + Uint16 released; + +}; + +} + +#endif /* APP_INPUT_H_ */