From 9c2791550782ece485ed9a5952925b458bbe00fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20=E2=80=98Touky=E2=80=99=20Huet?= Date: Sun, 29 Apr 2012 18:41:43 +0000 Subject: [PATCH] Added GetButtonState() in Input class. Added Escape button in to quit Orbital. Added Camera control with some little damping sweetness in Camera logic in main Tick. First Commit \o/ --- src/input.cpp | 15 +++++++++++++++ src/input.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/src/input.cpp b/src/input.cpp index d28f8065..4cc7d054 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -91,6 +91,21 @@ ivec3 Input::GetMouseButtons() return data->buttons; } +//BH : Added this, is a v0.1 Alpha version. +int Input::GetButtonState(int button) +{ +#if defined USE_SDL +#if SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION >= 3 + Uint8 *keystate = SDL_GetKeyboardState(NULL); +#else + Uint8 *keystate = SDL_GetKeyState(NULL); +#endif + return keystate[button]; +#else + return 0; +#endif +} + void Input::TrackMouse(WorldEntity *e) { if (data->nentities >= InputData::MAX_ENTITIES) diff --git a/src/input.h b/src/input.h index 99dc24eb..9cdea5d2 100644 --- a/src/input.h +++ b/src/input.h @@ -30,6 +30,8 @@ public: static vec2 GetAxis(int axis); static ivec2 GetMousePos(); static ivec3 GetMouseButtons(); + //BH : Added this, is a v0.1 Alpha version. + static int GetButtonState(int button); /* Entities can subscribe to events */ static void TrackMouse(WorldEntity *e);