🎨 Adds rotation keyboard controls
This commit is contained in:
@@ -15,12 +15,7 @@
|
|||||||
} from '$lib/stores'
|
} from '$lib/stores'
|
||||||
import type { vector } from '$lib/types/models'
|
import type { vector } from '$lib/types/models'
|
||||||
import { VerticalSlider } from '$lib/components/input'
|
import { VerticalSlider } from '$lib/components/input'
|
||||||
import {
|
import { gamepadAxes, gamepadButtonsEdges, hasGamepad } from '$lib/stores/gamepad'
|
||||||
gamepadAxes,
|
|
||||||
gamepadButtons,
|
|
||||||
gamepadButtonsEdges,
|
|
||||||
hasGamepad
|
|
||||||
} from '$lib/stores/gamepad'
|
|
||||||
import { notifications } from '$lib/components/toasts/notifications'
|
import { notifications } from '$lib/components/toasts/notifications'
|
||||||
|
|
||||||
let throttle = new throttler()
|
let throttle = new throttler()
|
||||||
@@ -41,7 +36,6 @@
|
|||||||
handleJoyMove('right', { x: $gamepadAxes[2], y: $gamepadAxes[3] })
|
handleJoyMove('right', { x: $gamepadAxes[2], y: $gamepadAxes[3] })
|
||||||
})
|
})
|
||||||
|
|
||||||
// TODO React to button press
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
if (!$hasGamepad) return
|
if (!$hasGamepad) return
|
||||||
const b = $gamepadButtonsEdges
|
const b = $gamepadButtonsEdges
|
||||||
@@ -109,9 +103,11 @@
|
|||||||
const down = event.type === 'keydown'
|
const down = event.type === 'keydown'
|
||||||
input.update(data => {
|
input.update(data => {
|
||||||
if (event.key === 'w') data.left.y = down ? 1 : 0
|
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 === '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
|
return data
|
||||||
})
|
})
|
||||||
throttle.throttle(updateData, throttle_timing)
|
throttle.throttle(updateData, throttle_timing)
|
||||||
|
|||||||
Reference in New Issue
Block a user