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 layout breaks hotkeys #398

Closed
A-tG opened this issue Apr 2, 2022 · 17 comments
Closed

Keyboard layout breaks hotkeys #398

A-tG opened this issue Apr 2, 2022 · 17 comments

Comments

@A-tG
Copy link

A-tG commented Apr 2, 2022

version 5.7.0.0 from MS Store
Windows 10 21H1

If mpv is launched while non-English keyboard layout is active (Russian layout in my case) it will not respond to keys (like a, z, ~), even after switching to English layout. Only restart helps.

@A-tG A-tG added the bug label Apr 2, 2022
@stax76
Copy link
Collaborator

stax76 commented Apr 2, 2022

Do you know an open source application not having this problem? If so, I can look in the source code for a solution, or maybe it's currently not possible doing something better.

@A-tG
Copy link
Author

A-tG commented Apr 2, 2022

To be clear if it launched first with English active layout, it works just fine with Russian layout too.
A few open source projects that seems dont have problems with layout:
https://github.com/JasonStein/Notepads
https://github.com/files-community/Files
and cpp
https://github.com/KDE/krita

@stax76
Copy link
Collaborator

stax76 commented Apr 3, 2022

I looked and didn't find any special keyboard code in Files and Notepads, both are likely UWP based, which could make a difference.

However, I switched the keyboard language using ALT+SHIFT and also using WIN+SPACE while mpv.net is active, and mpv.net reacted to the change, so here it is working correctly, this is Windows 11.

Unless another developer helps, I really don't know what to do.

Possibly related:

#319

mpv-player/mpv#9168

mpv-player/mpv#351

@A-tG
Copy link
Author

A-tG commented Apr 4, 2022

Once again it's not about switching keyboard language, it' about program being launched with specific keyboard language:

The problem I described:

  1. Russian keyboard language is selected (or probably any Cyrillic language)
  2. mpvnet is launched
  3. I press ` to open console (or any other letter key: a, i) - nothing happens
  4. I switch keyboard language to English with any method (win + space, alt + shift, or by clicking the icon in taskbar)
  5. repeat 3 - nothing happens
  6. I have to exit the program

What is working:

  1. English keyboard language is selected
  2. mpvnet is launched
  3. I press ` - console is opened, every key is working
  4. I switch keyboard language to Russian
  5. repeat 3 - everything is working

Something breaking at program start and I'm not sure why. Is it have to be this ways because of some Win32 inconveniences?

@stax76
Copy link
Collaborator

stax76 commented Apr 6, 2022

I can now reproduce it, but haven't yet found a solution.

@stax76
Copy link
Collaborator

stax76 commented Apr 6, 2022

Difficult issue it seems, it might take a while until I find a solution.

@stax76
Copy link
Collaborator

stax76 commented Apr 7, 2022

Unfortunately, I cannot find the reason, so I have to ask mpv developers.

@A-tG
Copy link
Author

A-tG commented Apr 7, 2022

If it helps when I launch mpvnet from command line, I see

[input] No key binding found for key 'ё'.

when I press ` ('ё' in Russian layout) so its like getting stuck with Russian layout if launched with it.
I'll also check if MPV have same problem.

@stax76
Copy link
Collaborator

stax76 commented Apr 7, 2022

I've already checked that, mpv is not having this issue.

@stax76
Copy link
Collaborator

stax76 commented Apr 7, 2022

I made a support request on the mpv tracker, waiting for help now.

@stax76
Copy link
Collaborator

stax76 commented Apr 8, 2022

It's finally making progress.

@stax76 stax76 closed this as completed in 309ddbf Apr 8, 2022
@stax76
Copy link
Collaborator

stax76 commented Apr 8, 2022

It will be fixed in the next build.

@stax76
Copy link
Collaborator

stax76 commented Apr 9, 2022

Find a hotfix to download here:
mpvnet-hotfix.zip

@stax76 stax76 reopened this Apr 9, 2022
@A-tG
Copy link
Author

A-tG commented Apr 9, 2022

Seems working. Though it would be nice to have ability to handle hotkeys (as English layout) regardless of current layout, if it even possible to implement.

@A-tG A-tG closed this as completed Apr 9, 2022
@stax76
Copy link
Collaborator

stax76 commented Apr 9, 2022

I don't know if there is an easy way, only changing the layout, for instance with ActivateKeyboardLayout.

There is a property input-bindings which can get you all bindings in JSON format. That could be analyzed and used to generate additional bindings with non-western characters, for that there is an input command keybind.

Relevant code is here:

https://github.com/stax76/mpv.net/blob/master/src/WPF/LearnWindow.xaml.cs

Another way might be installing a keyboard hook, see Win32 keyboard hooks.

@stax76
Copy link
Collaborator

stax76 commented Apr 9, 2022

I can try if it's possible to enforce a particular layout, if yes provide an option.

@stax76 stax76 reopened this Apr 9, 2022
@stax76
Copy link
Collaborator

stax76 commented Apr 10, 2022

I tried the Win32 function ActivateKeyboardLayout, and it changed the system layout and not only the process layout, that means there might not be an easy way to achieve your goal, it can only be done with a lot of work I guess.

Maybe ask somewhere like stackoverflow if you want to be sure, maybe somebody with experience in this area finds the question and answers it.

@stax76 stax76 closed this as completed Apr 10, 2022
@stax76 stax76 mentioned this issue Oct 2, 2023
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

2 participants