feat: dispatch key up event when in 2d mode
This commit is contained in:
@@ -17,12 +17,6 @@ const bottomScreen = useTemplateRef<ScreenInstance>("bottomScreen");
|
|||||||
const topScreenCanvas = computed(() => topScreen.value?.canvas ?? null);
|
const topScreenCanvas = computed(() => topScreen.value?.canvas ?? null);
|
||||||
const bottomScreenCanvas = computed(() => bottomScreen.value?.canvas ?? null);
|
const bottomScreenCanvas = computed(() => bottomScreen.value?.canvas ?? null);
|
||||||
|
|
||||||
useKeyDown((key) => {
|
|
||||||
// events are dispatched from NDS.vue in 3d mode
|
|
||||||
// events are dispatched from here in 2d mode
|
|
||||||
// that's a bit dirty but who cares, there is a lot of dirty things going on here
|
|
||||||
// like who choose Nuxt to build such an app
|
|
||||||
if (ENABLE_3D) return;
|
|
||||||
const keyToButton: Record<string, string> = {
|
const keyToButton: Record<string, string> = {
|
||||||
ArrowUp: "UP",
|
ArrowUp: "UP",
|
||||||
ArrowDown: "DOWN",
|
ArrowDown: "DOWN",
|
||||||
@@ -35,6 +29,13 @@ useKeyDown((key) => {
|
|||||||
" ": "SELECT",
|
" ": "SELECT",
|
||||||
Enter: "START",
|
Enter: "START",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// events are dispatched from NDS.vue in 3d mode
|
||||||
|
// events are dispatched from here in 2d mode
|
||||||
|
// that's a bit dirty but who cares, there is a lot of dirty things going on here
|
||||||
|
// like who choose Nuxt to build such an app
|
||||||
|
useKeyDown((key) => {
|
||||||
|
if (ENABLE_3D) return;
|
||||||
const button = keyToButton[key];
|
const button = keyToButton[key];
|
||||||
if (button) {
|
if (button) {
|
||||||
window.dispatchEvent(
|
window.dispatchEvent(
|
||||||
@@ -42,6 +43,14 @@ useKeyDown((key) => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
useKeyUp((key) => {
|
||||||
|
if (ENABLE_3D) return;
|
||||||
|
const button = keyToButton[key];
|
||||||
|
if (button) {
|
||||||
|
window.dispatchEvent(new KeyboardEvent("keyup", { key: `NDS_${button}` }));
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
Reference in New Issue
Block a user