From: Ingo Ruhnke Date: Wed, 30 Jul 2014 18:43:16 +0000 (+0200) Subject: Fixed text input in console, console itself doesn't handle unicode correctly, so... X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=76637b79c7b6276093a92faff16ed368220b0b67;p=supertux.git Fixed text input in console, console itself doesn't handle unicode correctly, so weird stuff happens when pressing umlauts --- diff --git a/src/control/joystickkeyboardcontroller.cpp b/src/control/joystickkeyboardcontroller.cpp index 20566e75f..0e176e295 100644 --- a/src/control/joystickkeyboardcontroller.cpp +++ b/src/control/joystickkeyboardcontroller.cpp @@ -342,6 +342,10 @@ void JoystickKeyboardController::process_event(const SDL_Event& event) { switch(event.type) { + case SDL_TEXTINPUT: + process_text_input_event(event.text); + break; + case SDL_KEYUP: case SDL_KEYDOWN: process_key_event(event.key); @@ -490,6 +494,17 @@ JoystickKeyboardController::process_hat_event(const SDL_JoyHatEvent& jhat) } void +JoystickKeyboardController::process_text_input_event(const SDL_TextInputEvent& event) +{ + if (Console::instance->hasFocus()) { + for(int i = 0; event.text[i] != '\0'; ++i) + { + Console::instance->input(event.text[i]); + } + } +} + +void JoystickKeyboardController::process_key_event(const SDL_KeyboardEvent& event) { KeyMap::iterator key_mapping = keymap.find(event.keysym.sym); @@ -559,10 +574,6 @@ JoystickKeyboardController::process_console_key_event(const SDL_KeyboardEvent& e Console::instance->move_cursor(+1); break; default: - // int c = SDL_GetScancodeName(event.keysym); - // if ((c >= 32) && (c <= 126)) { you need to move that "unicode" source we were originaly talkinga bout into a new function that gets called from the SDL_TextInput event..... you'll be adding that event. - // Console::instance->input((char)c); - // } break; } } diff --git a/src/control/joystickkeyboardcontroller.hpp b/src/control/joystickkeyboardcontroller.hpp index 1c1936004..705b7bc79 100644 --- a/src/control/joystickkeyboardcontroller.hpp +++ b/src/control/joystickkeyboardcontroller.hpp @@ -67,6 +67,7 @@ public: Controller *get_main_controller(); private: + void process_text_input_event(const SDL_TextInputEvent& event); void process_key_event(const SDL_KeyboardEvent& event); void process_hat_event(const SDL_JoyHatEvent& jhat); void process_axis_event(const SDL_JoyAxisEvent& jaxis);