浏览代码

Multiple fixes from 0.3rc

- Added brackets to READ functions
- Inline compiler fixes for MSVC
- Array initializer fix for MSVC
- Added compile options to CMakeList for PSVR and HTC Vive
- Readme additions
Joey Ferwerda 8 年之前
父节点
当前提交
ca77ca82b9
共有 8 个文件被更改,包括 46 次插入10 次删除
  1. 26 0
      CMakeLists.txt
  2. 2 1
      README.md
  3. 4 5
      src/drv_deepoon/deepoon.c
  4. 2 1
      src/drv_deepoon/packet.c
  5. 4 0
      src/drv_htc_vive/packet.c
  6. 2 1
      src/drv_oculus_rift/packet.c
  7. 5 1
      src/drv_psvr/packet.c
  8. 1 1
      src/platform-win32.c

+ 26 - 0
CMakeLists.txt

@@ -29,6 +29,8 @@ set(openhmd_source_files
 
 OPTION(OPENHMD_DRIVER_OCULUS_RIFT "Oculus Rift DK1 and DK2" ON)
 OPTION(OPENHMD_DRIVER_DEEPOON "Deepoon E2" ON)
+OPTION(OPENHMD_DRIVER_PSVR "Sony PSVR" ON)
+OPTION(OPENHMD_DRIVER_HTC_VIVE "HTC Vive" ON)
 OPTION(OPENHMD_DRIVER_EXTERNAL "External sensor driver" ON)
 OPTION(OPENHMD_DRIVER_ANDROID "General Android driver" OFF)
 
@@ -59,6 +61,30 @@ if(OPENHMD_DRIVER_DEEPOON)
 	set(LIBS ${LIBS} ${HIDAPI_LIBRARIES})
 endif(OPENHMD_DRIVER_DEEPOON)
 
+if(OPENHMD_DRIVER_PSVR)
+	set(openhmd_source_files ${openhmd_source_files}
+	${CMAKE_CURRENT_LIST_DIR}/src/drv_psvr/psvr.c
+	${CMAKE_CURRENT_LIST_DIR}/src/drv_psvr/packet.c
+	)
+	add_definitions(-DDRIVER_PSVR)
+
+	find_package(HIDAPI REQUIRED)
+	include_directories(${HIDAPI_INCLUDE_DIRS})
+	set(LIBS ${LIBS} ${HIDAPI_LIBRARIES})
+endif(OPENHMD_DRIVER_PSVR)
+
+if(OPENHMD_DRIVER_HTC_VIVE)
+	set(openhmd_source_files ${openhmd_source_files}
+	${CMAKE_CURRENT_LIST_DIR}/src/drv_htc_vive/vive.c
+	${CMAKE_CURRENT_LIST_DIR}/src/drv_htc_vive/packet.c
+	)
+	add_definitions(-DDRIVER_HTC_VIVE)
+
+	find_package(HIDAPI REQUIRED)
+	include_directories(${HIDAPI_INCLUDE_DIRS})
+	set(LIBS ${LIBS} ${HIDAPI_LIBRARIES})
+endif(OPENHMD_DRIVER_HTC_VIVE)
+
 if (OPENHMD_DRIVER_EXTERNAL)
 	set(openhmd_source_files ${openhmd_source_files}
 	${CMAKE_CURRENT_LIST_DIR}/src/drv_external/external.c

+ 2 - 1
README.md

@@ -8,6 +8,7 @@ OpenHMD is released under the permissive Boost Software License (see LICENSE for
   * Oculus Rift DK1, DK2 and CV1 (rotation only)
   * Deepoon E2
   * HTC Vive (rotation only)
+  * PSVR
   * Android based devices
   * External Sensor (passthrough for external sensors)
 
@@ -103,4 +104,4 @@ Will be available soon.
 ## Using OpenHMD
 See the examples/ subdirectory for usage examples. The OpenGL example is not built by default, to build it use the --enable-openglexample option for the configure script. It requires SDL, glew and OpenGL.
 
-An API reference can be generated using doxygen and is also available here: http://openhmd.net/doxygen/0.1.0/openhmd_8h.html
+An API reference can be generated using doxygen and is also available here: http://openhmd.net/doxygen/0.1.0/openhmd_8h.html

+ 4 - 5
src/drv_deepoon/deepoon.c

@@ -191,13 +191,12 @@ static void close_device(ohmd_device* device)
 
 static char* _hid_to_unix_path(char* path)
 {
-	const int len = 4;
-	char bus [len];
-	char dev [len];
+	char bus [4];
+	char dev [4];
 	char *result = malloc( sizeof(char) * ( 20 + 1 ) );
 
-	sprintf (bus, "%.*s\n", len, path);
-	sprintf (dev, "%.*s\n", len, path + 5);
+	sprintf (bus, "%.*s\n", 4, path);
+	sprintf (dev, "%.*s\n", 4, path + 5);
 
 	sprintf (result, "/dev/bus/usb/%03d/%03d",
 		(int)strtol(bus, NULL, 16),

+ 2 - 1
src/drv_deepoon/packet.c

@@ -58,8 +58,9 @@ bool dp_decodesensor_display_info(pkt_sensor_display_info* info, const unsigned
 
 	info->distortion_type_opts = 0;
 
-	for(int i = 0; i < 6; i++)
+	for(int i = 0; i < 6; i++){
 		info->distortion_k[i] = READFLOAT;
+	}
 
 	return true;
 }

+ 4 - 0
src/drv_htc_vive/packet.c

@@ -1,6 +1,10 @@
 #include "vive.h"
 #include "vive_config.h"
 
+#ifdef _MSC_VER
+#define inline __inline
+#endif
+
 inline static uint8_t read8(const unsigned char** buffer)
 {
 	uint8_t ret = **buffer;

+ 2 - 1
src/drv_oculus_rift/packet.c

@@ -58,8 +58,9 @@ bool decode_sensor_display_info(pkt_sensor_display_info* info, const unsigned ch
 
 	info->distortion_type_opts = 0;
 
-	for(int i = 0; i < 6; i++)
+	for(int i = 0; i < 6; i++){
 		info->distortion_k[i] = READFLOAT;
+	}
 
 	return true;
 }

+ 5 - 1
src/drv_psvr/packet.c

@@ -1,5 +1,9 @@
 #include "psvr.h"
 
+#ifdef _MSC_VER
+#define inline __inline
+#endif
+
 inline static uint8_t read8(const unsigned char** buffer)
 {
 	uint8_t ret = **buffer;
@@ -46,4 +50,4 @@ bool psvr_decode_sensor_packet(psvr_sensor_packet* pkt, const unsigned char* buf
 	pkt->samples[0].proximity_state = read8(&buffer); // 0 (nothing) to 3 (headset is on)
 
 	return true;
-}
+}

+ 1 - 1
src/platform-win32.c

@@ -111,7 +111,7 @@ static int _enable_ovr_service = 0;
 void ohmd_toggle_ovr_service(int state) //State is 0 for Disable, 1 for Enable
 {
 	SC_HANDLE serviceDbHandle = OpenSCManager(NULL,NULL,SC_MANAGER_ALL_ACCESS);
-	SC_HANDLE serviceHandle = OpenService(serviceDbHandle, 'OVRService', SC_MANAGER_ALL_ACCESS);
+	SC_HANDLE serviceHandle = OpenService(serviceDbHandle, "OVRService", SC_MANAGER_ALL_ACCESS);
 
 	SERVICE_STATUS_PROCESS status;
 	DWORD bytesNeeded;