natural-harmonia-gropius / input-event Goto Github PK
View Code? Open in Web Editor NEWInputEvent.lua for mpv-player, enhanced input.conf with better, conflict-free, low-latency event mechanism.
License: MIT License
InputEvent.lua for mpv-player, enhanced input.conf with better, conflict-free, low-latency event mechanism.
License: MIT License
Need to investigate how mpv distinguishes repeatable
In this case, both MBTN_LEFT double_click
in json conf and MBTN_LEFT_DBL
in input.conf have taken effect, double click cycle fullscreen twice.
# inputevent.conf
configs=~~/inputevent.json
[
{
"key": "MBTN_LEFT",
"on": {
"click": "cycle pause",
"double_click": "cycle fullscreen"
}
},
{
"key": "MBTN_LEFT_DBL",
"on": {
}
}
]
# input.conf
MBTN_LEFT cycle pause
MBTN_LEFT_DBL cycle fullscreen
In general, json conf overrides input.conf for the same keys, but the MBTN_LEFT_DBL
can't be ignored.
Just like Conditional auto profiles
for input key: bind keys only when conditions are met.
Example: When only pause and the file is played to the end, the → button is bound to "next file"
For same key, events will be merged with existing events.
I dislike this, shouldn't pollute to existing binds. every source should make changes in its own field.
bind_from_script_message
mp.commandv('script-message-to', 'inputevent', 'bind', field, key, on)
configs="input.conf,~~/test.conf,~~/test.json,example.field,example2.field"
update:
"field" should have higher priority than "options.configs" and modify configs would break hot-reload via auto-profile.
This script is an actual game-changer. Thank you for sharing it. I was just wondering if it is possible to reduce the delay on the click commands as it is quite noticeable. Every other command (double_click, release, and so on) works as intended with no delay, from what I can see. Thanks again for the awesome script.
This snippet looks ugly, needs better practice.
https://github.com/Natural-Harmonia-Gropius/InputEvent/blob/6c4b6f7c6677cb0e55fd8dae9ad438428909a5f7/inputevent.lua#L142-L146
Maybe do something about event_pattern
.
Note: Needs to be an ordered list, no key-value pairs.
https://github.com/Natural-Harmonia-Gropius/InputEvent/blob/6c4b6f7c6677cb0e55fd8dae9ad438428909a5f7/inputevent.lua#L5-L11
example.lua
local utils = require("mp.utils")
local key = "c"
local on = {
click = "show-text click",
penta_click = "show-text penta-click",
quatra_click = "show-text quatra-click",
double_click = "show-text double-click",
triple_click = "show-text triple-click",
press = "show-text pressed",
release = "show-text released",
}
function bind()
local json, err = utils.format_json(on)
mp.commandv('script-message-to', 'inputevent', 'bind', key, json)
end
function unbind()
mp.commandv('script-message-to', 'inputevent', 'unbind', key)
end
mp.add_forced_key_binding("z", "test-z", bind)
mp.add_forced_key_binding("x", "test-x", unbind)
https://github.com/Natural-Harmonia-Gropius/InputEvent#press-to-speedup-release-to-restore
I've been thinking about it for a while, and it looks like the step acceleration in evafast can be done like this.
We can do more in command of repeat, like max_speed. If #4 could be done.
But as the title, repeat before press can cause a bad experience.
SPACE cycle pause #@click
SPACE no-osd set speed 1; set pause no #@press
SPACE ignore #@release
SPACE no-osd add speed 0.1 #@repeat
dyphire/mpv-config#11 (reply in thread)
Submit a PR to uosc
or
Maintain own menu using uosc's menu api
These are the ones I can think of at the moment.
MBTN_LEFT #@double-click
fullscrren without pauseMBTN_LEFT_DBL
*_DBL
need to be set to ignore
SPACE #@press
to speedupRIGHT #@press
fast forwardLEFT #@press
fast rewindDOWN #@press
set volume 0UP #@press
set volume 100CTRL #@press
to flash uosc uiBTN ignore #@release
= auto-restore
needs to be clarifiedMBTN_RIGHT #@press
mouse gestures start release
mouse gestures end100ms not always well worked, states based approach should no more race issue.
and
mpv.conf
[background]
profile-cond=not focused and get("current-tracks/video/albumart") == false
profile-restore=copy-equal
script-opts-append=inputevent-configs=input.conf,~~/input.noleft.conf
pause
input.noleft.conf
MBTN_LEFT ignore #@click
部分osc或gui前端同样使用input.conf中的#注释来构建右键菜单,此时有可能使得InputEvent或osc/gui一方不能按预期工作(虽然目前没有),或者是gui支持可视化input.conf时脚本的重复绑定可能会使之产生问题。
可以考虑支持通过配置文件script-opts\InputEvent.conf
来设置键位绑定设置是从input.conf中读取,还是从自定义的其他文件中读取
这个“自定义的其他文件”,它的语法可以和input.conf一致,使代码可以复用;当从自定义文件读取时,可能出现click重复绑定的问题,希望可以允许设定是优先input.conf中的(脚本仍会读取input.conf但忽略其中注释部分的InputEvent设置,仅用于设定click),还是优先自定义配置的(即覆盖input.conf中的绑定),也可以考虑直接忽略自定义配置里的click绑定。可以结合 #20 (comment) 的设想添加优先级 从配置分离来考虑,应该是尊重input.conf中的绑定,但是不从那里读取脚本扩展的事件绑定,视之为最低优先级的click绑定(当没有实现 #20 时,则应该是用input.conf覆盖掉外部配置的click绑定)
I want to replace binding.on[event-ignore]
to binding:ignore(event, timeout)
Before this I thought mpv used a real template literals, the syntax of property-expansion is more complicated.
And more importantly, security is difficult to guarantee.
Document this.
Can make property be the value of another.
set target-trc ${video-params/gamma}
Ternary operators can be used. Can't.
set target-trc ${?video-params/gamma==pq:hlg}${!video-params/gamma==pq:bt.1886}
Need to prevent injection.
filename="example; set unsafe true; play another.mp4"
set title ${title}
set title example; set unsafe true; play another.mp4
https://github.com/CogentRedTester/mpv-scroll-list
I use chapter-list.lua
Scroll wheel and UP, DOWN were used to scroll among chapters.
UP, Down and Scroll Wheel are now just changing volume.
Would it be possible to add an ability to split a single key into two different actions, depending on how long it's pressed for? Similar to how mpv-pointer-event does it for mouse inputs.
continue #20
script-message not available in mpv.conf, But this should work.
mpv.conf
[fullscreen]
profile-cond=fullscreen
profile-restore=copy-equal
script-opts-add=inputevent-bind="KEY COMMAND @click"
script-opts-add=inputevent-unbind="KEY"
I have the following in input.conf
:
s script-binding uosc/subtitles #! Subtitles
TAB script-binding uosc/toggle-ui #@press
TAB script-binding uosc/toggle-ui #@release
If I keep pressing TAB
and then press s
(without releasing TAB
), then press either s
again or ESC
to close uosc/subtitles
window and finally release TAB
, then everything is inverted: uosc ui is permanently displayed and is hidden if I keep TAB
pressed.
Expected behavior in this case: when releasing TAB
, uosc UI isn't displayed because TAB
isn't pressed.
It also occurs when triggering other commands like script-binding quality_menu/audio_formats_toggle
or script-binding quality_menu/video_formats_toggle
.
Video of the issue, although the keys I'm pressing aren't displayed on the screen so it's not very useful:
Thoughts?
input.conf
, use either:TAB script-binding uosc/toggle-ui #@press
TAB script-binding uosc/toggle-ui #@release
# or
TAB script-message-to uosc toggle-elements timeline #@press
TAB script-message-to uosc toggle-elements timeline #@release
TAB
is now toggled when single pressing TAB
Is this expected?
When drag started the last down
should be remove.
Another question, How do I listen to this event?
-- InputEvent
-- https://github.com/Natural-Harmonia-Gropius/InputEvent
TODO
input-doubleclick-time
300 make people feel a little sluggish, 200 more comfortable.no-input-default-bindings
mp.add_forced_key_binding
https://github.com/Natural-Harmonia-Gropius/InputEvent#handling-raw-press
It's easy to do, but I want someone to prove to me that it's of practical use before I do it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.