1
0
Fork 0
mirror of https://github.com/bjornbytes/lovr.git synced 2024-07-03 04:53:35 +00:00

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 "../glfw.h"
#include "../osvr.h" #include "../osvr.h"
extern OSVR_ClientContext ctx;
void lovrEventPoll() { void lovrEventPoll() {
glfwPollEvents(); glfwPollEvents();
if (osvrClientCheckStatus(ctx) != OSVR_RETURN_FAILURE) { if (ctx != NULL && osvrClientCheckStatus(ctx) != OSVR_RETURN_FAILURE) {
osvrClientUpdate(ctx); osvrClientUpdate(ctx);
} }
} }

View file

@ -1,4 +1,6 @@
#include "headset.h" #include "headset.h"
#include "../util.h"
#include "../glfw.h"
extern OSVR_ClientContext ctx; extern OSVR_ClientContext ctx;
@ -10,13 +12,21 @@ typedef struct {
static HeadsetState headsetState; static HeadsetState headsetState;
void lovrHeadsetInit() { void lovrHeadsetInit() {
initOsvr();
if (ctx == NULL) { if (ctx == NULL) {
headsetState.interface = NULL; headsetState.interface = NULL;
return; return;
} }
osvrClientGetInterface(ctx, "/me/head", &headsetState.interface); 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) { 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 displayConfig, viewer, eye, surface, &left, &bottom, &width, &height
); );
glViewport(left, bottom, width, height);
double projectionMatrix[OSVR_MATRIX_SIZE]; double projectionMatrix[OSVR_MATRIX_SIZE];
float near = 0.1f; float near = 0.1f;
float far = 100.0f; float far = 100.0f;

View file

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

View file

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

View file

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

View file

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