-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix special key does not work in linux #62838
Conversation
You might want a local patch if you don't know how it would affected other environments. |
@@ -3202,7 +3202,7 @@ static void CheckMessages() | |||
last_input = input_event( lc, input_event_t::keyboard_char ); | |||
} else { | |||
// no key pressed in this event | |||
last_input = input_event(); | |||
// last_input = input_event(); //i don't know why it works |
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 an SDL_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 an SDL_TEXTEDITING
event which is handled in the same CheckMessage
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.
-----------------------------------------
16:27:04.328 : Starting log.
16:27:04.328 INFO : Cataclysm DDA version 211b11d37f-dirty
16:27:04.329 INFO : [main] C locale set to zh_CN.UTF-8
16:27:04.329 INFO : [main] C++ locale set to zh_CN.UTF-8
16:27:04.329 INFO : SDL version used during compile is 2.26.1
16:27:04.329 INFO : SDL version used during linking and in runtime is 2.26.1
16:27:04.353 INFO : Number of render drivers on your system: 3
16:27:04.353 INFO : Render driver: 0/opengl
16:27:04.353 INFO : Render driver: 1/opengles2
16:27:04.353 INFO : Render driver: 2/software
16:27:04.355 INFO : [options] C locale set to zh_CN.UTF-8
16:27:04.355 INFO : [options] C++ locale set to zh_CN.UTF-8
16:27:04.355 INFO : Setting language to: 'zh_CN'
16:27:04.355 INFO : [i18n] Scanning core translations from lang/mo/
16:27:04.355 INFO : [i18n] Scanning mod translations from ./mods/
16:27:04.355 WARNING : opendir [./mods/] failed with "没有那个文件或目录".
16:27:04.530 INFO : Active renderer: 0/opengl
16:27:04.697 INFO : USE_COLOR_MODULATED_TEXTURES is set to 0
16:27:04.707 INFO : Setting language to: 'zh_CN'
16:27:04.715 WARNING : opendir [./mods] failed with "没有那个文件或目录".
16:27:05.341 INFO : SDL_KEYDOWN{mod:0,scancode:79,sym:1073741903,unused:0}
16:27:05.341 INFO : SDL_TEXTEDITING{text:,length:0,start:0}
16:27:05.432 INFO : SDL_KEYUP{mod:0,scancode:79,sym:1073741903,unused:0}
16:27:05.578 INFO : SDL_KEYDOWN{mod:0,scancode:79,sym:1073741903,unused:0}
16:27:05.578 INFO : SDL_TEXTEDITING{text:,length:0,start:0}
16:27:05.647 INFO : SDL_KEYUP{mod:0,scancode:79,sym:1073741903,unused:0}
16:27:05.739 INFO : SDL_KEYDOWN{mod:0,scancode:79,sym:1073741903,unused:0}
16:27:05.739 INFO : SDL_TEXTEDITING{text:,length:0,start:0}
16:27:05.823 INFO : SDL_KEYUP{mod:0,scancode:79,sym:1073741903,unused:0}
16:27:05.909 INFO : SDL_KEYDOWN{mod:0,scancode:79,sym:1073741903,unused:0}
16:27:05.909 INFO : SDL_TEXTEDITING{text:,length:0,start:0}
16:27:05.979 INFO : SDL_KEYUP{mod:0,scancode:79,sym:1073741903,unused:0}
16:27:06.275 INFO : SDL_KEYDOWN{mod:0,scancode:79,sym:1073741903,unused:0}
16:27:06.275 INFO : SDL_TEXTEDITING{text:,length:0,start:0}
16:27:06.359 INFO : SDL_KEYUP{mod:0,scancode:79,sym:1073741903,unused:0}
16:27:06.667 INFO : SDL_KEYDOWN{mod:0,scancode:80,sym:1073741904,unused:0}
16:27:06.667 INFO : SDL_TEXTEDITING{text:,length:0,start:0}
16:27:06.780 INFO : SDL_KEYUP{mod:0,scancode:80,sym:1073741904,unused:0}
16:27:06.876 INFO : SDL_KEYDOWN{mod:0,scancode:80,sym:1073741904,unused:0}
16:27:06.876 INFO : SDL_TEXTEDITING{text:,length:0,start:0}
16:27:06.952 INFO : SDL_KEYUP{mod:0,scancode:80,sym:1073741904,unused:0}
16:27:08.873 INFO : SDL_KEYDOWN{mod:1,scancode:225,sym:1073742049,unused:0}
16:27:09.099 INFO : SDL_KEYDOWN{mod:1,scancode:4,sym:97,unused:0}
16:27:09.099 INFO : SDL_TEXTINPUT{text:A}
16:27:09.103 INFO : SDL_TEXTEDITING{text:,length:0,start:0}
16:27:09.303 INFO : SDL_KEYUP{mod:1,scancode:4,sym:97,unused:0}
16:27:09.374 INFO : SDL_KEYUP{mod:0,scancode:225,sym:1073742049,unused:0}
16:27:10.829 INFO : SDL_KEYDOWN{mod:1,scancode:225,sym:1073742049,unused:0}
16:27:11.160 INFO : SDL_KEYDOWN{mod:1,scancode:23,sym:116,unused:0}
16:27:11.160 INFO : SDL_TEXTINPUT{text:T}
16:27:11.168 INFO : SDL_TEXTEDITING{text:,length:0,start:0}
16:27:11.290 INFO : SDL_KEYUP{mod:1,scancode:23,sym:116,unused:0}
16:27:11.374 INFO : SDL_KEYUP{mod:0,scancode:225,sym:1073742049,unused:0}
16:27:11.943 INFO : SDL_KEYDOWN{mod:0,scancode:40,sym:13,unused:0}
16:27:11.943 INFO : SDL_TEXTEDITING{text:,length:0,start:0}
16:27:12.012 INFO : SDL_KEYUP{mod:0,scancode:40,sym:13,unused:0}
16:27:12.941 INFO : SDL_KEYDOWN{mod:0,scancode:40,sym:13,unused:0}
16:27:12.941 INFO : SDL_TEXTEDITING{text:,length:0,start:0}
16:27:13.016 INFO : SDL_KEYUP{mod:0,scancode:40,sym:13,unused:0}
16:27:13.848 INFO : SDL_KEYDOWN{mod:0,scancode:42,sym:8,unused:0}
16:27:13.848 INFO : SDL_TEXTEDITING{text:,length:0,start:0}
16:27:13.923 INFO : SDL_KEYUP{mod:0,scancode:42,sym:8,unused:0}
16:27:14.024 INFO : SDL_KEYDOWN{mod:0,scancode:42,sym:8,unused:0}
16:27:14.024 INFO : SDL_TEXTEDITING{text:,length:0,start:0}
16:27:14.094 INFO : SDL_KEYUP{mod:0,scancode:42,sym:8,unused:0}
16:27:14.185 INFO : SDL_KEYDOWN{mod:0,scancode:42,sym:8,unused:0}
16:27:14.185 INFO : SDL_TEXTEDITING{text:,length:0,start:0}
16:27:14.249 INFO : SDL_KEYUP{mod:0,scancode:42,sym:8,unused:0}
16:27:14.335 INFO : SDL_KEYDOWN{mod:0,scancode:42,sym:8,unused:0}
16:27:14.335 INFO : SDL_TEXTEDITING{text:,length:0,start:0}
16:27:14.405 INFO : SDL_KEYUP{mod:0,scancode:42,sym:8,unused:0}
16:27:14.486 INFO : SDL_KEYDOWN{mod:0,scancode:42,sym:8,unused:0}
16:27:14.486 INFO : SDL_TEXTEDITING{text:,length:0,start:0}
16:27:14.561 INFO : SDL_KEYUP{mod:0,scancode:42,sym:8,unused:0}
16:27:14.637 INFO : SDL_KEYDOWN{mod:0,scancode:42,sym:8,unused:0}
16:27:14.637 INFO : SDL_TEXTEDITING{text:,length:0,start:0}
16:27:14.701 INFO : SDL_KEYUP{mod:0,scancode:42,sym:8,unused:0}
16:27:14.891 INFO : SDL_KEYDOWN{mod:1,scancode:225,sym:1073742049,unused:0}
16:27:15.093 INFO : SDL_KEYDOWN{mod:1,scancode:23,sym:116,unused:0}
16:27:15.093 INFO : SDL_TEXTINPUT{text:T}
16:27:15.094 INFO : SDL_TEXTEDITING{text:,length:0,start:0}
16:27:15.188 INFO : SDL_KEYDOWN{mod:1,scancode:11,sym:104,unused:0}
16:27:15.188 INFO : SDL_TEXTINPUT{text:H}
16:27:15.190 INFO : SDL_TEXTEDITING{text:,length:0,start:0}
16:27:15.206 INFO : SDL_KEYUP{mod:0,scancode:225,sym:1073742049,unused:0}
16:27:15.222 INFO : SDL_KEYUP{mod:0,scancode:23,sym:116,unused:0}
16:27:15.273 INFO : SDL_KEYUP{mod:0,scancode:11,sym:104,unused:0}
16:27:15.339 INFO : SDL_KEYDOWN{mod:0,scancode:8,sym:101,unused:0}
16:27:15.339 INFO : SDL_TEXTINPUT{text:e}
16:27:15.340 INFO : SDL_TEXTEDITING{text:,length:0,start:0}
16:27:15.448 INFO : SDL_KEYUP{mod:0,scancode:8,sym:101,unused:0}
16:27:15.504 INFO : SDL_KEYDOWN{mod:1,scancode:225,sym:1073742049,unused:0}
16:27:15.719 INFO : SDL_KEYUP{mod:0,scancode:225,sym:1073742049,unused:0}
16:27:15.779 INFO : SDL_KEYDOWN{mod:0,scancode:42,sym:8,unused:0}
16:27:15.779 INFO : SDL_TEXTEDITING{text:,length:0,start:0}
16:27:15.850 INFO : SDL_KEYUP{mod:0,scancode:42,sym:8,unused:0}
16:27:15.920 INFO : SDL_KEYDOWN{mod:0,scancode:42,sym:8,unused:0}
16:27:15.920 INFO : SDL_TEXTEDITING{text:,length:0,start:0}
16:27:16.020 INFO : SDL_KEYUP{mod:0,scancode:42,sym:8,unused:0}
16:27:16.185 INFO : SDL_KEYDOWN{mod:0,scancode:42,sym:8,unused:0}
16:27:16.185 INFO : SDL_TEXTEDITING{text:,length:0,start:0}
16:27:16.280 INFO : SDL_KEYUP{mod:0,scancode:42,sym:8,unused:0}
16:27:16.592 INFO : SDL_KEYDOWN{mod:1,scancode:225,sym:1073742049,unused:0}
16:27:16.842 INFO : SDL_KEYDOWN{mod:1,scancode:23,sym:116,unused:0}
16:27:16.842 INFO : SDL_TEXTINPUT{text:T}
16:27:16.842 INFO : SDL_TEXTEDITING{text:,length:0,start:0}
16:27:16.947 INFO : SDL_KEYUP{mod:0,scancode:225,sym:1073742049,unused:0}
16:27:16.958 INFO : SDL_KEYDOWN{mod:0,scancode:11,sym:104,unused:0}
16:27:16.958 INFO : SDL_TEXTINPUT{text:h}
16:27:16.959 INFO : SDL_TEXTEDITING{text:,length:0,start:0}
16:27:16.972 INFO : SDL_KEYUP{mod:0,scancode:23,sym:116,unused:0}
16:27:17.043 INFO : SDL_KEYUP{mod:0,scancode:11,sym:104,unused:0}
16:27:17.098 INFO : SDL_KEYDOWN{mod:0,scancode:8,sym:101,unused:0}
16:27:17.098 INFO : SDL_TEXTINPUT{text:e}
16:27:17.099 INFO : SDL_TEXTEDITING{text:,length:0,start:0}
16:27:17.179 INFO : SDL_KEYUP{mod:0,scancode:8,sym:101,unused:0}
16:27:17.238 INFO : SDL_KEYDOWN{mod:1,scancode:225,sym:1073742049,unused:0}
16:27:17.384 INFO : SDL_KEYDOWN{mod:1,scancode:19,sym:112,unused:0}
16:27:17.384 INFO : SDL_TEXTINPUT{text:P}
16:27:17.385 INFO : SDL_TEXTEDITING{text:,length:0,start:0}
16:27:17.439 INFO : SDL_KEYUP{mod:0,scancode:225,sym:1073742049,unused:0}
16:27:17.464 INFO : SDL_KEYUP{mod:0,scancode:19,sym:112,unused:0}
16:27:17.515 INFO : SDL_KEYDOWN{mod:0,scancode:8,sym:101,unused:0}
16:27:17.515 INFO : SDL_TEXTINPUT{text:e}
16:27:17.516 INFO : SDL_TEXTEDITING{text:,length:0,start:0}
16:27:17.611 INFO : SDL_KEYDOWN{mod:0,scancode:12,sym:105,unused:0}
16:27:17.611 INFO : SDL_TEXTINPUT{text:i}
16:27:17.612 INFO : SDL_TEXTEDITING{text:,length:0,start:0}
16:27:17.650 INFO : SDL_KEYUP{mod:0,scancode:8,sym:101,unused:0}
16:27:17.690 INFO : SDL_KEYUP{mod:0,scancode:12,sym:105,unused:0}
16:27:17.941 INFO : SDL_KEYDOWN{mod:0,scancode:40,sym:13,unused:0}
16:27:17.941 INFO : SDL_TEXTEDITING{text:,length:0,start:0}
16:27:18.036 INFO : SDL_KEYUP{mod:0,scancode:40,sym:13,unused:0}
16:27:18.253 INFO : SDL_KEYDOWN{mod:0,scancode:41,sym:27,unused:0}
16:27:18.253 INFO : SDL_TEXTEDITING{text:,length:0,start:0}
16:27:18.337 INFO : SDL_KEYUP{mod:0,scancode:41,sym:27,unused:0}
16:27:18.909 INFO : SDL_KEYDOWN{mod:1,scancode:225,sym:1073742049,unused:0}
16:27:19.110 INFO : SDL_KEYDOWN{mod:1,scancode:20,sym:113,unused:0}
16:27:19.110 INFO : SDL_TEXTINPUT{text:Q}
16:27:19.118 INFO : SDL_TEXTEDITING{text:,length:0,start:0}
16:27:19.330 INFO : SDL_KEYUP{mod:1,scancode:20,sym:113,unused:0}
16:27:19.345 INFO : SDL_KEYUP{mod:0,scancode:225,sym:1073742049,unused:0}
16:27:19.947 INFO : SDL_KEYDOWN{mod:0,scancode:80,sym:1073741904,unused:0}
16:27:19.947 INFO : SDL_TEXTEDITING{text:,length:0,start:0}
16:27:20.083 INFO : SDL_KEYUP{mod:0,scancode:80,sym:1073741904,unused:0}
16:27:20.253 INFO : SDL_KEYDOWN{mod:0,scancode:40,sym:13,unused:0}
16:27:20.253 INFO : SDL_TEXTEDITING{text:,length:0,start:0}
16:27:20.253 : Log shutdown.
-----------------------------------------
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处理预览文本的时候考虑包括已处理事件的所有事件。
what a mystery |
奇了怪了 |
如果你有什么意见要提,请直接说明,否则还请不要进行无意义的回复。 If you have any suggestions feel free to make them, but please do not leave meaningless replies. |
Summary
Bugfixes "arrow keys and other key not work in linux"
Purpose of change
Fix #61154
Fix #62734
Describe the solution
comment a line
Describe alternatives you've considered
i don't know.
Testing
no
Additional context
at least,i can play it again.