mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-12-06 08:42:32 -08:00
Add more settings for controller tracking fallback
This commit is contained in:
5 files changed
+162
-40
No files matched your search
@@ -569,6 +569,7 @@ settings-driver = SteamVR / Monado
|
||||
settings-driver-description = Settings for the SlimeVR driver, used by SteamVR and Monado alike.
|
||||
settings-driver-output_group = Output
|
||||
settings-driver-data_group = Data sent
|
||||
settings-driver-features_group = Features
|
||||
settings-driver-enable = Enable
|
||||
settings-driver-enable-description = Send your trackers to and receive trackers from SteamVR or Monado through the SlimeVR driver. If this is off, they won't be able to connect to SlimeVR at all.
|
||||
settings-driver-status-title = Status
|
||||
@@ -587,7 +588,13 @@ settings-driver-bones-link = Open Bone Routing
|
||||
settings-driver-velocity = Send velocity
|
||||
settings-driver-velocity-description = Send linear and angular velocity data to the driver. Allows SteamVR/Monado tracker pose prediction and compatibility with applications that expect this data.
|
||||
settings-driver-controller_tracking_fallback = Controller tracking fallback
|
||||
settings-driver-controller_tracking_fallback-description = Override your controllers' tracking, with trackers mounted on your arms and hands, when your controllers lose tracking
|
||||
settings-driver-controller_tracking_fallback-description = Takes over your controllers' tracking when they lose tracking. Requires trackers mounted on your arms and hands.
|
||||
settings-driver-controller_tracking_fallback-pose_deadzone = Pose deadzone
|
||||
settings-driver-controller_tracking_fallback-pose_deadzone-description = How far the controller position and hand tracker position can diverge before the hand tracker takes over controller tracking.
|
||||
settings-driver-controller_tracking_fallback-interpolation = Interpolate on override begin
|
||||
settings-driver-controller_tracking_fallback-interpolation-description = Interpolate from the last good pose from the controller toward the pose from your hand tracker when it starts taking over.
|
||||
settings-driver-controller_tracking_fallback-interpolation_duration = Interpolation duration
|
||||
settings-driver-controller_tracking_fallback-interpolation_duration-description = How long the interpolation should last; as the elapsed time since takeover start increases, the takeover pose will be closer to the pose from your hand tracker.
|
||||
|
||||
## Tracker mechanics
|
||||
settings-general-mounting_method = Mounting calibration method
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { FieldPath, useForm } from 'react-hook-form';
|
||||
import { Button } from '@/components/commons/Button';
|
||||
import {
|
||||
ChangeDriverSettingsRequestT,
|
||||
@@ -29,18 +29,31 @@ import {
|
||||
} from '@/components/settings/SettingRow';
|
||||
import { SteamIcon } from '@/components/commons/icon/SteamIcon';
|
||||
import { defineSettingsPage } from '@/components/settings/settings-definitions';
|
||||
import { useLocaleConfig } from '@/i18n/config';
|
||||
import { NumberSelector } from '@/components/commons/NumberSelector';
|
||||
|
||||
type DriverForm = {
|
||||
enabled: boolean;
|
||||
sendVelocity: boolean;
|
||||
controllerTrackingFallback: boolean;
|
||||
controllerTrackingFallback: {
|
||||
enabled: boolean;
|
||||
poseDeadzone: number;
|
||||
interpolation: boolean;
|
||||
interpolationDuration: number;
|
||||
};
|
||||
};
|
||||
|
||||
function toForm(settings: DriverSettingsResponseT): DriverForm {
|
||||
return {
|
||||
enabled: settings.enabled,
|
||||
sendVelocity: settings.sendVelocity,
|
||||
controllerTrackingFallback: settings.controllerTrackingFallback,
|
||||
controllerTrackingFallback: {
|
||||
enabled: settings.controllerTrackingFallback,
|
||||
poseDeadzone: settings.controllerTrackingFallbackPoseDeadzone,
|
||||
interpolation: settings.controllerTrackingFallbackInterpolation,
|
||||
interpolationDuration:
|
||||
settings.controllerTrackingFallbackInterpolationDuration,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -110,11 +123,32 @@ export const driverSettingsPage = defineSettingsPage({
|
||||
title: 'settings-driver-velocity',
|
||||
description: 'settings-driver-velocity-description',
|
||||
},
|
||||
},
|
||||
},
|
||||
features: {
|
||||
title: 'settings-driver-features_group',
|
||||
rows: {
|
||||
controllerTrackingFallback: {
|
||||
title: 'settings-driver-controller_tracking_fallback',
|
||||
description:
|
||||
'settings-driver-controller_tracking_fallback-description',
|
||||
},
|
||||
controllerTrackingFallbackPoseDeadzone: {
|
||||
title: 'settings-driver-controller_tracking_fallback-pose_deadzone',
|
||||
description:
|
||||
'settings-driver-controller_tracking_fallback-pose_deadzone-description',
|
||||
},
|
||||
controllerTrackingFallbackInterpolation: {
|
||||
title: 'settings-driver-controller_tracking_fallback-interpolation',
|
||||
description:
|
||||
'settings-driver-controller_tracking_fallback-interpolation-description',
|
||||
},
|
||||
controllerTrackingFallbackInterpolationDuration: {
|
||||
title:
|
||||
'settings-driver-controller_tracking_fallback-interpolation_duration',
|
||||
description:
|
||||
'settings-driver-controller_tracking_fallback-interpolation_duration-description',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -129,6 +163,7 @@ export function DriverSettings() {
|
||||
const [status, setStatus] = useState<DriverStatusChangeResponseT | null>(
|
||||
null
|
||||
);
|
||||
const { currentLocales } = useLocaleConfig();
|
||||
const { sendRPCPacket, useRPCPacket, useConnectedEffect } = useWebsocketAPI();
|
||||
const defaults = useSettingsDefaults().driver;
|
||||
|
||||
@@ -144,15 +179,23 @@ export function DriverSettings() {
|
||||
const settingsReq = new ChangeDriverSettingsRequestT();
|
||||
settingsReq.enabled = values.enabled;
|
||||
settingsReq.sendVelocity = values.sendVelocity;
|
||||
settingsReq.controllerTrackingFallback = values.controllerTrackingFallback;
|
||||
settingsReq.controllerTrackingFallback =
|
||||
values.controllerTrackingFallback.enabled;
|
||||
settingsReq.controllerTrackingFallbackPoseDeadzone =
|
||||
values.controllerTrackingFallback.poseDeadzone;
|
||||
settingsReq.controllerTrackingFallbackInterpolation =
|
||||
values.controllerTrackingFallback.interpolation;
|
||||
settingsReq.controllerTrackingFallbackInterpolationDuration =
|
||||
values.controllerTrackingFallback.interpolationDuration;
|
||||
sendRPCPacket(RpcMessage.ChangeDriverSettingsRequest, settingsReq);
|
||||
};
|
||||
|
||||
const enabled = watch('enabled');
|
||||
|
||||
const resetTo = (name: keyof DriverForm) =>
|
||||
settingReset<DriverForm, typeof name>(
|
||||
defaults?.[name],
|
||||
const resetTo = (name: FieldPath<DriverForm>) =>
|
||||
settingReset<DriverForm, FieldPath<DriverForm>>(
|
||||
name.split('.').reduce<any>((value, key) => value?.[key], defaults) ??
|
||||
undefined,
|
||||
watch(name),
|
||||
(next) => {
|
||||
setValue(name, next);
|
||||
@@ -190,6 +233,58 @@ export function DriverSettings() {
|
||||
(res: DriverStatusChangeResponseT) => setStatus(res)
|
||||
);
|
||||
|
||||
const metresFormat = new Intl.NumberFormat(currentLocales, {
|
||||
style: 'unit',
|
||||
unit: 'meter',
|
||||
unitDisplay: 'narrow',
|
||||
maximumFractionDigits: 2,
|
||||
});
|
||||
const secondsFormat = new Intl.NumberFormat(currentLocales, {
|
||||
style: 'unit',
|
||||
unit: 'second',
|
||||
unitDisplay: 'narrow',
|
||||
maximumFractionDigits: 2,
|
||||
});
|
||||
|
||||
const toggle = (name: FieldPath<DriverForm>) => ({
|
||||
...resetTo(name),
|
||||
controlId: `driver-${name}`,
|
||||
control: (
|
||||
<CheckBox
|
||||
variant="toggle"
|
||||
control={control}
|
||||
name={name}
|
||||
id={`tracking-${name}`}
|
||||
/>
|
||||
),
|
||||
});
|
||||
const timeSelector = (
|
||||
name: FieldPath<DriverForm>,
|
||||
numberFormat: Intl.NumberFormat,
|
||||
min: number,
|
||||
max: number,
|
||||
step: number
|
||||
) => ({
|
||||
...resetTo(name),
|
||||
controlWidth: 'wide' as const,
|
||||
control: (
|
||||
<NumberSelector
|
||||
control={control}
|
||||
name={name}
|
||||
valueLabelFormat={(value) => numberFormat.format(value)}
|
||||
min={min}
|
||||
max={max}
|
||||
step={step}
|
||||
/>
|
||||
),
|
||||
});
|
||||
|
||||
const controllerTrackingFallback = watch(
|
||||
'controllerTrackingFallback.enabled'
|
||||
);
|
||||
const controllerTrackingFallbackInterpolation = watch(
|
||||
'controllerTrackingFallback.interpolation'
|
||||
);
|
||||
return (
|
||||
<SettingsPagePaneLayout
|
||||
icon={<SteamIcon size={24} />}
|
||||
@@ -203,16 +298,7 @@ export function DriverSettings() {
|
||||
<SettingsGroup group={groups.output}>
|
||||
<SettingRow
|
||||
setting={groups.output.rows.enable}
|
||||
controlId="driver-enabled"
|
||||
{...resetTo('enabled')}
|
||||
control={
|
||||
<CheckBox
|
||||
variant="toggle"
|
||||
control={control}
|
||||
name="enabled"
|
||||
id="driver-enabled"
|
||||
/>
|
||||
}
|
||||
{...toggle('enabled')}
|
||||
/>
|
||||
<SettingRow
|
||||
setting={groups.output.rows.bones}
|
||||
@@ -240,30 +326,50 @@ export function DriverSettings() {
|
||||
<SettingsGroup group={groups.data}>
|
||||
<SettingRow
|
||||
setting={groups.data.rows.velocity}
|
||||
controlId="driver-velocity"
|
||||
{...resetTo('sendVelocity')}
|
||||
control={
|
||||
<CheckBox
|
||||
variant="toggle"
|
||||
control={control}
|
||||
name="sendVelocity"
|
||||
id="driver-velocity"
|
||||
/>
|
||||
}
|
||||
{...toggle('sendVelocity')}
|
||||
/>
|
||||
</SettingsGroup>
|
||||
|
||||
<SettingsGroup group={groups.features}>
|
||||
<SettingRow
|
||||
setting={groups.data.rows.controllerTrackingFallback}
|
||||
controlId="driver-controller-tracking-fallback"
|
||||
{...resetTo('controllerTrackingFallback')}
|
||||
control={
|
||||
<CheckBox
|
||||
variant="toggle"
|
||||
control={control}
|
||||
name="controllerTrackingFallback"
|
||||
id="driver-controller-tracking-fallback"
|
||||
setting={groups.features.rows.controllerTrackingFallback}
|
||||
{...toggle('controllerTrackingFallback.enabled')}
|
||||
childrenDisabled={!controllerTrackingFallback}
|
||||
>
|
||||
<SettingRow
|
||||
setting={
|
||||
groups.features.rows.controllerTrackingFallbackPoseDeadzone
|
||||
}
|
||||
{...timeSelector(
|
||||
'controllerTrackingFallback.poseDeadzone',
|
||||
metresFormat,
|
||||
0.1,
|
||||
5.0,
|
||||
0.1
|
||||
)}
|
||||
/>
|
||||
<SettingRow
|
||||
setting={
|
||||
groups.features.rows.controllerTrackingFallbackInterpolation
|
||||
}
|
||||
{...toggle('controllerTrackingFallback.interpolation')}
|
||||
childrenDisabled={!controllerTrackingFallbackInterpolation}
|
||||
>
|
||||
<SettingRow
|
||||
setting={
|
||||
groups.features.rows
|
||||
.controllerTrackingFallbackInterpolationDuration
|
||||
}
|
||||
{...timeSelector(
|
||||
'controllerTrackingFallback.interpolationDuration',
|
||||
secondsFormat,
|
||||
0.1,
|
||||
2.0,
|
||||
0.1
|
||||
)}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</SettingRow>
|
||||
</SettingRow>
|
||||
</SettingsGroup>
|
||||
</SettingsAdvanced>
|
||||
</div>
|
||||
|
||||
@@ -47,6 +47,9 @@ data class DriverConfig(
|
||||
val enabled: Boolean = true,
|
||||
val sendVelocity: Boolean = false,
|
||||
val controllerTrackingFallback: Boolean = false,
|
||||
val controllerTrackingFallbackPoseDeadzone: Float = 0.2f,
|
||||
val controllerTrackingFallbackInterpolation: Boolean = true,
|
||||
val controllerTrackingFallbackInterpolationDuration: Float = 0.5f,
|
||||
)
|
||||
|
||||
// Used in TrackerActionConfig
|
||||
|
||||
@@ -25,6 +25,9 @@ internal fun buildDriverSettingsResponse(config: DriverConfig) = DriverSettingsR
|
||||
enabled = config.enabled,
|
||||
sendVelocity = config.sendVelocity,
|
||||
controllerTrackingFallback = config.controllerTrackingFallback,
|
||||
controllerTrackingFallbackPoseDeadzone = config.controllerTrackingFallbackPoseDeadzone,
|
||||
controllerTrackingFallbackInterpolation = config.controllerTrackingFallbackInterpolation,
|
||||
controllerTrackingFallbackInterpolationDuration = config.controllerTrackingFallbackInterpolationDuration,
|
||||
)
|
||||
|
||||
class DriverSettingsBehaviour(
|
||||
@@ -52,6 +55,9 @@ class DriverSettingsBehaviour(
|
||||
enabled = req.enabled,
|
||||
sendVelocity = req.sendVelocity,
|
||||
controllerTrackingFallback = req.controllerTrackingFallback,
|
||||
controllerTrackingFallbackPoseDeadzone = req.controllerTrackingFallbackPoseDeadzone,
|
||||
controllerTrackingFallbackInterpolation = req.controllerTrackingFallbackInterpolation,
|
||||
controllerTrackingFallbackInterpolationDuration = req.controllerTrackingFallbackInterpolationDuration,
|
||||
),
|
||||
)
|
||||
},
|
||||
|
||||
+1
-1
Submodule solarxr-protocol updated: 4c19ae41d3...6c5cd95493.
Reference in new issue
Block a user