mirror of
https://github.com/AkiChase/scrcpy-mask
synced 2025-02-21 22:22:18 +08:00
feat(hotkey): add swipe shortcut
This commit is contained in:
parent
3547e9e17a
commit
996bc2517b
@ -17,6 +17,7 @@ import {
|
|||||||
KeyObservation,
|
KeyObservation,
|
||||||
KeySight,
|
KeySight,
|
||||||
KeySteeringWheel,
|
KeySteeringWheel,
|
||||||
|
KeySwipe,
|
||||||
KeyTap,
|
KeyTap,
|
||||||
KeyTriggerWhenDoublePressedSkill,
|
KeyTriggerWhenDoublePressedSkill,
|
||||||
KeyTriggerWhenPressedSkill,
|
KeyTriggerWhenPressedSkill,
|
||||||
@ -948,6 +949,37 @@ function addSightShortcuts(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addSwipeShortcuts(
|
||||||
|
key: string,
|
||||||
|
relativeSize: { w: number; h: number },
|
||||||
|
// pos relative to the mask
|
||||||
|
pos: { x: number; y: number }[],
|
||||||
|
pointerId: number,
|
||||||
|
intervalBetweenPos: number
|
||||||
|
) {
|
||||||
|
for (const posObj of pos) {
|
||||||
|
posObj.x = Math.round((posObj.x / relativeSize.w) * store.screenSizeW);
|
||||||
|
posObj.y = Math.round((posObj.y / relativeSize.h) * store.screenSizeH);
|
||||||
|
}
|
||||||
|
addShortcut(
|
||||||
|
key,
|
||||||
|
async () => {
|
||||||
|
await swipe({
|
||||||
|
action: SwipeAction.Default,
|
||||||
|
pointerId,
|
||||||
|
screen: {
|
||||||
|
w: store.screenSizeW,
|
||||||
|
h: store.screenSizeH,
|
||||||
|
},
|
||||||
|
pos,
|
||||||
|
intervalBetweenPos,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
undefined,
|
||||||
|
undefined
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function createMouseRangeBox(): HTMLElement {
|
function createMouseRangeBox(): HTMLElement {
|
||||||
const box = document.createElement("div");
|
const box = document.createElement("div");
|
||||||
box.id = "mouseRangeBox";
|
box.id = "mouseRangeBox";
|
||||||
@ -1387,6 +1419,16 @@ function applyKeyMappingConfigShortcuts(
|
|||||||
item.pointerId
|
item.pointerId
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
case "Swipe":
|
||||||
|
asType<KeySwipe>(item);
|
||||||
|
addSwipeShortcuts(
|
||||||
|
item.key,
|
||||||
|
relativeSize,
|
||||||
|
item.pos,
|
||||||
|
item.pointerId,
|
||||||
|
item.intervalBetweenPos
|
||||||
|
);
|
||||||
|
break;
|
||||||
case "TriggerWhenPressedSkill":
|
case "TriggerWhenPressedSkill":
|
||||||
asType<KeyTriggerWhenPressedSkill>(item);
|
asType<KeyTriggerWhenPressedSkill>(item);
|
||||||
addTriggerWhenPressedSkillShortcuts(
|
addTriggerWhenPressedSkillShortcuts(
|
||||||
|
@ -65,6 +65,14 @@ export interface KeyTap extends KeyBase {
|
|||||||
time: number;
|
time: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface KeySwipe extends KeyBase {
|
||||||
|
type: "Swipe";
|
||||||
|
pointerId: number;
|
||||||
|
key: string;
|
||||||
|
pos: { x: number; y: number }[];
|
||||||
|
intervalBetweenPos: number;
|
||||||
|
}
|
||||||
|
|
||||||
export type KeyMacroList = Array<{
|
export type KeyMacroList = Array<{
|
||||||
type: "touch" | "sleep" | "swipe" | "key-input-mode";
|
type: "touch" | "sleep" | "swipe" | "key-input-mode";
|
||||||
args: any[];
|
args: any[];
|
||||||
@ -106,6 +114,7 @@ export type KeyMapping =
|
|||||||
| KeyMacro
|
| KeyMacro
|
||||||
| KeyCancelSkill
|
| KeyCancelSkill
|
||||||
| KeyTap
|
| KeyTap
|
||||||
|
| KeySwipe
|
||||||
| KeySight
|
| KeySight
|
||||||
| KeyFire;
|
| KeyFire;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user