mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-09-13 05:16:18 -07:00
fix(overlay): recognize prefixed SubMiner bindings
This commit is contained in:
@@ -88,3 +88,18 @@ test('SubMiner ownership excludes only its script commands and respects explicit
|
|||||||
['a', 'b', 'c', 'd'],
|
['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'],
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|||||||
@@ -17,6 +17,9 @@ const SPECIAL_KEYS: Record<string, string> = {
|
|||||||
ArrowDown: 'DOWN',
|
ArrowDown: 'DOWN',
|
||||||
};
|
};
|
||||||
const MPV_SPECIAL_KEYS = new Set(Object.values(SPECIAL_KEYS));
|
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
|
// Only single keyboard strokes are imported. Mouse input and sequences need
|
||||||
// their own focus and conflict rules before they can be forwarded safely.
|
// 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 === 'subminer' ||
|
||||||
(owner === undefined &&
|
(owner === undefined &&
|
||||||
/^(?:script-binding\s+["']?subminer\/|script-message\s+["']?subminer-)/.test(
|
/^(?:script-binding\s+["']?subminer\/|script-message\s+["']?subminer-)/.test(
|
||||||
entry.cmd.trimStart(),
|
entry.cmd.trimStart().replace(MPV_COMMAND_PREFIXES, ''),
|
||||||
));
|
));
|
||||||
const previous = bindings.get(key);
|
const previous = bindings.get(key);
|
||||||
// mpv's reported priority already ranks active non-weak bindings above weak
|
// mpv's reported priority already ranks active non-weak bindings above weak
|
||||||
|
|||||||
Reference in New Issue
Block a user