X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FInput.cpp;h=f7ab1ffa3dc6a5328c99a061575f0ba3df1410ca;hb=8afdcba610cded0e54b85069ba051268b29669a6;hp=3cf1b1ce99657b9d466589834047025056e680e0;hpb=735daf95aba0eef54d151daae01285f0959825d0;p=lugaru.git diff --git a/Source/Input.cpp b/Source/Input.cpp index 3cf1b1c..f7ab1ff 100644 --- a/Source/Input.cpp +++ b/Source/Input.cpp @@ -1,6 +1,6 @@ /* Copyright (C) 2003, 2010 - Wolfire Games -Copyright (C) 2010 - MCMic +Copyright (C) 2010 - Côme BERNIGAUD This file is part of Lugaru. @@ -25,13 +25,33 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern bool keyboardfrozen; +bool keyDown[SDLK_LAST+6]; +bool keyPressed[SDLK_LAST+6]; + +void Input::Tick(){ + SDL_PumpEvents(); + Uint8 *keyState = SDL_GetKeyState(NULL); + for(int i=0;i=SDLK_LAST+6) // really useful? check that. + return false; + return keyDown[k]; +} + +bool Input::isKeyPressed(int k) { + if(keyboardfrozen||k>=SDLK_LAST+6) + return false; + return keyPressed[k]; } const char* Input::keyToChar(unsigned short i) { @@ -47,8 +67,7 @@ const char* Input::keyToChar(unsigned short i) { return "unknown"; } -unsigned short Input::CharToKey(const char* which) -{ +unsigned short Input::CharToKey(const char* which) { for(unsigned short i=0;i