mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-10-26 23:35:17 -07:00
feat(overlay): forward mpv mouse button and wheel bindings (#279)
This commit is contained in:
1 parent
9fadbc8cdd
commit
9e79fa93c2
18 files changed
+500
-76
No files matched your search
@@ -34,12 +34,16 @@ type DraftBinding = {
|
||||
};
|
||||
|
||||
const MODIFIER_ORDER: SessionKeyModifier[] = ['ctrl', 'alt', 'shift', 'meta'];
|
||||
const MPV_MOUSE_BUTTON_CODES = new Set([
|
||||
const MPV_MOUSE_CODES = new Set([
|
||||
'MBTN_LEFT',
|
||||
'MBTN_MID',
|
||||
'MBTN_RIGHT',
|
||||
'MBTN_BACK',
|
||||
'MBTN_FORWARD',
|
||||
'WHEEL_UP',
|
||||
'WHEEL_DOWN',
|
||||
'WHEEL_LEFT',
|
||||
'WHEEL_RIGHT',
|
||||
]);
|
||||
|
||||
const SESSION_SHORTCUT_ACTIONS: Array<{
|
||||
@@ -82,7 +86,7 @@ function isValidCommandEntry(value: unknown): value is string | number {
|
||||
|
||||
function normalizeCodeToken(
|
||||
token: string,
|
||||
options: { allowMouseButtons?: boolean } = {},
|
||||
options: { allowMouseInput?: boolean } = {},
|
||||
): string | null {
|
||||
const normalized = token.trim();
|
||||
if (!normalized) return null;
|
||||
@@ -93,9 +97,9 @@ function normalizeCodeToken(
|
||||
.map((letter) => `Key${letter.toUpperCase()}`)
|
||||
.join('-');
|
||||
}
|
||||
if (options.allowMouseButtons === true) {
|
||||
if (options.allowMouseInput === true) {
|
||||
const normalizedMouse = normalized.toUpperCase();
|
||||
if (MPV_MOUSE_BUTTON_CODES.has(normalizedMouse)) {
|
||||
if (MPV_MOUSE_CODES.has(normalizedMouse)) {
|
||||
return normalizedMouse;
|
||||
}
|
||||
}
|
||||
@@ -270,7 +274,7 @@ export function parseSessionBindingKey(
|
||||
};
|
||||
}
|
||||
|
||||
const code = normalizeCodeToken(keyToken, { allowMouseButtons: true });
|
||||
const code = normalizeCodeToken(keyToken, { allowMouseInput: true });
|
||||
if (!code) {
|
||||
return {
|
||||
key: null,
|
||||
|
||||
Reference in new issue
Block a user