Git Product home page Git Product logo

input-event's Introduction

You said you have a dream… That dream… Make it come true

GitHub Stats Most Used Languages

input-event's People

Contributors

hill-98 avatar natural-harmonia-gropius avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

input-event's Issues

[Question] How to write ignore statement in json conf

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.

Conditional auto keybind

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"

Re-think "How to integrate with other scripts"

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.

  • add 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.

Delay on Click Commands

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.

Document for `script-message bind/unbind`

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)

Shouldn't have repeat before press.

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

Document for usage

These are the ones I can think of at the moment.

  • MBTN_LEFT #@double-click fullscrren without pause
    DOC MBTN_LEFT_DBL
  • *_DBL need to be set to ignore
  • SPACE #@press to speedup
  • RIGHT #@press fast forward
  • LEFT #@press fast rewind
  • DOWN #@press set volume 0
  • UP #@press set volume 100
  • CTRL #@press to flash uosc ui
  • BTN ignore #@release = auto-restore needs to be clarified
  • Can't do this now MBTN_RIGHT #@press mouse gestures start release mouse gestures end
    christoph-heinrich/mpv-pointer-event#1

Remove "Left-click will be ignored for a short time after the focus window"

100ms not always well worked, states based approach should no more race issue.

https://github.com/natural-harmonia-gropius/input-event/blob/239b2fc9c7486b9874e592bb8a95408d17e3c663/inputevent.lua#L445C1-L449C5

and

https://github.com/natural-harmonia-gropius/input-event?tab=readme-ov-file#left-click-will-be-ignored-for-a-short-time-after-the-focus-window

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绑定)

Support for template strings in command.

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.

    1. filename="example; set unsafe true; play another.mp4"
    2. set title ${title}
    3. set title example; set unsafe true; play another.mp4

Inline bind/unbind

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"

Weird behavior with `#@press` when triggering another command at the same time

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:

1.mp4

Thoughts?

press/release binding for uosc overwritten?

  1. In 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
  1. Press and release: works as expected
  2. Press once (can happen by mistake)
  3. Try to press/release again: no longer works, the command bound to TAB is now toggled when single pressing TAB

Is this expected?

Add a file header

-- InputEvent
-- https://github.com/Natural-Harmonia-Gropius/InputEvent

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.