🎨 Cleans up gait handling code

This commit is contained in:
Rune Harlyk
2025-09-01 22:23:02 +02:00
committed by Rune Harlyk
parent d7a6bffe0a
commit 54a0419770
12 changed files with 246 additions and 363 deletions
+31 -3
View File
@@ -2,7 +2,18 @@
import nipplejs from 'nipplejs'
import { onMount } from 'svelte'
import { capitalize, throttler } from '$lib/utilities'
import { input, outControllerData, mode, modes, type Modes, ModesEnum } from '$lib/stores'
import {
input,
outControllerData,
mode,
modes,
type Modes,
ModesEnum,
walkGaits,
WalkGaits,
walkGait,
walkGaitLabels
} from '$lib/stores'
import type { vector } from '$lib/types/models'
import { VerticalSlider } from '$lib/components/input'
import { gamepadAxes, hasGamepad } from '$lib/stores/gamepad'
@@ -13,7 +24,7 @@
let right: nipplejs.JoystickManager
let throttle_timing = 40
let data = new Array(8)
let data = new Array(7)
$effect(() => {
if ($hasGamepad) {
@@ -100,6 +111,10 @@
const changeMode = (modeValue: Modes) => {
mode.set(modes.indexOf(modeValue))
}
const changeWalkGait = (walkGaitValue: WalkGaits) => {
walkGait.set(walkGaitValue)
}
</script>
<div class="absolute top-0 left-0 w-screen h-screen">
@@ -141,7 +156,20 @@
{/each}
</div>
{#if $mode === ModesEnum.Walk || $mode === ModesEnum.Crawl}
{#if $mode === ModesEnum.Walk}
<div class="join">
{#each Object.values(WalkGaits) as gaitValue}
{#if typeof gaitValue === 'number'}
<button
class="btn join-item btn-sm"
class:btn-secondary={$walkGait === gaitValue}
onclick={() => changeWalkGait(gaitValue)}>
{walkGaitLabels[gaitValue]}
</button>
{/if}
{/each}
</div>
<div class="flex gap-4">
<div>
<label for="s1">S1</label>