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

Hotkeys are keyboard layout dependent #45

Closed
K900 opened this issue Mar 16, 2013 · 18 comments
Closed

Hotkeys are keyboard layout dependent #45

K900 opened this issue Mar 16, 2013 · 18 comments

Comments

@K900
Copy link

K900 commented Mar 16, 2013

For example, pressing 'F' when a Russian keyboard layout is used will result in 'А' (Cyrillic), and mpv will not accept that as a hotkey.

@ghost
Copy link

ghost commented Mar 16, 2013

Russian keys work fine (edit: or they should, never tested this, but unicode input works with other keyboard layouts), as long as you remap them in input.conf. Key bindings are text based: they follow what would appear if you typed into a text field, and they don't go by keycode or physical position or whatever.

In theory, we could add the missing russian characters to input.conf to make sure that it just works even when using a russian keyboard layout. (Yeah, that'd require duplicating almost every keybind entry.)

Why not just use an ASCII keyboard layout? I don't know how russian keyboards work, but not being able to type ASCII must be extremely annoying, especially when typing English text, using the command line, etc.

@K900
Copy link
Author

K900 commented Mar 16, 2013

I do use an ASCII layout, but I have to switch between Russian and ASCII (US English for me). What I was talking about is maybe allowing scancodes or some solution that is completely keyboard layout agnostic.

@ghost
Copy link

ghost commented Mar 16, 2013

In general, it's not possible to be perfectly keyboard layout independent, because, well, different keyboard layouts might not even have the same physical keys.

I don't really get why using scancodes would be simpler than just adding additional cyrillic bindings. The scancodes would most likely not work as expected on arbitrary other keyboards (and even then, they would map to arbitrary keys) - so it'd still be something every user has to do on his own.

I wonder if there's a way to force a different keyboard layout for a specific window? Or maybe it would be possible to run some sort of daemon, which switches the keyboard layout based on the foreground window?

@K900
Copy link
Author

K900 commented Mar 16, 2013

Scancodes should work on any keyboard, or at least any HID compliant one.

@divVerent
Copy link
Member

On Sa., 16. Mär. 2013 18:02:00 CET, wm4 notifications@github.com wrote:

I wonder if there's a way to force a different keyboard layout for a
specific window? Or maybe it would be possible to run some sort of
daemon, which switches the keyboard layout based on the foreground
window?

I know at least GNOME can do this, as well as Windows.

However, in GNOME's case it may be necessary for the application to support it. Have not tried it it works for mpv.

@ghost
Copy link

ghost commented Mar 16, 2013

Looking at the code, it would be quite annoying to support both the current key binding scheme and binding via scancodes at the same time. Though it might be possible to do.

Scancodes should work on any keyboard, or at least any HID compliant one.

Applications only get "keycodes" on X (additional to keysyms, which have been translated by the keyboard layout). They are defined to be in the range 8-255, and otherwise nothing is said about their value. I don't know if they map to what HID defines (maybe?), or if this could even be made portable to Windows and OSX.

However, in GNOME's case it may be necessary for the application to support it.

Do you know more about this mechanism, maybe what it is called?

@ghost
Copy link

ghost commented Mar 16, 2013

I also found this: https://github.com/qnikst/kbdd/

Apparently it remembers keyboard layouts per-window. Changing the window switches the keyboard layout. And it's independent from gnome. (I haven't actually tried it.)

@ghost
Copy link

ghost commented Mar 18, 2013

K900, does any of this help?

@K900
Copy link
Author

K900 commented Mar 20, 2013

Sorry for lagging behind, I ended up just adding mappings for Cyrillic
chars and doing some KWin magic to make sure IMEs stay off with mpv. Still
this is a thing that should be considered, IMHO, because setting the
hotkeys twice (or more) is tedious and not immediately obvious. I'll try to
put together a scancode based patch in a few days/weeks/when I have time.

2013/3/19 wm4 notifications@github.com

