[Bf-blender-cvs] [cde072b] HMD_viewport: Cleanup: Style, removed debug prints
Julian Eisel
noreply at git.blender.org
Wed Mar 16 16:11:08 CET 2016
Commit: cde072b6185bd3fed5c198bf5d0906f7e927dcd5
Author: Julian Eisel
Date: Fri Mar 11 04:50:23 2016 +0100
Branches: HMD_viewport
https://developer.blender.org/rBcde072b6185bd3fed5c198bf5d0906f7e927dcd5
Cleanup: Style, removed debug prints
===================================================================
M intern/ghost/intern/GHOST_OpenHMDManager.cpp
M intern/ghost/intern/GHOST_OpenHMDManager.h
===================================================================
diff --git a/intern/ghost/intern/GHOST_OpenHMDManager.cpp b/intern/ghost/intern/GHOST_OpenHMDManager.cpp
index 9461e53..597b39e 100644
--- a/intern/ghost/intern/GHOST_OpenHMDManager.cpp
+++ b/intern/ghost/intern/GHOST_OpenHMDManager.cpp
@@ -1,3 +1,23 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
#include "GHOST_OpenHMDManager.h"
// TODO replace with blender internal openhmd files
@@ -13,43 +33,35 @@ GHOST_OpenHMDManager::GHOST_OpenHMDManager(GHOST_System& sys)
m_device(NULL)
{
m_context = ohmd_ctx_create();
- if (m_context != NULL) {
-
- int num_devices = ohmd_ctx_probe(m_context);
- if (num_devices > 0) {
- m_available = true;
-
- printf("Found %i OpenHMD devices\n", num_devices);
- for (int i = 0; i < num_devices; ++i) {
- printf("Device %i\n", i);
- printf("vendor: %s\n", ohmd_list_gets(m_context, i, OHMD_VENDOR));
- printf("product: %s\n", ohmd_list_gets(m_context, i, OHMD_PRODUCT));
- printf("path: %s\n", ohmd_list_gets(m_context, i, OHMD_PATH));
- }
-
- //can't fail?
- m_device = ohmd_list_open_device(m_context, 0);
- }
- else {
- printf("No available devices in OpenHMD Context\n");
-
- ohmd_ctx_destroy(m_context);
- m_context = NULL;
- }
- }
- else {
- printf("Failed to create OpenHMD Context\n");
- }
+ if (m_context != NULL) {
+
+ int num_devices = ohmd_ctx_probe(m_context);
+ if (num_devices > 0) {
+ m_available = true;
+
+ //can't fail?
+ m_device = ohmd_list_open_device(m_context, 0);
+ }
+ else {
+ printf("No available devices in OpenHMD Context\n");
+
+ ohmd_ctx_destroy(m_context);
+ m_context = NULL;
+ }
+ }
+ else {
+ printf("Failed to create OpenHMD Context\n");
+ }
}
GHOST_OpenHMDManager::~GHOST_OpenHMDManager()
{
- if (m_available) {
- ohmd_ctx_destroy(m_context);
- m_context = NULL;
- m_device = NULL;
- m_available = false;
- }
+ if (m_available) {
+ ohmd_ctx_destroy(m_context);
+ m_context = NULL;
+ m_device = NULL;
+ m_available = false;
+ }
}
bool GHOST_OpenHMDManager::processEvents()
@@ -62,57 +74,49 @@ bool GHOST_OpenHMDManager::processEvents()
ohmd_ctx_update(m_context);
- GHOST_TUns64 now = m_system.getMilliSeconds();
-
- GHOST_EventOpenHMD *event = new GHOST_EventOpenHMD(now, window);
- GHOST_TEventOpenHMDData* data = (GHOST_TEventOpenHMDData*) event->getData();
- float quat[4];
+ GHOST_TUns64 now = m_system.getMilliSeconds();
- ohmd_device_getf(m_device, OHMD_ROTATION_QUAT, quat);
- data->orientation[0] = quat[3];
- data->orientation[1] = quat[0];
- data->orientation[2] = quat[1];
- data->orientation[3] = quat[2];
+ GHOST_EventOpenHMD *event = new GHOST_EventOpenHMD(now, window);
+ GHOST_TEventOpenHMDData* data = (GHOST_TEventOpenHMDData*) event->getData();
+ float quat[4];
-// printf("sending openhmd event with data x y z w %f %f %f %f at time %llu\n",
-// data->orientation[0],
-// data->orientation[1],
-// data->orientation[2],
-// data->orientation[3],
-// now);
+ ohmd_device_getf(m_device, OHMD_ROTATION_QUAT, quat);
+ data->orientation[0] = quat[3];
+ data->orientation[1] = quat[0];
+ data->orientation[2] = quat[1];
+ data->orientation[3] = quat[2];
-
- m_system.pushEvent(event);
- return true;
+ m_system.pushEvent(event);
+ return true;
}
else {
- return false;
+ return false;
}
}
bool GHOST_OpenHMDManager::available() const
{
- return m_available;
+ return m_available;
}
-bool GHOST_OpenHMDManager::setDevice(const char* requested_vendor_name, const char* requested_device_name)
+bool GHOST_OpenHMDManager::setDevice(const char *requested_vendor_name, const char *requested_device_name)
{
- if (!m_available) {
- return false;
- }
-
- int num_devices = ohmd_ctx_probe(m_context);
- for (int i = 0; i < num_devices; ++i) {
- const char* device_name = ohmd_list_gets(m_context, i, OHMD_PRODUCT);
- const char* vendor_name = ohmd_list_gets(m_context, i, OHMD_VENDOR);
-
- if (strcmp(device_name, requested_device_name) == 0 && strcmp(vendor_name, requested_vendor_name) == 0) {
- //can't fail
- m_device = ohmd_list_open_device(m_context, i);
- return true;
- }
- }
-
- //couldn't find a device by that name and vendor, the old device was preserved.
- return false;
+ if (!m_available) {
+ return false;
+ }
+
+ int num_devices = ohmd_ctx_probe(m_context);
+ for (int i = 0; i < num_devices; ++i) {
+ const char* device_name = ohmd_list_gets(m_context, i, OHMD_PRODUCT);
+ const char* vendor_name = ohmd_list_gets(m_context, i, OHMD_VENDOR);
+
+ if (strcmp(device_name, requested_device_name) == 0 && strcmp(vendor_name, requested_vendor_name) == 0) {
+ //can't fail
+ m_device = ohmd_list_open_device(m_context, i);
+ return true;
+ }
+ }
+
+ // couldn't find a device by that name and vendor, the old device was preserved.
+ return false;
}
diff --git a/intern/ghost/intern/GHOST_OpenHMDManager.h b/intern/ghost/intern/GHOST_OpenHMDManager.h
index 56b7966..7975342 100644
--- a/intern/ghost/intern/GHOST_OpenHMDManager.h
+++ b/intern/ghost/intern/GHOST_OpenHMDManager.h
@@ -15,9 +15,6 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor(s):
- * Mike Erwin
- *
* ***** END GPL LICENSE BLOCK *****
*/
@@ -33,22 +30,24 @@ struct ohmd_device;
class GHOST_OpenHMDManager
{
public:
- GHOST_OpenHMDManager(GHOST_System&); // TODO maybe cut out dependency on the system? (only used for getMilliSeconds and none of the others without platform implementations use it)
- virtual ~GHOST_OpenHMDManager();
-
- bool available() const;
- bool processEvents();
-
- bool setDevice(const char* requested_vendor_name, const char* requested_device_name);
-
+ // TODO maybe cut out dependency on the system? (only used for getMilliSeconds and
+ // none of the others without platform implementations use it)
+ GHOST_OpenHMDManager(GHOST_System&);
+ virtual ~GHOST_OpenHMDManager();
+
+ bool available() const;
+ bool processEvents();
+
+ bool setDevice(const char *requested_vendor_name, const char *requested_device_name);
+
protected:
- GHOST_System& m_system;
-
+ GHOST_System& m_system;
+
private:
- bool m_available;
-
- ohmd_context* m_context;
- ohmd_device* m_device;
+ bool m_available;
+
+ ohmd_context *m_context;
+ ohmd_device *m_device;
};
#endif //__GHOST_OPENHMDMANAGER_H__
More information about the Bf-blender-cvs
mailing list