Browse Source

Fixed typo in file, more frameworking for new hmd

TheOnlyJoey 9 years ago
parent
commit
8b803e53fc
6 changed files with 46 additions and 4 deletions
  1. 13 0
      CMakeLists.txt
  2. 13 0
      configure.ac
  3. 11 0
      src/Makefile.am
  4. 0 0
      src/drv_secret_hmd_one/secret_hmd_one.c
  5. 8 4
      src/openhmd.c
  6. 1 0
      src/openhmdi.h

+ 13 - 0
CMakeLists.txt

@@ -26,6 +26,7 @@ set(openhmd_source_files
 )
 
 OPTION(OPENHMD_DRIVER_OCULUS_RIFT "Oculus Rift DK1 and DK2" ON)
+OPTION(OPENHMD_DRIVER_SECRET_HMD_ONE "Secret HMD 1 driver" ON)
 OPTION(OPENHMD_DRIVER_EXTERNAL "External sensor driver" ON)
 OPTION(OPENHMD_DRIVER_ANDROID "General Android driver" OFF)
 
@@ -41,6 +42,18 @@ if(OPENHMD_DRIVER_OCULUS_RIFT)
 	set(LIBS ${LIBS} ${HIDAPI_LIBRARIES})
 endif(OPENHMD_DRIVER_OCULUS_RIFT)
 
