Skip to content
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

Keyboard events issue #1748

Open
excitoon opened this issue Sep 10, 2020 · 6 comments
Open

Keyboard events issue #1748

excitoon opened this issue Sep 10, 2020 · 6 comments
Labels

Comments

@excitoon
Copy link

I'm not sure if that's SDL or of this project, bug, but:

On Linux/Ubuntu, when you start application with unicode keyboard layout, KEYUP/KEYDOWN events contain keycodes (both sym and scancode) which are >256, even if you change layout while application is running. However if you run application having english layout selected, even if you change layout, you only get codes <256 in KEYUP/KEYDOWN. That leads to errors when sometimes your input is going to screen of the device 2 times per key press, and sometimes - 0 times.

TEXT events contain right symbols, so prefer-text would be good workaround.

@rom1v do you handle this SDL thing correctly? Is that their known behavior?

$ sdl2-config --version
2.0.8
@rom1v
Copy link
Collaborator

rom1v commented Sep 10, 2020

However if you run application having english layout selected, even if you change layout, you only get codes <256 in KEYUP/KEYDOWN.

For keycodes, it seems expected:

https://github.com/spurious/SDL-mirror/blob/66e0e5ad0d554d88d58b92c4ba70d1e4b2f98282/include/SDL_keycode.h#L47-L48

https://github.com/spurious/SDL-mirror/blob/66e0e5ad0d554d88d58b92c4ba70d1e4b2f98282/include/SDL_keycode.h#L154

do you handle this SDL thing correctly

scrcpy just receives the SDL key events SDL_KEYUP and SDL_KEYDOWN:

scrcpy/app/src/scrcpy.c

Lines 200 to 204 in 0be766e

case SDL_KEYDOWN:
case SDL_KEYUP:
// some key events do not interact with the device, so process the
// event even if control is disabled
input_manager_process_key(&input_manager, &event->key);

@excitoon
Copy link
Author

@rom1v I'm not about that thing, I see here that SDL application sticks to that keyboard layout with which it was started o_O, for KEY events, if I start with Russian then I receive Russian unicode characters no matter how I change it during that run of the application. This is totally unexpected, and good thing is that normally KEY events are not used for text processing.

@rom1v
Copy link
Collaborator

rom1v commented Sep 10, 2020

I see here that SDL application sticks to that keyboard layout with which it was started o_O, for KEY events, if I start with Russian then I receive Russian unicode characters no matter how I change it during that run of the application.

Yes, when I wrote "scrcpy just receives the SDL key events SDL_KEYUP and SDL_KEYDOWN", I meant that scrcpy just react to what SDL sends. So if SDL does not react to keyboard layout changes, I'm not sure scrcpy could do something.

Ref: #1729

@rom1v rom1v added the keyboard label Sep 10, 2020
@excitoon
Copy link
Author

excitoon commented Sep 10, 2020

I guess we shall never process text characters in input_manager_process_key in order to have consistent behavior. 🤷‍♂️ No matter prefer-text is set or not.

@rom1v
Copy link
Collaborator

rom1v commented Sep 10, 2020

That would defeat the purpose of --prefer-text (and it would just be the default).

The reason why it is not the default is #87.

@excitoon
Copy link
Author

@rom1v I guess we can tune SDL somehow. For example for X11 they call X11_UpdateKeymap in order to load keymap from X11 to SDL. It's likely that this method is just skipping being called for some reason, when user switches his keymap. It can be scrcpy bug, really.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants