Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was added in #24568 to avoid triggering an
UNKNOWN_UNICODE
input event when SDL sends anSDL_TEXTEDITING
event with an empty string.If commenting out this line fixes the issues, my guess is that the system sends an
SDL_KEYDOWN
event that is skipped due to being an auto-repeat event, immediately followed by anSDL_TEXTEDITING
event which is handled in the sameCheckMessage
call, therefore overwriting the first event.I wonder if you could print a log of key events when the issues happen so we can better understand what is happening and make a more specific fix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you describe what's wrong in your test? According to the log, you opened the options menu, entered a default character name, confirmed, and exited the game, but the issues you linked in the original post were about game not responding to auto-repeated keys.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这是我在注释了那一行代码后的输出的日志,如果没有注释掉那一行代码,令函数sdl_keysym_to_curses的返回值不为零的键盘事件的keysym都会使得在KEYDOWN事件后跟随一个TEXTEDITING事件,而这个跟随的TEXTEDTING事件的ev.edit.text长度为0,进而会执行被注释的那一行代码,使得原本的last_input的结果被覆盖掉
也就是说,这个bug会导致tab键、方向键回车键等都无效
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TEXTEDTING事件的ev.edit.text为空相当于系统告诉程序把输入法的预览文本设为空,如果只是注释掉这行代码的话,程序根据KEYDOWN和TEXTEDITING两个事件只返回一个input_event,可能导致输入法预览异常。感觉要正确修复比较复杂,可能需要改变SDL_TEXTEDITING的处理方式,不对last_input进行赋值(按理说输入法的预览文本不应该触发输入,不知道原来为啥这里有赋值),并且在根据edit_refresh处理预览文本的时候考虑包括已处理事件的所有事件。