mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-11-28 12:56:32 -08:00
Send SteamVRTrackersSetting when changing tracker toggles (#1778)
Co-authored-by: loucass003 <[email protected]>
This commit is contained in:
1 parent
306510c1d9
commit
f4646f1133
4 files changed
+31
-29
No files matched your search
@@ -43,6 +43,9 @@ import {
|
||||
loadResetSettings,
|
||||
ResetSettingsForm,
|
||||
} from '@/hooks/reset-settings';
|
||||
import { atom, useAtomValue, useSetAtom } from 'jotai';
|
||||
import { isEqual } from '@react-hookz/deep-equal';
|
||||
import { selectAtom } from 'jotai/utils';
|
||||
|
||||
export type SettingsForm = {
|
||||
trackers: {
|
||||
@@ -163,7 +166,16 @@ const defaultValues: SettingsForm = {
|
||||
hidSettings: { trackersOverHID: false },
|
||||
};
|
||||
|
||||
const settingsAtom = atom(new SettingsResponseT());
|
||||
const settingsValueAtom = selectAtom(
|
||||
settingsAtom,
|
||||
(settings) => settings,
|
||||
isEqual
|
||||
);
|
||||
|
||||
export function GeneralSettings() {
|
||||
const setSettings = useSetAtom(settingsAtom);
|
||||
const settings = useAtomValue(settingsValueAtom);
|
||||
const { l10n } = useLocalization();
|
||||
const { config } = useConfig();
|
||||
const { currentLocales } = useLocaleConfig();
|
||||
@@ -183,7 +195,10 @@ export function GeneralSettings() {
|
||||
const { reset, control, watch, handleSubmit, getValues, setValue } =
|
||||
useForm<SettingsForm>({
|
||||
defaultValues,
|
||||
mode: 'onChange',
|
||||
reValidateMode: 'onChange',
|
||||
});
|
||||
|
||||
const {
|
||||
trackers: {
|
||||
automaticTrackerToggle,
|
||||
@@ -302,10 +317,7 @@ export function GeneralSettings() {
|
||||
sendRPCPacket(RpcMessage.SettingsRequest, new SettingsRequestT());
|
||||
}, []);
|
||||
|
||||
// If null, we still haven't shown the hands warning
|
||||
// if false then initially the hands warning was disabled
|
||||
const [handsWarning, setHandsWarning] = useState<boolean | null>(null);
|
||||
useRPCPacket(RpcMessage.SettingsResponse, (settings: SettingsResponseT) => {
|
||||
useEffect(() => {
|
||||
const formData: DefaultValues<SettingsForm> = {};
|
||||
|
||||
if (settings.filtering) {
|
||||
@@ -408,6 +420,13 @@ export function GeneralSettings() {
|
||||
}
|
||||
|
||||
reset({ ...getValues(), ...formData });
|
||||
}, [settings]);
|
||||
|
||||
// If null, we still haven't shown the hands warning
|
||||
// if false then initially the hands warning was disabled
|
||||
const [handsWarning, setHandsWarning] = useState<boolean | null>(null);
|
||||
useRPCPacket(RpcMessage.SettingsResponse, (settings: SettingsResponseT) => {
|
||||
setSettings(settings);
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
@@ -421,18 +440,6 @@ export function GeneralSettings() {
|
||||
}
|
||||
}, [steamVrLeftHand, steamVrRightHand, handsWarning]);
|
||||
|
||||
// Handle scrolling to selected page
|
||||
// useEffect(() => {
|
||||
// const typedState: { scrollTo: string } = state as any;
|
||||
// if (!pageRef.current || !typedState || !typedState.scrollTo) {
|
||||
// return;
|
||||
// }
|
||||
// const elem = pageRef.current.querySelector(`#${typedState.scrollTo}`);
|
||||
// if (elem) {
|
||||
// elem.scrollIntoView({ behavior: 'smooth' });
|
||||
// }
|
||||
// }, [state]);
|
||||
|
||||
return (
|
||||
<SettingsPageLayout>
|
||||
<HandsWarningModal
|
||||
|
||||
@@ -302,9 +302,8 @@ class VRServer @JvmOverloads constructor(
|
||||
queueTask {
|
||||
humanPoseManager.updateSkeletonModelFromServer()
|
||||
vrcOSCHandler.setHeadTracker(TrackerUtils.getTrackerForSkeleton(trackers, TrackerPosition.HEAD))
|
||||
if (this.getVRBridge(ISteamVRBridge::class.java)?.updateShareSettingsAutomatically() == true) {
|
||||
RPCSettingsHandler.sendSteamVRUpdatedSettings(protocolAPI, protocolAPI.rpcHandler)
|
||||
}
|
||||
this.getVRBridge(ISteamVRBridge::class.java)?.updateShareSettingsAutomatically()
|
||||
RPCSettingsHandler.sendSteamVRUpdatedSettings(protocolAPI, protocolAPI.rpcHandler)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,9 +329,8 @@ class VRServer @JvmOverloads constructor(
|
||||
queueTask {
|
||||
humanPoseManager.setPauseTracking(pauseTracking, sourceName)
|
||||
// Toggle trackers as they don't toggle when tracking is paused
|
||||
if (this.getVRBridge(ISteamVRBridge::class.java)?.updateShareSettingsAutomatically() == true) {
|
||||
RPCSettingsHandler.sendSteamVRUpdatedSettings(protocolAPI, protocolAPI.rpcHandler)
|
||||
}
|
||||
this.getVRBridge(ISteamVRBridge::class.java)?.updateShareSettingsAutomatically()
|
||||
RPCSettingsHandler.sendSteamVRUpdatedSettings(protocolAPI, protocolAPI.rpcHandler)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,9 +338,8 @@ class VRServer @JvmOverloads constructor(
|
||||
queueTask {
|
||||
humanPoseManager.togglePauseTracking(sourceName)
|
||||
// Toggle trackers as they don't toggle when tracking is paused
|
||||
if (this.getVRBridge(ISteamVRBridge::class.java)?.updateShareSettingsAutomatically() == true) {
|
||||
RPCSettingsHandler.sendSteamVRUpdatedSettings(protocolAPI, protocolAPI.rpcHandler)
|
||||
}
|
||||
this.getVRBridge(ISteamVRBridge::class.java)?.updateShareSettingsAutomatically()
|
||||
RPCSettingsHandler.sendSteamVRUpdatedSettings(protocolAPI, protocolAPI.rpcHandler)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ class RPCSettingsHandler(var rpcHandler: RPCHandler, var api: ProtocolAPI) {
|
||||
bridge.changeShareSettings(TrackerRole.LEFT_HAND, req.steamVrTrackers().leftHand())
|
||||
bridge.changeShareSettings(TrackerRole.RIGHT_HAND, req.steamVrTrackers().rightHand())
|
||||
bridge.setAutomaticSharedTrackers(req.steamVrTrackers().automaticTrackerToggle())
|
||||
sendSteamVRUpdatedSettings(api, rpcHandler)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -119,10 +119,7 @@ abstract class SteamVRBridge(
|
||||
if (value == config.automaticSharedTrackersToggling) return
|
||||
|
||||
config.automaticSharedTrackersToggling = value
|
||||
if (value) {
|
||||
updateShareSettingsAutomatically()
|
||||
RPCSettingsHandler.sendSteamVRUpdatedSettings(instance.protocolAPI, instance.protocolAPI.rpcHandler)
|
||||
}
|
||||
updateShareSettingsAutomatically()
|
||||
instance.configManager.saveConfig()
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user