Fix some headset issues;

This commit is contained in:
bjorn 2016-08-16 20:35:15 -07:00
parent 49297ba59b
commit 604c5bcbab
6 changed files with 24 additions and 7 deletions

View File

@ -3,10 +3,12 @@
#include "../glfw.h"
#include "../osvr.h"
extern OSVR_ClientContext ctx;
void lovrEventPoll() {
glfwPollEvents();
if (osvrClientCheckStatus(ctx) != OSVR_RETURN_FAILURE) {
if (ctx != NULL && osvrClientCheckStatus(ctx) != OSVR_RETURN_FAILURE) {
osvrClientUpdate(ctx);
}
}

View File

@ -1,4 +1,6 @@
#include "headset.h"
#include "../util.h"
#include "../glfw.h"
extern OSVR_ClientContext ctx;
@ -10,13 +12,21 @@ typedef struct {
static HeadsetState headsetState;
void lovrHeadsetInit() {
initOsvr();
if (ctx == NULL) {
headsetState.interface = NULL;
return;
}
osvrClientGetInterface(ctx, "/me/head", &headsetState.interface);
osvrClientGetDisplay(ctx, &headsetState.displayConfig);
if (osvrClientGetDisplay(ctx, &headsetState.displayConfig) != OSVR_RETURN_SUCCESS) {
error("Could not get headset display config");
}
while (osvrClientCheckDisplayStartup(headsetState.displayConfig) != OSVR_RETURN_SUCCESS) {
osvrClientUpdate(ctx);
}
}
void lovrHeadsetGetPosition(float* x, float* y, float* z) {
@ -78,6 +88,8 @@ void lovrHeadsetRenderTo(headsetRenderCallback callback, void* userdata) {
displayConfig, viewer, eye, surface, &left, &bottom, &width, &height
);
glViewport(left, bottom, width, height);
double projectionMatrix[OSVR_MATRIX_SIZE];
float near = 0.1f;
float far = 100.0f;

View File

@ -61,7 +61,7 @@ void lovrJoysticksInit() {
OSVR_ClientInterface* buttonInterface = NULL;
for (int j = 0; i < 6; j++) {
for (int j = 0; j < 6; j++) {
if (buttonInterface == NULL) {
buttonInterface = malloc(sizeof(buttonInterface));
}
@ -101,6 +101,8 @@ void lovrJoysticksInit() {
}
free(axisInterface);
joystick = NULL;
}
}

View File

@ -3,8 +3,9 @@
void renderHelper(int eyeIndex, void* userdata) {
lua_State* L = (lua_State*)userdata;
luaL_checktype(L, -1, LUA_TFUNCTION);
lua_pushinteger(L, 1);
luaL_checktype(L, 1, LUA_TFUNCTION);
lua_pushvalue(L, 1);
lua_pushinteger(L, eyeIndex);
lua_call(L, 1, 0);
}

View File

@ -1,5 +1,5 @@
#include "osvr.h"
void initOSVR() {
void initOsvr() {
ctx = osvrClientInit("es.bjornbyt", 0);
}

View File

@ -11,4 +11,4 @@ typedef vec_t(OSVR_ClientInterface*) interface_vec_t;
OSVR_ClientContext ctx;
void osvrInit();
void initOsvr();