From 837ada7e2ca481b0cd854c5b97cd9015c0b567e9 Mon Sep 17 00:00:00 2001 From: relnev Date: Mon, 20 Jan 2003 20:36:30 +0000 Subject: properly fixed uninitialized key handling git-svn-id: svn://svn.icculus.org/blackshades/trunk@95 5198baeb-e213-0410-be47-fc2ff85ca46f --- Source/GameLoop.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'Source/GameLoop.cpp') diff --git a/Source/GameLoop.cpp b/Source/GameLoop.cpp index 35bc4fe..7b520bb 100644 --- a/Source/GameLoop.cpp +++ b/Source/GameLoop.cpp @@ -26,8 +26,6 @@ void Game::HandleKeyDown( char theChar ) { - ALint tempInt; - XYZ facing; @@ -214,6 +212,12 @@ static unsigned char ourkeys[16]; static void init_sdlkeymap() { + int i; + + for (i = 0; i < SDLK_LAST; i++) { + sdlkeymap[i] = -1; + } + sdlkeymap[SDLK_1] = MAC_1_KEY; sdlkeymap[SDLK_2] = MAC_2_KEY; sdlkeymap[SDLK_3] = MAC_3_KEY; @@ -320,10 +324,11 @@ static void DoSDLKey(Game *g, SDL_Event *event) } mackey = sdlkeymap[event->key.keysym.sym]; - index = mackey / 8; - mask = 1 << (mackey % 8); - if (mackey) { + if (mackey != -1) { + index = mackey / 8; + mask = 1 << (mackey % 8); + if (press) { ourkeys[index] |= mask; } else { -- cgit v1.2.3