mirror of
https://github.com/AkiChase/scrcpy-mask
synced 2024-11-09 09:41:17 +08:00
feat(hotkey): add swipe shortcut
This commit is contained in:
parent
3547e9e17a
commit
996bc2517b
@ -17,6 +17,7 @@ import {
|
||||
KeyObservation,
|
||||
KeySight,
|
||||
KeySteeringWheel,
|
||||
KeySwipe,
|
||||
KeyTap,
|
||||
KeyTriggerWhenDoublePressedSkill,
|
||||
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 {
|
||||
const box = document.createElement("div");
|
||||
box.id = "mouseRangeBox";
|
||||
@ -1387,6 +1419,16 @@ function applyKeyMappingConfigShortcuts(
|
||||
item.pointerId
|
||||
);
|
||||
break;
|
||||
case "Swipe":
|
||||
asType<KeySwipe>(item);
|
||||
addSwipeShortcuts(
|
||||
item.key,
|
||||
relativeSize,
|
||||
item.pos,
|
||||
item.pointerId,
|
||||
item.intervalBetweenPos
|
||||
);
|
||||
break;
|
||||
case "TriggerWhenPressedSkill":
|
||||
asType<KeyTriggerWhenPressedSkill>(item);
|
||||
addTriggerWhenPressedSkillShortcuts(
|
||||
|
@ -65,6 +65,14 @@ export interface KeyTap extends KeyBase {
|
||||
time: number;
|
||||
}
|
||||
|
||||
export interface KeySwipe extends KeyBase {
|
||||
type: "Swipe";
|
||||
pointerId: number;
|
||||
key: string;
|
||||
pos: { x: number; y: number }[];
|
||||
intervalBetweenPos: number;
|
||||
}
|
||||
|
||||
export type KeyMacroList = Array<{
|
||||
type: "touch" | "sleep" | "swipe" | "key-input-mode";
|
||||
args: any[];
|
||||
@ -106,6 +114,7 @@ export type KeyMapping =
|
||||
| KeyMacro
|
||||
| KeyCancelSkill
|
||||
| KeyTap
|
||||
| KeySwipe
|
||||
| KeySight
|
||||
| KeyFire;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user