diff --git a/TODO b/TODO index 4ba6481..b3f88c3 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,4 @@ -* Continue rebasing from 33d1e46684936a304ae82587a0c35c68d6b0b93c +* Continue rebasing from df337fb783bc0f8ce1bab1bc672e301f88b9d364 * Add a focus listener interface. * Make focus apply synchronously. * Graphics and input objects for DirectX. diff --git a/include/guisan/sdl/sdlinput.hpp b/include/guisan/sdl/sdlinput.hpp index 37f8701..8b9c454 100644 --- a/include/guisan/sdl/sdlinput.hpp +++ b/include/guisan/sdl/sdlinput.hpp @@ -119,13 +119,13 @@ namespace gcn int convertMouseButton(int button); /** - * Converts an SDL event key to a key value. + * Converts an SDL event to a Guisan key value. * - * @param event an SDL event with a key to convert. - * @return a key value. + * @param event The SDL event to convert. + * @return A Guisan key value. * @see Key */ - int convertKeyCharacter(SDL_Event event); + Key convertSDLEventToGuichanKeyValue(SDL_Event event); std::queue mKeyInputQueue; std::queue mMouseInputQueue; diff --git a/src/sdl/sdlinput.cpp b/src/sdl/sdlinput.cpp index 3162847..0b4e8eb 100644 --- a/src/sdl/sdlinput.cpp +++ b/src/sdl/sdlinput.cpp @@ -166,7 +166,7 @@ namespace gcn mKeyInputQueue.push(keyInput); break; case SDL_KEYDOWN: - keyInput.setKey(Key(convertKeyCharacter(event))); + keyInput.setKey(convertSDLEventToGuichanKeyValue(event)); keyInput.setType(KeyInput::PRESSED); keyInput.setShiftPressed(event.key.keysym.mod & KMOD_SHIFT); keyInput.setControlPressed(event.key.keysym.mod & KMOD_CTRL); @@ -183,7 +183,7 @@ namespace gcn break; case SDL_KEYUP: - keyInput.setKey(Key(convertKeyCharacter(event))); + keyInput.setKey(convertSDLEventToGuichanKeyValue(event)); keyInput.setType(KeyInput::RELEASED); keyInput.setShiftPressed(event.key.keysym.mod & KMOD_SHIFT); keyInput.setControlPressed(event.key.keysym.mod & KMOD_CTRL); @@ -278,12 +278,11 @@ namespace gcn } } - int SDLInput::convertKeyCharacter(SDL_Event event) + Key SDLInput::convertSDLEventToGuichanKeyValue(SDL_Event event) { - SDL_Keysym keysym = event.key.keysym; - - int value = 0; - switch (keysym.sym) + int value = -1; + + switch (event.key.keysym.sym) { case SDLK_TAB: value = Key::TAB; @@ -422,13 +421,13 @@ namespace gcn break; default: - value = keysym.sym; + value = event.key.keysym.sym; break; } - if (!(keysym.mod & KMOD_NUM)) + if (!(event.key.keysym.mod & KMOD_NUM)) { - switch (keysym.sym) + switch (event.key.keysym.sym) { case SDLK_KP_0: value = Key::INSERT; @@ -466,7 +465,7 @@ namespace gcn } else { - switch (keysym.sym) + switch (event.key.keysym.sym) { case SDLK_KP_0: value = SDLK_0;