summaryrefslogtreecommitdiffstats
path: root/src/oculusvr/classes/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/oculusvr/classes/com')
-rw-r--r--src/oculusvr/classes/com/jogamp/oculusvr/OVRDynamicLibraryBundleInfo.java113
-rw-r--r--src/oculusvr/classes/com/jogamp/oculusvr/OVRException.java50
-rw-r--r--src/oculusvr/classes/com/jogamp/oculusvr/OVRVersion.java107
3 files changed, 270 insertions, 0 deletions
diff --git a/src/oculusvr/classes/com/jogamp/oculusvr/OVRDynamicLibraryBundleInfo.java b/src/oculusvr/classes/com/jogamp/oculusvr/OVRDynamicLibraryBundleInfo.java
new file mode 100644
index 000000000..6bd9d1a64
--- /dev/null
+++ b/src/oculusvr/classes/com/jogamp/oculusvr/OVRDynamicLibraryBundleInfo.java
@@ -0,0 +1,113 @@
+/**
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.oculusvr;
+
+import com.jogamp.common.jvm.JNILibLoaderBase;
+import com.jogamp.common.os.DynamicLibraryBundle;
+import com.jogamp.common.os.DynamicLibraryBundleInfo;
+import com.jogamp.common.os.Platform;
+import com.jogamp.common.util.RunnableExecutor;
+import com.jogamp.common.util.cache.TempJarCache;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.*;
+
+/* pp */ final class OVRDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo {
+ private static final List<String> glueLibNames;
+ static {
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ Platform.initSingleton();
+
+ if(TempJarCache.isInitialized()) {
+ // only: joal.jar -> joal-natives-<os.and.arch>.jar
+ JNILibLoaderBase.addNativeJarLibs(new Class<?>[] { OVRDynamicLibraryBundleInfo.class }, null, null );
+ }
+ return null;
+ }
+ });
+
+ glueLibNames = new ArrayList<String>();
+ glueLibNames.add("oculusvr");
+ }
+
+ /* pp */ OVRDynamicLibraryBundleInfo() {
+ }
+
+ /**
+ * <p>
+ * Returns <code>true</code>,
+ * since we might load the library and allow symbol access to subsequent libs.
+ * </p>
+ */
+ @Override
+ public final boolean shallLinkGlobal() { return true; }
+
+ /**
+ * {@inheritDoc}
+ * <p>
+ * Returns <code>false</code>.
+ * </p>
+ */
+ @Override
+ public final boolean shallLookupGlobal() { return true; }
+
+ @Override
+ public final List<String> getGlueLibNames() {
+ return glueLibNames;
+ }
+
+ @Override
+ public final List<List<String>> getToolLibNames() {
+ return new ArrayList<List<String>>(); // None
+ }
+
+ @Override
+ public final List<String> getToolGetProcAddressFuncNameList() {
+ return null;
+ }
+
+ @Override
+ public final long toolGetProcAddress(long toolGetProcAddressHandle, String funcName) {
+ return 0;
+ }
+
+ @Override
+ public final boolean useToolGetProcAdressFirst(String funcName) {
+ return false;
+ }
+
+ @Override
+ public final RunnableExecutor getLibLoaderExecutor() {
+ return DynamicLibraryBundle.getDefaultRunnableExecutor();
+ }
+}
+
+
diff --git a/src/oculusvr/classes/com/jogamp/oculusvr/OVRException.java b/src/oculusvr/classes/com/jogamp/oculusvr/OVRException.java
new file mode 100644
index 000000000..e65338025
--- /dev/null
+++ b/src/oculusvr/classes/com/jogamp/oculusvr/OVRException.java
@@ -0,0 +1,50 @@
+/**
+ * Copyright (C) 2014 JogAmp Community. All rights reserved.
+ *
+ * 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
+ * BRIAN PAUL 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.
+ */
+
+package com.jogamp.oculusvr;
+
+/** A generic exception for OculusVR errors used throughout the binding
+ as a substitute for {@link RuntimeException}. */
+@SuppressWarnings("serial")
+public class OVRException extends RuntimeException {
+ /** Constructs an ALException object. */
+ public OVRException() {
+ super();
+ }
+
+ /** Constructs an ALException object with the specified detail
+ message. */
+ public OVRException(String message) {
+ super(message);
+ }
+
+ /** Constructs an ALException object with the specified detail
+ message and root cause. */
+ public OVRException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /** Constructs an ALException object with the specified root
+ cause. */
+ public OVRException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/src/oculusvr/classes/com/jogamp/oculusvr/OVRVersion.java b/src/oculusvr/classes/com/jogamp/oculusvr/OVRVersion.java
new file mode 100644
index 000000000..a7c64940f
--- /dev/null
+++ b/src/oculusvr/classes/com/jogamp/oculusvr/OVRVersion.java
@@ -0,0 +1,107 @@
+/**
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.oculusvr;
+
+import com.jogamp.common.GlueGenVersion;
+
+import com.jogamp.common.os.Platform;
+import com.jogamp.common.util.VersionUtil;
+import com.jogamp.common.util.JogampVersion;
+
+import java.util.jar.Manifest;
+
+public class OVRVersion extends JogampVersion {
+
+ protected static volatile OVRVersion jogampCommonVersionInfo;
+
+ protected OVRVersion(String packageName, Manifest mf) {
+ super(packageName, mf);
+ }
+
+ public static OVRVersion getInstance() {
+ if(null == jogampCommonVersionInfo) { // volatile: ok
+ synchronized(OVRVersion.class) {
+ if( null == jogampCommonVersionInfo ) {
+ final String packageName = "com.jogamp.oculusvr";
+ final Manifest mf = VersionUtil.getManifest(OVRVersion.class.getClassLoader(), packageName);
+ jogampCommonVersionInfo = new OVRVersion(packageName, mf);
+ }
+ }
+ }
+ return jogampCommonVersionInfo;
+ }
+
+ public static StringBuilder getAvailableCapabilitiesInfo(final int ovrHmdIndex, StringBuilder sb) {
+ if(null==sb) {
+ sb = new StringBuilder();
+ }
+ if( !OVR.ovr_Initialize() ) { // recursive ..
+ sb.append("\tOVR not available").append(Platform.getNewline());
+ } else {
+ final long ovrHmdHandle = OVR.ovrHmd_Create(ovrHmdIndex);
+ if( 0 != ovrHmdHandle ) {
+ ovrHmdDesc hmdDesc = ovrHmdDesc.create();
+ OVR.ovrHmd_GetDesc(ovrHmdHandle, hmdDesc);
+ sb.append("\thmd."+ovrHmdIndex+".type:\t"+hmdDesc.getType()).append(Platform.getNewline());
+ sb.append("\thmd."+ovrHmdIndex+".hmdCaps:\t"+hmdDesc.getHmdCaps()).append(Platform.getNewline());
+ sb.append("\thmd."+ovrHmdIndex+".distorCaps:\t"+hmdDesc.getDistortionCaps()).append(Platform.getNewline());
+ sb.append("\thmd."+ovrHmdIndex+".sensorCaps:\t"+hmdDesc.getSensorCaps()).append(Platform.getNewline());
+ final ovrSizei resolution = hmdDesc.getResolution();
+ sb.append("\thmd."+ovrHmdIndex+".resolution:\t"+resolution.getW()+"x"+resolution.getH()).append(Platform.getNewline());
+ ovrVector2i winPos = hmdDesc.getWindowsPos();
+ sb.append("\thmd."+ovrHmdIndex+".winPos:\t"+winPos.getX()+" / "+winPos.getY()).append(Platform.getNewline());
+ OVR.ovrHmd_Destroy(ovrHmdHandle);
+ } else {
+ sb.append("\thmd."+ovrHmdIndex+" not available").append(Platform.getNewline());
+ }
+ }
+ // Nope .. ovr.ovr_Shutdown();
+ sb.append(Platform.getNewline());
+ return sb;
+ }
+
+ public static StringBuilder getAllAvailableCapabilitiesInfo(StringBuilder sb) {
+ if(null==sb) {
+ sb = new StringBuilder();
+ }
+ sb.append(Platform.getNewline()).append(Platform.getNewline());
+ sb.append("HMD.0 Capabilities: ").append(Platform.getNewline());
+ getAvailableCapabilitiesInfo(0, sb);
+ return sb;
+ }
+
+ public static void main(String args[]) {
+ System.err.println(VersionUtil.getPlatformInfo());
+ System.err.println(GlueGenVersion.getInstance());
+ // System.err.println(NativeWindowVersion.getInstance());
+ System.err.println(OVRVersion.getInstance());
+ System.err.println(OVRVersion.getAllAvailableCapabilitiesInfo(null).toString());
+ }
+}
+