Skip to content

Commit

Permalink
Fixed text input in console, console itself doesn't handle unicode co…
Browse files Browse the repository at this point in the history
…rrectly, so weird stuff happens when pressing umlauts
  • Loading branch information
Grumbel committed Jul 30, 2014
1 parent e7b6de6 commit 76637b7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/control/joystickkeyboardcontroller.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -489,6 +493,17 @@ JoystickKeyboardController::process_hat_event(const SDL_JoyHatEvent& jhat)
hat_state = jhat.value;
}

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)
{
Expand Down Expand Up @@ -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;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/control/joystickkeyboardcontroller.hpp
Expand Up @@ -67,6 +67,7 @@ class JoystickKeyboardController // http://wiki.libsdl.org/moin.fcg/SDL_Joystick
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);
Expand Down

0 comments on commit 76637b7

Please sign in to comment.