mirror of
https://github.com/AkiChase/scrcpy-mask
synced 2025-02-22 23:12:16 +08:00
fix(hotkey): up doublepress skill button when another skill button pressed
This commit is contained in:
parent
14d1d75eff
commit
6bcaca105f
@ -308,19 +308,15 @@ function addTriggerWhenPressedSkillShortcuts(
|
|||||||
rangeOrTime: number,
|
rangeOrTime: number,
|
||||||
pointerId: number
|
pointerId: number
|
||||||
) {
|
) {
|
||||||
if (directional) {
|
|
||||||
posX = Math.round((posX / relativeSize.w) * screenSizeW);
|
posX = Math.round((posX / relativeSize.w) * screenSizeW);
|
||||||
posY = Math.round((posY / relativeSize.h) * screenSizeH);
|
posY = Math.round((posY / relativeSize.h) * screenSizeH);
|
||||||
|
if (directional) {
|
||||||
addShortcut(
|
addShortcut(
|
||||||
key,
|
key,
|
||||||
// down
|
// down
|
||||||
async () => {
|
async () => {
|
||||||
// up doublepress skill
|
// up doublepress skill
|
||||||
for (const [key, val] of doublePressedDownKey) {
|
await upDoublePressedKey();
|
||||||
if (val) {
|
|
||||||
downKeyCBMap.get(key)?.();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const skillOffset = clientPosToSkillOffset(
|
const skillOffset = clientPosToSkillOffset(
|
||||||
{ x: mouseX, y: mouseY },
|
{ x: mouseX, y: mouseY },
|
||||||
rangeOrTime
|
rangeOrTime
|
||||||
@ -346,7 +342,27 @@ function addTriggerWhenPressedSkillShortcuts(
|
|||||||
undefined
|
undefined
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
addTapShortcuts(key, relativeSize, rangeOrTime, posX, posY, pointerId);
|
addShortcut(
|
||||||
|
key,
|
||||||
|
async () => {
|
||||||
|
await upDoublePressedKey();
|
||||||
|
await touch({
|
||||||
|
action: TouchAction.Default,
|
||||||
|
pointerId,
|
||||||
|
screen: {
|
||||||
|
w: screenSizeW,
|
||||||
|
h: screenSizeH,
|
||||||
|
},
|
||||||
|
pos: {
|
||||||
|
x: posX,
|
||||||
|
y: posY,
|
||||||
|
},
|
||||||
|
time: rangeOrTime,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
undefined,
|
||||||
|
undefined
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -456,11 +472,7 @@ function addDirectionlessSkillShortcuts(
|
|||||||
// down
|
// down
|
||||||
async () => {
|
async () => {
|
||||||
// up doublepress skill
|
// up doublepress skill
|
||||||
for (const [key, val] of doublePressedDownKey) {
|
await upDoublePressedKey();
|
||||||
if (val) {
|
|
||||||
downKeyCBMap.get(key)?.();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
await touch({
|
await touch({
|
||||||
action: TouchAction.Down,
|
action: TouchAction.Down,
|
||||||
pointerId,
|
pointerId,
|
||||||
@ -495,6 +507,15 @@ function addDirectionlessSkillShortcuts(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// up all double pressed key
|
||||||
|
async function upDoublePressedKey() {
|
||||||
|
for (const [key, val] of doublePressedDownKey) {
|
||||||
|
if (val) {
|
||||||
|
await downKeyCBMap.get(key)?.();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// add shortcuts for directional skill (cancelable)
|
// add shortcuts for directional skill (cancelable)
|
||||||
function addDirectionalSkillShortcuts(
|
function addDirectionalSkillShortcuts(
|
||||||
key: string,
|
key: string,
|
||||||
@ -512,11 +533,7 @@ function addDirectionalSkillShortcuts(
|
|||||||
// down
|
// down
|
||||||
async () => {
|
async () => {
|
||||||
// up doublepress skill
|
// up doublepress skill
|
||||||
for (const [key, val] of doublePressedDownKey) {
|
await upDoublePressedKey();
|
||||||
if (val) {
|
|
||||||
downKeyCBMap.get(key)?.();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const skillOffset = clientPosToSkillOffset(
|
const skillOffset = clientPosToSkillOffset(
|
||||||
{ x: mouseX, y: mouseY },
|
{ x: mouseX, y: mouseY },
|
||||||
range
|
range
|
||||||
@ -787,8 +804,8 @@ const upKeyCBMap: Map<string, () => Promise<void>> = new Map();
|
|||||||
const cancelAbleKeyList: string[] = [];
|
const cancelAbleKeyList: string[] = [];
|
||||||
|
|
||||||
function keydownHandler(event: KeyboardEvent) {
|
function keydownHandler(event: KeyboardEvent) {
|
||||||
if (event.repeat) return;
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
if (event.repeat) return;
|
||||||
if (downKeyMap.has(event.code)) {
|
if (downKeyMap.has(event.code)) {
|
||||||
downKeyMap.set(event.code, true);
|
downKeyMap.set(event.code, true);
|
||||||
// execute the down callback (if there is) asyncily
|
// execute the down callback (if there is) asyncily
|
||||||
|
Loading…
Reference in New Issue
Block a user