Rename resets (#611)

This commit is contained in:
Erimel
2023-03-02 12:37:03 -05:00
committed by GitHub
parent 233a754d20
commit 7c1fd5b6ab
22 changed files with 261 additions and 243 deletions

View File

@@ -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

View File

@@ -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) {

View File

@@ -64,10 +64,7 @@ export function MainLayoutRoute({
{widgets && (
<div className="flex flex-col px-2 min-w-[274px] w-[274px] gap-2 pt-2 rounded-xl overflow-y-auto bg-background-70">
<div className="grid grid-cols-2 gap-2 w-full [&>*:nth-child(odd):last-of-type]:col-span-full">
<ResetButton
type={ResetType.Quick}
variant="big"
></ResetButton>
<ResetButton type={ResetType.Yaw} variant="big"></ResetButton>
<ResetButton
type={ResetType.Full}
variant="big"

View File

@@ -1,4 +1,4 @@
export function ResetIcon({ width = 33 }: { width?: number }) {
export function FullResetIcon({ width = 33 }: { width?: number }) {
return (
<svg
width={width}
@@ -25,7 +25,7 @@ export function ResetIcon({ width = 33 }: { width?: number }) {
);
}
export function QuickResetIcon({ width = 33 }: { width?: number }) {
export function YawResetIcon({ width = 33 }: { width?: number }) {
return (
<svg
width={width}

View File

@@ -7,8 +7,8 @@ import { BigButton } from '../commons/BigButton';
import { Button } from '../commons/Button';
import {
MountingResetIcon,
QuickResetIcon,
ResetIcon,
YawResetIcon,
FullResetIcon,
} from '../commons/icon/ResetIcon';
export function ResetButton({
@@ -38,8 +38,8 @@ export function ResetButton({
const text = useMemo(() => {
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 <QuickResetIcon width={20} />;
case ResetType.Yaw:
return <YawResetIcon width={20} />;
case ResetType.Mounting:
return <MountingResetIcon width={20} />;
}
return <ResetIcon width={20} />;
return <FullResetIcon width={20} />;
};
const variantsMap = {
small:
type == ResetType.Quick ? (
type == ResetType.Yaw ? (
<Button icon={getIcon()} onClick={reset} variant="primary">
{text}
</Button>
@@ -78,7 +78,7 @@ export function ResetButton({
</Button>
),
big:
type == ResetType.Quick ? (
type == ResetType.Yaw ? (
<BigButton text={text} icon={getIcon()} onClick={reset}></BigButton>
) : (
<BigButton

View File

@@ -58,15 +58,15 @@ interface SettingsForm {
footPlant: boolean;
};
tapDetection: {
tapMountingResetEnabled: boolean;
tapQuickResetEnabled: boolean;
tapResetEnabled: boolean;
tapQuickResetDelay: number;
tapResetDelay: number;
tapMountingResetDelay: number;
tapQuickResetTaps: number;
tapResetTaps: number;
tapMountingResetTaps: number;
mountingResetEnabled: boolean;
yawResetEnabled: boolean;
fullResetEnabled: boolean;
yawResetDelay: number;
fullResetDelay: number;
mountingResetDelay: number;
yawResetTaps: number;
fullResetTaps: number;
mountingResetTaps: number;
};
legTweaks: {
correctionStrength: number;
@@ -104,15 +104,15 @@ const defaultValues = {
maxResets: 1,
},
tapDetection: {
tapMountingResetEnabled: false,
tapQuickResetEnabled: false,
tapResetEnabled: false,
tapQuickResetDelay: 0.2,
tapResetDelay: 1.0,
tapMountingResetDelay: 1.0,
tapQuickResetTaps: 2,
tapResetTaps: 3,
tapMountingResetTaps: 3,
mountingResetEnabled: false,
yawResetEnabled: false,
fullResetEnabled: false,
yawResetDelay: 0.2,
fullResetDelay: 1.0,
mountingResetDelay: 1.0,
yawResetTaps: 2,
fullResetTaps: 3,
mountingResetTaps: 3,
},
legTweaks: { correctionStrength: 0.3 },
interface: { devmode: false, watchNewDevices: true },
@@ -162,19 +162,16 @@ export function GeneralSettings() {
settings.modelSettings = modelSettings;
const tapDetection = new TapDetectionSettingsT();
tapDetection.tapResetDelay = values.tapDetection.tapResetDelay;
tapDetection.tapResetEnabled = values.tapDetection.tapResetEnabled;
tapDetection.tapResetTaps = values.tapDetection.tapResetTaps;
tapDetection.tapQuickResetDelay = values.tapDetection.tapQuickResetDelay;
tapDetection.tapQuickResetEnabled =
values.tapDetection.tapQuickResetEnabled;
tapDetection.tapQuickResetTaps = values.tapDetection.tapQuickResetTaps;
tapDetection.tapMountingResetEnabled =
values.tapDetection.tapMountingResetEnabled;
tapDetection.tapMountingResetDelay =
values.tapDetection.tapMountingResetDelay;
tapDetection.tapMountingResetTaps =
values.tapDetection.tapMountingResetTaps;
tapDetection.fullResetDelay = values.tapDetection.fullResetDelay;
tapDetection.fullResetEnabled = values.tapDetection.fullResetEnabled;
tapDetection.fullResetTaps = values.tapDetection.fullResetTaps;
tapDetection.yawResetDelay = values.tapDetection.yawResetDelay;
tapDetection.yawResetEnabled = values.tapDetection.yawResetEnabled;
tapDetection.yawResetTaps = values.tapDetection.yawResetTaps;
tapDetection.mountingResetEnabled =
values.tapDetection.mountingResetEnabled;
tapDetection.mountingResetDelay = values.tapDetection.mountingResetDelay;
tapDetection.mountingResetTaps = values.tapDetection.mountingResetTaps;
settings.tapDetectionSettings = tapDetection;
const filtering = new FilteringSettingsT();
@@ -240,33 +237,33 @@ export function GeneralSettings() {
if (settings.tapDetectionSettings) {
formData.tapDetection = {
tapQuickResetEnabled:
settings.tapDetectionSettings.tapQuickResetEnabled ||
defaultValues.tapDetection.tapQuickResetEnabled,
tapResetEnabled:
settings.tapDetectionSettings.tapResetEnabled ||
defaultValues.tapDetection.tapResetEnabled,
tapMountingResetEnabled:
settings.tapDetectionSettings.tapMountingResetEnabled ||
defaultValues.tapDetection.tapMountingResetEnabled,
tapQuickResetDelay:
settings.tapDetectionSettings.tapQuickResetDelay ||
defaultValues.tapDetection.tapQuickResetDelay,
tapResetDelay:
settings.tapDetectionSettings.tapResetDelay ||
defaultValues.tapDetection.tapResetDelay,
tapMountingResetDelay:
settings.tapDetectionSettings.tapMountingResetDelay ||
defaultValues.tapDetection.tapMountingResetDelay,
tapQuickResetTaps:
settings.tapDetectionSettings.tapQuickResetTaps ||
defaultValues.tapDetection.tapQuickResetTaps,
tapResetTaps:
settings.tapDetectionSettings.tapResetTaps ||
defaultValues.tapDetection.tapResetTaps,
tapMountingResetTaps:
settings.tapDetectionSettings.tapMountingResetTaps ||
defaultValues.tapDetection.tapMountingResetTaps,
yawResetEnabled:
settings.tapDetectionSettings.yawResetEnabled ||
defaultValues.tapDetection.yawResetEnabled,
fullResetEnabled:
settings.tapDetectionSettings.fullResetEnabled ||
defaultValues.tapDetection.fullResetEnabled,
mountingResetEnabled:
settings.tapDetectionSettings.mountingResetEnabled ||
defaultValues.tapDetection.mountingResetEnabled,
yawResetDelay:
settings.tapDetectionSettings.yawResetDelay ||
defaultValues.tapDetection.yawResetDelay,
fullResetDelay:
settings.tapDetectionSettings.fullResetDelay ||
defaultValues.tapDetection.fullResetDelay,
mountingResetDelay:
settings.tapDetectionSettings.mountingResetDelay ||
defaultValues.tapDetection.mountingResetDelay,
yawResetTaps:
settings.tapDetectionSettings.yawResetTaps ||
defaultValues.tapDetection.yawResetTaps,
fullResetTaps:
settings.tapDetectionSettings.fullResetTaps ||
defaultValues.tapDetection.fullResetTaps,
mountingResetTaps:
settings.tapDetectionSettings.mountingResetTaps ||
defaultValues.tapDetection.mountingResetTaps,
};
}
@@ -696,25 +693,25 @@ export function GeneralSettings() {
variant="toggle"
outlined
control={control}
name="tapDetection.tapQuickResetEnabled"
name="tapDetection.yawResetEnabled"
label={l10n.getString(
'settings-general-gesture_control-quickResetEnabled'
'settings-general-gesture_control-yawResetEnabled'
)}
/>
<CheckBox
variant="toggle"
outlined
control={control}
name="tapDetection.tapResetEnabled"
name="tapDetection.fullResetEnabled"
label={l10n.getString(
'settings-general-gesture_control-resetEnabled'
'settings-general-gesture_control-fullResetEnabled'
)}
/>
<CheckBox
variant="toggle"
outlined
control={control}
name="tapDetection.tapMountingResetEnabled"
name="tapDetection.mountingResetEnabled"
label={l10n.getString(
'settings-general-gesture_control-mountingResetEnabled'
)}
@@ -723,9 +720,9 @@ export function GeneralSettings() {
<div className="grid sm:grid-cols-3 gap-5 pb-2">
<NumberSelector
control={control}
name="tapDetection.tapQuickResetDelay"
name="tapDetection.yawResetDelay"
label={l10n.getString(
'settings-general-gesture_control-quickResetDelay'
'settings-general-gesture_control-yawResetDelay'
)}
valueLabelFormat={(value) => `${Math.round(value * 10) / 10} s`}
min={0.2}
@@ -734,9 +731,9 @@ export function GeneralSettings() {
/>
<NumberSelector
control={control}
name="tapDetection.tapResetDelay"
name="tapDetection.fullResetDelay"
label={l10n.getString(
'settings-general-gesture_control-resetDelay'
'settings-general-gesture_control-fullResetDelay'
)}
valueLabelFormat={(value) => `${Math.round(value * 10) / 10} s`}
min={0.2}
@@ -745,7 +742,7 @@ export function GeneralSettings() {
/>
<NumberSelector
control={control}
name="tapDetection.tapMountingResetDelay"
name="tapDetection.mountingResetDelay"
label={l10n.getString(
'settings-general-gesture_control-mountingResetDelay'
)}
@@ -758,9 +755,9 @@ export function GeneralSettings() {
<div className="grid sm:grid-cols-3 gap-5 pb-2">
<NumberSelector
control={control}
name="tapDetection.tapQuickResetTaps"
name="tapDetection.yawResetTaps"
label={l10n.getString(
'settings-general-gesture_control-quickResetTaps'
'settings-general-gesture_control-yawResetTaps'
)}
valueLabelFormat={(value) =>
l10n.getString('settings-general-gesture_control-taps', {
@@ -773,9 +770,9 @@ export function GeneralSettings() {
/>
<NumberSelector
control={control}
name="tapDetection.tapResetTaps"
name="tapDetection.fullResetTaps"
label={l10n.getString(
'settings-general-gesture_control-resetTaps'
'settings-general-gesture_control-fullResetTaps'
)}
valueLabelFormat={(value) =>
l10n.getString('settings-general-gesture_control-taps', {
@@ -788,7 +785,7 @@ export function GeneralSettings() {
/>
<NumberSelector
control={control}
name="tapDetection.tapMountingResetTaps"
name="tapDetection.mountingResetTaps"
label={l10n.getString(
'settings-general-gesture_control-mountingResetTaps'
)}

View File

@@ -11,9 +11,9 @@ import io.eiren.util.logging.LogManager;
public class Keybinding implements HotkeyListener {
private static final String resetSourceName = "Keybinding";
private static final int RESET = 1;
private static final int QUICK_RESET = 2;
private static final int RESET_MOUNTING = 3;
private static final int FULL_RESET = 1;
private static final int YAW_RESET = 2;
private static final int MOUNTING_RESET = 3;
public final VRServer server;
public final KeybindingsConfig config;
@@ -35,17 +35,17 @@ public class Keybinding implements HotkeyListener {
if (JIntellitype.getInstance() instanceof JIntellitype) {
JIntellitype.getInstance().addHotKeyListener(this);
String resetBinding = this.config.getResetBinding();
JIntellitype.getInstance().registerHotKey(RESET, resetBinding);
LogManager.info("[Keybinding] Bound reset to " + resetBinding);
String fullResetBinding = this.config.getFullResetBinding();
JIntellitype.getInstance().registerHotKey(FULL_RESET, fullResetBinding);
LogManager.info("[Keybinding] Bound full reset to " + fullResetBinding);
String quickResetBinding = this.config.getQuickResetBinding();
JIntellitype.getInstance().registerHotKey(QUICK_RESET, quickResetBinding);
LogManager.info("[Keybinding] Bound quick reset to " + quickResetBinding);
String yawResetBinding = this.config.getYawResetBinding();
JIntellitype.getInstance().registerHotKey(YAW_RESET, yawResetBinding);
LogManager.info("[Keybinding] Bound yaw reset to " + yawResetBinding);
String resetMountingBinding = this.config.getResetMountingBinding();
JIntellitype.getInstance().registerHotKey(RESET_MOUNTING, resetMountingBinding);
LogManager.info("[Keybinding] Bound reset mounting to " + resetMountingBinding);
String mountingResetBinding = this.config.getMountingResetBinding();
JIntellitype.getInstance().registerHotKey(MOUNTING_RESET, mountingResetBinding);
LogManager.info("[Keybinding] Bound reset mounting to " + mountingResetBinding);
}
} catch (Throwable e) {
LogManager
@@ -59,17 +59,17 @@ public class Keybinding implements HotkeyListener {
@Override
public void onHotKey(int identifier) {
switch (identifier) {
case RESET -> {
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()
);
}
}

View File

@@ -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(() -> {

View File

@@ -189,7 +189,7 @@ public abstract class ProtobufBridge<T extends VRTracker> 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);

View File

@@ -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;
}

View File

@@ -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;
}
}

View File

@@ -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() {

View File

@@ -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 {

View File

@@ -198,10 +198,10 @@ public class RPCHandler extends ProtocolHandler<RpcMessageHeader>
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);
}

View File

@@ -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(),

View File

@@ -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();

View File

@@ -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)

View File

@@ -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

View File

@@ -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";

View File

@@ -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;

View File

@@ -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);
}
}