mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-15 17:12:59 -04:00
guh
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -5,7 +5,7 @@
|
|||||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>webui</title>
|
<title>webui</title>
|
||||||
<script type="module" crossorigin src="/assets/index-CMp74UW-.js"></script>
|
<script type="module" crossorigin src="/assets/index-DXMuVRMQ.js"></script>
|
||||||
<link rel="stylesheet" crossorigin href="/assets/index-DxO2_uri.css">
|
<link rel="stylesheet" crossorigin href="/assets/index-DxO2_uri.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useEffect, useMemo, useState } from 'react';
|
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||||
import { useSettingsNamespace } from '../settings/index.js';
|
import { useSettingsNamespace } from '../settings/index.js';
|
||||||
import { GAMEPAD_MAPPING_DEFAULT } from '../settings/namespaces.js';
|
import { GAMEPAD_MAPPING_DEFAULT } from '../settings/namespaces.js';
|
||||||
|
|
||||||
@@ -60,6 +60,11 @@ export default function GamepadMappingSettings() {
|
|||||||
const gamepadConnected = useGamepad();
|
const gamepadConnected = useGamepad();
|
||||||
const { value: mapping, save, reset } = useSettingsNamespace('gamepadMapping', GAMEPAD_MAPPING_DEFAULT);
|
const { value: mapping, save, reset } = useSettingsNamespace('gamepadMapping', GAMEPAD_MAPPING_DEFAULT);
|
||||||
const [capture, setCapture] = useState(null);
|
const [capture, setCapture] = useState(null);
|
||||||
|
const axisBaselineRef = useRef(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
axisBaselineRef.current = null;
|
||||||
|
}, [capture]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!capture) return undefined;
|
if (!capture) return undefined;
|
||||||
@@ -69,9 +74,14 @@ export default function GamepadMappingSettings() {
|
|||||||
const pad = pads && Array.from(pads).find(Boolean);
|
const pad = pads && Array.from(pads).find(Boolean);
|
||||||
if (pad) {
|
if (pad) {
|
||||||
if (capture.type === 'axis') {
|
if (capture.type === 'axis') {
|
||||||
|
if (!axisBaselineRef.current) {
|
||||||
|
axisBaselineRef.current = Array.from(pad.axes ?? []).map((value) => value ?? 0);
|
||||||
|
}
|
||||||
for (let i = 0; i < pad.axes.length; i += 1) {
|
for (let i = 0; i < pad.axes.length; i += 1) {
|
||||||
const value = pad.axes[i];
|
const value = pad.axes[i];
|
||||||
if (Math.abs(value) > 0.65) {
|
const baseline = axisBaselineRef.current?.[i] ?? 0;
|
||||||
|
const delta = Math.abs(value - baseline);
|
||||||
|
if (Math.abs(value) > 0.65 && delta > 0.5) {
|
||||||
save((prev) =>
|
save((prev) =>
|
||||||
updatePath(prev, capture.path, () => ({
|
updatePath(prev, capture.path, () => ({
|
||||||
index: i,
|
index: i,
|
||||||
|
|||||||
Reference in New Issue
Block a user