-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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 shortcuts work correctly only when using English layout #351
Comments
Wouldn't that be confusing? Also, I generally use US layout even on i.e. Italian keyboards at work (because companies buy PCs for the masses), wouldn't this feature troll me in that scenario? |
In most GUI software keyboard shortcuts do not depend on layout, switching layout for using player is annoying. Please add this feature. |
This was already discussed here: #45 |
This is mostly for non-latin layouts. Specifically Russian in my case. With such layouts, necessary letters are nowhere to be found. This is unlike Italian, that uses the same letters (maybe just in different places). Also on Cocoa layout switching for some reason does not work when keyboard focus is in mpv. So it is triple-pain: switch away, switch layout, switch back. |
I've read through discussion, but I don't agree with the conclusion:
It is definitely possible, as SDL (or any other similar library) does that exact thing for games. In fact it provides both layout-independent code and layout-dependent one AFAIK. I would recommend checking the code there for specifics. For mpv, I would recommend a user option switch. So that both latin keyboard users with non-English-weird-key-positions, and non-latin users (I am only aware of Cyrillic) can be happy. |
As an obviously highly biased Neo user I agree. I’m always pleased when games and programs manage to cope with my layout. But: In (well written) games and other applications you generally assign actions to positions on the keyboard, what would be a non confusing way to do this in a config file? Letter → position of it on the US layout → letter on the corresponding position of your layout is kinda dumb. And really confusing. Not nearly as confusing as having to type scancodes though. Some kind of layout switching script could work though, convert all hotkeys to the active layout or something. I’m pretty sure some program (a tiling WM?) does this, I just can’t remember which one… |
It already does: |
There are programs that can switch your keyboard layout depending on what application's window is focused. |
You miss (entirely) the point of this issue. Imagine the situation: two keyboard layouts on the system - English and Russian, and user switches between them. In current situation no matter what bindings you specify, one of the layouts won't work. And that is frustrating. |
Then use a keyboard layout switcher. These scancodes are not portable and you'd need huge lookup tables. And in the end you'd bother everyone with weird crap like the 'Z' binding actually mapping to the 'Y' key on German keyboard. Everyone would have trouble finding the correct symbol to bind. I don't see how that's an advantage. |
They are portable to the extent we should care about (they will work on any PC with a keyboard). For implementation specifics, check SDL (or others) - they should have figured portability already, and SDL is widely used.
That's why I recommended it to be a user option. To not bother people with weird crap.
Advantage is for multi-layout users, that would like the same key to trigger shortcut regardless of what layout was current at the moment. |
Yes, and I've seen a very big bunch of dirty hacks.
Making it an option would require even more code. (You'd have to keep the code for old method and the new one.)
Just use a program that switches the keyboard layout based on the currently focused application window. This is much simpler, saves us a lot of trouble, and avoids bloat in mpv. |
Few more points for completeness:
Besides, this:
forces user to a specific workflow (per-window layout) which might not necessarily be what the user wants (in fact I prefer global layout). |
If someone wants to implement it (in a non-intrusive enough way) I wouldn't be opposed to it. But personally I don't want to work on this. Probably nothing will happen into this direction, so I'm closing this for now.
You could configure it to switch the layout for mpv, but not any other application. |
Checkout xkb-switch ! |
I would suggest leaving the issue open, so that people can find it. |
Having too many issues open is a problem for me, because I can't see which things need work and for which are resolved. |
I can reopen it, if you take offense. I won't work on this, though. |
There are three issues if we made the controls scancode-aware:
|
2 and 3 do not exist: input.conf will still use english letters. |
That IS the issue. When the doc says press Y but you have to press Z, that
|
As user i press button with both 'm' and 'ь', but software may interpret it as 'm', 'ь' or 'cycle mute', etc depending on circumstances. The idea is to make mpv layout agnostic. |
As end user, if the docs say press Y - why do you expect me to know that is
|
Adding: the only fix I can see is a layout picture, instead of saying "the But how to fit that in the manpage? |
Yep, it would be very strange if the manpage says "Key Y does action A" and "Z does action B", but then the actions are apparently swapped on the keyboard. And then the user tries the terminal, and it's acting as the manpage documents. That must be pretty confusing. Maybe we'd then get feature requests demanding to reverse-map terminal input as if it used the other layout... Anyway, I think MadFishTheOne suggested that the "layout independent" way shouldn't be default, just that there should be a switch to enable it. And again, I don't see how that's better than creating a Russian input.conf, which had to be there additionally to the English bindings to make sure it works with both keyboard layouts. |
As for Russian: why not just add Cyrillic bindings to our default config? Only issue: there are two common Cyrillic layouts. My wife uses the non As for reverse mapping on the terminal: forget it. Too complex due to So I suggest: for now let's make it an option, handled by each vo event In the future: make audio use a vo window too (then only non-window vo like As for the manpage: one idea might be to include ascii art of US layout, BTW: on windows, editing shortcuts are NOT layout independent, as opposed |
Like with |
RFC patch: Adds |
How does it complicate user configuration if only users who want this feature would enable it with Re. input handling complications not sure what you mean since this thread doesn't contain any specific argument against MadFishTheOne's patch, only some rather tangential discussions on what the flag name should be (here is another idea |
Because it's weird and hard to explain. Users would complain that it doesn't work in any intuitive way, and then complain that it's not "fixed".
It requires a huge lookup table, and his patch even duplicates it for combination with shift. The patch is also OSX-specific and every platform would need its own code for it. |
In fact, X11 provides no such lookup facility (X11's lowest "public" layer Anyway, is there an X11 or at least freedesktop way for per-window keyboard On Wed, Apr 6, 2016, 15:08 V. Lang [email protected] wrote:
|
It's not hard to explain: (with this option) any key press is recognized as though you had US English layout active even when your current layout is different.
Users don't even need to know how it works as long as it does.
~40 elements is a huge table? Hm, ok.
If it bothers you, just leave only OSX version since there is already a patch for it and you don't have to add any code by yourself. And if someone else prepares a patch for another OS. |
The platform where this is most complicated is X11. Incidentally the is Wayland any better there? On Wed, Apr 6, 2016, 16:36 Evgeny [email protected] wrote:
|
Wayland just uses libxkb. (Which we could also do under X btw. The core input we're using is basically ancient crap.) |
libxkbcommon could indeed help - it'd reduce the platform dependent stuff On Wed, Apr 6, 2016, 16:58 V. Lang [email protected] wrote:
|
This is still a problem |
Folks,
etc. This issue is very useful though, as other apps' devs can be referred here for their own version of this problem analysis and potential solutions. Thanks to all who contributing to the project! |
my workaround https://github.com/whoizit/mpv-351-workaround |
we still have this annoying issue with this in 2019 year you do not need to change input.conf, you need to interpret the English letters in input.conf as keycodes in mpv. There is no difference in the keycodes for the English, Russian, Italian, Franch, Germany, Finnish layouts, I tested. This is all the same codes 0-255, in the same places, "1" on the English layout means keycode 10, as well as in any others layouts. Letters and numbers and special characters, all have the same keycode on the keyboard, on different layouts. I only test in on So we can press any key on any layout and it will be have same keycode. Why not using it in mpv? I don't know C or C++. I rly hard to understand how it works inside mpv and make a patch. But I belive u can do it eazily. Seems like it's a simple issue for main developer. the whole world suffers because you have a single layout and don't understand all the pain as it is inconvenient and annoying to constantly switch to English layout every time. again, keycodes absolutely the same, why not load English latters in input.conf and operate with it as keycodes in mpv? |
GTK apps handle this issue correctly, and I don't see the reason why mpv on X11 cannot be the same. Here is simple workaround patch for current master edbc199: diff --git a/video/out/x11_common.c b/video/out/x11_common.c
index 467fa827ac..95ca38e598 100644
--- a/video/out/x11_common.c
+++ b/video/out/x11_common.c
@@ -1080,6 +1080,11 @@ void vo_x11_check_events(struct vo *vo)
int modifiers = get_mods(Event.xkey.state);
if (x11->no_autorepeat)
modifiers |= MP_KEY_STATE_DOWN;
+ keySym = XLookupKeysym(&Event.xkey, 0);
+ int mpkey = vo_x11_lookupkey(keySym);
+ if (mpkey)
+ mp_input_put_key(x11->input_ctx, mpkey | modifiers);
+ break;
if (x11->xic) {
Status status;
int len = Xutf8LookupString(x11->xic, &Event.xkey, buf,
Drawbacks:
These drawbacks can be fixed, but I think it would require more intrusive code changes, and I am not familiar with mpv code base. The idea is to check keybinding for keysym in the current active layout first, then (if no such binding) fallback to other layouts. Or, as a first approximation, check
No, e.g. keycode for us: |
It's ok, because I'm using an US layout by default.
We can let user to specify such file as a keymap |
No. At most someone could add an option that makes the backends send "scancodes" or whatever, but as I said a few years ago, I won't implement this myself. |
@wm4 I did not assume that you should implement this function yourself. Just shared my opinion. Perhaps I will make a merge request someday if it will bother me so much. |
@wm4 What's about your idea #351 (comment)? Is this #351 (comment) still relevant? Workaround from @whoizit include needed mapping. |
@norstbox hm maybe not, at least not by me. Also, the scancode idea (using raw scancodes, keysyms, or whatever in input.conf) would be the simplest and most flexible, just not most user friendly. |
workaround with mapping isn't working as it should, because the special characters are in other places. It is simple on_mpv_window_focus to set the EN layout and save the previous window's layout, then, when the focus changes, restore the previous state of the layout. This is works for me on i3-wm very well. https://gist.github.com/whoizit/ee6fe17673bae63f17cbdca5c611e9c0 |
Is there anyway to script keyboard layout change after launching MPV? That would be most convenient way to deal with it at least for Windows which has keyboard layout state for each program (basically). |
Guys, seems like implay respects non-english keyboard layouts. It uses libmpv. |
Update: could be a false alarm - I reset my keyboard settings, enabled one IME input for Japanese and "Japanese (QWERTY)" for English, and now the mpv inputs register even when the Japanese IME is the active language. |
I wonder why this issue was closed. It's still relevant. |
Shortcuts should not depend on current layout.
Layout-independent key codes can be obtained from:
The text was updated successfully, but these errors were encountered: