Fixed text input in console, console itself doesn't handle unicode correctly, so...
authorIngo Ruhnke <grumbel@gmail.com>
Wed, 30 Jul 2014 18:43:16 +0000 (20:43 +0200)
committerIngo Ruhnke <grumbel@gmail.com>
Wed, 30 Jul 2014 18:43:16 +0000 (20:43 +0200)
src/control/joystickkeyboardcontroller.cpp
src/control/joystickkeyboardcontroller.hpp

index 20566e7..0e176e2 100644 (file)
@@ -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)) { <Xeek> 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;
   }
 }
index 1c19360..705b7bc 100644 (file)
@@ -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);