mirror of
https://github.com/AkiChase/scrcpy-mask
synced 2025-02-23 07:22:17 +08:00
fix(keyMappingConfig): type error
This commit is contained in:
parent
b39241c858
commit
408a5076ac
@ -12,6 +12,7 @@ import {
|
|||||||
KeyObservation as KeyMappingObservation,
|
KeyObservation as KeyMappingObservation,
|
||||||
KeyTap,
|
KeyTap,
|
||||||
KeyMacro,
|
KeyMacro,
|
||||||
|
KeyMapping,
|
||||||
} from "../../keyMappingConfig";
|
} from "../../keyMappingConfig";
|
||||||
import { useGlobalStore } from "../../store/global";
|
import { useGlobalStore } from "../../store/global";
|
||||||
import { DropdownOption, NDropdown, useDialog, useMessage } from "naive-ui";
|
import { DropdownOption, NDropdown, useDialog, useMessage } from "naive-ui";
|
||||||
@ -91,9 +92,10 @@ function onAddButtonSelect(
|
|||||||
loop: null,
|
loop: null,
|
||||||
up: null,
|
up: null,
|
||||||
};
|
};
|
||||||
|
delete (keyMapping as any).pointerId;
|
||||||
} else return;
|
} else return;
|
||||||
keyboardStore.edited = true;
|
keyboardStore.edited = true;
|
||||||
store.editKeyMappingList.push(keyMapping);
|
store.editKeyMappingList.push(keyMapping as KeyMapping);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isKeyUnique(curKey: string): boolean {
|
function isKeyUnique(curKey: string): boolean {
|
||||||
|
@ -14,7 +14,7 @@ import {
|
|||||||
NInputNumber,
|
NInputNumber,
|
||||||
} from "naive-ui";
|
} from "naive-ui";
|
||||||
import { CloseCircle, Settings } from "@vicons/ionicons5";
|
import { CloseCircle, Settings } from "@vicons/ionicons5";
|
||||||
import { KeyMacro, KeyMacroList, KeyTap } from "../../keyMappingConfig";
|
import { KeyCommon, KeyMacro, KeyMacroList } from "../../keyMappingConfig";
|
||||||
import { useKeyboardStore } from "../../store/keyboard";
|
import { useKeyboardStore } from "../../store/keyboard";
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
@ -30,7 +30,9 @@ const elementRef = ref<HTMLElement | null>(null);
|
|||||||
const isActive = computed(
|
const isActive = computed(
|
||||||
() => props.index === keyboardStore.activeButtonIndex
|
() => props.index === keyboardStore.activeButtonIndex
|
||||||
);
|
);
|
||||||
const keyMapping = computed(() => store.editKeyMappingList[props.index]);
|
const keyMapping = computed(
|
||||||
|
() => store.editKeyMappingList[props.index] as KeyCommon
|
||||||
|
);
|
||||||
|
|
||||||
const showMacroModal = ref(false);
|
const showMacroModal = ref(false);
|
||||||
const editedMacroRaw = ref({
|
const editedMacroRaw = ref({
|
||||||
@ -216,7 +218,7 @@ function showSetting() {
|
|||||||
</NFormItem>
|
</NFormItem>
|
||||||
<NFormItem v-if="keyMapping.type === 'Tap'" label="触摸时长">
|
<NFormItem v-if="keyMapping.type === 'Tap'" label="触摸时长">
|
||||||
<NInputNumber
|
<NInputNumber
|
||||||
v-model:value="(keyMapping as KeyTap).time"
|
v-model:value="keyMapping.time"
|
||||||
:min="0"
|
:min="0"
|
||||||
placeholder="请输入触摸时长(ms)"
|
placeholder="请输入触摸时长(ms)"
|
||||||
@update:value="keyboardStore.edited = true"
|
@update:value="keyboardStore.edited = true"
|
||||||
|
@ -14,7 +14,7 @@ import {
|
|||||||
} from "naive-ui";
|
} from "naive-ui";
|
||||||
import {
|
import {
|
||||||
KeyDirectionalSkill,
|
KeyDirectionalSkill,
|
||||||
KeyTriggerWhenDoublePressedSkill,
|
KeySkill,
|
||||||
KeyTriggerWhenPressedSkill,
|
KeyTriggerWhenPressedSkill,
|
||||||
} from "../../keyMappingConfig";
|
} from "../../keyMappingConfig";
|
||||||
import { useKeyboardStore } from "../../store/keyboard";
|
import { useKeyboardStore } from "../../store/keyboard";
|
||||||
@ -31,7 +31,9 @@ const elementRef = ref<HTMLElement | null>(null);
|
|||||||
const isActive = computed(
|
const isActive = computed(
|
||||||
() => props.index === keyboardStore.activeButtonIndex
|
() => props.index === keyboardStore.activeButtonIndex
|
||||||
);
|
);
|
||||||
const keyMapping = computed(() => store.editKeyMappingList[props.index]);
|
const keyMapping = computed(
|
||||||
|
() => store.editKeyMappingList[props.index] as KeySkill
|
||||||
|
);
|
||||||
|
|
||||||
function dragHandler(downEvent: MouseEvent) {
|
function dragHandler(downEvent: MouseEvent) {
|
||||||
keyboardStore.activeButtonIndex = props.index;
|
keyboardStore.activeButtonIndex = props.index;
|
||||||
@ -97,12 +99,14 @@ function changeSkillType(flag: string) {
|
|||||||
keyboardStore.edited = true;
|
keyboardStore.edited = true;
|
||||||
if (t === "DirectionalSkill") {
|
if (t === "DirectionalSkill") {
|
||||||
// to DirectionlessSkill
|
// to DirectionlessSkill
|
||||||
delete (keyMapping.value as any).range;
|
const k = keyMapping.value as any;
|
||||||
keyMapping.value.type = "DirectionlessSkill";
|
delete k.range;
|
||||||
|
k.type = "DirectionlessSkill";
|
||||||
} else if (t === "DirectionlessSkill") {
|
} else if (t === "DirectionlessSkill") {
|
||||||
// to DirectionalSkill
|
// to DirectionalSkill
|
||||||
(keyMapping.value as any).range = 0;
|
const k = keyMapping.value as any;
|
||||||
keyMapping.value.type = "DirectionalSkill";
|
k.range = 0;
|
||||||
|
k.type = "DirectionalSkill";
|
||||||
} else if (t === "TriggerWhenPressedSkill") {
|
} else if (t === "TriggerWhenPressedSkill") {
|
||||||
// change directional flag
|
// change directional flag
|
||||||
const k = keyMapping.value as KeyTriggerWhenPressedSkill;
|
const k = keyMapping.value as KeyTriggerWhenPressedSkill;
|
||||||
@ -110,8 +114,9 @@ function changeSkillType(flag: string) {
|
|||||||
k.rangeOrTime = k.directional ? 0 : 80;
|
k.rangeOrTime = k.directional ? 0 : 80;
|
||||||
} else if (t === "TriggerWhenDoublePressedSkill") {
|
} else if (t === "TriggerWhenDoublePressedSkill") {
|
||||||
// to DirectionlessSkill
|
// to DirectionlessSkill
|
||||||
delete (keyMapping.value as any).range;
|
const k = keyMapping.value as any;
|
||||||
keyMapping.value.type = "DirectionlessSkill";
|
delete k.range;
|
||||||
|
k.type = "DirectionlessSkill";
|
||||||
}
|
}
|
||||||
} else if (flag === "trigger") {
|
} else if (flag === "trigger") {
|
||||||
keyboardStore.edited = true;
|
keyboardStore.edited = true;
|
||||||
@ -278,7 +283,7 @@ function updateRangeIndicator(element?: HTMLElement) {
|
|||||||
<NFormItem v-if="!isDirectionless" label="范围">
|
<NFormItem v-if="!isDirectionless" label="范围">
|
||||||
<NInputNumber
|
<NInputNumber
|
||||||
v-if="keyMapping.type === 'DirectionalSkill'"
|
v-if="keyMapping.type === 'DirectionalSkill'"
|
||||||
v-model:value="(keyMapping as KeyDirectionalSkill).range"
|
v-model:value="keyMapping.range"
|
||||||
placeholder="range"
|
placeholder="range"
|
||||||
:min="0"
|
:min="0"
|
||||||
:max="100"
|
:max="100"
|
||||||
@ -289,7 +294,7 @@ function updateRangeIndicator(element?: HTMLElement) {
|
|||||||
/>
|
/>
|
||||||
<NInputNumber
|
<NInputNumber
|
||||||
v-else-if="keyMapping.type === 'TriggerWhenPressedSkill'"
|
v-else-if="keyMapping.type === 'TriggerWhenPressedSkill'"
|
||||||
v-model:value="(keyMapping as KeyTriggerWhenPressedSkill).rangeOrTime"
|
v-model:value="keyMapping.rangeOrTime"
|
||||||
placeholder="rangeOrTime"
|
placeholder="rangeOrTime"
|
||||||
:min="0"
|
:min="0"
|
||||||
:max="100"
|
:max="100"
|
||||||
@ -300,7 +305,7 @@ function updateRangeIndicator(element?: HTMLElement) {
|
|||||||
/>
|
/>
|
||||||
<NInputNumber
|
<NInputNumber
|
||||||
v-else-if="keyMapping.type === 'TriggerWhenDoublePressedSkill'"
|
v-else-if="keyMapping.type === 'TriggerWhenDoublePressedSkill'"
|
||||||
v-model:value="(keyMapping as KeyTriggerWhenDoublePressedSkill).range"
|
v-model:value="keyMapping.range"
|
||||||
placeholder="range"
|
placeholder="range"
|
||||||
:min="0"
|
:min="0"
|
||||||
:max="100"
|
:max="100"
|
||||||
@ -315,7 +320,7 @@ function updateRangeIndicator(element?: HTMLElement) {
|
|||||||
label="触摸时长"
|
label="触摸时长"
|
||||||
>
|
>
|
||||||
<NInputNumber
|
<NInputNumber
|
||||||
v-model:value="(keyMapping as KeyTriggerWhenPressedSkill).rangeOrTime"
|
v-model:value="keyMapping.rangeOrTime"
|
||||||
:min="0"
|
:min="0"
|
||||||
placeholder="请输入触摸时长(ms)"
|
placeholder="请输入触摸时长(ms)"
|
||||||
@update:value="keyboardStore.edited = true"
|
@update:value="keyboardStore.edited = true"
|
||||||
|
@ -28,11 +28,8 @@ const offset = computed(() => {
|
|||||||
const clientWidth = keyboardElement.clientWidth;
|
const clientWidth = keyboardElement.clientWidth;
|
||||||
const screenSizeW =
|
const screenSizeW =
|
||||||
store.screenSizeW === 0 ? clientWidth : store.screenSizeW;
|
store.screenSizeW === 0 ? clientWidth : store.screenSizeW;
|
||||||
return (
|
return (keyMapping.value.offset * clientWidth) / screenSizeW;
|
||||||
((keyMapping.value as KeySteeringWheel).offset * clientWidth) /
|
} else return keyMapping.value.offset;
|
||||||
screenSizeW
|
|
||||||
);
|
|
||||||
} else return (keyMapping.value as KeySteeringWheel).offset;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function dragHandler(downEvent: MouseEvent) {
|
function dragHandler(downEvent: MouseEvent) {
|
||||||
|
@ -1,21 +1,12 @@
|
|||||||
interface Key {
|
interface KeyBase {
|
||||||
type:
|
|
||||||
| "SteeringWheel"
|
|
||||||
| "DirectionalSkill"
|
|
||||||
| "DirectionlessSkill"
|
|
||||||
| "CancelSkill"
|
|
||||||
| "Tap"
|
|
||||||
| "TriggerWhenPressedSkill"
|
|
||||||
| "TriggerWhenDoublePressedSkill"
|
|
||||||
| "Observation"
|
|
||||||
| "Macro";
|
|
||||||
note: string;
|
note: string;
|
||||||
posX: number;
|
posX: number;
|
||||||
posY: number;
|
posY: number;
|
||||||
pointerId: number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface KeySteeringWheel extends Key {
|
export interface KeySteeringWheel extends KeyBase {
|
||||||
|
type: "SteeringWheel";
|
||||||
|
pointerId: number;
|
||||||
key: {
|
key: {
|
||||||
left: string;
|
left: string;
|
||||||
right: string;
|
right: string;
|
||||||
@ -25,54 +16,62 @@ interface KeySteeringWheel extends Key {
|
|||||||
offset: number;
|
offset: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface KeyDirectionalSkill extends Key {
|
export interface KeyDirectionalSkill extends KeyBase {
|
||||||
|
type: "DirectionalSkill";
|
||||||
|
pointerId: number;
|
||||||
key: string;
|
key: string;
|
||||||
range: number;
|
range: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface KeyDirectionlessSkill extends Key {
|
export interface KeyDirectionlessSkill extends KeyBase {
|
||||||
|
type: "DirectionlessSkill";
|
||||||
|
pointerId: number;
|
||||||
key: string;
|
key: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface KeyCancelSkill extends Key {
|
export interface KeyCancelSkill extends KeyBase {
|
||||||
|
type: "CancelSkill";
|
||||||
|
pointerId: number;
|
||||||
key: string;
|
key: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface KeyTriggerWhenPressedSkill extends Key {
|
export interface KeyTriggerWhenPressedSkill extends KeyBase {
|
||||||
|
type: "TriggerWhenPressedSkill";
|
||||||
|
pointerId: number;
|
||||||
key: string;
|
key: string;
|
||||||
directional: boolean;
|
directional: boolean;
|
||||||
rangeOrTime: number;
|
rangeOrTime: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface KeyTriggerWhenDoublePressedSkill extends Key {
|
export interface KeyTriggerWhenDoublePressedSkill extends KeyBase {
|
||||||
|
type: "TriggerWhenDoublePressedSkill";
|
||||||
|
pointerId: number;
|
||||||
key: string;
|
key: string;
|
||||||
range: number;
|
range: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface KeyObservation extends Key {
|
export interface KeyObservation extends KeyBase {
|
||||||
|
type: "Observation";
|
||||||
|
pointerId: number;
|
||||||
key: string;
|
key: string;
|
||||||
scale: number;
|
scale: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface KeyTap extends Key {
|
export interface KeyTap extends KeyBase {
|
||||||
|
type: "Tap";
|
||||||
|
pointerId: number;
|
||||||
key: string;
|
key: string;
|
||||||
time: number;
|
time: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
type KeyMacroType = "touch" | "sleep" | "swipe" | "input-text";
|
export type KeyMacroList = Array<{
|
||||||
type KeyMacroArgs = any[];
|
type: "touch" | "sleep" | "swipe" | "input-text";
|
||||||
|
args: any[];
|
||||||
type KeyMacroList = Array<{
|
|
||||||
type: KeyMacroType;
|
|
||||||
args: KeyMacroArgs;
|
|
||||||
}> | null;
|
}> | null;
|
||||||
|
|
||||||
interface KeyMacro {
|
export interface KeyMacro extends KeyBase {
|
||||||
type: "Macro";
|
type: "Macro";
|
||||||
key: string;
|
key: string;
|
||||||
note: string;
|
|
||||||
posX: number;
|
|
||||||
posY: number;
|
|
||||||
macro: {
|
macro: {
|
||||||
down: KeyMacroList;
|
down: KeyMacroList;
|
||||||
loop: KeyMacroList;
|
loop: KeyMacroList;
|
||||||
@ -80,7 +79,7 @@ interface KeyMacro {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
type KeyMapping =
|
export type KeyMapping =
|
||||||
| KeySteeringWheel
|
| KeySteeringWheel
|
||||||
| KeyDirectionalSkill
|
| KeyDirectionalSkill
|
||||||
| KeyDirectionlessSkill
|
| KeyDirectionlessSkill
|
||||||
@ -91,23 +90,16 @@ type KeyMapping =
|
|||||||
| KeyCancelSkill
|
| KeyCancelSkill
|
||||||
| KeyTap;
|
| KeyTap;
|
||||||
|
|
||||||
interface KeyMappingConfig {
|
export type KeyCommon = KeyMacro | KeyCancelSkill | KeyTap;
|
||||||
|
|
||||||
|
export type KeySkill =
|
||||||
|
| KeyDirectionalSkill
|
||||||
|
| KeyDirectionlessSkill
|
||||||
|
| KeyTriggerWhenPressedSkill
|
||||||
|
| KeyTriggerWhenDoublePressedSkill;
|
||||||
|
|
||||||
|
export interface KeyMappingConfig {
|
||||||
relativeSize: { w: number; h: number };
|
relativeSize: { w: number; h: number };
|
||||||
title: string;
|
title: string;
|
||||||
list: KeyMapping[];
|
list: KeyMapping[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export type {
|
|
||||||
KeyMacroList,
|
|
||||||
KeySteeringWheel,
|
|
||||||
KeyDirectionalSkill,
|
|
||||||
KeyDirectionlessSkill,
|
|
||||||
KeyCancelSkill,
|
|
||||||
KeyTap,
|
|
||||||
KeyTriggerWhenPressedSkill,
|
|
||||||
KeyTriggerWhenDoublePressedSkill,
|
|
||||||
KeyObservation,
|
|
||||||
KeyMacro,
|
|
||||||
KeyMapping,
|
|
||||||
KeyMappingConfig,
|
|
||||||
};
|
|
||||||
|
Loading…
Reference in New Issue
Block a user