natural-harmonia-gropius / input-event

InputEvent.lua for mpv-player, enhanced input.conf with better, conflict-free, low-latency event mechanism.
MIT License
45 stars 5 forks source link

Document for `script-message bind/unbind` #6

Closed natural-harmonia-gropius closed 2 years ago

natural-harmonia-gropius commented 2 years ago

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)
natural-harmonia-gropius commented 2 years ago

fixed by https://github.com/Natural-Harmonia-Gropius/InputEvent/commit/18173db2296ba436fc62bee4d9130a1d6d00796f