[Bf-blender-cvs] [1a3c402] HMD_viewport: Display HMD vendor name in UserPref HMD device option
Julian Eisel
noreply at git.blender.org
Sun Apr 10 20:48:08 CEST 2016
Commit: 1a3c40258554209b1f52df9666339fdc6cc61130
Author: Julian Eisel
Date: Sun Apr 10 20:42:26 2016 +0200
Branches: HMD_viewport
https://developer.blender.org/rB1a3c40258554209b1f52df9666339fdc6cc61130
Display HMD vendor name in UserPref HMD device option
And minor cleanup.
===================================================================
M intern/ghost/GHOST_C-api.h
M intern/ghost/intern/GHOST_C-api.cpp
M intern/ghost/intern/GHOST_OpenHMDManager.cpp
M intern/ghost/intern/GHOST_OpenHMDManager.h
M source/blender/makesrna/intern/rna_userdef.c
M source/blender/windowmanager/WM_api.h
M source/blender/windowmanager/intern/wm_device.c
===================================================================
diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h
index 7a43f0d..672de91 100644
--- a/intern/ghost/GHOST_C-api.h
+++ b/intern/ghost/GHOST_C-api.h
@@ -935,6 +935,7 @@ extern void GHOST_HMDopenDevice(int index);
extern void GHOST_HMDcloseDevice(void);
extern int GHOST_HMDgetOpenDeviceIndex(void);
extern const char *GHOST_HMDgetDeviceName(int index);
+extern const char *GHOST_HMDgetVendorName(int index);
extern float GHOST_HMDgetDeviceIPD(void);
#ifdef __cplusplus
diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp
index 2b2c874..ddf84e1 100644
--- a/intern/ghost/intern/GHOST_C-api.cpp
+++ b/intern/ghost/intern/GHOST_C-api.cpp
@@ -989,6 +989,18 @@ const char *GHOST_HMDgetDeviceName(int index)
#endif
}
+const char *GHOST_HMDgetVendorName(int index)
+{
+#ifdef WITH_OPENHMD
+ GHOST_ISystem *system = GHOST_ISystem::getSystem();
+ GHOST_OpenHMDManager *ohmd = system->getOpenHMDManager();
+ return ohmd->getVendorName(index);
+#else
+ (void)index;
+ return NULL;
+#endif
+}
+
float GHOST_HMDgetDeviceIPD()
{
#ifdef WITH_OPENHMD
diff --git a/intern/ghost/intern/GHOST_OpenHMDManager.cpp b/intern/ghost/intern/GHOST_OpenHMDManager.cpp
index be3d406..90b69a9 100644
--- a/intern/ghost/intern/GHOST_OpenHMDManager.cpp
+++ b/intern/ghost/intern/GHOST_OpenHMDManager.cpp
@@ -28,6 +28,8 @@
# include "udew.h"
#endif
+#define CONTEXT_ASSERT GHOST_ASSERT(m_context, "No OpenHMD context found")
+
GHOST_OpenHMDManager::GHOST_OpenHMDManager(GHOST_System& sys)
: m_system(sys),
m_context(NULL),
@@ -179,7 +181,7 @@ void GHOST_OpenHMDManager::closeDevice()
int GHOST_OpenHMDManager::getNumDevices()
{
- GHOST_ASSERT(m_context, "No OpenHMD context found");
+ CONTEXT_ASSERT;
return ohmd_ctx_probe(m_context);
}
@@ -202,8 +204,8 @@ const char *GHOST_OpenHMDManager::getDeviceName() const
const char *GHOST_OpenHMDManager::getDeviceName(int index)
{
- GHOST_ASSERT(m_context, "No OpenHMD context found");
- // You need to probe to fetch the device information from the hardware
+ CONTEXT_ASSERT;
+ // Probe to fetch the device information from the hardware
ohmd_ctx_probe(m_context);
return ohmd_list_gets(m_context, index, OHMD_PRODUCT);
}
@@ -216,6 +218,14 @@ const char *GHOST_OpenHMDManager::getVendorName() const
return ohmd_list_gets(m_context, m_deviceIndex, OHMD_VENDOR);
}
+const char *GHOST_OpenHMDManager::getVendorName(int index)
+{
+ CONTEXT_ASSERT;
+ // Probe to fetch the device information from the hardware
+ ohmd_ctx_probe(m_context);
+ return ohmd_list_gets(m_context, index, OHMD_VENDOR);
+}
+
const char *GHOST_OpenHMDManager::getPath() const
{
if (!m_device)
diff --git a/intern/ghost/intern/GHOST_OpenHMDManager.h b/intern/ghost/intern/GHOST_OpenHMDManager.h
index 1df5845..db6cfdc 100644
--- a/intern/ghost/intern/GHOST_OpenHMDManager.h
+++ b/intern/ghost/intern/GHOST_OpenHMDManager.h
@@ -105,6 +105,12 @@ public:
const char *getVendorName() const;
/**
+ * \return A c-style string with the human-readable name of the vendor at \a index.
+ * NULL is returned if available() is false.
+ */
+ const char *getVendorName(int index);
+
+ /**
* \return A c-style string with the driver-specific path where the current device is attached.
* NULL is returned if available() is false.
*/
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 4400a5a..53d87d9 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -114,6 +114,8 @@ EnumPropertyItem rna_enum_navigation_mode_items[] = {
#include "BKE_pbvh.h"
#include "BKE_paint.h"
+#include "BLI_string.h"
+
#include "GPU_draw.h"
#include "GPU_select.h"
@@ -658,8 +660,11 @@ static EnumPropertyItem *rna_userdef_hmd_device_itemf(
/* add devices */
for (int i = 0; i < WM_device_HMD_num_devices_get(); i++) {
+ static char name[MAX_NAME];
EnumPropertyItem tmp = {i, "", 0, "", ""};
- tmp.identifier = tmp.name = WM_device_HMD_name_get(i);
+
+ BLI_snprintf(name, sizeof(name), "%s %s", WM_device_HMD_vendor_get(i), WM_device_HMD_name_get(i));
+ tmp.identifier = tmp.name = name;
RNA_enum_item_add(&item, &totitem, &tmp);
}
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index f4b3f52..b4106ad 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -524,7 +524,8 @@ bool WM_event_is_ime_switch(const struct wmEvent *event);
int WM_device_HMD_num_devices_get(void);
void WM_device_HMD_state_set(const int device, const bool enable);
int WM_device_HMD_current_get(void);
-const char *WM_device_HMD_name_get(const int index);
+const char *WM_device_HMD_name_get(int index);
+const char *WM_device_HMD_vendor_get(int index);
float WM_device_HMD_IPD_get(void);
#endif
diff --git a/source/blender/windowmanager/intern/wm_device.c b/source/blender/windowmanager/intern/wm_device.c
index 19747a5..1168a89 100644
--- a/source/blender/windowmanager/intern/wm_device.c
+++ b/source/blender/windowmanager/intern/wm_device.c
@@ -45,8 +45,6 @@
/** \name Head Mounted Displays
* \{ */
-/* XXX doing WITH_OPENHMD checks here is ugly */
-
int WM_device_HMD_num_devices_get(void)
{
return GHOST_HMDgetNumDevices();
@@ -79,6 +77,11 @@ const char *WM_device_HMD_name_get(int index)
return GHOST_HMDgetDeviceName(index);
}
+const char *WM_device_HMD_vendor_get(int index)
+{
+ return GHOST_HMDgetVendorName(index);
+}
+
/**
* Get IPD from currently opened HMD.
*/
More information about the Bf-blender-cvs
mailing list