Selaa lähdekoodia

Re-written PSVR detection, implementations for Unix and Windows

TheOnlyJoey 8 vuotta sitten
vanhempi
commit
a902d8808e
4 muutettua tiedostoa jossa 30 lisäystä ja 4 poistoa
  1. 3 3
      src/drv_psvr/psvr.c
  2. 12 1
      src/platform-posix.c
  3. 12 0
      src/platform-win32.c
  4. 3 0
      src/platform.h

+ 3 - 3
src/drv_psvr/psvr.c

@@ -158,7 +158,7 @@ static hid_device* open_device_idx(int manufacturer, int product, int iface, int
 	while (cur_dev) {
 		printf("%04x:%04x %s\n", manufacturer, product, cur_dev->path);
 
-		if(idx == device_index && iface == iface_cur){
+		if(findEndPoint(cur_dev->path, device_index) > 0 && iface == iface_cur){
 			ret = hid_open_path(cur_dev->path);
 			printf("opening\n");
 		}
@@ -190,7 +190,7 @@ static ohmd_device* open_device(ohmd_driver* driver, ohmd_device_desc* desc)
 	int idx = atoi(desc->path);
 
 	// Open the HMD device
-	priv->hmd_handle = open_device_idx(SONY_ID, PSVR_HMD, 0, 0, idx);
+	priv->hmd_handle = open_device_idx(SONY_ID, PSVR_HMD, 0, 0, 4);
 
 	if(!priv->hmd_handle)
 		goto cleanup;
@@ -201,7 +201,7 @@ static ohmd_device* open_device(ohmd_driver* driver, ohmd_device_desc* desc)
 	}
 
 	// Open the HMD Control device
-	priv->hmd_control = open_device_idx(SONY_ID, PSVR_HMD, 0, 0, 1);
+	priv->hmd_control = open_device_idx(SONY_ID, PSVR_HMD, 0, 0, 5);
 
 	if(!priv->hmd_control)
 		goto cleanup;

+ 12 - 1
src/platform-posix.c

@@ -19,6 +19,7 @@
 #include <sys/time.h>
 #include <stdio.h>
 #include <pthread.h>
+#include <string.h>
 
 #include "platform.h"
 #include "openhmdi.h"
@@ -127,6 +128,16 @@ void ohmd_unlock_mutex(ohmd_mutex* mutex)
 /// Handling ovr service
 void ohmd_toggle_ovr_service(int state) //State is 0 for Disable, 1 for Enable
 {
-	//Empty implementation	
+	//Empty implementation
+}
+
+int findEndPoint(char* path, int endpoint)
+{
+	char comp[6];
+	sprintf(comp,":0%d",endpoint);
+	if (strstr(path, comp) != NULL) {
+		return 1;
+	}
+	return 0;
 }
 #endif

+ 12 - 0
src/platform-win32.c

@@ -105,6 +105,18 @@ void ohmd_unlock_mutex(ohmd_mutex* mutex)
 		ReleaseMutex(mutex->handle);
 }
 
+int findEndPoint(char* path, int endpoint)
+{
+	char comp[8];
+	sprintf(comp,"mi_0%d",endpoint);
+
+	if (strstr(path, comp) != NULL) {
+		return 1;
+	}
+
+	return 0;
+}
+
 /// Handling ovr service
 static int _enable_ovr_service = 0;
 

+ 3 - 0
src/platform.h

@@ -28,5 +28,8 @@ void ohmd_unlock_mutex(ohmd_mutex* mutex);
 ohmd_thread* ohmd_create_thread(ohmd_context* ctx, unsigned int (*routine)(void* arg), void* arg);
 void ohmd_destroy_thread(ohmd_thread* thread);
 
+/* String functions */
+
+int findEndPoint(char* path, int endpoint);
 
 #endif