+if(OPENHMD_DRIVER_OCULUS_RIFT)
+	set(openhmd_source_files ${openhmd_source_files} 
+	${CMAKE_CURRENT_LIST_DIR}/src/drv_secret_hmd_one/secret_hmd_one.c
+	${CMAKE_CURRENT_LIST_DIR}/src/drv_secret_hmd_one/packet.c
+	)
+	add_definitions(-DDRIVER_SECRET_HMD_ONE)
+
+	find_package(HIDAPI REQUIRED)
+	include_directories(${HIDAPI_INCLUDE_DIRS})
+	set(LIBS ${LIBS} ${HIDAPI_LIBRARIES})
+endif(OPENHMD_DRIVER_SECRET_HMD_ONE)
+
 if (OPENHMD_DRIVER_EXTERNAL)
 	set(openhmd_source_files ${openhmd_source_files} 
 	${CMAKE_CURRENT_LIST_DIR}/src/drv_external/external.c

+ 13 - 0
configure.ac

@@ -40,6 +40,15 @@ AC_ARG_ENABLE([driver-oculus-rift],
 
 AM_CONDITIONAL([BUILD_DRIVER_OCULUS_RIFT], [test "x$driver_oculus_rift_enabled" != "xno"])
 
+# Secret HMD One Driver
+AC_ARG_ENABLE([driver-secret-hmd-one],
+        [AS_HELP_STRING([--disable-driver-secret-hmd-one],
+                [disable building of secret-hmd-one driver [default=yes]])],
+        [driver_secret_hmd_one_enabled=$enableval],
+        [driver_secret_hmd_one_enabled='yes'])
+
+AM_CONDITIONAL([BUILD_DRIVER_SECRET_HMD_ONE], [test "x$driver_secret_hmd_one_enabled" != "xno"])
+
 # External Driver
 AC_ARG_ENABLE([driver-external],
         [AS_HELP_STRING([--disable-driver-external],
@@ -62,6 +71,10 @@ AM_CONDITIONAL([BUILD_DRIVER_ANDROID], [test "x$driver_android_enabled" != "xno"
 AS_IF([test "x$driver_oculus_rift_enabled" != "xno"],
 	[PKG_CHECK_MODULES([hidapi], [$hidapi] >= 0.0.5)])
 
+# Libs required by secret-hmd-one Driver
+AS_IF([test "x$driver_secret_hmd_one_enabled" != "xno"],
+	[PKG_CHECK_MODULES([hidapi], [$hidapi] >= 0.0.5)])
+
 # Do we build OpenGL example?
 AC_ARG_ENABLE([openglexample],
         [AS_HELP_STRING([--enable-openglexample],

+ 11 - 0
src/Makefile.am

@@ -25,6 +25,17 @@ libopenhmd_la_LDFLAGS += $(hidapi_LIBS)
 
 endif
 
+if BUILD_DRIVER_SECRET_HMD_ONE
+
+libopenhmd_la_SOURCES += \
+	drv_secret_hmd_one/secret_hmd_one.c \
+	drv_secret_hmd_one/packet.c
+
+libopenhmd_la_CPPFLAGS += $(hidapi_CFLAGS) -DDRIVER_SECRET_HMD_ONE
+libopenhmd_la_LDFLAGS += $(hidapi_LIBS)
+
+endif
+
 if BUILD_DRIVER_EXTERNAL
 
 libopenhmd_la_SOURCES += \

src/drv_secret_hmd_one/secret-hmd-one.c → src/drv_secret_hmd_one/secret_hmd_one.c


+ 8 - 4
src/openhmd.c

@@ -27,6 +27,10 @@ ohmd_context* OHMD_APIENTRY ohmd_ctx_create(void)
 	ctx->drivers[ctx->num_drivers++] = ohmd_create_oculus_rift_drv(ctx);
 #endif
 
+#if DRIVER_SECRET_HMD_ONE
+	ctx->drivers[ctx->num_drivers++] = ohmd_create_secret_hmd_one_drv(ctx);
+#endif
+
 #if DRIVER_EXTERNAL
 	ctx->drivers[ctx->num_drivers++] = ohmd_create_external_drv(ctx);
 #endif
@@ -68,7 +72,7 @@ void OHMD_APIENTRY ohmd_ctx_update(ohmd_context* ctx)
 		ohmd_device* dev = ctx->active_devices[i];
 		if(!dev->settings.automatic_update && dev->update)
 			dev->update(dev);
-	
+
 		ohmd_lock_mutex(ctx->update_mutex);
 		dev->getf(dev, OHMD_POSITION_VECTOR, (float*)&dev->position);
 		dev->getf(dev, OHMD_ROTATION_QUAT, (float*)&dev->rotation);
@@ -111,7 +115,7 @@ const char* OHMD_APIENTRY ohmd_list_gets(ohmd_context* ctx, int index, ohmd_stri
 static unsigned int ohmd_update_thread(void* arg)
 {
 	ohmd_context* ctx = (ohmd_context*)arg;
-	
+
 	while(!ctx->update_request_quit)
 	{
 		ohmd_lock_mutex(ctx->update_mutex);
@@ -120,7 +124,7 @@ static unsigned int ohmd_update_thread(void* arg)
 			if(ctx->active_devices[i]->settings.automatic_update && ctx->active_devices[i]->update)
 				ctx->active_devices[i]->update(ctx->active_devices[i]);
 		}
-		
+
 		ohmd_unlock_mutex(ctx->update_mutex);
 
 		ohmd_sleep(AUTOMATIC_UPDATE_SLEEP);
@@ -197,7 +201,7 @@ OHMD_APIENTRYDLL int OHMD_APIENTRY ohmd_close_device(ohmd_device* device)
 
 	for(int i = idx; i < ctx->num_active_devices; i++)
 		ctx->active_devices[i]->active_device_idx--;
-	
+
 	ohmd_unlock_mutex(device->ctx->update_mutex);
 
 	return OHMD_S_OK;

+ 1 - 0
src/openhmdi.h

@@ -126,6 +126,7 @@ void ohmd_calc_default_proj_matrices(ohmd_device_properties* props);
 // drivers
 ohmd_driver* ohmd_create_dummy_drv(ohmd_context* ctx);
 ohmd_driver* ohmd_create_oculus_rift_drv(ohmd_context* ctx);
+ohmd_driver* ohmd_create_secret_hmd_one_drv(ohmd_context* ctx);
 ohmd_driver* ohmd_create_external_drv(ohmd_context* ctx);
 ohmd_driver* ohmd_create_android_drv(ohmd_context* ctx);