mirror of https://github.com/bjornbytes/lovr.git
Fixup lovr.headset.getName;
This commit is contained in:
parent
50e77fc023
commit
85d461e71c
|
@ -115,7 +115,12 @@ static int l_lovrHeadsetGetDriver(lua_State* L) {
|
|||
}
|
||||
|
||||
static int l_lovrHeadsetGetName(lua_State* L) {
|
||||
lua_pushstring(L, lovrHeadsetDriver->getName());
|
||||
char name[256];
|
||||
if (lovrHeadsetDriver->getName(name, sizeof(name))) {
|
||||
lua_pushstring(L, name);
|
||||
} else {
|
||||
lua_pushnil(L);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,8 +38,10 @@ static void destroy(void) {
|
|||
memset(&state, 0, sizeof(state));
|
||||
}
|
||||
|
||||
static const char* getName(void) {
|
||||
return "VR Simulator";
|
||||
static bool getName(char* name, size_t length) {
|
||||
strncpy(name, "VR Simulator", length - 1);
|
||||
name[length - 1] = '\0';
|
||||
return true;
|
||||
}
|
||||
|
||||
static HeadsetOrigin getOriginType(void) {
|
||||
|
|
|
@ -54,7 +54,7 @@ typedef struct HeadsetInterface {
|
|||
HeadsetDriver driverType;
|
||||
bool (*init)(float offset, int msaa);
|
||||
void (*destroy)(void);
|
||||
const char* (*getName)(void);
|
||||
bool (*getName)(char* name, size_t length);
|
||||
HeadsetOrigin (*getOriginType)(void);
|
||||
void (*getDisplayDimensions)(uint32_t* width, uint32_t* height);
|
||||
void (*getClipDistance)(float* clipNear, float* clipFar);
|
||||
|
|
|
@ -118,9 +118,11 @@ static void destroy() {
|
|||
memset(&state, 0, sizeof(state));
|
||||
}
|
||||
|
||||
static const char* getName() {
|
||||
// return ovr_GetHmdDesc(state.session).ProductName; // MEMORY
|
||||
return NULL;
|
||||
static bool getName(char* name, size_t length) {
|
||||
ovrHmdDesc desc = ovr_GetHmdDesc(state.session);
|
||||
strncpy(name, desc.ProductName, length - 1);
|
||||
name[length - 1] = '\0';
|
||||
return true;
|
||||
}
|
||||
|
||||
static HeadsetOrigin getOriginType() {
|
||||
|
|
|
@ -34,12 +34,17 @@ static void destroy() {
|
|||
//
|
||||
}
|
||||
|
||||
static const char* getName() {
|
||||
static bool getName(char* buffer, size_t length) {
|
||||
const char* name;
|
||||
switch (bridgeLovrMobileData.deviceType) {
|
||||
case BRIDGE_LOVR_DEVICE_GEAR: return "Gear VR";
|
||||
case BRIDGE_LOVR_DEVICE_GO: return "Oculus Go";
|
||||
default: return NULL;
|
||||
case BRIDGE_LOVR_DEVICE_GEAR: name = "Gear VR"; break;
|
||||
case BRIDGE_LOVR_DEVICE_GO: name = "Oculus Go"; break;
|
||||
default: return false;
|
||||
}
|
||||
|
||||
strncpy(buffer, name, length - 1);
|
||||
buffer[length - 1] = '\0';
|
||||
return true;
|
||||
}
|
||||
|
||||
static HeadsetOrigin getOriginType() {
|
||||
|
|
|
@ -36,7 +36,6 @@ static struct {
|
|||
RenderModel_TextureMap_t* deviceTextures[16];
|
||||
Canvas* canvas;
|
||||
vec_float_t boundsGeometry;
|
||||
char name[128];
|
||||
bool rift;
|
||||
float clipNear;
|
||||
float clipFar;
|
||||
|
@ -147,6 +146,7 @@ static bool getButtonState(Path path, bool touch, bool* value) {
|
|||
}
|
||||
}
|
||||
|
||||
static bool getName(char* name, size_t length);
|
||||
static bool init(float offset, int msaa) {
|
||||
if (!VR_IsHmdPresent() || !VR_IsRuntimeInstalled()) {
|
||||
return false;
|
||||
|
@ -169,8 +169,8 @@ static bool init(float offset, int msaa) {
|
|||
return false;
|
||||
}
|
||||
|
||||
state.system->GetStringTrackedDeviceProperty(HEADSET_INDEX, ETrackedDeviceProperty_Prop_ManufacturerName_String, state.name, sizeof(state.name), NULL);
|
||||
state.rift = !strncmp(state.name, "Oculus", sizeof(state.name));
|
||||
getName(buffer, sizeof(buffer));
|
||||
state.rift = !strncmp(buffer, "Oculus", sizeof(buffer));
|
||||
state.clipNear = 0.1f;
|
||||
state.clipFar = 30.f;
|
||||
state.offset = state.compositor->GetTrackingSpace() == ETrackingUniverseOrigin_TrackingUniverseStanding ? 0. : offset;
|
||||
|
@ -197,8 +197,10 @@ static void destroy(void) {
|
|||
memset(&state, 0, sizeof(state));
|
||||
}
|
||||
|
||||
static const char* getName(void) {
|
||||
return state.name;
|
||||
static bool getName(char* name, size_t length) {
|
||||
ETrackedPropertyError error;
|
||||
state.system->GetStringTrackedDeviceProperty(HEADSET_INDEX, ETrackedDeviceProperty_Prop_ManufacturerName_String, name, length, &error);
|
||||
return error == ETrackedPropertyError_TrackedProp_Success;
|
||||
}
|
||||
|
||||
static HeadsetOrigin getOriginType(void) {
|
||||
|
|
Loading…
Reference in New Issue