mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-08 23:12:16 +02:00
get PlatformActivity menu working in GVR
This commit is contained in:
parent
3f50311d04
commit
951617d40a
7 changed files with 58 additions and 19 deletions
|
@ -73,6 +73,7 @@ else (NOT ANDROID)
|
|||
find_path(JNI_DIR VrCommon.h PATH_SUFFIXES ${_VRLIB_JNI_DIR} HINTS ${LIBOVR_SEARCH_DIRS})
|
||||
|
||||
find_library(LIBOVR_LIBRARY_RELEASE NAMES oculus PATH_SUFFIXES ${_VRLIB_LIBS_DIR} HINTS ${LIBOVR_SEARCH_DIRS})
|
||||
find_library(TURBOJPEG_LIBRARY NAMES jpeg PATH_SUFFIXES 3rdParty/turbojpeg HINTS ${LIBOVR_SEARCH_DIRS})
|
||||
endif (NOT ANDROID)
|
||||
|
||||
select_library_configurations(LIBOVR)
|
||||
|
@ -84,8 +85,9 @@ if (APPLE)
|
|||
list(APPEND LIBOVR_LIBRARIES ${IOKit} ${ApplicationServices})
|
||||
list(APPEND LIBOVR_ARGS_LIST IOKit ApplicationServices)
|
||||
elseif (ANDROID)
|
||||
|
||||
list(APPEND LIBOVR_ANDROID_LIBRARIES "-lGLESv3" "-lEGL" "-landroid" "-lOpenMAXAL" "-llog" "-lz" "-lOpenSLES")
|
||||
list(APPEND LIBOVR_ARGS_LIST LIBOVR_ANDROID_LIBRARIES LIBOVR_VRLIB_DIR MINIZIP_DIR JNI_DIR)
|
||||
list(APPEND LIBOVR_ARGS_LIST LIBOVR_ANDROID_LIBRARIES LIBOVR_VRLIB_DIR MINIZIP_DIR JNI_DIR TURBOJPEG_LIBRARY)
|
||||
elseif (UNIX)
|
||||
list(APPEND LIBOVR_LIBRARIES "${UDEV_LIBRARY}" "${XINERAMA_LIBRARY}")
|
||||
list(APPEND LIBOVR_ARGS_LIST UDEV_LIBRARY XINERAMA_LIBRARY)
|
||||
|
|
|
@ -34,7 +34,7 @@ if (ANDROID)
|
|||
|
||||
if (LIBOVR_FOUND)
|
||||
add_definitions(-DHAVE_LIBOVR)
|
||||
target_link_libraries(${TARGET_NAME} ${LIBOVR_LIBRARIES} ${LIBOVR_ANDROID_LIBRARIES})
|
||||
target_link_libraries(${TARGET_NAME} ${LIBOVR_LIBRARIES} ${LIBOVR_ANDROID_LIBRARIES} ${TURBOJPEG_LIBRARY})
|
||||
include_directories(SYSTEM ${LIBOVR_INCLUDE_DIRS})
|
||||
|
||||
# we need VRLib, so add a project.properties to our apk build folder that says that
|
||||
|
|
|
@ -19,9 +19,8 @@
|
|||
|
||||
#ifdef HAVE_LIBOVR
|
||||
|
||||
#include <VrApi/LocalPreferences.h>
|
||||
#include <KeyState.h>
|
||||
#include <VrApi/VrApi.h>
|
||||
#include <VrApi/VrApi_local.h>
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -37,8 +36,21 @@
|
|||
|
||||
static QString launchURLString = QString();
|
||||
|
||||
#ifdef ANDROID
|
||||
|
||||
extern "C" {
|
||||
|
||||
JNIEXPORT void Java_io_highfidelity_gvrinterface_InterfaceActivity_handleHifiURL(JNIEnv *jni, jclass clazz, jstring hifiURLString) {
|
||||
launchURLString = QAndroidJniObject(hifiURLString).toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
GVRInterface::GVRInterface(int argc, char* argv[]) :
|
||||
QApplication(argc, argv),
|
||||
_mainWindow(NULL),
|
||||
_inVRMode(false)
|
||||
{
|
||||
if (!launchURLString.isEmpty()) {
|
||||
|
@ -59,6 +71,11 @@ GVRInterface::GVRInterface(int argc, char* argv[]) :
|
|||
jobject activity = (jobject) interface->nativeResourceForIntegration("QtActivity");
|
||||
|
||||
ovr_RegisterHmtReceivers(&*jniEnv, activity);
|
||||
|
||||
// PLATFORMACTIVITY_REMOVAL: Temp workaround for PlatformActivity being
|
||||
// stripped from UnityPlugin. Alternate is to use LOCAL_WHOLE_STATIC_LIBRARIES
|
||||
// but that increases the size of the plugin by ~1MiB
|
||||
OVR::linkerPlatformActivity++;
|
||||
#endif
|
||||
|
||||
// call our idle function whenever we can
|
||||
|
@ -67,25 +84,13 @@ GVRInterface::GVRInterface(int argc, char* argv[]) :
|
|||
idleTimer->start(0);
|
||||
}
|
||||
|
||||
#ifdef ANDROID
|
||||
|
||||
extern "C" {
|
||||
|
||||
JNIEXPORT void Java_io_highfidelity_gvrinterface_InterfaceActivity_handleHifiURL(JNIEnv *jni, jclass clazz, jstring hifiURLString) {
|
||||
launchURLString = QAndroidJniObject(hifiURLString).toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void GVRInterface::idle() {
|
||||
#if defined(ANDROID) && defined(HAVE_LIBOVR)
|
||||
if (!_inVRMode && ovr_IsHeadsetDocked()) {
|
||||
qDebug() << "The headset just got docked - enter VR mode.";
|
||||
enterVRMode();
|
||||
} else if (_inVRMode) {
|
||||
|
||||
|
||||
if (ovr_IsHeadsetDocked()) {
|
||||
static int counter = 0;
|
||||
|
||||
|
@ -113,6 +118,18 @@ void GVRInterface::idle() {
|
|||
leaveVRMode();
|
||||
}
|
||||
}
|
||||
|
||||
OVR::KeyState& backKeyState = _mainWindow->getBackKeyState();
|
||||
auto backEvent = backKeyState.Update(ovr_GetTimeInSeconds());
|
||||
|
||||
if (backEvent == OVR::KeyState::KEY_EVENT_LONG_PRESS) {
|
||||
qDebug() << "Attemping to start the Platform UI Activity.";
|
||||
ovr_StartPackageActivity(_ovr, PUI_CLASS_NAME, PUI_GLOBAL_MENU);
|
||||
} else if (backEvent == OVR::KeyState::KEY_EVENT_DOUBLE_TAP || backEvent == OVR::KeyState::KEY_EVENT_SHORT_PRESS) {
|
||||
qDebug() << "Got an event we should cancel for!";
|
||||
} else if (backEvent == OVR::KeyState::KEY_EVENT_DOUBLE_TAP) {
|
||||
qDebug() << "The button is down!";
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -17,8 +17,19 @@
|
|||
#if defined(ANDROID) && defined(HAVE_LIBOVR)
|
||||
class ovrMobile;
|
||||
class ovrHmdInfo;
|
||||
|
||||
// This is set by JNI_OnLoad() when the .so is initially loaded.
|
||||
// Must use to attach each thread that will use JNI:
|
||||
namespace OVR {
|
||||
// PLATFORMACTIVITY_REMOVAL: Temp workaround for PlatformActivity being
|
||||
// stripped from UnityPlugin. Alternate is to use LOCAL_WHOLE_STATIC_LIBRARIES
|
||||
// but that increases the size of the plugin by ~1MiB
|
||||
extern int linkerPlatformActivity;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
class GVRMainWindow;
|
||||
class RenderingClient;
|
||||
class QKeyEvent;
|
||||
|
||||
|
@ -33,6 +44,8 @@ public:
|
|||
GVRInterface(int argc, char* argv[]);
|
||||
RenderingClient* getClient() { return _client; }
|
||||
|
||||
void setMainWindow(GVRMainWindow* mainWindow) { _mainWindow = mainWindow; }
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
|
||||
|
@ -49,6 +62,8 @@ private:
|
|||
ovrHmdInfo* _hmdInfo;
|
||||
#endif
|
||||
|
||||
GVRMainWindow* _mainWindow;
|
||||
|
||||
RenderingClient* _client;
|
||||
bool _inVRMode;
|
||||
};
|
||||
|
|
|
@ -88,8 +88,6 @@ void GVRMainWindow::keyReleaseEvent(QKeyEvent* event) {
|
|||
// release on the Android back key, hand off to OVR KeyState
|
||||
_backKeyState.HandleEvent(ovr_GetTimeInSeconds(), false, 0);
|
||||
_wasBackKeyDown = false;
|
||||
|
||||
auto backEvent = _backKeyState.Update(ovr_GetTimeInSeconds());
|
||||
}
|
||||
#endif
|
||||
QWidget::keyReleaseEvent(event);
|
||||
|
|
|
@ -29,6 +29,11 @@ public:
|
|||
~GVRMainWindow();
|
||||
public slots:
|
||||
void showAddressBar();
|
||||
|
||||
#if defined(ANDROID) && defined(HAVE_LIBOVR)
|
||||
OVR::KeyState& getBackKeyState() { return _backKeyState; }
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
void keyReleaseEvent(QKeyEvent* event);
|
||||
|
|
|
@ -22,5 +22,7 @@ int main(int argc, char* argv[]) {
|
|||
mainWindow.showMaximized();
|
||||
#endif
|
||||
|
||||
app.setMainWindow(&mainWindow);
|
||||
|
||||
return app.exec();
|
||||
}
|
Loading…
Reference in a new issue