internal AndroidNativeControllerProvider(bool enableGyro, bool enableAccel)
{
Debug.Log("Initializing Daydream controller API.");
options = new gvr_controller_api_options();
gvr_controller_init_default_options(ref options);
options.enable_accel = enableAccel ? (byte) 1 : (byte) 0;
options.enable_gyro = enableGyro ? (byte) 1 : (byte) 0;
// Get a hold of the activity, context and class loader.
AndroidJavaObject activity = GetActivity();
if (activity == null) {
error = true;
errorDetails = "Failed to get Activity from Unity Player.";
return;
}
androidContext = GetApplicationContext(activity);
if (androidContext == null) {
error = true;
errorDetails = "Failed to get Android application context from Activity.";
return;
}
classLoader = GetClassLoaderFromActivity(activity);
if (classLoader == null) {
error = true;
errorDetails = "Failed to get class loader from Activity.";
return;
}
Debug.Log("Creating and initializing GVR API controller object.");
api = gvr_controller_create_and_init_android(IntPtr.Zero, androidContext.GetRawObject(),
classLoader.GetRawObject(), ref options, IntPtr.Zero);
if (IntPtr.Zero == api) {
Debug.LogError("Error creating/initializing Daydream controller API.");
error = true;
errorDetails = "Failed to initialize Daydream controller API.";
return;
}
Debug.Log("GVR API successfully initialized. Now resuming it.");
gvr_controller_resume(api);
Debug.Log("GVR API resumed.");
}