From 887e7b1690ca74f1f272261090e83fa584c5816c Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sat, 28 Aug 2010 17:19:11 +0000 Subject: [PATCH] Switch from esdf controls to wasd, but support qwerty and azerty keyboards. --- src/input.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/input.cpp b/src/input.cpp index 77fc42e7..de3a1f9b 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -41,12 +41,11 @@ Float2 Input::GetAxis(int axis) /* Simulate a joystick using the keyboard. This SDL call is free. */ Uint8 *keystate = SDL_GetKeyState(NULL); - f.y -= keystate[SDLK_e]; - f.y += keystate[SDLK_d]; - f.x -= keystate[SDLK_s]; - f.x += keystate[SDLK_f]; - if (keystate[SDLK_e] + keystate[SDLK_d] - == keystate[SDLK_s] + keystate[SDLK_f]) + int left = keystate[SDLK_d] - (keystate[SDLK_a] | keystate[SDLK_q]); + int up = keystate[SDLK_s] - (keystate[SDLK_w] | keystate[SDLK_z]); + f.y += up; + f.x += left; + if (left && up) { f.x *= invsqrt2; f.y *= invsqrt2;