K900, does any of this help?


Reply to this email directly or view it on GitHubhttps://github.com//issues/45#issuecomment-15088714
.

@ghost
Copy link

ghost commented Mar 20, 2013

I'll try to put together a scancode based patch in a few days/weeks/when I have time.

Looking at it myself, it didn't seem easy (you'd have to drag around both keycode and scancode or so), but I'm looking forward to your patch.

@K900
Copy link
Author

K900 commented Mar 20, 2013

Yeah, that's the main problem I've run into. Also had some fun with trying
to get mpv to at least build with the Android NDK, but it seems a no-go for
now.

2013/3/20 wm4 notifications@github.com

I'll try to put together a scancode based patch in a few days/weeks/when I
have time.

Looking at it myself, it didn't seem easy (you'd have to drag around both
keycode and scancode or so), but I'm looking forward to your patch.


Reply to this email directly or view it on GitHubhttps://github.com//issues/45#issuecomment-15195722
.

@ghost
Copy link

ghost commented Mar 20, 2013

Also had some fun with trying
to get mpv to at least build with the Android NDK, but it seems a no-go for
now.

Since I don't have any Android device, I never tested if it works on Android. Since Android's libc is completely broken from what I hear, I can see problems cropping up. Also, it's likely that the only VO that works on Android is vo_sdl (requires SDL 1.3/2.0).

@K900
Copy link
Author

K900 commented Mar 20, 2013

Bionic isn't really broken, it doesn't have some stuff glibc has, but
someone could get mplayer running on it without too much problems a while
ago, and I haven't run into too many breakages right now. The main problem
is going to be the UI though.

2013/3/20 wm4 notifications@github.com

Also had some fun with trying
to get mpv to at least build with the Android NDK, but it seems a no-go for
now.

Since I don't have any Android device, I never tested if it works on
Android. Since Android's libc is completely broken from what I hear, I can
see problems cropping up. Also, it's likely that the only VO that works on
Android is vo_sdl (requires SDL 1.3/2.0).


Reply to this email directly or view it on GitHubhttps://github.com//issues/45#issuecomment-15196587
.

@ghost
Copy link

ghost commented Apr 1, 2013

Ping?

@K900
Copy link
Author

K900 commented Apr 2, 2013

Ouch. I think the spam filter ate the previous email. I've set it up with
another map for Cyrillic characters for now, so that (obviously) works.
Haven't worked on the patch at all, don't have any free time now...
02.04.2013 2:36 пользователь "wm4" notifications@github.com написал:

Ping?


Reply to this email directly or view it on GitHubhttps://github.com//issues/45#issuecomment-15741630
.

@ghost
Copy link

ghost commented Apr 27, 2013

Closing due to inactivity. Again, it's not generally possible to be independent of keyboard layout, no matter what you do it will always cuse inconveniences in one way or another.

@pbaykalov
Copy link

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).

@barsikus007
Copy link

barsikus007 commented Jan 15, 2024

I made workaround for my usecase
This is python script to patch default input.conf values

input_bindings = """"""  # paste here from https://github.com/mpv-player/mpv/blob/master/etc/input.conf

eng = """~QWERTYUIOP{}ASDFGHJKL:"ZXCVBNM<>?`qwertyuiop[]asdfghjkl;"zxcvbnm,./"""
rus = """ЁЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ,ёйцукенгшщзхъфывапролджэячсмитьбю."""
for line in input_bindings.splitlines():
    if not line.startswith("#"):
        continue
    keybind, *rest = line.split(" ", 1)
    if keybind == "#":
        continue
    keybind = keybind[1:]
    keys = keybind.split("+")
    new_keys = [key.translate(key.maketrans(eng, rus)) if len(key) == 1 else key for key in keys]
    if new_keys == keys:
        continue
    print("+".join(new_keys), next(iter(rest), ""))

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

No branches or pull requests

4 participants