It is possible to set custom key bindings with libmpv C/C++?

169 views Asked by At

i'm using libmpv as video player backend for my Qt/c++ application and i can't find any way to set custom key bindings without an input.conf file or at least using lua scripting from the terminal so i can send it through mpv_command().

I looked for the way of MPV_EVENTS but i only was able to receive mouse events.
I tried using Qt events but of course, if the user touch the video area, the Qt widget can't keep the focus because the embedded mpv is in fact another window.
I couldn't find in the documentation an argument to set custom key bindings from terminal.
I couldn't find anything related on google for that!.
I don't want to provide and maintain a whole custom mpv source code with the application just for a custom key binding.

In the official documentation there's nothing related with that in the section of libmpv or command line arguments. I only found an approach for plugins made with Lua "mp.add_key_binding()" but nothing with pure c/c++ libmpv library.

Is there's something i'm missing or for now the only way to do that is modifying the mpv source code?
Sorry if i'm not clear enough, i not an expert speaking English but thank for your patience!.

1

There are 1 answers

2
Not a real meerkat On

If you are simply embedding the native mpv window into your own window, there's not much you can do. input.conf or lua scripting are the ways to go.

If you want true customization possibilities though, what you want to do is use the render api instead, documented in render.h.

You will need to keep your own OpenGL context and use the API functions to render into it. Then you control the window, and can do whatever you want with it. How to do that exactly is too large of a scope for this answer, but the documentation on the header explains it well.

Since this is only a rendering API, there will be no default key bindings. Or any input functionality, really. You will have to implement it all yourself. Again, how to do that exactly with OpenGL + Qt is way too big of a scope for this answer.