Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Mod compatibility is important to us. If you find any issues, don't be afraid to
- [X] Iris support
- [X] In game VR switching
- [X] API, details [here](https://github.com/Vivecraft/VivecraftMod/wiki/Mod-API)
- [ ] OpenXR support
- [X] OpenXR support

[Vivecraft Discord server](https://discord.gg/2x3QCk8qa9)\
[Development Discord server](https://discord.gg/jYyyv7zhSW)
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ subprojects {
implementation("org.lwjgl:lwjgl-openvr:${rootProject.lwjgl_version}:natives-macos") { transitive = false }
implementation("org.lwjgl:lwjgl-openvr:${rootProject.lwjgl_version}:natives-windows") { transitive = false }

implementation("org.lwjgl:lwjgl-openxr:${rootProject.lwjgl_version}") { transitive = false }
implementation("org.lwjgl:lwjgl-openxr:${rootProject.lwjgl_version}:natives-linux") { transitive = false }
implementation("org.lwjgl:lwjgl-openxr:${rootProject.lwjgl_version}:natives-windows") { transitive = false }

// for OSC tracker support
implementation("com.illposed.osc:javaosc-core:0.9")

Expand Down
14 changes: 13 additions & 1 deletion common/src/main/java/org/vivecraft/client_vr/VRState.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.vivecraft.client_vr.gameplay.VRPlayer;
import org.vivecraft.client_vr.menuworlds.MenuWorldRenderer;
import org.vivecraft.client_vr.provider.nullvr.NullVR;
import org.vivecraft.client_vr.provider.openxr_lwjgl.MCOpenXR;
import org.vivecraft.client_vr.provider.openvr_lwjgl.MCOpenVR;
import org.vivecraft.client_vr.render.RenderConfigException;
import org.vivecraft.client_vr.render.VRShaders;
Expand Down Expand Up @@ -64,9 +65,20 @@ public static void initializeVR() {
}

ClientDataHolderVR dh = ClientDataHolderVR.getInstance();
VRSettings.LOGGER.info("Vivecraft: VR Provider setting = {}", dh.vrSettings.stereoProviderPluginID);

// Force OpenXR for all VR modes - OpenVR/SteamVR is no longer used
if (dh.vrSettings.stereoProviderPluginID == VRSettings.VRProvider.OPENVR) {
dh.vr = new MCOpenVR(Minecraft.getInstance(), dh);
VRSettings.LOGGER.info("Vivecraft: OpenVR setting detected, overriding to OpenXR (SteamVR bypass)");
dh.vrSettings.stereoProviderPluginID = VRSettings.VRProvider.OPENXR;
dh.vrSettings.saveOptions();
}

if (dh.vrSettings.stereoProviderPluginID == VRSettings.VRProvider.OPENXR) {
VRSettings.LOGGER.info("Vivecraft: Using OpenXR provider (bypassing SteamVR)");
dh.vr = new MCOpenXR(Minecraft.getInstance(), dh);
} else {
VRSettings.LOGGER.info("Vivecraft: Using NullVR provider");
dh.vr = new NullVR(Minecraft.getInstance(), dh);
}
if (!dh.vr.init()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public boolean equals(Object o) {
public enum Source {
NULL,
OPENVR,
OPENXR,
OSC
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1536,4 +1536,10 @@ public boolean capFPS() {
* @return the name of the VR runtime
*/
public abstract String getRuntimeName();

/**
* @param inputValueHandle the origin handle from the VR runtime
* @return which controller the origin belongs to, or {@code null} if unknown
*/
public abstract ControllerType getOriginControllerType(long inputValueHandle);
}
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,11 @@ public String getRuntimeName() {
return "Null";
}

@Override
public ControllerType getOriginControllerType(long inputValueHandle) {
return null;
}

@Override
public boolean handleKeyboardInputs(int key, int scanCode, int action, int modifiers) {
boolean triggered = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1701,7 +1701,8 @@ private long getInputSourceHandle(String path) {
* @param inputValueHandle inputHandle to check
* @return what controller the inputHandle is on, {@code null} if the handle or device is invalid
*/
protected ControllerType getOriginControllerType(long inputValueHandle) {
@Override
public ControllerType getOriginControllerType(long inputValueHandle) {
if (inputValueHandle != k_ulInvalidInputValueHandle) {
this.readOriginInfo(inputValueHandle);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,15 @@ public VRInputAction setPriority(int priority) {
*/
public boolean isEnabled() {
if (!this.isEnabledRaw(this.currentHand)) return false;
if (MCOpenVR.get() == null) return false;
if (MCVR.get() == null) return false;

long lastOrigin = this.getLastOrigin();
ControllerType hand = MCOpenVR.get().getOriginControllerType(lastOrigin);
ControllerType hand = MCVR.get().getOriginControllerType(lastOrigin);

if (hand == null && this.isHanded()) return false;

// iterate over all actions, and check if another action has a higher priority
for (VRInputAction action : MCOpenVR.get().getInputActions()) {
for (VRInputAction action : MCVR.get().getInputActions()) {
if (action != this && action.isEnabledRaw(hand) && action.isActive() &&
action.getPriority() > this.getPriority() && MCVR.get().getOrigins(action).contains(lastOrigin))
{
Expand Down
Loading