From 1caa844dad647b03cf3c1d11bf211e9fcde4b7f1 Mon Sep 17 00:00:00 2001 From: mwturvey Date: Wed, 15 Mar 2017 11:38:22 -0700 Subject: Windows Compiling --- src/survive_config.c | 8 +++++--- src/survive_vive.c | 33 +++++++++++++++------------------ 2 files changed, 20 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/survive_config.c b/src/survive_config.c index 10da9a6..7435cc4 100644 --- a/src/survive_config.c +++ b/src/survive_config.c @@ -3,7 +3,7 @@ #include #include "survive_config.h" #include - +#include //for alloca #include //#define MAX_CONFIG_ENTRIES 100 @@ -293,7 +293,8 @@ void pop_config_group() { int parse_floats(char* tag, char** values, uint16_t count) { uint16_t i = 0; - FLT f[count]; + FLT *f; + f = alloca(sizeof(FLT) * count); char* end = NULL; config_group* cg = cg_stack[cg_stack_head]; @@ -321,7 +322,8 @@ int parse_floats(char* tag, char** values, uint16_t count) { int parse_uint32(char* tag, char** values, uint16_t count) { uint16_t i = 0; - uint32_t l[count]; + FLT *l; + l = alloca(sizeof(FLT) * count); char* end = NULL; config_group* cg = cg_stack[cg_stack_head]; diff --git a/src/survive_vive.c b/src/survive_vive.c index fc05647..116d18b 100755 --- a/src/survive_vive.c +++ b/src/survive_vive.c @@ -17,11 +17,11 @@ #include #include #include - +#include // for alloca #ifdef HIDAPI #include -#if defined(WINDOWS) || defined(WIN32) +#if defined(WINDOWS) || defined(WIN32) || defined (_WIN32) #include #undef WCHAR_MAX #endif @@ -125,14 +125,12 @@ void survive_data_cb( SurviveUSBInterface * si ); void survive_usb_close( SurviveContext * t ); int survive_usb_init( SurviveViveData * sv, SurviveObject * hmd, SurviveObject *wm0, SurviveObject * wm1, SurviveObject * tr0 ); int survive_usb_poll( SurviveContext * ctx ); -int survive_get_config( char ** config, SurviveViveData * ctx, int devno, int interface, int send_extra_magic ); +int survive_get_config( char ** config, SurviveViveData * ctx, int devno, int iface, int send_extra_magic ); int survive_vive_send_magic(struct SurviveContext * ctx, void * drv, int magic_code, void * data, int datalen ); #ifdef HIDAPI void * HAPIReceiver( void * v ) { - char buf[65]; - int res; SurviveUSBInterface * iface = v; USBHANDLE * hp = &iface->uh; @@ -239,13 +237,13 @@ static void debug_cb( struct SurviveUSBInterface * si ) #ifdef HIDAPI -static inline int update_feature_report(USBHANDLE dev, uint16_t interface, uint8_t * data, int datalen ) +static inline int update_feature_report(USBHANDLE dev, uint16_t iface, uint8_t * data, int datalen ) { int r = hid_send_feature_report( dev, data, datalen ); // printf( "HUR: (%p) %d (%d) [%d]\n", dev, r, datalen, data[0] ); return r; } -static inline int getupdate_feature_report(USBHANDLE dev, uint16_t interface, uint8_t * data, int datalen ) +static inline int getupdate_feature_report(USBHANDLE dev, uint16_t iface, uint8_t * data, size_t datalen ) { int r = hid_get_feature_report( dev, data, datalen ); // printf( "HGR: (%p) %d (%d) (%d)\n", dev, r, datalen, data[0] ); @@ -277,13 +275,13 @@ static inline int getupdate_feature_report(libusb_device_handle* dev, uint16_t i #endif -static inline int hid_get_feature_report_timeout(USBHANDLE device, uint16_t interface, unsigned char *buf, size_t len ) +static inline int hid_get_feature_report_timeout(USBHANDLE device, uint16_t iface, unsigned char *buf, size_t len ) { int ret; uint8_t i = 0; for (i = 0; i < 50; i++) { - ret = getupdate_feature_report(device, interface, buf, len); + ret = getupdate_feature_report(device, iface, buf, len); if( ret != -9 && ( ret != -1 || errno != EPIPE ) ) return ret; OGUSleep( 1000 ); } @@ -604,7 +602,7 @@ int survive_vive_usb_poll( struct SurviveContext * ctx, void * v ) int survive_get_config( char ** config, struct SurviveViveData * sv, int devno, int iface, int send_extra_magic ) { struct SurviveContext * ctx = sv->ctx; - int i, ret, count = 0, size = 0; + int ret, count = 0, size = 0; uint8_t cfgbuff[64]; uint8_t compressed_data[8192]; uint8_t uncompressed_data[65536]; @@ -730,14 +728,13 @@ int survive_get_config( char ** config, struct SurviveViveData * sv, int devno, static void handle_watchman( struct SurviveObject * w, uint8_t * readdata ) { - int i; uint8_t startread[29]; memcpy( startread, readdata, 29 ); #if 0 printf( "DAT: " ); - for( i = 0; i < 29; i++ ) + for(int i = 0; i < 29; i++ ) { printf( "%02x ", readdata[i] ); } @@ -823,7 +820,6 @@ static void handle_watchman( struct SurviveObject * w, uint8_t * readdata ) if( qty ) { - int j; qty++; readdata--; *readdata = type; //Put 'type' back on stack. @@ -846,7 +842,6 @@ static void handle_watchman( struct SurviveObject * w, uint8_t * readdata ) const int nrtime = sizeof(times)/sizeof(uint32_t); int timecount = 0; int leds; - int parameters; int fault = 0; ///Handle uint32_tifying (making sure we keep it incrementing) @@ -900,7 +895,8 @@ static void handle_watchman( struct SurviveObject * w, uint8_t * readdata ) //Second, go through all LEDs and extract the lightevent from them. { - uint8_t marked[nrtime]; + uint8_t *marked; + marked = alloca(nrtime); memset( marked, 0, sizeof( marked ) ); int i, parpl = 0; timecount--; @@ -1141,7 +1137,6 @@ static int ParsePoints( SurviveContext * ctx, SurviveObject * so, char * ct0conf { tk = &t[i+2+k*4]; - FLT vals[3]; int m; for( m = 0; m < 3; m++ ) { @@ -1264,7 +1259,7 @@ int survive_vive_close( SurviveContext * ctx, void * driver ) int DriverRegHTCVive( SurviveContext * ctx ) { - int i, r; + int r; SurviveObject * hmd = calloc( 1, sizeof( SurviveObject ) ); SurviveObject * wm0 = calloc( 1, sizeof( SurviveObject ) ); SurviveObject * wm1 = calloc( 1, sizeof( SurviveObject ) ); @@ -1273,7 +1268,9 @@ int DriverRegHTCVive( SurviveContext * ctx ) sv->ctx = ctx; - #ifdef WINDOWS + #ifdef _WIN32 + CreateDirectoryA("calinfo", NULL); + #elif defined WINDOWS mkdir( "calinfo" ); #else mkdir( "calinfo", 0755 ); -- cgit v1.2.3 From a409645cd3e2b8f0cc67541a9e4c88bf2cd96a79 Mon Sep 17 00:00:00 2001 From: mwturvey Date: Wed, 15 Mar 2017 15:31:17 -0700 Subject: Building & basic running --- src/survive.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/survive.c b/src/survive.c index 1b5bed1..2982a4f 100755 --- a/src/survive.c +++ b/src/survive.c @@ -14,7 +14,8 @@ static int did_runtime_symnum; int SymnumCheck( const char * path, const char * name, void * location, long size ) { - if( strncmp( name, "REGISTER", 8 ) == 0 ) + printf("%s\n", name); + if( strncmp( name, "LTRegister", 8 ) == 0 ) { typedef void (*sf)(); sf fn = (sf)location; -- cgit v1.2.3 From fa0f4825937ed93163bb2cd165c001d7444d8928 Mon Sep 17 00:00:00 2001 From: mwturvey Date: Thu, 16 Mar 2017 10:31:19 -0700 Subject: Last try at getting linktime registration working under MSVC --- src/survive.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src') diff --git a/src/survive.c b/src/survive.c index 2982a4f..c2b2940 100755 --- a/src/survive.c +++ b/src/survive.c @@ -47,6 +47,17 @@ SurviveContext * survive_init( int headless ) did_runtime_symnum = 1; } #endif +//#ifdef MANUAL_REGISTRATION +// // note: this manual registration is currently only in use on builds using Visual Studio. +// +//#define MANUAL_DRIVER_REGISTRATION(func) int func( SurviveObject * so, PoserData * pd ); RegisterDriver( #func, &func); +// +// MANUAL_DRIVER_REGISTRATION(PoserCharlesSlow) +// MANUAL_DRIVER_REGISTRATION(PoserDaveOrtho) +// MANUAL_DRIVER_REGISTRATION(PoserDummy) +// MANUAL_DRIVER_REGISTRATION(DriverRegHTCVive) +// +//#endif int r = 0; int i = 0; -- cgit v1.2.3 From 27c9edd889c746e818dc3aa55971d9cd6d8595a7 Mon Sep 17 00:00:00 2001 From: mwturvey Date: Thu, 16 Mar 2017 10:32:18 -0700 Subject: Manual registration on Windows --- src/survive.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/survive.c b/src/survive.c index c2b2940..d7aa691 100755 --- a/src/survive.c +++ b/src/survive.c @@ -47,17 +47,17 @@ SurviveContext * survive_init( int headless ) did_runtime_symnum = 1; } #endif -//#ifdef MANUAL_REGISTRATION -// // note: this manual registration is currently only in use on builds using Visual Studio. -// -//#define MANUAL_DRIVER_REGISTRATION(func) int func( SurviveObject * so, PoserData * pd ); RegisterDriver( #func, &func); -// -// MANUAL_DRIVER_REGISTRATION(PoserCharlesSlow) -// MANUAL_DRIVER_REGISTRATION(PoserDaveOrtho) -// MANUAL_DRIVER_REGISTRATION(PoserDummy) -// MANUAL_DRIVER_REGISTRATION(DriverRegHTCVive) -// -//#endif +#ifdef MANUAL_REGISTRATION + // note: this manual registration is currently only in use on builds using Visual Studio. + +#define MANUAL_DRIVER_REGISTRATION(func) int func( SurviveObject * so, PoserData * pd ); RegisterDriver( #func, &func); + + MANUAL_DRIVER_REGISTRATION(PoserCharlesSlow) + MANUAL_DRIVER_REGISTRATION(PoserDaveOrtho) + MANUAL_DRIVER_REGISTRATION(PoserDummy) + MANUAL_DRIVER_REGISTRATION(DriverRegHTCVive) + +#endif int r = 0; int i = 0; -- cgit v1.2.3 From d9c9ebe6de1e6f255d645dd6e641f2c288238bc2 Mon Sep 17 00:00:00 2001 From: mwturvey Date: Thu, 16 Mar 2017 10:42:56 -0700 Subject: fix linux build --- src/survive.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/survive.c b/src/survive.c index d7aa691..9d0ef01 100755 --- a/src/survive.c +++ b/src/survive.c @@ -14,8 +14,7 @@ static int did_runtime_symnum; int SymnumCheck( const char * path, const char * name, void * location, long size ) { - printf("%s\n", name); - if( strncmp( name, "LTRegister", 8 ) == 0 ) + if( strncmp( name, "REGISTER", 8 ) == 0 ) { typedef void (*sf)(); sf fn = (sf)location; -- cgit v1.2.3