From 4d0aec2c54c838d9389798e1384339b1e9ee2f00 Mon Sep 17 00:00:00 2001 From: AkiChase <1003019131@qq.com> Date: Sun, 5 May 2024 21:09:30 +0800 Subject: [PATCH 1/4] fix(KeyBoard): TriggerWhenPressedSkill setting error --- src/components/keyboard/KeySkill.vue | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/components/keyboard/KeySkill.vue b/src/components/keyboard/KeySkill.vue index a5682e7..9202d45 100644 --- a/src/components/keyboard/KeySkill.vue +++ b/src/components/keyboard/KeySkill.vue @@ -14,6 +14,7 @@ import { } from "naive-ui"; import { KeyDirectionalSkill, + KeyTriggerWhenDoublePressedSkill, KeyTriggerWhenPressedSkill, } from "../../keyMappingConfig"; import { useKeyboardStore } from "../../store/keyboard"; @@ -276,12 +277,9 @@ function updateRangeIndicator(element?: HTMLElement) { + Date: Mon, 6 May 2024 09:12:43 +0800 Subject: [PATCH 3/4] fix(hotkey): double press skill conflict with other skill --- src/hotkey.ts | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/src/hotkey.ts b/src/hotkey.ts index df889fa..be6812e 100644 --- a/src/hotkey.ts +++ b/src/hotkey.ts @@ -252,7 +252,13 @@ function addCancelSkillShortcuts( loopDownKeyCBMap.delete(cancelAbleKey); upKeyCBMap.delete(cancelAbleKey); } - + // special case for double press skill + for (const [key, val] of doublePressedDownKey) { + if (val) { + loopDownKeyCBMap.delete(key); + doublePressedDownKey.set(key, false); + } + } let distance = 0; while (distance <= 20) { await touch({ @@ -308,6 +314,12 @@ function addTriggerWhenPressedSkillShortcuts( key, // down async () => { + // up doublepress skill + for (const [key, val] of doublePressedDownKey) { + if (val) { + downKeyCBMap.get(key)?.(); + } + } const skillOffset = clientPosToSkillOffset( { x: mouseX, y: mouseY }, rangeOrTime @@ -337,6 +349,8 @@ function addTriggerWhenPressedSkillShortcuts( } } +// add shortcuts for trigger when double pressed skill (cancelable, but in another way) +const doublePressedDownKey = new Map(); function addTriggerWhenDoublePressedSkillShortcuts( key: string, relativeSize: { w: number; h: number }, @@ -348,12 +362,12 @@ function addTriggerWhenDoublePressedSkillShortcuts( ) { posX = Math.round((posX / relativeSize.w) * screenSizeW); posY = Math.round((posY / relativeSize.h) * screenSizeH); - let curKeyDownFlag = false; + doublePressedDownKey.set(key, false); addShortcut( key, // down async () => { - if (curKeyDownFlag === false) { + if (doublePressedDownKey.get(key) === false) { // first press: touch down const skillOffset = clientPosToSkillOffset( { x: mouseX, y: mouseY }, @@ -376,7 +390,7 @@ function addTriggerWhenDoublePressedSkillShortcuts( intervalBetweenPos: 0, }); // set the flag to true - curKeyDownFlag = true; + doublePressedDownKey.set(key, true); // add loop CB loopDownKeyCBMap.set(key, async () => { const loopSkillOffset = clientPosToSkillOffset( @@ -417,7 +431,7 @@ function addTriggerWhenDoublePressedSkillShortcuts( }, }); // set the flag to false - curKeyDownFlag = false; + doublePressedDownKey.set(key, false); } }, undefined, @@ -440,6 +454,12 @@ function addDirectionlessSkillShortcuts( key, // down async () => { + // up doublepress skill + for (const [key, val] of doublePressedDownKey) { + if (val) { + downKeyCBMap.get(key)?.(); + } + } await touch({ action: TouchAction.Down, pointerId, @@ -490,6 +510,12 @@ function addDirectionalSkillShortcuts( key, // down async () => { + // up doublepress skill + for (const [key, val] of doublePressedDownKey) { + if (val) { + downKeyCBMap.get(key)?.(); + } + } const skillOffset = clientPosToSkillOffset( { x: mouseX, y: mouseY }, range From da8d7f28588ba351b3ce066c12bcb661b9ef5f48 Mon Sep 17 00:00:00 2001 From: AkiChase <1003019131@qq.com> Date: Mon, 6 May 2024 09:29:49 +0800 Subject: [PATCH 4/4] Scrcpy Mask v0.1.6 --- package.json | 2 +- src-tauri/Cargo.toml | 2 +- src-tauri/tauri.conf.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 8a4dd4d..5e06c89 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "scrcpy-mask", "private": true, - "version": "0.1.5", + "version": "0.1.6", "type": "module", "scripts": { "dev": "vite", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 495dbf8..14a83c8 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "scrcpy-mask" -version = "0.1.5" +version = "0.1.6" description = "A Tauri App" authors = ["AkiChase"] edition = "2021" diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 99b1119..49f4f7a 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,6 +1,6 @@ { "productName": "scrcpy-mask", - "version": "0.1.5", + "version": "0.1.6", "identifier": "com.akichase.mask", "build": { "beforeDevCommand": "pnpm dev",