diff options
Diffstat (limited to 'libjin/Input/Event.h')
-rw-r--r-- | libjin/Input/Event.h | 62 |
1 files changed, 60 insertions, 2 deletions
diff --git a/libjin/Input/Event.h b/libjin/Input/Event.h index e09f422..91d8593 100644 --- a/libjin/Input/Event.h +++ b/libjin/Input/Event.h @@ -1,13 +1,71 @@ #ifndef __JIN_EVENT_H #define __JIN_EVENT_H +#include "../modules.h" +#if JIN_MODULES_INPUT + namespace jin { namespace input { +#if JIN_INPUT_SDL +#include "SDL.h" - - + typedef SDL_Event Event; + typedef SDL_Keycode Key; + typedef SDL_MouseWheelEvent Wheel; + + enum EventType { + QUIT = SDL_QUIT, + KEYDOWN = SDL_KEYDOWN, + KEYUP = SDL_KEYUP, + MOUSEMOTION = SDL_MOUSEMOTION, + MOUSEBUTTONDOWN = SDL_MOUSEBUTTONDOWN, + MOUSEBUTTONUP = SDL_MOUSEBUTTONUP, + MOUSEWHEEL = SDL_MOUSEWHEEL + }; + + inline int pollEvent(Event* e) + { + return SDL_PollEvent(e); + } + + inline const char* getKeyName(Key key) + { + return SDL_GetKeyName(key); + } + + inline const char* getButtonName(int button) + { + switch (button) + { + case 1: return "left"; + case 2: return "middle"; + case 3: return "right"; + case 4: return "wheelup"; + case 5: return "wheeldown"; + default: return "?"; + } + } + +/* + inline const char* getWheelName(Wheel wheel) + { + if (wheel.x == -1) + return "left"; + else if (wheel.x == 1) + return "right"; + else if (wheel.y == -1) + return "near"; + else if (wheel.y == 1) + return "far"; + else + return "none"; + } +*/ + +#endif // JIN_INPUT_SDL } } +#endif // JIN_MODULES_INPUT #endif
\ No newline at end of file |