vrapi: Add support for focus awareness;

This commit is contained in:
bjorn 2020-06-25 15:00:12 -06:00
parent 6819a04f31
commit 27b04b2bde
3 changed files with 18 additions and 2 deletions

View File

@ -212,8 +212,7 @@ ifeq ($(PLATFORM),android)
LDFLAGS_@(DATA) += -L$(ROOT)/build/lib_msdfgen -lmsdfgen
LDFLAGS_@(PHYSICS) += -L$(ROOT)/build/ode -lode
LDFLAGS_@(ENET) += -L$(ROOT)/build/enet -lenet
LDFLAGS_@(VRAPI) += -L$(VRAPI_LIB_PATH)
LDFLAGS_@(VRAPI) += -lvrapi
LDFLAGS_@(VRAPI) += -L$(VRAPI_LIB_PATH) -lvrapi
LIBS_@(AUDIO) += $(ROOT)/build/openal/libopenal.*so*
LIBS_@(PHYSICS) += $(ROOT)/build/ode/libode.so

View File

@ -1,4 +1,5 @@
#include "headset/headset.h"
#include "event/event.h"
#include "graphics/canvas.h"
#include "graphics/graphics.h"
#include "core/maf.h"
@ -413,6 +414,21 @@ static void vrapi_renderTo(void (*callback)(void*), void* userdata) {
static void vrapi_update(float dt) {
if (!state.session) return;
VRAPI_LARGEST_EVENT_TYPE event;
while (vrapi_PollEvent(&event.EventHeader) == ovrSuccess) {
switch (event.EventHeader.EventType) {
case VRAPI_EVENT_FOCUS_GAINED:
lovrEventPush((Event) { .type = EVENT_FOCUS, .data.boolean = { true } });
break;
case VRAPI_EVENT_FOCUS_LOST:
lovrEventPush((Event) { .type = EVENT_FOCUS, .data.boolean = { false } });
break;
default: break;
}
}
state.frameIndex++;
state.displayTime = vrapi_GetPredictedDisplayTime(state.session, state.frameIndex);

View File

@ -7,6 +7,7 @@
<meta-data android:name="com.samsung.android.vr.application.mode" android:value="vr_only"/>
<activity android:name="Activity">
<meta-data android:name="android.app.lib_name" android:value="lovr"/>
<meta-data android:name="com.oculus.vr.focusaware" android:value="true"/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>