Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #132 from m4gr3d/dev_3.0.2
Browse files Browse the repository at this point in the history
Development branch for version 3.1.0
  • Loading branch information
Fredia Huya-Kouadio authored Jun 18, 2021
2 parents 3f0a2d6 + c4bde08 commit 7205e2c
Show file tree
Hide file tree
Showing 25 changed files with 229 additions and 153 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ insert_final_newline = true
max_line_length = 100
trim_trailing_whitespace = true
tab_width = 4
ij_continuation_indent_size = 8
ij_continuation_indent_size = 4
ij_formatter_off_tag = @formatter:off
ij_formatter_on_tag = @formatter:on
ij_formatter_tags_enabled = false
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Clone the repository and **initialise the submodules** with `git submodule updat

#### Oculus Mobile SDK
- Download the [latest version](https://developer.oculus.com/downloads/package/oculus-mobile-sdk/)
(**Oculus Mobile SDK 23.0** (1.40.0) or higher) of the Oculus Mobile SDK and extract it into the
(**Oculus Mobile SDK 27.0** (1.44.0) or higher) of the Oculus Mobile SDK and extract it into the
`plugin/libs/ovr_sdk_mobile` directory (create the directory if it doesn't exist).
- If you change the default install location, update the `OVR_ROOT_DIR` cmake variable in the the
`plugin/CMakeLists.txt` build file to point to the Oculus Mobile SDK install location.
Expand Down
1 change: 0 additions & 1 deletion plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wredundant-decls -Wreturn-type
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wswitch -Wswitch-enum -Wtrigraphs")
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wuninitialized -Wunknown-pragmas -Wunreachable-code -Wunused-label")
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wunused-value -Wvariadic-macros -Wvolatile-register-var -Wno-error=attributes")
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -fno-omit-frame-pointer -O0")

if (NOT CMAKE_SYSTEM_NAME STREQUAL "Android")
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wno-ignored-attributes")
Expand Down
4 changes: 2 additions & 2 deletions plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
defaultConfig {
minSdkVersion versions.minSdk
targetSdkVersion versions.targetSdk
versionCode 5
versionName '3.0.1'
versionCode 8
versionName '3.1.0'
setProperty("archivesBaseName", "gdovrmobile.${versionName}")

externalNativeBuild {
Expand Down
2 changes: 1 addition & 1 deletion plugin/gdovrmobile.gdap
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

name="OVRMobile"
binary_type="local"
binary="gdovrmobile.3.0.1-release.aar"
binary="gdovrmobile.3.1.0-release.aar"
Binary file not shown.
12 changes: 12 additions & 0 deletions plugin/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,24 @@
xmlns:tools="http://schemas.android.com/tools"
package="org.godotengine.plugin.vr.oculus.mobile">

<uses-feature
android:name="android.hardware.vr.headtracking"
android:required="true"
android:version="1"
tools:node="replace"/>

<application>

<meta-data
android:name="com.samsung.android.vr.application.mode"
android:value="vr_only"
tools:node="replace" />

<meta-data
android:name="org.godotengine.plugin.v1.OVRMobile"
android:value="org.godotengine.plugin.vr.oculus.mobile.OvrMobilePlugin" />

<!-- List of Supported Devices. "delmar" is the codename for Quest 2. -->
<meta-data
android:name="com.oculus.supportedDevices"
android:value="quest|delmar"
Expand Down
2 changes: 2 additions & 0 deletions plugin/src/main/cpp/api/ovr_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "ovr_display.h"
#include "api_common.h"
#include <gen/Engine.hpp>

namespace ovrmobile {
OvrDisplay::OvrDisplay() {}
Expand Down Expand Up @@ -53,6 +54,7 @@ std::vector<float> get_supported_display_refresh_rates(OvrMobileSession *session

bool set_display_refresh_rate(OvrMobileSession *session, float refresh_rate) {
return check_session_initialized<bool>(session, [&]() {
Engine::get_singleton()->set_iterations_per_second(refresh_rate);
return vrapi_SetDisplayRefreshRate(session->get_ovr_mobile_context(), refresh_rate) ==
ovrSuccess;
});
Expand Down
5 changes: 5 additions & 0 deletions plugin/src/main/cpp/api/ovr_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ void OvrSystem::_init() {}

void OvrSystem::_register_methods() {
register_method("get_device_type", &OvrSystem::get_device_type);
register_method("get_driver_version", &OvrSystem::get_driver_version);
register_method("is_oculus_quest_1_device", &OvrSystem::is_oculus_quest_1_device);
register_method("is_oculus_quest_2_device", &OvrSystem::is_oculus_quest_2_device);
}
Expand Down Expand Up @@ -41,4 +42,8 @@ bool is_oculus_quest_2_device(OvrMobileSession *session) {
device_type <= VRAPI_DEVICE_TYPE_OCULUSQUEST2_END;
}

String get_driver_version() {
return vrapi_GetVersionString();
}

} // namespace ovrmobile
5 changes: 5 additions & 0 deletions plugin/src/main/cpp/api/ovr_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ bool is_oculus_quest_2_device(OvrMobileSession *session);
/// Return the current device type.
ovrDeviceType get_device_type(OvrMobileSession *session);

/// Return the version of the vrapi driver.
String get_driver_version();

class OvrSystem : public Reference {
GODOT_CLASS(OvrSystem, Reference)

Expand All @@ -40,6 +43,8 @@ class OvrSystem : public Reference {
inline bool is_oculus_quest_2_device() {
return ovrmobile::is_oculus_quest_2_device(OvrMobileSession::get_singleton_instance());
}

inline String get_driver_version() { return ovrmobile::get_driver_version(); }
};
} // namespace ovrmobile

Expand Down
130 changes: 69 additions & 61 deletions plugin/src/main/cpp/jni/ovr_mobile_plugin_wrapper.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Created by Fredia Huya-Kouadio.
*/
* Created by Fredia Huya-Kouadio.
*/

#include "ovr_mobile_plugin_wrapper.h"
#include "common.h"
Expand All @@ -14,95 +14,103 @@ jmethodID OvrMobilePluginWrapper::on_input_focus_gained_id = nullptr;
jmethodID OvrMobilePluginWrapper::on_input_focus_lost_id = nullptr;
jmethodID OvrMobilePluginWrapper::on_enter_vr_mode_id = nullptr;
jmethodID OvrMobilePluginWrapper::on_leave_vr_mode_id = nullptr;
jmethodID OvrMobilePluginWrapper::on_pose_recentered_id = nullptr;

OvrMobilePluginWrapper::OvrMobilePluginWrapper() {}

OvrMobilePluginWrapper::~OvrMobilePluginWrapper() {}

void OvrMobilePluginWrapper::initializeWrapper(JNIEnv* env,
jobject ovr_mobile_plugin) {
ovr_mobile_plugin_instance = env->NewGlobalRef(ovr_mobile_plugin);
ALOG_ASSERT(ovr_mobile_plugin_instance != nullptr, "Invalid jobject value.");
void OvrMobilePluginWrapper::initializeWrapper(JNIEnv *env, jobject ovr_mobile_plugin) {
ovr_mobile_plugin_instance = env->NewGlobalRef(ovr_mobile_plugin);
ALOG_ASSERT(ovr_mobile_plugin_instance != nullptr, "Invalid jobject value.");

jclass
ovr_mobile_plugin_class = env->GetObjectClass(ovr_mobile_plugin_instance);
ALOG_ASSERT(ovr_mobile_plugin_class != nullptr, "Invalid jclass value.");
jclass ovr_mobile_plugin_class = env->GetObjectClass(ovr_mobile_plugin_instance);
ALOG_ASSERT(ovr_mobile_plugin_class != nullptr, "Invalid jclass value.");

on_headset_mounted_id =
env->GetMethodID(ovr_mobile_plugin_class, "onHeadsetMounted", "()V");
ALOG_ASSERT(on_headset_mounted_id != nullptr,
"Unable to find onHeadsetMounted");
on_headset_mounted_id = env->GetMethodID(ovr_mobile_plugin_class, "onHeadsetMounted", "()V");
ALOG_ASSERT(on_headset_mounted_id != nullptr, "Unable to find onHeadsetMounted");

on_headset_unmounted_id =
env->GetMethodID(ovr_mobile_plugin_class, "onHeadsetUnmounted", "()V");
ALOG_ASSERT(on_headset_unmounted_id != nullptr,
"Unable to find onHeadsetUnmounted");
on_headset_unmounted_id =
env->GetMethodID(ovr_mobile_plugin_class, "onHeadsetUnmounted", "()V");
ALOG_ASSERT(on_headset_unmounted_id != nullptr, "Unable to find onHeadsetUnmounted");

on_input_focus_gained_id = env->GetMethodID(ovr_mobile_plugin_class, "onInputFocusGained", "()V");
ALOG_ASSERT(on_input_focus_gained_id != nullptr, "Unable to find onInputFocusGained");
on_input_focus_gained_id =
env->GetMethodID(ovr_mobile_plugin_class, "onInputFocusGained", "()V");
ALOG_ASSERT(on_input_focus_gained_id != nullptr, "Unable to find onInputFocusGained");

on_input_focus_lost_id = env->GetMethodID(ovr_mobile_plugin_class, "onInputFocusLost", "()V");
ALOG_ASSERT(on_input_focus_lost_id != nullptr, "Unable to find onInputFocusLost");
on_input_focus_lost_id = env->GetMethodID(ovr_mobile_plugin_class, "onInputFocusLost", "()V");
ALOG_ASSERT(on_input_focus_lost_id != nullptr, "Unable to find onInputFocusLost");

on_enter_vr_mode_id = env->GetMethodID(ovr_mobile_plugin_class, "onEnterVrMode", "()V");
ALOG_ASSERT(on_enter_vr_mode_id != nullptr, "Unable to find onEnterVrMode");
on_enter_vr_mode_id = env->GetMethodID(ovr_mobile_plugin_class, "onEnterVrMode", "()V");
ALOG_ASSERT(on_enter_vr_mode_id != nullptr, "Unable to find onEnterVrMode");

on_leave_vr_mode_id = env->GetMethodID(ovr_mobile_plugin_class, "onLeaveVrMode", "()V");
ALOG_ASSERT(on_leave_vr_mode_id != nullptr, "Unable to find onLeaveVrMode");
on_leave_vr_mode_id = env->GetMethodID(ovr_mobile_plugin_class, "onLeaveVrMode", "()V");
ALOG_ASSERT(on_leave_vr_mode_id != nullptr, "Unable to find onLeaveVrMode");

on_pose_recentered_id = env->GetMethodID(ovr_mobile_plugin_class, "onPoseRecentered", "()V");
ALOG_ASSERT(on_pose_recentered_id != nullptr, "Unable to find onPoseRecentered");
}

void OvrMobilePluginWrapper::uninitializeWrapper(JNIEnv* env) {
if (ovr_mobile_plugin_instance) {
env->DeleteGlobalRef(ovr_mobile_plugin_instance);
ovr_mobile_plugin_instance = nullptr;
on_headset_mounted_id = nullptr;
on_headset_unmounted_id = nullptr;
on_input_focus_gained_id = nullptr;
on_input_focus_lost_id = nullptr;
on_enter_vr_mode_id = nullptr;
on_leave_vr_mode_id = nullptr;
}
void OvrMobilePluginWrapper::uninitializeWrapper(JNIEnv *env) {
if (ovr_mobile_plugin_instance) {
env->DeleteGlobalRef(ovr_mobile_plugin_instance);
ovr_mobile_plugin_instance = nullptr;
on_headset_mounted_id = nullptr;
on_headset_unmounted_id = nullptr;
on_input_focus_gained_id = nullptr;
on_input_focus_lost_id = nullptr;
on_enter_vr_mode_id = nullptr;
on_leave_vr_mode_id = nullptr;
on_pose_recentered_id = nullptr;
}
}

void OvrMobilePluginWrapper::on_headset_mounted() {
if (ovr_mobile_plugin_instance && on_headset_mounted_id) {
JNIEnv *env = godot::android_api->godot_android_get_env();
env->CallVoidMethod(ovr_mobile_plugin_instance, on_headset_mounted_id);
}
if (ovr_mobile_plugin_instance && on_headset_mounted_id) {
JNIEnv *env = godot::android_api->godot_android_get_env();
env->CallVoidMethod(ovr_mobile_plugin_instance, on_headset_mounted_id);
}
}

void OvrMobilePluginWrapper::on_headset_unmounted() {
if (ovr_mobile_plugin_instance && on_headset_unmounted_id) {
JNIEnv* env = godot::android_api->godot_android_get_env();
env->CallVoidMethod(ovr_mobile_plugin_instance, on_headset_unmounted_id);
}
if (ovr_mobile_plugin_instance && on_headset_unmounted_id) {
JNIEnv *env = godot::android_api->godot_android_get_env();
env->CallVoidMethod(ovr_mobile_plugin_instance, on_headset_unmounted_id);
}
}

void OvrMobilePluginWrapper::on_input_focus_gained() {
if (ovr_mobile_plugin_instance && on_input_focus_gained_id) {
JNIEnv* env = godot::android_api->godot_android_get_env();
env->CallVoidMethod(ovr_mobile_plugin_instance, on_input_focus_gained_id);
}
if (ovr_mobile_plugin_instance && on_input_focus_gained_id) {
JNIEnv *env = godot::android_api->godot_android_get_env();
env->CallVoidMethod(ovr_mobile_plugin_instance, on_input_focus_gained_id);
}
}

void OvrMobilePluginWrapper::on_input_focus_lost() {
if (ovr_mobile_plugin_instance && on_input_focus_lost_id) {
JNIEnv* env = godot::android_api->godot_android_get_env();
env->CallVoidMethod(ovr_mobile_plugin_instance, on_input_focus_lost_id);
}
if (ovr_mobile_plugin_instance && on_input_focus_lost_id) {
JNIEnv *env = godot::android_api->godot_android_get_env();
env->CallVoidMethod(ovr_mobile_plugin_instance, on_input_focus_lost_id);
}
}

void OvrMobilePluginWrapper::on_enter_vr_mode() {
if (ovr_mobile_plugin_instance && on_enter_vr_mode_id) {
JNIEnv *env = godot::android_api->godot_android_get_env();
env->CallVoidMethod(ovr_mobile_plugin_instance, on_enter_vr_mode_id);
}
if (ovr_mobile_plugin_instance && on_enter_vr_mode_id) {
JNIEnv *env = godot::android_api->godot_android_get_env();
env->CallVoidMethod(ovr_mobile_plugin_instance, on_enter_vr_mode_id);
}
}

void OvrMobilePluginWrapper::on_leave_vr_mode() {
if (ovr_mobile_plugin_instance && on_leave_vr_mode_id) {
JNIEnv *env = godot::android_api->godot_android_get_env();
env->CallVoidMethod(ovr_mobile_plugin_instance, on_leave_vr_mode_id);
}
if (ovr_mobile_plugin_instance && on_leave_vr_mode_id) {
JNIEnv *env = godot::android_api->godot_android_get_env();
env->CallVoidMethod(ovr_mobile_plugin_instance, on_leave_vr_mode_id);
}
}

void OvrMobilePluginWrapper::on_pose_recentered() {
if (ovr_mobile_plugin_instance && on_pose_recentered_id) {
JNIEnv *env = godot::android_api->godot_android_get_env();
env->CallVoidMethod(ovr_mobile_plugin_instance, on_pose_recentered_id);
}
}
} // namespace ovrmobile
} // namespace ovrmobile
47 changes: 25 additions & 22 deletions plugin/src/main/cpp/jni/ovr_mobile_plugin_wrapper.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Created by Fredia Huya-Kouadio.
*/
* Created by Fredia Huya-Kouadio.
*/

#ifndef OVRMOBILE_OVR_MOBILE_PLUGIN_WRAPPER_H
#define OVRMOBILE_OVR_MOBILE_PLUGIN_WRAPPER_H
Expand All @@ -9,37 +9,40 @@

namespace ovrmobile {

// Provide native access to the org.godotengine.plugin.vr.oculus.mobile.OvrMobilePlugin instance.
// Provide native access to the
// org.godotengine.plugin.vr.oculus.mobile.OvrMobilePlugin instance.
class OvrMobilePluginWrapper {
public:
static void initializeWrapper(JNIEnv* env, jobject ovr_mobile_plugin);
static void initializeWrapper(JNIEnv *env, jobject ovr_mobile_plugin);

static void uninitializeWrapper(JNIEnv* env);
static void uninitializeWrapper(JNIEnv *env);

static void on_headset_mounted();
static void on_headset_mounted();

static void on_headset_unmounted();
static void on_headset_unmounted();

static void on_input_focus_gained();
static void on_input_focus_gained();

static void on_input_focus_lost();
static void on_input_focus_lost();

static void on_enter_vr_mode();
static void on_enter_vr_mode();

static void on_leave_vr_mode();
static void on_leave_vr_mode();

private:
OvrMobilePluginWrapper();
~OvrMobilePluginWrapper();

static jobject ovr_mobile_plugin_instance;
static jmethodID on_headset_mounted_id;
static jmethodID on_headset_unmounted_id;
static jmethodID on_input_focus_gained_id;
static jmethodID on_input_focus_lost_id;
static jmethodID on_enter_vr_mode_id;
static jmethodID on_leave_vr_mode_id;
static void on_pose_recentered();

private:
OvrMobilePluginWrapper();
~OvrMobilePluginWrapper();

static jobject ovr_mobile_plugin_instance;
static jmethodID on_headset_mounted_id;
static jmethodID on_headset_unmounted_id;
static jmethodID on_input_focus_gained_id;
static jmethodID on_input_focus_lost_id;
static jmethodID on_enter_vr_mode_id;
static jmethodID on_leave_vr_mode_id;
static jmethodID on_pose_recentered_id;
};

} // namespace ovrmobile
Expand Down
4 changes: 4 additions & 0 deletions plugin/src/main/cpp/jni/ovr_system_jni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ extern "C" {
JNIEXPORT jint JNICALL JNI_METHOD(nativeGetDeviceType)(JNIEnv *, jclass) {
return ovrmobile::get_device_type(get_session());
}

JNIEXPORT jstring JNICALL JNI_METHOD(nativeGetDriverVersion)(JNIEnv *env, jclass) {
return string_to_jstring(env, ovrmobile::get_driver_version());
}
};
Loading

0 comments on commit 7205e2c

Please sign in to comment.