diff --git a/.classpath b/.classpath
index 2d5a50750..79fef635c 100644
--- a/.classpath
+++ b/.classpath
@@ -1,33 +1,33 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.editorconfig b/.editorconfig
index e9a2391ae..dad0286d5 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -1,13 +1,13 @@
-# This file is for unifying the coding style for different editors and IDEs
-# See editorconfig.org
-
-root = true
-
-[*]
-indent_style = tab
-end_of_line = lf
-charset = utf-8
-# This line causes problems with VSCode and potentially with other editors where all purely
-# whitespace lines are trimmed to be empty when saved, causing excessive worthless changes with Git
-#trim_trailing_whitespace = true
-insert_final_newline = true
+# This file is for unifying the coding style for different editors and IDEs
+# See editorconfig.org
+
+root = true
+
+[*]
+indent_style = tab
+end_of_line = lf
+charset = utf-8
+# This line causes problems with VSCode and potentially with other editors where all purely
+# whitespace lines are trimmed to be empty when saved, causing excessive worthless changes with Git
+#trim_trailing_whitespace = true
+insert_final_newline = true
diff --git a/.gitattributes b/.gitattributes
index 00a51aff5..61793db4d 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,6 +1,6 @@
-#
-# https://help.github.com/articles/dealing-with-line-endings/
-#
-# These are explicitly windows files and should use crlf
-*.bat text eol=crlf
-
+#
+# https://help.github.com/articles/dealing-with-line-endings/
+#
+# These are explicitly windows files and should use crlf
+*.bat text eol=crlf
+
diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs
index 99f26c020..4824b8026 100644
--- a/.settings/org.eclipse.core.resources.prefs
+++ b/.settings/org.eclipse.core.resources.prefs
@@ -1,2 +1,2 @@
-eclipse.preferences.version=1
-encoding/=UTF-8
+eclipse.preferences.version=1
+encoding/=UTF-8
diff --git a/.settings/org.eclipse.core.runtime.prefs b/.settings/org.eclipse.core.runtime.prefs
index deae05a97..f8a67de1d 100644
--- a/.settings/org.eclipse.core.runtime.prefs
+++ b/.settings/org.eclipse.core.runtime.prefs
@@ -1,2 +1,2 @@
-eclipse.preferences.version=1
-line.separator=\r\n
+eclipse.preferences.version=1
+line.separator=\r\n
diff --git a/.settings/org.eclipse.jdt.ui.prefs b/.settings/org.eclipse.jdt.ui.prefs
index 494d16a1f..4dbc8cbda 100644
--- a/.settings/org.eclipse.jdt.ui.prefs
+++ b/.settings/org.eclipse.jdt.ui.prefs
@@ -1,3 +1,3 @@
-eclipse.preferences.version=1
-formatter_profile=_Essentia
-formatter_settings_version=13
+eclipse.preferences.version=1
+formatter_profile=_Essentia
+formatter_settings_version=13
diff --git a/LICENSE b/LICENSE
index ab710e08c..ebf07f7a3 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,21 +1,21 @@
-MIT License
-
-Copyright (c) 2021 Eiren Rain, SlimeVR
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
+MIT License
+
+Copyright (c) 2021 Eiren Rain, SlimeVR
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/log_last.log.lck b/log_last.log.lck
deleted file mode 100644
index e69de29bb..000000000
diff --git a/log_main.log.lck b/log_main.log.lck
deleted file mode 100644
index e69de29bb..000000000
diff --git a/resources/LICENSE.txt b/resources/LICENSE.txt
index ab710e08c..ebf07f7a3 100644
--- a/resources/LICENSE.txt
+++ b/resources/LICENSE.txt
@@ -1,21 +1,21 @@
-MIT License
-
-Copyright (c) 2021 Eiren Rain, SlimeVR
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
+MIT License
+
+Copyright (c) 2021 Eiren Rain, SlimeVR
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/slimevr_protocol b/slimevr_protocol
index 89caefa09..5070a99f3 160000
--- a/slimevr_protocol
+++ b/slimevr_protocol
@@ -1 +1 @@
-Subproject commit 89caefa09aa66a1116e663b26b5ab088604e2531
+Subproject commit 5070a99f3c13c9f96fe1ef025c93eef5dd44a1c3
diff --git a/src/main/java/dev/slimevr/Main.java b/src/main/java/dev/slimevr/Main.java
index f59fc4e14..677f0e316 100644
--- a/src/main/java/dev/slimevr/Main.java
+++ b/src/main/java/dev/slimevr/Main.java
@@ -52,7 +52,7 @@ public class Main {
vrServer = new VRServer();
vrServer.start();
new Keybinding(vrServer);
-// new VRServerGUI(vrServer);
+ new VRServerGUI(vrServer);
} catch(Throwable e) {
e.printStackTrace();
try {
diff --git a/src/main/java/dev/slimevr/VRServer.java b/src/main/java/dev/slimevr/VRServer.java
index 07fd8ab0a..ab187ecd3 100644
--- a/src/main/java/dev/slimevr/VRServer.java
+++ b/src/main/java/dev/slimevr/VRServer.java
@@ -16,16 +16,14 @@ import java.util.concurrent.LinkedBlockingQueue;
import java.util.function.Consumer;
import dev.slimevr.bridge.Bridge;
+import dev.slimevr.bridge.ProtobufBridge;
import dev.slimevr.platform.windows.WindowsNamedPipeBridge;
import dev.slimevr.bridge.VMCBridge;
+import dev.slimevr.vr.trackers.*;
import dev.slimevr.websocketapi.WebSocketVRBridge;
import dev.slimevr.util.ann.VRServerThread;
import dev.slimevr.vr.processor.HumanPoseProcessor;
import dev.slimevr.vr.processor.skeleton.HumanSkeleton;
-import dev.slimevr.vr.trackers.HMDTracker;
-import dev.slimevr.vr.trackers.ShareableTracker;
-import dev.slimevr.vr.trackers.Tracker;
-import dev.slimevr.vr.trackers.TrackerConfig;
import dev.slimevr.vr.trackers.udp.TrackersUDPServer;
import io.eiren.util.OperatingSystem;
import io.eiren.util.ann.ThreadSafe;
@@ -260,6 +258,25 @@ public class VRServer extends Thread {
newTrackersConsumers.get(i).accept(tracker);
});
}
+
+
+ public void updateTrackersFilters(TrackerFilters filter, float amount, int ticks) {
+ config.setProperty("filters.type", filter.name());
+ config.setProperty("filters.amount", amount);
+ config.setProperty("filters.tickCount", ticks);
+ saveConfig();
+
+ IMUTracker imu;
+ for (Tracker t : this.getAllTrackers()) {
+ Tracker realTracker = t;
+ if(t instanceof ReferenceAdjustedTracker)
+ realTracker = ((ReferenceAdjustedTracker extends Tracker>) t).getTracker();
+ if(realTracker instanceof IMUTracker){
+ imu = (IMUTracker)realTracker;
+ imu.setFilter(filter.name(), amount, ticks);
+ }
+ }
+ }
public void resetTrackers() {
queueTask(() -> {
diff --git a/src/main/java/dev/slimevr/bridge/BridgeThread.java b/src/main/java/dev/slimevr/bridge/BridgeThread.java
index 295a71036..8d2e74b5a 100644
--- a/src/main/java/dev/slimevr/bridge/BridgeThread.java
+++ b/src/main/java/dev/slimevr/bridge/BridgeThread.java
@@ -1,9 +1,9 @@
-package dev.slimevr.bridge;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-@Retention(value = RetentionPolicy.SOURCE)
-public @interface BridgeThread {
-
-}
+package dev.slimevr.bridge;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Retention(value = RetentionPolicy.SOURCE)
+public @interface BridgeThread {
+
+}
diff --git a/src/main/java/dev/slimevr/gui/TrackersFiltersGUI.java b/src/main/java/dev/slimevr/gui/TrackersFiltersGUI.java
index 21bfdb230..ea630e3fd 100644
--- a/src/main/java/dev/slimevr/gui/TrackersFiltersGUI.java
+++ b/src/main/java/dev/slimevr/gui/TrackersFiltersGUI.java
@@ -21,14 +21,14 @@ import dev.slimevr.vr.trackers.Tracker;
import dev.slimevr.vr.trackers.TrackerFilters;
import io.eiren.util.StringUtils;
import io.eiren.util.collections.FastList;
+import slimevr_protocol.server.FilteringType;
public class TrackersFiltersGUI extends EJBagNoStretch {
private final VRServer server;
- String filterType;
+ TrackerFilters filterType;
float filterAmount;
int filterTicks;
- private List allTrackers = new FastList<>();
private JLabel amountLabel, ticksLabel;
public TrackersFiltersGUI(VRServer server, VRServerGUI gui) {
@@ -41,10 +41,7 @@ public class TrackersFiltersGUI extends EJBagNoStretch {
setAlignmentY(TOP_ALIGNMENT);
add(Box.createVerticalStrut(10));
- filterType = server.config.getString("filters.type");
- if(filterType == null){
- filterType = "NONE";
- }
+ filterType = TrackerFilters.valueOf(server.config.getString("filters.type", "NONE"));
JComboBox filterSelect;
add(filterSelect = new JComboBox<>(), s(c(0, row, 2), 4, 1));
@@ -52,19 +49,13 @@ public class TrackersFiltersGUI extends EJBagNoStretch {
for(TrackerFilters f : TrackerFilters.values()) {
filterSelect.addItem(f.name());
}
- if(filterType != null) {
- filterSelect.setSelectedItem(filterType);
- } else {
- filterSelect.setSelectedItem(TrackerFilters.NONE);
- }
+ filterSelect.setSelectedItem(filterType.toString());
filterSelect.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
- filterType = filterSelect.getSelectedItem().toString();
- server.config.setProperty("filters.type", filterType);
- server.saveConfig();
- updateTrackersFilters();
+ filterType = TrackerFilters.valueOf(filterSelect.getSelectedItem().toString());
+ server.updateTrackersFilters(filterType, filterAmount, filterTicks);
}
});
add(Box.createVerticalStrut(40));
@@ -87,20 +78,6 @@ public class TrackersFiltersGUI extends EJBagNoStretch {
}
- void updateTrackersFilters(){
- allTrackers = server.getAllTrackers();
- IMUTracker imu;
- for (Tracker t : allTrackers) {
- Tracker realTracker = t;
- if(t instanceof ReferenceAdjustedTracker)
- realTracker = ((ReferenceAdjustedTracker extends Tracker>) t).getTracker();
- if(realTracker instanceof IMUTracker){
- imu = (IMUTracker)realTracker;
- imu.setFilter(filterType, filterAmount, filterTicks);
- }
- }
- }
-
void adjustValues(int cat, boolean neg){
if(cat == 0){
if(neg){
@@ -110,7 +87,6 @@ public class TrackersFiltersGUI extends EJBagNoStretch {
filterAmount = (Float) FastMath.clamp(filterAmount + 0.1f, 0, 1);
}
amountLabel.setText((StringUtils.prettyNumber(filterAmount * 100f)) + "%");
- server.config.setProperty("filters.amount", filterAmount);
}
else if(cat == 1){
if(neg){
@@ -120,12 +96,11 @@ public class TrackersFiltersGUI extends EJBagNoStretch {
filterTicks = (int) FastMath.clamp(filterTicks + 1, 0, 80);
}
ticksLabel.setText((StringUtils.prettyNumber(filterTicks)));
- server.config.setProperty("filters.tickCount", filterTicks);
}
- server.saveConfig();
- updateTrackersFilters();
+ server.updateTrackersFilters(filterType, filterAmount, filterTicks);
}
+
private class AdjButton extends JButton {
public AdjButton(String text, int category, boolean neg) {
diff --git a/src/main/java/dev/slimevr/gui/swing/ButtonTimer.java b/src/main/java/dev/slimevr/gui/swing/ButtonTimer.java
index 3a8c45dc2..0559657fc 100644
--- a/src/main/java/dev/slimevr/gui/swing/ButtonTimer.java
+++ b/src/main/java/dev/slimevr/gui/swing/ButtonTimer.java
@@ -1,42 +1,42 @@
-package dev.slimevr.gui.swing;
-
-import java.util.Timer;
-import java.util.TimerTask;
-
-import javax.swing.AbstractButton;
-
-public class ButtonTimer {
-
- private static Timer timer = new Timer();
-
- public static void runTimer(AbstractButton button, int seconds, String defaultText, Runnable runnable) {
- if(seconds <= 0) {
- button.setText(defaultText);
- runnable.run();
- } else {
- button.setText(String.valueOf(seconds));
- timer.schedule(new ButtonTimerTask(button, seconds - 1, defaultText, runnable), 1000);
- }
- }
-
- private static class ButtonTimerTask extends TimerTask {
-
- private final AbstractButton button;
- private final int seconds;
- private final String defaultText;
- private final Runnable runnable;
-
- private ButtonTimerTask(AbstractButton button, int seconds, String defaultText, Runnable runnable) {
- this.button = button;
- this.seconds = seconds;
- this.defaultText = defaultText;
- this.runnable = runnable;
- }
-
- @Override
- public void run() {
- runTimer(button, seconds, defaultText, runnable);
- }
-
- }
-}
+package dev.slimevr.gui.swing;
+
+import java.util.Timer;
+import java.util.TimerTask;
+
+import javax.swing.AbstractButton;
+
+public class ButtonTimer {
+
+ private static Timer timer = new Timer();
+
+ public static void runTimer(AbstractButton button, int seconds, String defaultText, Runnable runnable) {
+ if(seconds <= 0) {
+ button.setText(defaultText);
+ runnable.run();
+ } else {
+ button.setText(String.valueOf(seconds));
+ timer.schedule(new ButtonTimerTask(button, seconds - 1, defaultText, runnable), 1000);
+ }
+ }
+
+ private static class ButtonTimerTask extends TimerTask {
+
+ private final AbstractButton button;
+ private final int seconds;
+ private final String defaultText;
+ private final Runnable runnable;
+
+ private ButtonTimerTask(AbstractButton button, int seconds, String defaultText, Runnable runnable) {
+ this.button = button;
+ this.seconds = seconds;
+ this.defaultText = defaultText;
+ this.runnable = runnable;
+ }
+
+ @Override
+ public void run() {
+ runTimer(button, seconds, defaultText, runnable);
+ }
+
+ }
+}
diff --git a/src/main/java/dev/slimevr/gui/swing/EJBag.java b/src/main/java/dev/slimevr/gui/swing/EJBag.java
index 589544605..a8235031b 100644
--- a/src/main/java/dev/slimevr/gui/swing/EJBag.java
+++ b/src/main/java/dev/slimevr/gui/swing/EJBag.java
@@ -1,10 +1,10 @@
-package dev.slimevr.gui.swing;
-
-import java.awt.GridBagLayout;
-
-public class EJBag extends EJPanel {
-
- public EJBag() {
- super(new GridBagLayout());
- }
-}
+package dev.slimevr.gui.swing;
+
+import java.awt.GridBagLayout;
+
+public class EJBag extends EJPanel {
+
+ public EJBag() {
+ super(new GridBagLayout());
+ }
+}
diff --git a/src/main/java/dev/slimevr/gui/swing/EJBagNoStretch.java b/src/main/java/dev/slimevr/gui/swing/EJBagNoStretch.java
index 7052ac773..4b2d519a3 100644
--- a/src/main/java/dev/slimevr/gui/swing/EJBagNoStretch.java
+++ b/src/main/java/dev/slimevr/gui/swing/EJBagNoStretch.java
@@ -1,33 +1,33 @@
-package dev.slimevr.gui.swing;
-
-import java.awt.Container;
-import java.awt.Dimension;
-import java.awt.GridBagLayout;
-
-public class EJBagNoStretch extends EJPanel {
-
- public EJBagNoStretch(boolean stretchVertical, boolean stretchHorizontal) {
- super(new EGridBagLayoutNoStretch(stretchVertical, stretchHorizontal));
- }
-
- private static class EGridBagLayoutNoStretch extends GridBagLayout {
-
- private final boolean stretchVertical;
- private final boolean stretchHorizontal;
-
- public EGridBagLayoutNoStretch(boolean stretchVertical, boolean stretchHorizontal) {
- this.stretchVertical = stretchVertical;
- this.stretchHorizontal = stretchHorizontal;
- }
-
- @Override
- public Dimension maximumLayoutSize(Container target) {
- Dimension pref = preferredLayoutSize(target);
- if(stretchVertical)
- pref.height = Integer.MAX_VALUE;
- if(stretchHorizontal)
- pref.width = Integer.MAX_VALUE;
- return pref;
- }
- }
-}
+package dev.slimevr.gui.swing;
+
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.GridBagLayout;
+
+public class EJBagNoStretch extends EJPanel {
+
+ public EJBagNoStretch(boolean stretchVertical, boolean stretchHorizontal) {
+ super(new EGridBagLayoutNoStretch(stretchVertical, stretchHorizontal));
+ }
+
+ private static class EGridBagLayoutNoStretch extends GridBagLayout {
+
+ private final boolean stretchVertical;
+ private final boolean stretchHorizontal;
+
+ public EGridBagLayoutNoStretch(boolean stretchVertical, boolean stretchHorizontal) {
+ this.stretchVertical = stretchVertical;
+ this.stretchHorizontal = stretchHorizontal;
+ }
+
+ @Override
+ public Dimension maximumLayoutSize(Container target) {
+ Dimension pref = preferredLayoutSize(target);
+ if(stretchVertical)
+ pref.height = Integer.MAX_VALUE;
+ if(stretchHorizontal)
+ pref.width = Integer.MAX_VALUE;
+ return pref;
+ }
+ }
+}
diff --git a/src/main/java/dev/slimevr/gui/swing/EJBox.java b/src/main/java/dev/slimevr/gui/swing/EJBox.java
index 2e609559d..b4020c27e 100644
--- a/src/main/java/dev/slimevr/gui/swing/EJBox.java
+++ b/src/main/java/dev/slimevr/gui/swing/EJBox.java
@@ -1,11 +1,11 @@
-package dev.slimevr.gui.swing;
-
-import javax.swing.BoxLayout;
-
-public class EJBox extends EJPanel {
-
- public EJBox(int layout) {
- super();
- setLayout(new BoxLayout(this, layout));
- }
-}
+package dev.slimevr.gui.swing;
+
+import javax.swing.BoxLayout;
+
+public class EJBox extends EJPanel {
+
+ public EJBox(int layout) {
+ super();
+ setLayout(new BoxLayout(this, layout));
+ }
+}
diff --git a/src/main/java/dev/slimevr/gui/swing/EJBoxNoStretch.java b/src/main/java/dev/slimevr/gui/swing/EJBoxNoStretch.java
index 5e3ea436e..a26fa61ab 100644
--- a/src/main/java/dev/slimevr/gui/swing/EJBoxNoStretch.java
+++ b/src/main/java/dev/slimevr/gui/swing/EJBoxNoStretch.java
@@ -1,36 +1,36 @@
-package dev.slimevr.gui.swing;
-
-import java.awt.Container;
-import java.awt.Dimension;
-
-import javax.swing.BoxLayout;
-
-public class EJBoxNoStretch extends EJPanel {
-
- public EJBoxNoStretch(int layout, boolean stretchVertical, boolean stretchHorizontal) {
- super();
- setLayout(new BoxLayoutNoStretch(this, layout, stretchVertical, stretchHorizontal));
- }
-
- private static class BoxLayoutNoStretch extends BoxLayout {
-
- private final boolean stretchVertical;
- private final boolean stretchHorizontal;
-
- public BoxLayoutNoStretch(Container target, int axis, boolean stretchVertical, boolean stretchHorizontal) {
- super(target, axis);
- this.stretchVertical = stretchVertical;
- this.stretchHorizontal = stretchHorizontal;
- }
-
- @Override
- public Dimension maximumLayoutSize(Container target) {
- Dimension pref = preferredLayoutSize(target);
- if(stretchVertical)
- pref.height = Integer.MAX_VALUE;
- if(stretchHorizontal)
- pref.width = Integer.MAX_VALUE;
- return pref;
- }
- }
-}
+package dev.slimevr.gui.swing;
+
+import java.awt.Container;
+import java.awt.Dimension;
+
+import javax.swing.BoxLayout;
+
+public class EJBoxNoStretch extends EJPanel {
+
+ public EJBoxNoStretch(int layout, boolean stretchVertical, boolean stretchHorizontal) {
+ super();
+ setLayout(new BoxLayoutNoStretch(this, layout, stretchVertical, stretchHorizontal));
+ }
+
+ private static class BoxLayoutNoStretch extends BoxLayout {
+
+ private final boolean stretchVertical;
+ private final boolean stretchHorizontal;
+
+ public BoxLayoutNoStretch(Container target, int axis, boolean stretchVertical, boolean stretchHorizontal) {
+ super(target, axis);
+ this.stretchVertical = stretchVertical;
+ this.stretchHorizontal = stretchHorizontal;
+ }
+
+ @Override
+ public Dimension maximumLayoutSize(Container target) {
+ Dimension pref = preferredLayoutSize(target);
+ if(stretchVertical)
+ pref.height = Integer.MAX_VALUE;
+ if(stretchHorizontal)
+ pref.width = Integer.MAX_VALUE;
+ return pref;
+ }
+ }
+}
diff --git a/src/main/java/dev/slimevr/gui/swing/EJPanel.java b/src/main/java/dev/slimevr/gui/swing/EJPanel.java
index 1ffe96e68..21ca1bc61 100644
--- a/src/main/java/dev/slimevr/gui/swing/EJPanel.java
+++ b/src/main/java/dev/slimevr/gui/swing/EJPanel.java
@@ -1,110 +1,110 @@
-package dev.slimevr.gui.swing;
-
-import java.awt.Component;
-import java.awt.Dimension;
-import java.awt.GridBagConstraints;
-import java.awt.Insets;
-import java.awt.LayoutManager;
-
-import javax.swing.Box;
-import javax.swing.JPanel;
-
-public abstract class EJPanel extends JPanel {
-
- public static boolean NEEDS_DOWNSCALE = false;
- public static float DOWNSCALE_FACTOR = 0.75f;
-
- public EJPanel() {
- super();
- }
-
- public EJPanel(LayoutManager manager) {
- super(manager);
- }
-
- public static void s(Component c, int width, int height) {
- if(NEEDS_DOWNSCALE) {
- width = (int) Math.ceil(width * DOWNSCALE_FACTOR);
- height = (int) Math.ceil(height * DOWNSCALE_FACTOR);
- }
- c.setSize(width, height);
- Dimension d = new Dimension(width, height);
- c.setPreferredSize(d);
- c.setMaximumSize(d);
- c.setMinimumSize(d);
- }
-
- public static void minWidth(Component c, int width, int height) {
- if(NEEDS_DOWNSCALE) {
- height = (int) Math.ceil(height * DOWNSCALE_FACTOR);
- width = (int) Math.ceil(width * DOWNSCALE_FACTOR);
- }
- c.setPreferredSize(new Dimension(Short.MAX_VALUE, height));
- c.setMaximumSize(new Dimension(Short.MAX_VALUE, height));
- c.setMinimumSize(new Dimension(width, height));
- }
-
- public static void minHeight(Component c, int width, int height) {
- if(NEEDS_DOWNSCALE) {
- height = (int) Math.ceil(height * DOWNSCALE_FACTOR);
- width = (int) Math.ceil(width * DOWNSCALE_FACTOR);
- }
- c.setPreferredSize(new Dimension(width, Short.MAX_VALUE));
- c.setMaximumSize(new Dimension(width, Short.MAX_VALUE));
- c.setMinimumSize(new Dimension(width, height));
- }
-
- public static GridBagConstraints c(int x, int y) {
- GridBagConstraints c = new GridBagConstraints();
- c.gridx = x;
- c.gridy = y;
- return c;
- }
-
- public static GridBagConstraints c(int x, int y, int padding) {
- GridBagConstraints c = new GridBagConstraints();
- c.gridx = x;
- c.gridy = y;
- c.insets = new Insets(padding, padding, padding, padding);
- return c;
- }
-
- public static GridBagConstraints c(int x, int y, int padding, int anchor) {
- GridBagConstraints c = new GridBagConstraints();
- c.gridx = x;
- c.gridy = y;
- c.insets = new Insets(padding, padding, padding, padding);
- c.anchor = anchor;
- return c;
- }
-
- public static GridBagConstraints c(int x, int y, Insets insets) {
- GridBagConstraints c = new GridBagConstraints();
- c.gridx = x;
- c.gridy = y;
- c.insets = insets;
- return c;
- }
-
- public static GridBagConstraints s(GridBagConstraints c, int gridwidth, int gridheight) {
- c.gridwidth = gridwidth;
- c.gridheight = gridheight;
- return c;
- }
-
- public static Insets i(int s) {
- return new Insets(s, s, s, s);
- }
-
- public static Insets i(int h, int v) {
- return new Insets(v, h, v, h);
- }
-
- public static Component padding(int width, int height) {
- return Box.createRigidArea(new Dimension(width, height));
- }
-
- public static int fontSize(int baseSize) {
- return NEEDS_DOWNSCALE ? (int) Math.ceil(baseSize * DOWNSCALE_FACTOR) : baseSize;
- }
-}
+package dev.slimevr.gui.swing;
+
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.GridBagConstraints;
+import java.awt.Insets;
+import java.awt.LayoutManager;
+
+import javax.swing.Box;
+import javax.swing.JPanel;
+
+public abstract class EJPanel extends JPanel {
+
+ public static boolean NEEDS_DOWNSCALE = false;
+ public static float DOWNSCALE_FACTOR = 0.75f;
+
+ public EJPanel() {
+ super();
+ }
+
+ public EJPanel(LayoutManager manager) {
+ super(manager);
+ }
+
+ public static void s(Component c, int width, int height) {
+ if(NEEDS_DOWNSCALE) {
+ width = (int) Math.ceil(width * DOWNSCALE_FACTOR);
+ height = (int) Math.ceil(height * DOWNSCALE_FACTOR);
+ }
+ c.setSize(width, height);
+ Dimension d = new Dimension(width, height);
+ c.setPreferredSize(d);
+ c.setMaximumSize(d);
+ c.setMinimumSize(d);
+ }
+
+ public static void minWidth(Component c, int width, int height) {
+ if(NEEDS_DOWNSCALE) {
+ height = (int) Math.ceil(height * DOWNSCALE_FACTOR);
+ width = (int) Math.ceil(width * DOWNSCALE_FACTOR);
+ }
+ c.setPreferredSize(new Dimension(Short.MAX_VALUE, height));
+ c.setMaximumSize(new Dimension(Short.MAX_VALUE, height));
+ c.setMinimumSize(new Dimension(width, height));
+ }
+
+ public static void minHeight(Component c, int width, int height) {
+ if(NEEDS_DOWNSCALE) {
+ height = (int) Math.ceil(height * DOWNSCALE_FACTOR);
+ width = (int) Math.ceil(width * DOWNSCALE_FACTOR);
+ }
+ c.setPreferredSize(new Dimension(width, Short.MAX_VALUE));
+ c.setMaximumSize(new Dimension(width, Short.MAX_VALUE));
+ c.setMinimumSize(new Dimension(width, height));
+ }
+
+ public static GridBagConstraints c(int x, int y) {
+ GridBagConstraints c = new GridBagConstraints();
+ c.gridx = x;
+ c.gridy = y;
+ return c;
+ }
+
+ public static GridBagConstraints c(int x, int y, int padding) {
+ GridBagConstraints c = new GridBagConstraints();
+ c.gridx = x;
+ c.gridy = y;
+ c.insets = new Insets(padding, padding, padding, padding);
+ return c;
+ }
+
+ public static GridBagConstraints c(int x, int y, int padding, int anchor) {
+ GridBagConstraints c = new GridBagConstraints();
+ c.gridx = x;
+ c.gridy = y;
+ c.insets = new Insets(padding, padding, padding, padding);
+ c.anchor = anchor;
+ return c;
+ }
+
+ public static GridBagConstraints c(int x, int y, Insets insets) {
+ GridBagConstraints c = new GridBagConstraints();
+ c.gridx = x;
+ c.gridy = y;
+ c.insets = insets;
+ return c;
+ }
+
+ public static GridBagConstraints s(GridBagConstraints c, int gridwidth, int gridheight) {
+ c.gridwidth = gridwidth;
+ c.gridheight = gridheight;
+ return c;
+ }
+
+ public static Insets i(int s) {
+ return new Insets(s, s, s, s);
+ }
+
+ public static Insets i(int h, int v) {
+ return new Insets(v, h, v, h);
+ }
+
+ public static Component padding(int width, int height) {
+ return Box.createRigidArea(new Dimension(width, height));
+ }
+
+ public static int fontSize(int baseSize) {
+ return NEEDS_DOWNSCALE ? (int) Math.ceil(baseSize * DOWNSCALE_FACTOR) : baseSize;
+ }
+}
diff --git a/src/main/java/dev/slimevr/gui/swing/EJlabel.java b/src/main/java/dev/slimevr/gui/swing/EJlabel.java
index a6be19d5a..815517b30 100644
--- a/src/main/java/dev/slimevr/gui/swing/EJlabel.java
+++ b/src/main/java/dev/slimevr/gui/swing/EJlabel.java
@@ -1,8 +1,8 @@
-package dev.slimevr.gui.swing;
-
-import javax.swing.JLabel;
-
-public class EJlabel extends JLabel {
-
-
-}
+package dev.slimevr.gui.swing;
+
+import javax.swing.JLabel;
+
+public class EJlabel extends JLabel {
+
+
+}
diff --git a/src/main/java/dev/slimevr/poserecorder/TrackerFrameData.java b/src/main/java/dev/slimevr/poserecorder/TrackerFrameData.java
index e7d61983b..ed3e8bf1f 100644
--- a/src/main/java/dev/slimevr/poserecorder/TrackerFrameData.java
+++ b/src/main/java/dev/slimevr/poserecorder/TrackerFrameData.java
@@ -1,19 +1,19 @@
-package dev.slimevr.poserecorder;
-
-public enum TrackerFrameData {
-
- DESIGNATION(0),
- ROTATION(1),
- POSITION(2),
- ;
-
- public final int flag;
-
- TrackerFrameData(int id) {
- this.flag = 1 << id;
- }
-
- public boolean check(int dataFlags) {
- return (dataFlags & this.flag) != 0;
- }
-}
+package dev.slimevr.poserecorder;
+
+public enum TrackerFrameData {
+
+ DESIGNATION(0),
+ ROTATION(1),
+ POSITION(2),
+ ;
+
+ public final int flag;
+
+ TrackerFrameData(int id) {
+ this.flag = 1 << id;
+ }
+
+ public boolean check(int dataFlags) {
+ return (dataFlags & this.flag) != 0;
+ }
+}
diff --git a/src/main/java/dev/slimevr/vr/trackers/TrackerFilters.java b/src/main/java/dev/slimevr/vr/trackers/TrackerFilters.java
index 2de4103dd..9bd8c605a 100644
--- a/src/main/java/dev/slimevr/vr/trackers/TrackerFilters.java
+++ b/src/main/java/dev/slimevr/vr/trackers/TrackerFilters.java
@@ -1,7 +1,21 @@
package dev.slimevr.vr.trackers;
public enum TrackerFilters {
- NONE,
- INTERPOLATION,
- EXTRAPOLATION;
+ NONE(0),
+ INTERPOLATION(1),
+ EXTRAPOLATION(2);
+
+ public final int id;
+
+ TrackerFilters(int id) {
+ this.id = id;
+ }
+
+ public static TrackerFilters fromId(int id) {
+ for (TrackerFilters filter : values()) {
+ if (filter.id == id)
+ return filter;
+ }
+ return null;
+ }
}
diff --git a/src/main/java/dev/slimevr/vr/trackers/TrackerMountingRotation.java b/src/main/java/dev/slimevr/vr/trackers/TrackerMountingRotation.java
index 98da32f1d..bd2bac8d0 100644
--- a/src/main/java/dev/slimevr/vr/trackers/TrackerMountingRotation.java
+++ b/src/main/java/dev/slimevr/vr/trackers/TrackerMountingRotation.java
@@ -3,6 +3,8 @@ package dev.slimevr.vr.trackers;
import com.jme3.math.FastMath;
import com.jme3.math.Quaternion;
+import java.util.Arrays;
+
public enum TrackerMountingRotation {
FRONT(180),
@@ -19,4 +21,12 @@ public enum TrackerMountingRotation {
this.angle = angle;
quaternion.fromAngles(0, angle * FastMath.DEG_TO_RAD, 0);
}
+
+ public static TrackerMountingRotation fromAngle(float angle) {
+ for (TrackerMountingRotation val : values) {
+ if (val.angle == angle)
+ return val;
+ }
+ return null;
+ }
}
diff --git a/src/main/java/dev/slimevr/websocketapi/WebsocketAPI.java b/src/main/java/dev/slimevr/websocketapi/WebsocketAPI.java
index cef90c027..395ed2188 100644
--- a/src/main/java/dev/slimevr/websocketapi/WebsocketAPI.java
+++ b/src/main/java/dev/slimevr/websocketapi/WebsocketAPI.java
@@ -4,10 +4,10 @@ import com.google.flatbuffers.FlatBufferBuilder;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
import dev.slimevr.VRServer;
-import dev.slimevr.vr.processor.skeleton.SkeletonConfigValue;
-import dev.slimevr.vr.trackers.IMUTracker;
-import dev.slimevr.vr.trackers.ReferenceAdjustedTracker;
-import dev.slimevr.vr.trackers.Tracker;
+import dev.slimevr.bridge.ProtobufBridge;
+import dev.slimevr.platform.windows.WindowsNamedPipeBridge;
+import dev.slimevr.vr.trackers.*;
+import dev.slimevr.vr.trackers.TrackerRole;
import io.eiren.util.ann.ThreadSafe;
import io.eiren.util.logging.LogManager;
import org.java_websocket.WebSocket;
@@ -17,12 +17,15 @@ import org.java_websocket.handshake.ClientHandshake;
import org.java_websocket.server.WebSocketServer;
import slimevr_protocol.datatypes.Quat;
import slimevr_protocol.datatypes.Vec3f;
+import slimevr_protocol.misc.Acknowledgement;
import slimevr_protocol.server.*;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.util.Collections;
import java.util.HashMap;
+import java.util.function.Supplier;
+import java.util.stream.Stream;
public class WebsocketAPI extends WebSocketServer {
@@ -64,19 +67,118 @@ public class WebsocketAPI extends WebSocketServer {
try {
switch (inboundPacket.packetType()) {
- case InboundUnion.HandshakeRequest: {
+ case InboundUnion.ConnectionRequest: {
HandshakeRequest req = (HandshakeRequest) inboundPacket.packet(new HandshakeRequest());
if (req != null) this.onHandshakeRequest(conn, req);
break;
}
+ case InboundUnion.AssignTrackerRequest: {
+ AssignTrackerRequest req = (AssignTrackerRequest) inboundPacket.packet(new AssignTrackerRequest());
+ if (req != null) this.onAssignTrackerRequest(conn, req);
+ break;
+ }
+ case InboundUnion.ResetRequest: {
+ ResetRequest req = (ResetRequest) inboundPacket.packet(new ResetRequest());
+ if (req != null) this.onResetRequest(conn, req);
+ break;
+ }
+ case InboundUnion.SettingsRequest: {
+ SettingsRequest req = (SettingsRequest) inboundPacket.packet(new SettingsRequest());
+ if (req != null) this.onSettingsRequest(conn, req);
+ break;
+ }
+ case InboundUnion.ChangeSettingsRequest: {
+ ChangeSettingsRequest req = (ChangeSettingsRequest) inboundPacket.packet(new ChangeSettingsRequest());
+ if (req != null) this.onChangeSettingsRequest(conn, req);
+ break;
+ }
default:
LogManager.log.warning("[WebSocketAPI] Received unknown packet type: " + inboundPacket.packetType());
}
} catch (Exception e) {
LogManager.log.severe("[WebSocketAPI] Failed to parse packet: " + inboundPacket.packetType(), e);
}
+
+
+ if (inboundPacket.acknowledgeMe()) {
+ FlatBufferBuilder fbb = new FlatBufferBuilder(40);
+ int acknowledgement = Acknowledgement.createAcknowledgement(fbb, inboundPacket.packetCounter());
+ int outbound = this.createOutboundPacket(fbb, OutboundUnion.slimevr_protocol_misc_Acknowledgement, acknowledgement);
+ fbb.finish(outbound);
+ conn.send(fbb.dataBuffer());
+ }
}
+ public void onSettingsRequest(WebSocket conn, SettingsRequest req) {
+ FlatBufferBuilder fbb = new FlatBufferBuilder(40);
+
+ WindowsNamedPipeBridge bridge = this.server.getVRBridge(WindowsNamedPipeBridge.class);
+
+ int steamvrTrackerSettings = SteamVRTrackersSetting.createSteamVRTrackersSetting(fbb,
+ bridge.getShareSetting(TrackerRole.WAIST),
+ bridge.getShareSetting(TrackerRole.CHEST),
+ bridge.getShareSetting(TrackerRole.LEFT_FOOT) && bridge.getShareSetting(TrackerRole.RIGHT_FOOT),
+ bridge.getShareSetting(TrackerRole.LEFT_KNEE) &&bridge.getShareSetting(TrackerRole.RIGHT_KNEE),
+ bridge.getShareSetting(TrackerRole.LEFT_ELBOW) && bridge.getShareSetting(TrackerRole.RIGHT_ELBOW)
+ );
+
+ int filterSettings = FilteringSettings.createFilteringSettings(
+ fbb,
+ TrackerFilters.valueOf(this.server.config.getString("filters.type", "NONE")).id,
+ (int)(server.config.getFloat("filters.amount", 0.3f) * 100),
+ server.config.getInt("filters.tickCount", 2)
+ );
+
+ int settings = SettingsResponse.createSettingsResponse(fbb, steamvrTrackerSettings, filterSettings);
+ int outbound = this.createOutboundPacket(fbb, OutboundUnion.SettingsResponse, settings);
+ fbb.finish(outbound);
+ conn.send(fbb.dataBuffer());
+ }
+
+ public void onChangeSettingsRequest(WebSocket conn, ChangeSettingsRequest req) {
+ if (req.steamVrTrackers() != null) {
+ WindowsNamedPipeBridge bridge = this.server.getVRBridge(WindowsNamedPipeBridge.class);
+ bridge.changeShareSettings(TrackerRole.WAIST, req.steamVrTrackers().waist());
+ bridge.changeShareSettings(TrackerRole.CHEST, req.steamVrTrackers().chest());
+ bridge.changeShareSettings(TrackerRole.LEFT_FOOT, req.steamVrTrackers().legs());
+ bridge.changeShareSettings(TrackerRole.RIGHT_FOOT, req.steamVrTrackers().legs());
+ bridge.changeShareSettings(TrackerRole.LEFT_KNEE, req.steamVrTrackers().knees());
+ bridge.changeShareSettings(TrackerRole.RIGHT_KNEE, req.steamVrTrackers().knees());
+ bridge.changeShareSettings(TrackerRole.LEFT_ELBOW, req.steamVrTrackers().elbows());
+ bridge.changeShareSettings(TrackerRole.RIGHT_ELBOW, req.steamVrTrackers().elbows());
+ }
+
+ if (req.filtering() != null) {
+ TrackerFilters type = TrackerFilters.fromId(req.filtering().type());
+ if (type != null) {
+ this.server.updateTrackersFilters(type, (float)req.filtering().intensity() / 100.0f, req.filtering().ticks());
+ }
+ }
+ }
+
+ public void onResetRequest(WebSocket con, ResetRequest req) {
+ if (req.quick()) {
+ this.server.resetTrackersYaw();
+ } else {
+ this.server.resetTrackers();
+ }
+ LogManager.log.severe("[WebSocketAPI] Reset performed");
+ }
+
+ public void onAssignTrackerRequest(WebSocket con, AssignTrackerRequest req) {
+ Tracker tracker = this.server.getAllTrackers().get(req.id());
+ if (tracker == null)
+ return ;
+
+ tracker.setBodyPosition(TrackerPosition.getByRole(TrackerRole.getById(req.role())));
+ if (tracker instanceof IMUTracker) {
+ IMUTracker imu = (IMUTracker) tracker;
+ TrackerMountingRotation rot = TrackerMountingRotation.fromAngle(req.mountingRotation());
+ if (rot != null)
+ imu.setMountingRotation(rot);
+ }
+ this.server.trackerUpdated(tracker);
+ }
public void onHandshakeRequest(WebSocket con, HandshakeRequest req) {
APIApplication app = new APIApplication();
@@ -111,17 +213,16 @@ public class WebsocketAPI extends WebSocketServer {
DeviceStatus.addPosition(fbb, Vec3f.createVec3f(fbb, pos3f.x, pos3f.y, pos3f.z));
DeviceStatus.addRotation(fbb, Quat.createQuat(fbb, quatRot.getX(), quatRot.getY(), quatRot.getZ(), quatRot.getW()));
DeviceStatus.addComputed(fbb, tracker.isComputed());
-
+ DeviceStatus.addEditable(fbb, tracker.userEditable());
if (tracker.getBodyPosition() != null && tracker.getBodyPosition().trackerRole != null) {
DeviceStatus.addRole(fbb, tracker.getBodyPosition().trackerRole.id);
-
}
if (tracker instanceof IMUTracker) {
IMUTracker imu = (IMUTracker) tracker;
-
- imu.getMountingRotation();
+ if (imu.getMountingRotation() != null)
+ DeviceStatus.addMountingRotation(fbb, (short)imu.getMountingRotation().angle);
// put back to 0 - 256 so we can fit it in a byte instead of float
DeviceStatus.addBattery(fbb, (int)((imu.getBatteryLevel() / 100) * 255));
DeviceStatus.addPing(fbb, imu.ping);