From c449cb339093acbd1f467578fb421f280d4f622d Mon Sep 17 00:00:00 2001 From: Rune Harlyk Date: Mon, 20 Oct 2025 18:15:37 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Adds=20rotation=20keyboard=20con?= =?UTF-8?q?trols?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/routes/controller/Controls.svelte | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/app/src/routes/controller/Controls.svelte b/app/src/routes/controller/Controls.svelte index 79b00be..d793378 100644 --- a/app/src/routes/controller/Controls.svelte +++ b/app/src/routes/controller/Controls.svelte @@ -15,12 +15,7 @@ } from '$lib/stores' import type { vector } from '$lib/types/models' import { VerticalSlider } from '$lib/components/input' - import { - gamepadAxes, - gamepadButtons, - gamepadButtonsEdges, - hasGamepad - } from '$lib/stores/gamepad' + import { gamepadAxes, gamepadButtonsEdges, hasGamepad } from '$lib/stores/gamepad' import { notifications } from '$lib/components/toasts/notifications' let throttle = new throttler() @@ -41,7 +36,6 @@ handleJoyMove('right', { x: $gamepadAxes[2], y: $gamepadAxes[3] }) }) - // TODO React to button press $effect(() => { if (!$hasGamepad) return const b = $gamepadButtonsEdges @@ -109,9 +103,11 @@ const down = event.type === 'keydown' input.update(data => { if (event.key === 'w') data.left.y = down ? 1 : 0 - if (event.key === 'a') data.left.x = down ? 1 : 0 + if (event.key === 'a') data.left.x = down ? -1 : 0 if (event.key === 's') data.left.y = down ? -1 : 0 - if (event.key === 'd') data.left.x = down ? -1 : 0 + if (event.key === 'd') data.left.x = down ? 1 : 0 + if (event.key === 'ArrowLeft') data.right.x = down ? 1 : 0 + if (event.key === 'ArrowRight') data.right.x = down ? -1 : 0 return data }) throttle.throttle(updateData, throttle_timing)