mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-04-06 02:01:58 +02:00
Compare commits
3 Commits
v0.16.3
...
hide-new-r
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eb073bc095 | ||
|
|
436ce4e679 | ||
|
|
b016ecfb4f |
@@ -12,7 +12,11 @@ import { parseStatusToLocale, useStatusContext } from '@/hooks/status-system';
|
||||
import { ClearMountingButton } from './ClearMountingButton';
|
||||
import { ToggleableSkeletonVisualizerWidget } from './widgets/SkeletonVisualizerWidget';
|
||||
import { useAtomValue } from 'jotai';
|
||||
import { flatTrackersAtom } from '@/store/app-store';
|
||||
import {
|
||||
feetAssignedTrackers,
|
||||
fingerAssignedTrackers,
|
||||
flatTrackersAtom,
|
||||
} from '@/store/app-store';
|
||||
import { A } from './commons/A';
|
||||
|
||||
function UnprioritizedStatuses() {
|
||||
@@ -48,6 +52,8 @@ function UnprioritizedStatuses() {
|
||||
|
||||
export function WidgetsComponent() {
|
||||
const { config } = useConfig();
|
||||
const hasFeetTrackers = useAtomValue(feetAssignedTrackers);
|
||||
const hasFingerTrackers = useAtomValue(fingerAssignedTrackers);
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -55,16 +61,20 @@ export function WidgetsComponent() {
|
||||
<ResetButton type={ResetType.Yaw} size="big"></ResetButton>
|
||||
<ResetButton type={ResetType.Full} size="big"></ResetButton>
|
||||
<ResetButton type={ResetType.Mounting} size="big"></ResetButton>
|
||||
<ResetButton
|
||||
type={ResetType.Mounting}
|
||||
size="big"
|
||||
bodyPartsToReset="feet"
|
||||
></ResetButton>
|
||||
<ResetButton
|
||||
type={ResetType.Mounting}
|
||||
size="big"
|
||||
bodyPartsToReset="fingers"
|
||||
></ResetButton>
|
||||
{hasFeetTrackers && (
|
||||
<ResetButton
|
||||
type={ResetType.Mounting}
|
||||
size="big"
|
||||
bodyPartsToReset="feet"
|
||||
></ResetButton>
|
||||
)}
|
||||
{hasFingerTrackers && (
|
||||
<ResetButton
|
||||
type={ResetType.Mounting}
|
||||
size="big"
|
||||
bodyPartsToReset="fingers"
|
||||
></ResetButton>
|
||||
)}
|
||||
<ClearMountingButton></ClearMountingButton>
|
||||
{(typeof __ANDROID__ === 'undefined' || !__ANDROID__?.isThere()) && (
|
||||
<BVHButton></BVHButton>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { useLocalization } from '@fluent/react';
|
||||
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import {
|
||||
BodyPart,
|
||||
ResetRequestT,
|
||||
ResetType,
|
||||
RpcMessage,
|
||||
@@ -25,6 +24,7 @@ import { useStatusContext } from '@/hooks/status-system';
|
||||
import classNames from 'classnames';
|
||||
import { FootIcon } from '@/components/commons/icon/FootIcon';
|
||||
import { FingersIcon } from '@/components/commons/icon/FingersIcon';
|
||||
import { FEET_BODY_PARTS, FINGER_BODY_PARTS } from '@/store/app-store';
|
||||
|
||||
export function ResetButton({
|
||||
type,
|
||||
@@ -55,40 +55,6 @@ export function ResetButton({
|
||||
[statuses]
|
||||
);
|
||||
|
||||
const feetBodyParts = [BodyPart.LEFT_FOOT, BodyPart.RIGHT_FOOT];
|
||||
const fingerBodyParts = [
|
||||
BodyPart.LEFT_THUMB_METACARPAL,
|
||||
BodyPart.LEFT_THUMB_PROXIMAL,
|
||||
BodyPart.LEFT_THUMB_DISTAL,
|
||||
BodyPart.LEFT_INDEX_PROXIMAL,
|
||||
BodyPart.LEFT_INDEX_INTERMEDIATE,
|
||||
BodyPart.LEFT_INDEX_DISTAL,
|
||||
BodyPart.LEFT_MIDDLE_PROXIMAL,
|
||||
BodyPart.LEFT_MIDDLE_INTERMEDIATE,
|
||||
BodyPart.LEFT_MIDDLE_DISTAL,
|
||||
BodyPart.LEFT_RING_PROXIMAL,
|
||||
BodyPart.LEFT_RING_INTERMEDIATE,
|
||||
BodyPart.LEFT_RING_DISTAL,
|
||||
BodyPart.LEFT_LITTLE_PROXIMAL,
|
||||
BodyPart.LEFT_LITTLE_INTERMEDIATE,
|
||||
BodyPart.LEFT_LITTLE_DISTAL,
|
||||
BodyPart.RIGHT_THUMB_METACARPAL,
|
||||
BodyPart.RIGHT_THUMB_PROXIMAL,
|
||||
BodyPart.RIGHT_THUMB_DISTAL,
|
||||
BodyPart.RIGHT_INDEX_PROXIMAL,
|
||||
BodyPart.RIGHT_INDEX_INTERMEDIATE,
|
||||
BodyPart.RIGHT_INDEX_DISTAL,
|
||||
BodyPart.RIGHT_MIDDLE_PROXIMAL,
|
||||
BodyPart.RIGHT_MIDDLE_INTERMEDIATE,
|
||||
BodyPart.RIGHT_MIDDLE_DISTAL,
|
||||
BodyPart.RIGHT_RING_PROXIMAL,
|
||||
BodyPart.RIGHT_RING_INTERMEDIATE,
|
||||
BodyPart.RIGHT_RING_DISTAL,
|
||||
BodyPart.RIGHT_LITTLE_PROXIMAL,
|
||||
BodyPart.RIGHT_LITTLE_INTERMEDIATE,
|
||||
BodyPart.RIGHT_LITTLE_DISTAL,
|
||||
];
|
||||
|
||||
const reset = () => {
|
||||
const req = new ResetRequestT();
|
||||
req.resetType = type;
|
||||
@@ -98,10 +64,10 @@ export function ResetButton({
|
||||
req.bodyParts = [];
|
||||
break;
|
||||
case 'feet':
|
||||
req.bodyParts = feetBodyParts;
|
||||
req.bodyParts = FEET_BODY_PARTS;
|
||||
break;
|
||||
case 'fingers':
|
||||
req.bodyParts = fingerBodyParts;
|
||||
req.bodyParts = [...FINGER_BODY_PARTS.values()];
|
||||
break;
|
||||
}
|
||||
sendRPCPacket(RpcMessage.ResetRequest, req);
|
||||
|
||||
@@ -95,3 +95,49 @@ export const trackerFromIdAtom = ({
|
||||
(a) => a,
|
||||
isEqual
|
||||
);
|
||||
|
||||
export const FEET_BODY_PARTS = [BodyPart.LEFT_FOOT, BodyPart.RIGHT_FOOT];
|
||||
export const FINGER_BODY_PARTS = new Set([
|
||||
BodyPart.LEFT_THUMB_METACARPAL,
|
||||
BodyPart.LEFT_THUMB_PROXIMAL,
|
||||
BodyPart.LEFT_THUMB_DISTAL,
|
||||
BodyPart.LEFT_INDEX_PROXIMAL,
|
||||
BodyPart.LEFT_INDEX_INTERMEDIATE,
|
||||
BodyPart.LEFT_INDEX_DISTAL,
|
||||
BodyPart.LEFT_MIDDLE_PROXIMAL,
|
||||
BodyPart.LEFT_MIDDLE_INTERMEDIATE,
|
||||
BodyPart.LEFT_MIDDLE_DISTAL,
|
||||
BodyPart.LEFT_RING_PROXIMAL,
|
||||
BodyPart.LEFT_RING_INTERMEDIATE,
|
||||
BodyPart.LEFT_RING_DISTAL,
|
||||
BodyPart.LEFT_LITTLE_PROXIMAL,
|
||||
BodyPart.LEFT_LITTLE_INTERMEDIATE,
|
||||
BodyPart.LEFT_LITTLE_DISTAL,
|
||||
BodyPart.RIGHT_THUMB_METACARPAL,
|
||||
BodyPart.RIGHT_THUMB_PROXIMAL,
|
||||
BodyPart.RIGHT_THUMB_DISTAL,
|
||||
BodyPart.RIGHT_INDEX_PROXIMAL,
|
||||
BodyPart.RIGHT_INDEX_INTERMEDIATE,
|
||||
BodyPart.RIGHT_INDEX_DISTAL,
|
||||
BodyPart.RIGHT_MIDDLE_PROXIMAL,
|
||||
BodyPart.RIGHT_MIDDLE_INTERMEDIATE,
|
||||
BodyPart.RIGHT_MIDDLE_DISTAL,
|
||||
BodyPart.RIGHT_RING_PROXIMAL,
|
||||
BodyPart.RIGHT_RING_INTERMEDIATE,
|
||||
BodyPart.RIGHT_RING_DISTAL,
|
||||
BodyPart.RIGHT_LITTLE_PROXIMAL,
|
||||
BodyPart.RIGHT_LITTLE_INTERMEDIATE,
|
||||
BodyPart.RIGHT_LITTLE_DISTAL,
|
||||
]);
|
||||
|
||||
export const fingerAssignedTrackers = atom((get) =>
|
||||
get(assignedTrackersAtom).some(
|
||||
(t) => t.tracker.info?.bodyPart && FINGER_BODY_PARTS.has(t.tracker.info.bodyPart)
|
||||
)
|
||||
);
|
||||
|
||||
export const feetAssignedTrackers = atom((get) =>
|
||||
get(assignedTrackersAtom).some(
|
||||
(t) => t.tracker.info?.bodyPart && FEET_BODY_PARTS.includes(t.tracker.info.bodyPart)
|
||||
)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user