fix(overlay): recognize prefixed SubMiner bindings

This commit is contained in:
2026-09-11 04:01:12 -07:00
parent e1a0bf4db0
commit 8057e9f757
2 changed files with 19 additions and 1 deletions
+15
View File
@@ -88,3 +88,18 @@ test('SubMiner ownership excludes only its script commands and respects explicit
['a', 'b', 'c', 'd'],
);
});
test('SubMiner ownership recognizes leading mpv prefixes without matching command arguments', () => {
assert.deepEqual(
parseMpvInputBindingKeys([
{ key: 'a', cmd: 'no-osd script-binding subminer/action', priority: 1 },
{ key: 'b', cmd: ' repeatable\tasync raw script-binding "subminer/action"', priority: 1 },
{ key: 'c', cmd: 'osd-msg-bar sync script-message subminer-toggle', priority: 1 },
{ key: 'd', cmd: 'no-osd show-text "script-binding subminer/action"', priority: 1 },
{ key: 'e', cmd: 'show-text "no-osd script-binding subminer/action"', priority: 1 },
{ key: 'f', cmd: 'no-osd script-binding other/action', priority: 1 },
{ key: 'g', cmd: 'no-osd script-binding subminer/action', owner: 'other', priority: 1 },
]),
['d', 'e', 'f', 'g'],
);
});
+4 -1
View File
@@ -17,6 +17,9 @@ const SPECIAL_KEYS: Record<string, string> = {
ArrowDown: 'DOWN',
};
const MPV_SPECIAL_KEYS = new Set(Object.values(SPECIAL_KEYS));
// Leading command flags accepted by mpv's input/cmd.c, before the command name.
const MPV_COMMAND_PREFIXES =
/^(?:(?:no-osd|osd-bar|osd-msg|osd-msg-bar|osd-auto|expand-properties|raw|repeatable|nonrepeatable|nonscalable|async|sync)\s+)+/;
// Only single keyboard strokes are imported. Mouse input and sequences need
// their own focus and conflict rules before they can be forwarded safely.
@@ -81,7 +84,7 @@ export function parseMpvInputBindingKeys(value: unknown): string[] {
owner === 'subminer' ||
(owner === undefined &&
/^(?:script-binding\s+["']?subminer\/|script-message\s+["']?subminer-)/.test(
entry.cmd.trimStart(),
entry.cmd.trimStart().replace(MPV_COMMAND_PREFIXES, ''),
));
const previous = bindings.get(key);
// mpv's reported priority already ranks active non-weak bindings above weak