Skip to content

Commit

Permalink
defaults.js: support custom arg in mp.add_key_binding()
Browse files Browse the repository at this point in the history
  • Loading branch information
na-na-hi committed Nov 18, 2024
1 parent cdf3e44 commit 3444a0f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions player/javascript/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,10 @@ mp.get_osd_margins = function get_osd_margins() {
// {cb: fn, forced: bool, maybe input: str, repeatable: bool, complex: bool}
var binds = new_cache();

function dispatch_key_binding(name, state, key_name, key_text, scale) {
function dispatch_key_binding(name, state, key_name, key_text, scale, arg) {
var cb = binds[name] ? binds[name].cb : false;
if (cb) // "script-binding [<script_name>/]<name>" command was invoked
cb(state, key_name, key_text, scale);
cb(state, key_name, key_text, scale, arg);
}

var binds_tid = 0; // flush timer id. actual id's are always true-thy
Expand Down Expand Up @@ -314,7 +314,8 @@ function add_binding(forced, key, name, fn, opts) {
canceled: state[2] == "c",
key_name: key_name || undefined,
key_text: key_text || undefined,
scale: scale ? parseFloat(scale) : 1.0
scale: scale ? parseFloat(scale) : 1.0,
arg: arg
});
}
} else {
Expand All @@ -333,8 +334,11 @@ function add_binding(forced, key, name, fn, opts) {
}

var prefix = key_data.scalable ? "" : " nonscalable";
if (key)
if (key) {
key_data.input = key + prefix + " script-binding " + mp.script_name + "/" + name;
if (key_data.arg)
key_data.input = key_data.input + " " + key_data.arg;
}
binds[name] = key_data; // used by user and/or our (key) script-binding
sched_bindings_flush();
}
Expand Down

0 comments on commit 3444a0f

Please sign in to comment.