summaryrefslogtreecommitdiffstats
path: root/make/config/oculusvr/oculusvr-ovr-CustomJavaCode.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-06-25 12:58:13 +0200
committerSven Gothel <[email protected]>2014-06-25 12:58:13 +0200
commit08649aec02bae161423871c9bb3ec9a011e91088 (patch)
tree1b0e6f1bb13644bfd5b885ef1231a8d992ea9594 /make/config/oculusvr/oculusvr-ovr-CustomJavaCode.java
parent008b3512be183cefc82e051b36c7a74d53c4906d (diff)
Bug 1021: OVR GlueGen Mapping: Handle non-existent native oculusvr lib gracefully
- query isAvailable() in ovr_Initialize(), ovrHmd_Create(..) and ovrHmd_CreateDebug(..) and return appropriate values.
Diffstat (limited to 'make/config/oculusvr/oculusvr-ovr-CustomJavaCode.java')
-rw-r--r--make/config/oculusvr/oculusvr-ovr-CustomJavaCode.java51
1 files changed, 31 insertions, 20 deletions
diff --git a/make/config/oculusvr/oculusvr-ovr-CustomJavaCode.java b/make/config/oculusvr/oculusvr-ovr-CustomJavaCode.java
index 06f7b3234..281610a20 100644
--- a/make/config/oculusvr/oculusvr-ovr-CustomJavaCode.java
+++ b/make/config/oculusvr/oculusvr-ovr-CustomJavaCode.java
@@ -1,22 +1,33 @@
-static {
- AccessController.doPrivileged(new PrivilegedAction<DynamicLibraryBundle>() {
- public DynamicLibraryBundle run() {
- final DynamicLibraryBundle bundle = new DynamicLibraryBundle(new OVRDynamicLibraryBundleInfo());
- if(null==bundle) {
- throw new RuntimeException("Null DynamicLibraryBundle");
- }
- /** No native tool library to load
- if(!bundle.isToolLibLoaded()) {
- throw new RuntimeException("Couln't load native OVR library");
- } */
- if(!bundle.isLibComplete()) {
- throw new RuntimeException("Couln't load native OVR/JNI glue library");
- }
- if( !initializeImpl() ) {
- throw new RuntimeException("Initialization failure");
- }
- return bundle;
- } } );
-}
+ static final DynamicLibraryBundle dynamicLookupHelper;
+
+ static {
+ dynamicLookupHelper = AccessController.doPrivileged(new PrivilegedAction<DynamicLibraryBundle>() {
+ public DynamicLibraryBundle run() {
+ final DynamicLibraryBundle bundle = new DynamicLibraryBundle(new OVRDynamicLibraryBundleInfo());
+ if(null==bundle) {
+ throw new RuntimeException("Null DynamicLibraryBundle");
+ }
+ /** No native tool library to load
+ if(!bundle.isToolLibLoaded()) {
+ System.err.println("Couln't load native OVR/JNI glue library");
+ return null;
+ } */
+ if(!bundle.isLibComplete()) {
+ System.err.println("Couln't load native OVR/JNI glue library");
+ return null;
+ }
+ if( !initializeImpl() ) {
+ System.err.println("Native initialization failure of OVR/JNI glue library");
+ return null;
+ }
+ return bundle;
+ } } );
+ }
+
+ /**
+ * Accessor.
+ * @returns true if OVR library is available on this machine.
+ */
+ public static boolean isAvailable() { return dynamicLookupHelper != null; }