mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-04-06 02:01:58 +02:00
Add config delays for reset/quickreset keybindings (#278)
This commit is contained in:
@@ -29,6 +29,8 @@ import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@@ -51,6 +53,7 @@ public class VRServer extends Thread {
|
||||
private final AutoBoneHandler autoBoneHandler;
|
||||
private final ProtocolAPI protocolAPI;
|
||||
private final ConfigManager configManager;
|
||||
private final Timer timer = new Timer();
|
||||
private final NanoTimer fpsTimer = new NanoTimer();
|
||||
|
||||
/**
|
||||
@@ -251,16 +254,47 @@ public class VRServer extends Thread {
|
||||
queueTask(humanPoseProcessor::resetTrackers);
|
||||
}
|
||||
|
||||
public void resetTrackersMounting() {
|
||||
queueTask(() -> {
|
||||
humanPoseProcessor.resetTrackersMounting();
|
||||
});
|
||||
}
|
||||
|
||||
public void resetTrackersYaw() {
|
||||
queueTask(humanPoseProcessor::resetTrackersYaw);
|
||||
}
|
||||
|
||||
public void resetTrackersMounting() {
|
||||
queueTask(humanPoseProcessor::resetTrackersMounting);
|
||||
}
|
||||
|
||||
public void scheduleResetTrackers(long delay) {
|
||||
TimerTask resetTask = new resetTask();
|
||||
timer.schedule(resetTask, delay);
|
||||
}
|
||||
|
||||
public void scheduleResetTrackersYaw(long delay) {
|
||||
TimerTask yawResetTask = new yawResetTask();
|
||||
timer.schedule(yawResetTask, delay);
|
||||
}
|
||||
|
||||
public void scheduleResetTrackersMounting(long delay) {
|
||||
TimerTask resetMountingTask = new resetMountingTask();
|
||||
timer.schedule(resetMountingTask, delay);
|
||||
}
|
||||
|
||||
class resetTask extends TimerTask {
|
||||
public void run() {
|
||||
queueTask(humanPoseProcessor::resetTrackers);
|
||||
}
|
||||
}
|
||||
|
||||
class yawResetTask extends TimerTask {
|
||||
public void run() {
|
||||
queueTask(humanPoseProcessor::resetTrackersYaw);
|
||||
}
|
||||
}
|
||||
|
||||
class resetMountingTask extends TimerTask {
|
||||
public void run() {
|
||||
queueTask(humanPoseProcessor::resetTrackersMounting);
|
||||
}
|
||||
}
|
||||
|
||||
public void setLegTweaksEnabled(boolean value) {
|
||||
queueTask(() -> humanPoseProcessor.setLegTweaksEnabled(value));
|
||||
}
|
||||
|
||||
@@ -8,6 +8,13 @@ public class KeybindingsConfig {
|
||||
|
||||
private String resetMountingBinding = "CTRL+ALT+SHIFT+I";
|
||||
|
||||
private long resetDelay = 0L;
|
||||
|
||||
private long quickResetDelay = 0L;
|
||||
|
||||
private long resetMountingDelay = 0L;
|
||||
|
||||
|
||||
public KeybindingsConfig() {
|
||||
}
|
||||
|
||||
@@ -22,4 +29,28 @@ public class KeybindingsConfig {
|
||||
public String getResetMountingBinding() {
|
||||
return resetMountingBinding;
|
||||
}
|
||||
|
||||
public long getResetDelay() {
|
||||
return resetDelay;
|
||||
}
|
||||
|
||||
public void setResetDelay(long delay) {
|
||||
resetDelay = delay;
|
||||
}
|
||||
|
||||
public long getQuickResetDelay() {
|
||||
return quickResetDelay;
|
||||
}
|
||||
|
||||
public void setQuickResetDelay(long delay) {
|
||||
quickResetDelay = delay;
|
||||
}
|
||||
|
||||
public long getResetMountingDelay() {
|
||||
return resetMountingDelay;
|
||||
}
|
||||
|
||||
public void setResetMountingDelay(long delay) {
|
||||
resetMountingDelay = delay;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,6 @@ public class Keybinding implements HotkeyListener {
|
||||
private static final int QUICK_RESET = 2;
|
||||
private static final int RESET_MOUNTING = 3;
|
||||
public final VRServer server;
|
||||
|
||||
|
||||
public final KeybindingsConfig config;
|
||||
|
||||
@AWTThread
|
||||
@@ -50,7 +48,7 @@ public class Keybinding implements HotkeyListener {
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
LogManager
|
||||
.info(
|
||||
.warning(
|
||||
"[Keybinding] JIntellitype initialization failed. Keybindings will be disabled. Try restarting your computer."
|
||||
);
|
||||
}
|
||||
@@ -62,15 +60,15 @@ public class Keybinding implements HotkeyListener {
|
||||
switch (identifier) {
|
||||
case RESET -> {
|
||||
LogManager.info("[Keybinding] Reset pressed");
|
||||
server.resetTrackers();
|
||||
server.scheduleResetTrackers(this.config.getResetDelay());
|
||||
}
|
||||
case QUICK_RESET -> {
|
||||
LogManager.info("[Keybinding] Quick reset pressed");
|
||||
server.resetTrackersYaw();
|
||||
server.scheduleResetTrackersYaw(this.config.getQuickResetDelay());
|
||||
}
|
||||
case RESET_MOUNTING -> {
|
||||
LogManager.info("[Keybinding] Reset mounting pressed");
|
||||
server.resetTrackersMounting();
|
||||
server.scheduleResetTrackersMounting(this.config.getResetMountingDelay());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user