mirror of
https://github.com/bjornbytes/lovr.git
synced 2024-07-02 12:33:52 +00:00
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) {
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,8 +38,10 @@ static void destroy(void) {
|
||||||
memset(&state, 0, sizeof(state));
|
memset(&state, 0, sizeof(state));
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* getName(void) {
|
static bool getName(char* name, size_t length) {
|
||||||
return "VR Simulator";
|
strncpy(name, "VR Simulator", length - 1);
|
||||||
|
name[length - 1] = '\0';
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HeadsetOrigin getOriginType(void) {
|
static HeadsetOrigin getOriginType(void) {
|
||||||
|
|
|
@ -54,7 +54,7 @@ typedef struct HeadsetInterface {
|
||||||
HeadsetDriver driverType;
|
HeadsetDriver driverType;
|
||||||
bool (*init)(float offset, int msaa);
|
bool (*init)(float offset, int msaa);
|
||||||
void (*destroy)(void);
|
void (*destroy)(void);
|
||||||
const char* (*getName)(void);
|
bool (*getName)(char* name, size_t length);
|
||||||
HeadsetOrigin (*getOriginType)(void);
|
HeadsetOrigin (*getOriginType)(void);
|
||||||
void (*getDisplayDimensions)(uint32_t* width, uint32_t* height);
|
void (*getDisplayDimensions)(uint32_t* width, uint32_t* height);
|
||||||
void (*getClipDistance)(float* clipNear, float* clipFar);
|
void (*getClipDistance)(float* clipNear, float* clipFar);
|
||||||
|
|
|
@ -118,9 +118,11 @@ static void destroy() {
|
||||||
memset(&state, 0, sizeof(state));
|
memset(&state, 0, sizeof(state));
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* getName() {
|
static bool getName(char* name, size_t length) {
|
||||||
// return ovr_GetHmdDesc(state.session).ProductName; // MEMORY
|
ovrHmdDesc desc = ovr_GetHmdDesc(state.session);
|
||||||
return NULL;
|
strncpy(name, desc.ProductName, length - 1);
|
||||||
|
name[length - 1] = '\0';
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HeadsetOrigin getOriginType() {
|
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) {
|
switch (bridgeLovrMobileData.deviceType) {
|
||||||
case BRIDGE_LOVR_DEVICE_GEAR: return "Gear VR";
|
case BRIDGE_LOVR_DEVICE_GEAR: name = "Gear VR"; break;
|
||||||
case BRIDGE_LOVR_DEVICE_GO: return "Oculus Go";
|
case BRIDGE_LOVR_DEVICE_GO: name = "Oculus Go"; break;
|
||||||
default: return NULL;
|
default: return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
strncpy(buffer, name, length - 1);
|
||||||
|
buffer[length - 1] = '\0';
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HeadsetOrigin getOriginType() {
|
static HeadsetOrigin getOriginType() {
|
||||||
|
|
|
@ -36,7 +36,6 @@ static struct {
|
||||||
RenderModel_TextureMap_t* deviceTextures[16];
|
RenderModel_TextureMap_t* deviceTextures[16];
|
||||||
Canvas* canvas;
|
Canvas* canvas;
|
||||||
vec_float_t boundsGeometry;
|
vec_float_t boundsGeometry;
|
||||||
char name[128];
|
|
||||||
bool rift;
|
bool rift;
|
||||||
float clipNear;
|
float clipNear;
|
||||||
float clipFar;
|
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) {
|
static bool init(float offset, int msaa) {
|
||||||
if (!VR_IsHmdPresent() || !VR_IsRuntimeInstalled()) {
|
if (!VR_IsHmdPresent() || !VR_IsRuntimeInstalled()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -169,8 +169,8 @@ static bool init(float offset, int msaa) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
state.system->GetStringTrackedDeviceProperty(HEADSET_INDEX, ETrackedDeviceProperty_Prop_ManufacturerName_String, state.name, sizeof(state.name), NULL);
|
getName(buffer, sizeof(buffer));
|
||||||
state.rift = !strncmp(state.name, "Oculus", sizeof(state.name));
|
state.rift = !strncmp(buffer, "Oculus", sizeof(buffer));
|
||||||
state.clipNear = 0.1f;
|
state.clipNear = 0.1f;
|
||||||
state.clipFar = 30.f;
|
state.clipFar = 30.f;
|
||||||
state.offset = state.compositor->GetTrackingSpace() == ETrackingUniverseOrigin_TrackingUniverseStanding ? 0. : offset;
|
state.offset = state.compositor->GetTrackingSpace() == ETrackingUniverseOrigin_TrackingUniverseStanding ? 0. : offset;
|
||||||
|
@ -197,8 +197,10 @@ static void destroy(void) {
|
||||||
memset(&state, 0, sizeof(state));
|
memset(&state, 0, sizeof(state));
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* getName(void) {
|
static bool getName(char* name, size_t length) {
|
||||||
return state.name;
|
ETrackedPropertyError error;
|
||||||
|
state.system->GetStringTrackedDeviceProperty(HEADSET_INDEX, ETrackedDeviceProperty_Prop_ManufacturerName_String, name, length, &error);
|
||||||
|
return error == ETrackedPropertyError_TrackedProp_Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HeadsetOrigin getOriginType(void) {
|
static HeadsetOrigin getOriginType(void) {
|
||||||
|
|
Loading…
Reference in a new issue