Skip to content

Commit

Permalink
Engine: in ags_simulate_keypress() only do TEXT event for "old mode"
Browse files Browse the repository at this point in the history
This is because old mode uses TEXT events for running "on_key_press" for printable characters.
Passing TEXT event in the new mode will result in inconsistent behavior, as only limited number of characters (<128 indexes) will be reported correctly in "on_text_input", and there may be incorrect calls too for unicode chars.
So it's better to leave that for later. Maybe we should somehow use SDL2 internals for converting simulated key presses to textual representation instead of trying to handle this ourselves.
  • Loading branch information
ivan-mogilko committed Sep 15, 2024
1 parent 4c2cb8e commit 6a1a5e5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Engine/ac/sys_events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ void ags_simulate_keypress(eAGSKeyCode ags_key, bool old_keyhandle)
SDL_PushEvent(&sdlevent);
// Push a text input event for ascii printable characters;
// in case of "old key handling mode" this instead will trigger on_key_press for them.
if (/*old_keyhandle &&*/ (key_sym >= SDLK_SPACE && key_sym <= SDLK_z))
if (old_keyhandle && (key_sym >= SDLK_SPACE && key_sym <= SDLK_z))
{
sdlevent.type = SDL_TEXTINPUT;
sdlevent.text.text[0] = static_cast<char>(key_sym);
Expand Down

0 comments on commit 6a1a5e5

Please sign in to comment.