From 7c1fd5b6ab19b5468195289f770d509942a8913d Mon Sep 17 00:00:00 2001 From: Erimel Date: Thu, 2 Mar 2023 12:37:03 -0500 Subject: [PATCH] Rename resets (#611) --- gui/public/i18n/en/translation.ftl | 20 +-- gui/scripts/check-missing.js | 4 +- gui/src/components/MainLayout.tsx | 5 +- gui/src/components/commons/icon/ResetIcon.tsx | 4 +- gui/src/components/home/ResetButton.tsx | 18 +-- .../settings/pages/GeneralSettings.tsx | 143 +++++++++--------- .../src/main/java/dev/slimevr/Keybinding.java | 36 ++--- .../src/main/java/dev/slimevr/VRServer.java | 4 +- .../dev/slimevr/bridge/ProtobufBridge.java | 2 +- .../config/CurrentVRConfigConverter.java | 26 ++++ .../dev/slimevr/config/KeybindingsConfig.java | 48 +++--- .../slimevr/config/TapDetectionConfig.java | 64 ++++---- .../java/dev/slimevr/config/VRConfig.java | 2 +- .../dev/slimevr/protocol/rpc/RPCHandler.java | 4 +- .../rpc/settings/RPCSettingsBuilder.java | 12 +- .../rpc/settings/RPCSettingsHandler.java | 30 ++-- .../skeleton/TapDetectionManager.java | 66 ++++---- .../slimevr/tracking/trackers/IMUTracker.java | 4 +- .../trackers/udp/TrackersUDPServer.java | 6 +- .../trackers/udp/UDPPacket21UserAction.java | 2 +- .../websocketapi/WebSocketVRBridge.java | 2 +- solarxr-protocol | 2 +- 22 files changed, 261 insertions(+), 243 deletions(-) diff --git a/gui/public/i18n/en/translation.ftl b/gui/public/i18n/en/translation.ftl index 1900c9865..eea8bd9fd 100644 --- a/gui/public/i18n/en/translation.ftl +++ b/gui/public/i18n/en/translation.ftl @@ -61,9 +61,9 @@ skeleton_bone-ELBOW_OFFSET = Elbow Offset ## Tracker reset buttons reset-reset_all = Reset all proportions -reset-full = Reset +reset-full = Full Reset reset-mounting = Reset Mounting -reset-quick = Quick Reset +reset-yaw = Yaw Reset ## Serial detection stuff serial_detection-new_device-p0 = New serial device detected! @@ -305,19 +305,19 @@ settings-general-fk_settings-vive_emulation-label = Enable Vive emulation ## Gesture control settings (tracker tapping) settings-general-gesture_control = Gesture control settings-general-gesture_control-subtitle = Tap based resets -settings-general-gesture_control-description = Allows for resets to be triggered by tapping a tracker. The tracker highest up on your torso is used for Quick Reset, the tracker highest up on your left leg is used for Reset, and the tracker highest up on your right leg is used for Mounting Reset. It should be mentioned that taps must happen within 0.6 seconds to be registered. +settings-general-gesture_control-description = Allows for resets to be triggered by tapping a tracker. The tracker highest up on your torso is used for Yaw Reset, the tracker highest up on your left leg is used for Full Reset, and the tracker highest up on your right leg is used for Mounting Reset. It should be mentioned that taps must happen within 0.6 seconds to be registered. # This is a unit: 3 taps, 2 taps, 1 tap # $amount (Number) - Amount of taps (touches to the tracker's case) settings-general-gesture_control-taps = { $amount -> [one] 1 tap *[other] { $amount } taps } -settings-general-gesture_control-quickResetEnabled = Enable tap to quick reset -settings-general-gesture_control-quickResetDelay = Quick reset delay -settings-general-gesture_control-quickResetTaps = Taps for quick reset -settings-general-gesture_control-resetEnabled = Enable tap to reset -settings-general-gesture_control-resetDelay = Reset delay -settings-general-gesture_control-resetTaps = Taps for reset +settings-general-gesture_control-yawResetEnabled = Enable tap to yaw reset +settings-general-gesture_control-yawResetDelay = Yaw reset delay +settings-general-gesture_control-yawResetTaps = Taps for yaw reset +settings-general-gesture_control-fullResetEnabled = Enable tap to full reset +settings-general-gesture_control-fullResetDelay = Full reset delay +settings-general-gesture_control-fullResetTaps = Taps for full reset settings-general-gesture_control-mountingResetEnabled = Enable tap to reset mounting settings-general-gesture_control-mountingResetDelay = Mounting reset delay settings-general-gesture_control-mountingResetTaps = Taps for mounting reset @@ -605,7 +605,7 @@ onboarding-automatic_mounting-mounting_reset-step-0 = 1. Squat in a "skiing" pos onboarding-automatic_mounting-mounting_reset-step-1 = 2. Press the "Reset Mounting" button and wait for 3 seconds before the trackers' mounting rotations will reset. onboarding-automatic_mounting-preparation-title = Preparation onboarding-automatic_mounting-preparation-step-0 = 1. Stand upright with your arms to your sides. -onboarding-automatic_mounting-preparation-step-1 = 2. Press the "Reset" button and wait for 3 seconds before the trackers will reset. +onboarding-automatic_mounting-preparation-step-1 = 2. Press the "Full Reset" button and wait for 3 seconds before the trackers will reset. onboarding-automatic_mounting-put_trackers_on-title = Put on your trackers onboarding-automatic_mounting-put_trackers_on-description = To calibrate mounting rotations, we're gonna use the trackers you just assigned. Put on all your trackers, you can see which are which in the figure to the right. onboarding-automatic_mounting-put_trackers_on-next = I have all my trackers on diff --git a/gui/scripts/check-missing.js b/gui/scripts/check-missing.js index 84bbc46a0..c3027f3ef 100755 --- a/gui/scripts/check-missing.js +++ b/gui/scripts/check-missing.js @@ -28,9 +28,7 @@ const PATH = path.join( const langs = fs.readdirSync(PATH).filter((x) => x !== 'en'); const en = new FluentBundle('en'); const enErrors = en.addResource( - new FluentResource( - fs.readFileSync(path.join(PATH, 'en/translation.ftl'), 'utf-8') - ) + new FluentResource(fs.readFileSync(path.join(PATH, 'en/translation.ftl'), 'utf-8')) ); if (enErrors.length) { for (const error of enErrors) { diff --git a/gui/src/components/MainLayout.tsx b/gui/src/components/MainLayout.tsx index 38e90e865..543cc03d3 100644 --- a/gui/src/components/MainLayout.tsx +++ b/gui/src/components/MainLayout.tsx @@ -64,10 +64,7 @@ export function MainLayoutRoute({ {widgets && (
- + { switch (type) { - case ResetType.Quick: - return l10n.getString('reset-quick'); + case ResetType.Yaw: + return l10n.getString('reset-yaw'); case ResetType.Mounting: return l10n.getString('reset-mounting'); case ResetType.Full: @@ -50,17 +50,17 @@ export function ResetButton({ const getIcon = () => { switch (type) { - case ResetType.Quick: - return ; + case ResetType.Yaw: + return ; case ResetType.Mounting: return ; } - return ; + return ; }; const variantsMap = { small: - type == ResetType.Quick ? ( + type == ResetType.Yaw ? ( @@ -78,7 +78,7 @@ export function ResetButton({ ), big: - type == ResetType.Quick ? ( + type == ResetType.Yaw ? ( ) : ( `${Math.round(value * 10) / 10} s`} min={0.2} @@ -734,9 +731,9 @@ export function GeneralSettings() { /> `${Math.round(value * 10) / 10} s`} min={0.2} @@ -745,7 +742,7 @@ export function GeneralSettings() { /> l10n.getString('settings-general-gesture_control-taps', { @@ -773,9 +770,9 @@ export function GeneralSettings() { /> l10n.getString('settings-general-gesture_control-taps', { @@ -788,7 +785,7 @@ export function GeneralSettings() { /> { - server.scheduleResetTrackers(resetSourceName, this.config.getResetDelay()); + case FULL_RESET -> { + server.scheduleResetTrackersFull(resetSourceName, this.config.getFullResetDelay()); } - case QUICK_RESET -> { - server.scheduleResetTrackersYaw(resetSourceName, this.config.getQuickResetDelay()); + case YAW_RESET -> { + server.scheduleResetTrackersYaw(resetSourceName, this.config.getYawResetDelay()); } - case RESET_MOUNTING -> { + case MOUNTING_RESET -> { server .scheduleResetTrackersMounting( resetSourceName, - this.config.getResetMountingDelay() + this.config.getMountingResetDelay() ); } } diff --git a/server/src/main/java/dev/slimevr/VRServer.java b/server/src/main/java/dev/slimevr/VRServer.java index 8c7daaf18..f1039cddd 100644 --- a/server/src/main/java/dev/slimevr/VRServer.java +++ b/server/src/main/java/dev/slimevr/VRServer.java @@ -326,7 +326,7 @@ public class VRServer extends Thread { queueTask(humanPoseManager::updateSkeletonModelFromServer); } - public void resetTrackers(String resetSourceName) { + public void resetTrackersFull(String resetSourceName) { queueTask(() -> { humanPoseManager.resetTrackersFull(resetSourceName); }); @@ -344,7 +344,7 @@ public class VRServer extends Thread { }); } - public void scheduleResetTrackers(String resetSourceName, long delay) { + public void scheduleResetTrackersFull(String resetSourceName, long delay) { TimerTask resetTask = new TimerTask() { public void run() { queueTask(() -> { diff --git a/server/src/main/java/dev/slimevr/bridge/ProtobufBridge.java b/server/src/main/java/dev/slimevr/bridge/ProtobufBridge.java index c09b2a0bb..5711affce 100644 --- a/server/src/main/java/dev/slimevr/bridge/ProtobufBridge.java +++ b/server/src/main/java/dev/slimevr/bridge/ProtobufBridge.java @@ -189,7 +189,7 @@ public abstract class ProtobufBridge implements Bridge { .warning("[" + bridgeName + "] Received deprecated user action 'calibrate'!"); case "reset": // TODO : Check pose field - Main.getVrServer().resetTrackers(resetSourceName); + Main.getVrServer().resetTrackersFull(resetSourceName); break; case "fast_reset": Main.getVrServer().resetTrackersYaw(resetSourceName); diff --git a/server/src/main/java/dev/slimevr/config/CurrentVRConfigConverter.java b/server/src/main/java/dev/slimevr/config/CurrentVRConfigConverter.java index b928d27b2..d3a03c169 100644 --- a/server/src/main/java/dev/slimevr/config/CurrentVRConfigConverter.java +++ b/server/src/main/java/dev/slimevr/config/CurrentVRConfigConverter.java @@ -175,6 +175,32 @@ public class CurrentVRConfigConverter implements VersionedModelConverter { } } } + if (version < 8) { + // reset > fullReset, quickReset > yawReset + ObjectNode keybindingsNode = (ObjectNode) modelData.get("keybindings"); + if (keybindingsNode != null) { + keybindingsNode.set("fullResetBinding", keybindingsNode.get("resetBinding")); + keybindingsNode.set("yawResetBinding", keybindingsNode.get("quickResetBinding")); + keybindingsNode + .set("mountingResetBinding", keybindingsNode.get("resetMountingBinding")); + if (keybindingsNode.get("resetDelay") != null) { + keybindingsNode.set("fullResetDelay", keybindingsNode.get("resetDelay")); + keybindingsNode.set("yawResetDelay", keybindingsNode.get("quickResetDelay")); + keybindingsNode + .set("mountingResetDelay", keybindingsNode.get("resetMountingDelay")); + } + } + + ObjectNode tapDetectionNode = (ObjectNode) modelData.get("tapDetection"); + if (tapDetectionNode != null) { + tapDetectionNode.set("yawResetDelay", tapDetectionNode.get("quickResetDelay")); + tapDetectionNode.set("fullResetDelay", tapDetectionNode.get("resetDelay")); + tapDetectionNode.set("yawResetEnabled", tapDetectionNode.get("quickResetEnabled")); + tapDetectionNode.set("fullResetEnabled", tapDetectionNode.get("resetEnabled")); + tapDetectionNode.set("yawResetTaps", tapDetectionNode.get("quickResetTaps")); + tapDetectionNode.set("fullResetTaps", tapDetectionNode.get("resetTaps")); + } + } return modelData; } diff --git a/server/src/main/java/dev/slimevr/config/KeybindingsConfig.java b/server/src/main/java/dev/slimevr/config/KeybindingsConfig.java index 095b90f5c..198552f54 100644 --- a/server/src/main/java/dev/slimevr/config/KeybindingsConfig.java +++ b/server/src/main/java/dev/slimevr/config/KeybindingsConfig.java @@ -2,55 +2,55 @@ package dev.slimevr.config; public class KeybindingsConfig { - private String resetBinding = "CTRL+ALT+SHIFT+Y"; + private String fullResetBinding = "CTRL+ALT+SHIFT+Y"; - private String quickResetBinding = "CTRL+ALT+SHIFT+U"; + private String yawResetBinding = "CTRL+ALT+SHIFT+U"; - private String resetMountingBinding = "CTRL+ALT+SHIFT+I"; + private String mountingResetBinding = "CTRL+ALT+SHIFT+I"; - private long resetDelay = 0L; + private long fullResetDelay = 0L; - private long quickResetDelay = 0L; + private long yawResetDelay = 0L; - private long resetMountingDelay = 0L; + private long mountingResetDelay = 0L; public KeybindingsConfig() { } - public String getResetBinding() { - return resetBinding; + public String getFullResetBinding() { + return fullResetBinding; } - public String getQuickResetBinding() { - return quickResetBinding; + public String getYawResetBinding() { + return yawResetBinding; } - public String getResetMountingBinding() { - return resetMountingBinding; + public String getMountingResetBinding() { + return mountingResetBinding; } - public long getResetDelay() { - return resetDelay; + public long getFullResetDelay() { + return fullResetDelay; } - public void setResetDelay(long delay) { - resetDelay = delay; + public void setFullResetDelay(long delay) { + fullResetDelay = delay; } - public long getQuickResetDelay() { - return quickResetDelay; + public long getYawResetDelay() { + return yawResetDelay; } - public void setQuickResetDelay(long delay) { - quickResetDelay = delay; + public void setYawResetDelay(long delay) { + yawResetDelay = delay; } - public long getResetMountingDelay() { - return resetMountingDelay; + public long getMountingResetDelay() { + return mountingResetDelay; } - public void setResetMountingDelay(long delay) { - resetMountingDelay = delay; + public void setMountingResetDelay(long delay) { + mountingResetDelay = delay; } } diff --git a/server/src/main/java/dev/slimevr/config/TapDetectionConfig.java b/server/src/main/java/dev/slimevr/config/TapDetectionConfig.java index dc4a7dfcd..4622ca63a 100644 --- a/server/src/main/java/dev/slimevr/config/TapDetectionConfig.java +++ b/server/src/main/java/dev/slimevr/config/TapDetectionConfig.java @@ -8,31 +8,31 @@ import com.jme3.math.FastMath; // for each reset type public class TapDetectionConfig { - private float quickResetDelay = 0.2f; - private float resetDelay = 1.0f; + private float yawResetDelay = 0.2f; + private float fullResetDelay = 1.0f; private float mountingResetDelay = 1.0f; - private boolean quickResetEnabled = true; - private boolean resetEnabled = true; + private boolean yawResetEnabled = true; + private boolean fullResetEnabled = true; private boolean mountingResetEnabled = true; - private int quickResetTaps = 2; - private int resetTaps = 3; + private int yawResetTaps = 2; + private int fullResetTaps = 3; private int mountingResetTaps = 3; private int numberTrackersOverThreshold = 1; - public float getQuickResetDelay() { - return quickResetDelay; + public float getYawResetDelay() { + return yawResetDelay; } - public void setQuickResetDelay(float quickResetDelay) { - this.quickResetDelay = quickResetDelay; + public void setYawResetDelay(float yawResetDelay) { + this.yawResetDelay = yawResetDelay; } - public float getResetDelay() { - return resetDelay; + public float getFullResetDelay() { + return fullResetDelay; } - public void setResetDelay(float resetDelay) { - this.resetDelay = resetDelay; + public void setFullResetDelay(float fullResetDelay) { + this.fullResetDelay = fullResetDelay; } public float getMountingResetDelay() { @@ -43,20 +43,20 @@ public class TapDetectionConfig { this.mountingResetDelay = mountingResetDelay; } - public boolean getQuickResetEnabled() { - return quickResetEnabled; + public boolean getYawResetEnabled() { + return yawResetEnabled; } - public void setQuickResetEnabled(boolean quickResetEnabled) { - this.quickResetEnabled = quickResetEnabled; + public void setYawResetEnabled(boolean yawResetEnabled) { + this.yawResetEnabled = yawResetEnabled; } - public boolean getResetEnabled() { - return resetEnabled; + public boolean getFullResetEnabled() { + return fullResetEnabled; } - public void setResetEnabled(boolean resetEnabled) { - this.resetEnabled = resetEnabled; + public void setFullResetEnabled(boolean fullResetEnabled) { + this.fullResetEnabled = fullResetEnabled; } public boolean getMountingResetEnabled() { @@ -67,23 +67,23 @@ public class TapDetectionConfig { this.mountingResetEnabled = mountingResetEnabled; } - public int getQuickResetTaps() { - return quickResetTaps; + public int getYawResetTaps() { + return yawResetTaps; } // clamp to 2-3 to prevent errors - public void setQuickResetTaps(int quickResetTaps) { - this.quickResetTaps = (int) FastMath.clamp(quickResetTaps, 2, 10); - this.quickResetTaps = quickResetTaps; + public void setYawResetTaps(int yawResetTaps) { + this.yawResetTaps = (int) FastMath.clamp(yawResetTaps, 2, 10); + this.yawResetTaps = yawResetTaps; } - public int getResetTaps() { - return resetTaps; + public int getFullResetTaps() { + return fullResetTaps; } - public void setResetTaps(int resetTaps) { - this.resetTaps = (int) FastMath.clamp(resetTaps, 2, 10); - this.resetTaps = resetTaps; + public void setFullResetTaps(int fullResetTaps) { + this.fullResetTaps = (int) FastMath.clamp(fullResetTaps, 2, 10); + this.fullResetTaps = fullResetTaps; } public int getMountingResetTaps() { diff --git a/server/src/main/java/dev/slimevr/config/VRConfig.java b/server/src/main/java/dev/slimevr/config/VRConfig.java index 16ba255a1..a1a70765f 100644 --- a/server/src/main/java/dev/slimevr/config/VRConfig.java +++ b/server/src/main/java/dev/slimevr/config/VRConfig.java @@ -14,7 +14,7 @@ import java.util.Map; @JsonVersionedModel( - currentVersion = "7", defaultDeserializeToVersion = "7", toCurrentConverterClass = CurrentVRConfigConverter.class + currentVersion = "8", defaultDeserializeToVersion = "8", toCurrentConverterClass = CurrentVRConfigConverter.class ) public class VRConfig { diff --git a/server/src/main/java/dev/slimevr/protocol/rpc/RPCHandler.java b/server/src/main/java/dev/slimevr/protocol/rpc/RPCHandler.java index ec992af95..80809aa61 100644 --- a/server/src/main/java/dev/slimevr/protocol/rpc/RPCHandler.java +++ b/server/src/main/java/dev/slimevr/protocol/rpc/RPCHandler.java @@ -198,10 +198,10 @@ public class RPCHandler extends ProtocolHandler if (req == null) return; - if (req.resetType() == ResetType.Quick) + if (req.resetType() == ResetType.Yaw) this.api.server.resetTrackersYaw(resetSourceName); if (req.resetType() == ResetType.Full) - this.api.server.resetTrackers(resetSourceName); + this.api.server.resetTrackersFull(resetSourceName); if (req.resetType() == ResetType.Mounting) this.api.server.resetTrackersMounting(resetSourceName); } diff --git a/server/src/main/java/dev/slimevr/protocol/rpc/settings/RPCSettingsBuilder.java b/server/src/main/java/dev/slimevr/protocol/rpc/settings/RPCSettingsBuilder.java index 44bff5e4a..abf040d5a 100644 --- a/server/src/main/java/dev/slimevr/protocol/rpc/settings/RPCSettingsBuilder.java +++ b/server/src/main/java/dev/slimevr/protocol/rpc/settings/RPCSettingsBuilder.java @@ -133,12 +133,12 @@ public class RPCSettingsBuilder { return TapDetectionSettings .createTapDetectionSettings( fbb, - tapDetectionConfig.getResetDelay(), - tapDetectionConfig.getResetEnabled(), - tapDetectionConfig.getResetTaps(), - tapDetectionConfig.getQuickResetDelay(), - tapDetectionConfig.getQuickResetEnabled(), - tapDetectionConfig.getQuickResetTaps(), + tapDetectionConfig.getFullResetDelay(), + tapDetectionConfig.getFullResetEnabled(), + tapDetectionConfig.getFullResetTaps(), + tapDetectionConfig.getYawResetDelay(), + tapDetectionConfig.getYawResetEnabled(), + tapDetectionConfig.getYawResetTaps(), tapDetectionConfig.getMountingResetDelay(), tapDetectionConfig.getMountingResetEnabled(), tapDetectionConfig.getMountingResetTaps(), diff --git a/server/src/main/java/dev/slimevr/protocol/rpc/settings/RPCSettingsHandler.java b/server/src/main/java/dev/slimevr/protocol/rpc/settings/RPCSettingsHandler.java index 681cc706e..6b628c7a2 100644 --- a/server/src/main/java/dev/slimevr/protocol/rpc/settings/RPCSettingsHandler.java +++ b/server/src/main/java/dev/slimevr/protocol/rpc/settings/RPCSettingsHandler.java @@ -219,38 +219,38 @@ public record RPCSettingsHandler(RPCHandler rpcHandler, ProtocolAPI api) { if (tapDetectionSettings != null) { // enable/disable tap detection tapDetectionConfig - .setQuickResetEnabled(tapDetectionSettings.tapQuickResetEnabled()); + .setYawResetEnabled(tapDetectionSettings.yawResetEnabled()); tapDetectionConfig - .setResetEnabled(tapDetectionSettings.tapResetEnabled()); + .setFullResetEnabled(tapDetectionSettings.fullResetEnabled()); tapDetectionConfig - .setMountingResetEnabled(tapDetectionSettings.tapMountingResetEnabled()); + .setMountingResetEnabled(tapDetectionSettings.mountingResetEnabled()); // set tap detection delays - if (tapDetectionSettings.hasTapQuickResetDelay()) { + if (tapDetectionSettings.hasYawResetDelay()) { tapDetectionConfig - .setQuickResetDelay(tapDetectionSettings.tapQuickResetDelay()); + .setYawResetDelay(tapDetectionSettings.yawResetDelay()); } - if (tapDetectionSettings.hasTapResetDelay()) { + if (tapDetectionSettings.hasFullResetDelay()) { tapDetectionConfig - .setResetDelay(tapDetectionSettings.tapResetDelay()); + .setFullResetDelay(tapDetectionSettings.fullResetDelay()); } - if (tapDetectionSettings.hasTapMountingResetDelay()) { + if (tapDetectionSettings.hasMountingResetDelay()) { tapDetectionConfig - .setMountingResetDelay(tapDetectionSettings.tapMountingResetDelay()); + .setMountingResetDelay(tapDetectionSettings.mountingResetDelay()); } // set the number of taps required for each action - if (tapDetectionSettings.hasTapQuickResetTaps()) { + if (tapDetectionSettings.hasYawResetTaps()) { tapDetectionConfig - .setQuickResetTaps(tapDetectionSettings.tapQuickResetTaps()); + .setYawResetTaps(tapDetectionSettings.yawResetTaps()); } - if (tapDetectionSettings.hasTapResetTaps()) { + if (tapDetectionSettings.hasFullResetTaps()) { tapDetectionConfig - .setResetTaps(tapDetectionSettings.tapResetTaps()); + .setFullResetTaps(tapDetectionSettings.fullResetTaps()); } - if (tapDetectionSettings.hasTapMountingResetTaps()) { + if (tapDetectionSettings.hasMountingResetTaps()) { tapDetectionConfig - .setMountingResetTaps(tapDetectionSettings.tapMountingResetTaps()); + .setMountingResetTaps(tapDetectionSettings.mountingResetTaps()); } this.api.server.humanPoseManager.updateTapDetectionConfig(); diff --git a/server/src/main/java/dev/slimevr/tracking/processor/skeleton/TapDetectionManager.java b/server/src/main/java/dev/slimevr/tracking/processor/skeleton/TapDetectionManager.java index 393e4d5cd..6ab6843bf 100644 --- a/server/src/main/java/dev/slimevr/tracking/processor/skeleton/TapDetectionManager.java +++ b/server/src/main/java/dev/slimevr/tracking/processor/skeleton/TapDetectionManager.java @@ -16,19 +16,19 @@ public class TapDetectionManager { private TapDetectionConfig config; // tap detectors - private TapDetection quickResetDetector; - private TapDetection resetDetector; + private TapDetection yawResetDetector; + private TapDetection fullResetDetector; private TapDetection mountingResetDetector; // number of taps to detect - private int quickResetTaps = 2; - private int resetTaps = 3; + private int yawResetTaps = 2; + private int fullResetTaps = 3; private int mountingResetTaps = 3; // delay private static final float NS_CONVERTER = 1.0e9f; - private float resetDelayNs = 0.20f * NS_CONVERTER; - private float quickResetDelayNs = 1.00f * NS_CONVERTER; + private float fullResetDelayNs = 0.20f * NS_CONVERTER; + private float yawResetDelayNs = 1.00f * NS_CONVERTER; private float mountingResetDelayNs = 1.00f * NS_CONVERTER; public TapDetectionManager(HumanSkeleton skeleton) { @@ -44,17 +44,17 @@ public class TapDetectionManager { this.humanPoseManager = humanPoseManager; this.config = config; - quickResetDetector = new TapDetection(skeleton, getTrackerToWatchQuickReset()); - resetDetector = new TapDetection(skeleton, getTrackerToWatchReset()); + yawResetDetector = new TapDetection(skeleton, getTrackerToWatchYawReset()); + fullResetDetector = new TapDetection(skeleton, getTrackerToWatchFullReset()); mountingResetDetector = new TapDetection(skeleton, getTrackerToWatchMountingReset()); // since this config value is only modified by editing the config file, // we can set it here - quickResetDetector + yawResetDetector .setNumberTrackersOverThreshold( config.getNumberTrackersOverThreshold() ); - resetDetector + fullResetDetector .setNumberTrackersOverThreshold( config.getNumberTrackersOverThreshold() ); @@ -67,59 +67,59 @@ public class TapDetectionManager { } public void updateConfig() { - this.quickResetDelayNs = config.getQuickResetDelay() * NS_CONVERTER; - this.resetDelayNs = config.getResetDelay() * NS_CONVERTER; + this.yawResetDelayNs = config.getYawResetDelay() * NS_CONVERTER; + this.fullResetDelayNs = config.getFullResetDelay() * NS_CONVERTER; this.mountingResetDelayNs = config.getMountingResetDelay() * NS_CONVERTER; - quickResetDetector.setEnabled(config.getQuickResetEnabled()); - resetDetector.setEnabled(config.getResetEnabled()); + yawResetDetector.setEnabled(config.getYawResetEnabled()); + fullResetDetector.setEnabled(config.getFullResetEnabled()); mountingResetDetector.setEnabled(config.getMountingResetEnabled()); - quickResetTaps = config.getQuickResetTaps(); - resetTaps = config.getResetTaps(); + yawResetTaps = config.getYawResetTaps(); + fullResetTaps = config.getFullResetTaps(); mountingResetTaps = config.getMountingResetTaps(); - quickResetDetector.setMaxTaps(quickResetTaps); - resetDetector.setMaxTaps(resetTaps); + yawResetDetector.setMaxTaps(yawResetTaps); + fullResetDetector.setMaxTaps(fullResetTaps); mountingResetDetector.setMaxTaps(mountingResetTaps); } public void update() { - if (quickResetDetector == null || resetDetector == null || mountingResetDetector == null) + if (yawResetDetector == null || fullResetDetector == null || mountingResetDetector == null) return; // update the tap detectors - quickResetDetector.update(); - resetDetector.update(); + yawResetDetector.update(); + fullResetDetector.update(); mountingResetDetector.update(); // check if any tap detectors have detected taps - checkQuickReset(); - checkReset(); + checkYawReset(); + checkFullReset(); checkMountingReset(); } - private void checkQuickReset() { - boolean tapped = (quickResetTaps <= quickResetDetector.getTaps()); + private void checkYawReset() { + boolean tapped = (yawResetTaps <= yawResetDetector.getTaps()); if ( - tapped && System.nanoTime() - quickResetDetector.getDetectionTime() > quickResetDelayNs + tapped && System.nanoTime() - yawResetDetector.getDetectionTime() > yawResetDelayNs ) { if (humanPoseManager != null) humanPoseManager.resetTrackersYaw(resetSourceName); else skeleton.resetTrackersYaw(resetSourceName); - quickResetDetector.resetDetector(); + yawResetDetector.resetDetector(); } } - private void checkReset() { - boolean tapped = (resetTaps <= resetDetector.getTaps()); + private void checkFullReset() { + boolean tapped = (fullResetTaps <= fullResetDetector.getTaps()); if ( - tapped && System.nanoTime() - resetDetector.getDetectionTime() > resetDelayNs + tapped && System.nanoTime() - fullResetDetector.getDetectionTime() > fullResetDelayNs ) { if (humanPoseManager != null) humanPoseManager.resetTrackersFull(resetSourceName); else skeleton.resetTrackersFull(resetSourceName); - resetDetector.resetDetector(); + fullResetDetector.resetDetector(); } } @@ -139,7 +139,7 @@ public class TapDetectionManager { // returns either the chest tracker, hip tracker, or waist tracker depending // on which one is available // if none are available, returns null - private Tracker getTrackerToWatchQuickReset() { + private Tracker getTrackerToWatchYawReset() { if (skeleton.chestTracker != null) return skeleton.chestTracker; else if (skeleton.hipTracker != null) @@ -150,7 +150,7 @@ public class TapDetectionManager { return null; } - private Tracker getTrackerToWatchReset() { + private Tracker getTrackerToWatchFullReset() { if (skeleton.leftUpperLegTracker != null) return skeleton.leftUpperLegTracker; else if (skeleton.leftLowerLegTracker != null) diff --git a/server/src/main/java/dev/slimevr/tracking/trackers/IMUTracker.java b/server/src/main/java/dev/slimevr/tracking/trackers/IMUTracker.java index 2440f1904..e22268494 100644 --- a/server/src/main/java/dev/slimevr/tracking/trackers/IMUTracker.java +++ b/server/src/main/java/dev/slimevr/tracking/trackers/IMUTracker.java @@ -260,7 +260,7 @@ public class IMUTracker } /** - * Calculates reference-adjusted rotation (with full/quick reset) including + * Calculates reference-adjusted rotation (with full/yaw reset) including * the mounting orientation (front, back, left, right) and mounting reset * adjustment. Also taking drift compensation into account. * @@ -286,7 +286,7 @@ public class IMUTracker } /** - * Calculates zero-reference-adjusted rotation (with full/quick reset). Same + * Calculates zero-reference-adjusted rotation (with full/yaw reset). Same * as {@link #getRotation(Quaternion)}, except rotation is aligned to an * identity quaternion instead of HMD and does not include mounting reset * and mounting orientation adjustments. Does not take drift compensation diff --git a/server/src/main/java/dev/slimevr/tracking/trackers/udp/TrackersUDPServer.java b/server/src/main/java/dev/slimevr/tracking/trackers/udp/TrackersUDPServer.java index 85d812f1e..f0b5315fb 100644 --- a/server/src/main/java/dev/slimevr/tracking/trackers/udp/TrackersUDPServer.java +++ b/server/src/main/java/dev/slimevr/tracking/trackers/udp/TrackersUDPServer.java @@ -571,14 +571,14 @@ public class TrackersUDPServer extends Thread { break; UDPPacket21UserAction action = (UDPPacket21UserAction) packet; switch (action.type) { - case UDPPacket21UserAction.RESET: + case UDPPacket21UserAction.RESET_FULL: case UDPPacket21UserAction.RESET_YAW: case UDPPacket21UserAction.RESET_MOUNTING: String name = ""; switch (action.type) { - case UDPPacket21UserAction.RESET: + case UDPPacket21UserAction.RESET_FULL: name = "Full"; - Main.getVrServer().resetTrackers(resetSourceName); + Main.getVrServer().resetTrackersFull(resetSourceName); break; case UDPPacket21UserAction.RESET_YAW: name = "Yaw"; diff --git a/server/src/main/java/dev/slimevr/tracking/trackers/udp/UDPPacket21UserAction.java b/server/src/main/java/dev/slimevr/tracking/trackers/udp/UDPPacket21UserAction.java index 658588bb4..930cdb996 100644 --- a/server/src/main/java/dev/slimevr/tracking/trackers/udp/UDPPacket21UserAction.java +++ b/server/src/main/java/dev/slimevr/tracking/trackers/udp/UDPPacket21UserAction.java @@ -6,7 +6,7 @@ import java.nio.ByteBuffer; public class UDPPacket21UserAction extends UDPPacket { - public static final int RESET = 2; + public static final int RESET_FULL = 2; public static final int RESET_YAW = 3; public static final int RESET_MOUNTING = 4; diff --git a/server/src/main/java/dev/slimevr/websocketapi/WebSocketVRBridge.java b/server/src/main/java/dev/slimevr/websocketapi/WebSocketVRBridge.java index 0c4b6657c..3ab496550 100644 --- a/server/src/main/java/dev/slimevr/websocketapi/WebSocketVRBridge.java +++ b/server/src/main/java/dev/slimevr/websocketapi/WebSocketVRBridge.java @@ -172,7 +172,7 @@ public class WebSocketVRBridge extends WebsocketAPI implements Bridge { private void parseAction(ObjectNode json, WebSocket conn) { switch (json.get("name").asText()) { case "calibrate" -> Main.getVrServer().resetTrackersYaw(resetSourceName); - case "full_calibrate" -> Main.getVrServer().resetTrackers(resetSourceName); + case "full_calibrate" -> Main.getVrServer().resetTrackersFull(resetSourceName); } } diff --git a/solarxr-protocol b/solarxr-protocol index 05647cfad..8ff2ce62a 160000 --- a/solarxr-protocol +++ b/solarxr-protocol @@ -1 +1 @@ -Subproject commit 05647cfad0cdde80e99360d8cbe8b69ce86d2eeb +Subproject commit 8ff2ce62aeac9e76e6fc9d2d92377e0808715349