Skip to content

Commit

Permalink
Added jopenvrwrapper.
Browse files Browse the repository at this point in the history
  • Loading branch information
indianajohn committed Sep 11, 2016
1 parent 4b48a0c commit ee3c931
Show file tree
Hide file tree
Showing 21 changed files with 715 additions and 0 deletions.
1 change: 1 addition & 0 deletions engine/build.gradle
Expand Up @@ -105,6 +105,7 @@ dependencies {
compile group: 'org.lwjgl.lwjgl', name: 'lwjgl', version: LwjglVersion
compile group: 'org.lwjgl.lwjgl', name: 'lwjgl_util', version: LwjglVersion
compile group: 'java3d', name: 'vecmath', version: '1.3.1' // Note: Downgraded to this release until TeraMath ready
compile "org.joml:joml:1.8.1"
compile group: 'org.abego.treelayout', name: 'org.abego.treelayout.core', version: '1.0.3'
compile group: 'com.miglayout', name: 'miglayout-core', version: '5.0'
compile group: 'de.matthiasmann.twl', name: 'PNGDecoder', version: '1111'
Expand Down
@@ -0,0 +1,20 @@
package openvrprovider;

import jopenvr.JOpenVRLibrary;
import jopenvr.VRControllerState_t;

/* Interface intended to be front-facing to user for controller interaction. */
public interface ControllerListener {
public final int LEFT_CONTROLLER = 0;
public final int RIGHT_CONTROLLER = 1;
public static int k_EAxis_Trigger = 1;
public static int k_EAxis_TouchPad = 0;
public static long k_buttonTouchpad = (1L << JOpenVRLibrary.EVRButtonId.EVRButtonId_k_EButton_SteamVR_Touchpad);
public static long k_buttonTrigger = (1L << JOpenVRLibrary.EVRButtonId.EVRButtonId_k_EButton_SteamVR_Trigger);
public static long k_buttonAppMenu = (1L << JOpenVRLibrary.EVRButtonId.EVRButtonId_k_EButton_ApplicationMenu);
public static long k_buttonGrip = (1L << JOpenVRLibrary.EVRButtonId.EVRButtonId_k_EButton_Grip);
public static float triggerThreshold = .25f;

public void buttonStateChanged(VRControllerState_t stateBefore, VRControllerState_t stateAfter, int nController);
// TODO: touch, axes
}
@@ -0,0 +1,59 @@
package openvrprovider;

/* Mainly used to locate the OpenVR library on different platforms. */
public class OSValidator {
private static final String OS = System.getProperty("os.name").toLowerCase();
private static final String arch = System.getProperty("os.arch");
private static final String userDir = System.getProperty("user.dir");

public static boolean isWin64() {

return (OS.indexOf("win") >= 0 && arch.contains("64"));

}

public static boolean isWin32() {

return (OS.indexOf("win") >= 0 && arch.contains("32"));

}

public static boolean isLinux64() {

return (OS.indexOf("linux") >= 0 && arch.contains("64"));

}

public static boolean isLinux32() {

return (OS.indexOf("linux") >= 0 && arch.contains("32"));

}

public static boolean isMac() {

return (OS.indexOf("mac") >= 0);

}

public static String getOsString() {
if (isWin64())
return new String("win32-x86-64");
else if (isWin32())
return new String("win32-x86");
else if (isLinux64())
return new String("linux-x86-64");
else if (isLinux32())
return new String("linux-x86");
else if (isMac())
return new String("darwin");
return new String("unknown");
}

public static String getLibPath() {
if (getOsString().contains("win"))
return userDir + "\\openvr_natives\\" + getOsString();
return userDir + "/openvr_natives/" + getOsString();
}

}

0 comments on commit ee3c931

Please sign in to comment.