diff options
author | chai <chaifix@163.com> | 2018-07-28 09:58:37 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-07-28 09:58:37 +0800 |
commit | 61301a96d309fe2deef0d0dc2e2bc2f3d4003bf9 (patch) | |
tree | d335e4312b28addf40f13e7f49900e9b5e3058a7 /src/libjin/input/event.h | |
parent | 92dab582ccac31be7fa410e7f4fb3789e88a0629 (diff) |
*update
Diffstat (limited to 'src/libjin/input/event.h')
-rw-r--r-- | src/libjin/input/event.h | 60 |
1 files changed, 50 insertions, 10 deletions
diff --git a/src/libjin/input/event.h b/src/libjin/input/event.h index 4d7230a..83db070 100644 --- a/src/libjin/input/event.h +++ b/src/libjin/input/event.h @@ -9,22 +9,62 @@ namespace input { #if JIN_INPUT_SDL #include "SDL.h" - typedef SDL_Event Event; + 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); } - enum EventType{ - QUIT = SDL_QUIT, - KEYDOWN = SDL_KEYDOWN , - KEYUP = SDL_KEYUP, - MOUSEMOTION = SDL_MOUSEMOTION, - MOUSEBUTTONDOWN = SDL_MOUSEBUTTONDOWN, - MOUSEBUTTONUP = SDL_MOUSEBUTTONUP, - MOUSEWHEEL = SDL_MOUSEWHEEL - }; + 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 } } |