From 50061dff9f31848045f397fda3f39b9bc0398077 Mon Sep 17 00:00:00 2001 From: Justin Berger Date: Fri, 29 Jun 2018 19:21:29 +0000 Subject: Blacklisted devices now dont claim interface; fixed ootx option --- src/ootx_decoder.c | 15 +++++++++------ src/survive_cal.c | 12 ++++++------ src/survive_vive.c | 34 +++++++++++++++++++++++++--------- 3 files changed, 40 insertions(+), 21 deletions(-) diff --git a/src/ootx_decoder.c b/src/ootx_decoder.c index e110d11..253dd18 100644 --- a/src/ootx_decoder.c +++ b/src/ootx_decoder.c @@ -4,10 +4,11 @@ /* ootx data decoder */ +#include "ootx_decoder.h" +#include "string.h" +#include #include #include -#include -#include "ootx_decoder.h" #ifdef NOZLIB #include "crc32.h" @@ -124,10 +125,12 @@ void ootx_pump_bit(ootx_decoder_context *ctx, uint8_t dbit) { if( !dbit ) { // printf("Bad sync bit\n"); - ootx_error(ctx, "OOTX Decoder: Bad sync bit"); - - if (ctx->ignore_sync_bit_error == 0) + if (ctx->ignore_sync_bit_error == 0) { + ootx_error(ctx, "OOTX Decoder: Bad sync bit"); ootx_reset_buffer(ctx); + } else { + ootx_error(ctx, "OOTX Decoder: Ignoring bad sync bit"); + } } ctx->bits_processed = 0; } @@ -157,7 +160,7 @@ void ootx_pump_bit(ootx_decoder_context *ctx, uint8_t dbit) { op.length = *(ctx->payload_size); op.data = ctx->buffer+2; - op.crc32 = *(uint32_t*)(op.data+padded_length); + memcpy(&op.crc32, op.data + padded_length, sizeof(uint32_t)); uint32_t crc = crc32( 0L, 0 /*Z_NULL*/, 0 ); crc = crc32( crc, op.data,op.length); diff --git a/src/survive_cal.c b/src/survive_cal.c index a9f9e00..79519b6 100755 --- a/src/survive_cal.c +++ b/src/survive_cal.c @@ -53,8 +53,9 @@ static void reset_calibration( struct SurviveCalData * cd ); void ootx_error_clbk_d(ootx_decoder_context *ct, const char *msg) { SurviveContext *ctx = (SurviveContext *)(ct->user); + SurviveCalData *cd = ctx->calptr; int id = ct->user1; - SV_INFO("(%d) %s", id, msg); + SV_INFO("(%s %d) %s", cd->poseobjects[0]->codename, id, msg); } void ootx_packet_clbk_d(ootx_decoder_context *ct, ootx_packet* packet) @@ -144,7 +145,7 @@ void survive_cal_install( struct SurviveContext * ctx ) for( i = 0; i < NUM_LIGHTHOUSES; i++ ) { ootx_init_decoder_context(&cd->ootx_decoders[i]); - survive_attach_configi(ctx, "ootx-ignore-sync-error", &cd->ootx_decoders[i].ignore_sync_bit_error); + cd->ootx_decoders[i].ignore_sync_bit_error = survive_configi(ctx, "ootx-ignore-sync-error", SC_SETCONFIG, 0); cd->ootx_decoders[i].user = ctx; cd->ootx_decoders[i].user1 = i; } @@ -176,10 +177,9 @@ void survive_cal_install( struct SurviveContext * ctx ) { if (MAX_DEVICES_TO_CAL > cd->numPoseObjects) { - cd->poseobjects[j] = ctx->objs[j]; + cd->poseobjects[cd->numPoseObjects] = ctx->objs[j]; + SV_INFO("Calibration is using %s", cd->poseobjects[cd->numPoseObjects]->codename); cd->numPoseObjects++; - - SV_INFO("Calibration is using %s", cd->poseobjects[j]->codename); } else { @@ -489,7 +489,7 @@ static void handle_calibration( struct SurviveCalData *cd ) #define OUTLIER_ANGLE 0.001 //TODO: Tune #define OUTLIER_LENGTH 0.001 //TODO: Tune - #define ANGLE_STDEV_TOO_HIGH 0.000001 //TODO: Tune +#define ANGLE_STDEV_TOO_HIGH 0.001 // TODO: Tune FLT avgsweep = sumsweepangle / dpmax; FLT avglen = sumlentime / dpmax; diff --git a/src/survive_vive.c b/src/survive_vive.c index 3c5994b..5bf0800 100755 --- a/src/survive_vive.c +++ b/src/survive_vive.c @@ -353,6 +353,9 @@ static inline int hid_get_feature_report_timeout(USBHANDLE device, uint16_t ifac int survive_usb_init( SurviveViveData * sv, SurviveObject * hmd, SurviveObject *wm0, SurviveObject * wm1, SurviveObject * tr0, SurviveObject * tr1, SurviveObject * ww0 ) { SurviveContext * ctx = sv->ctx; + const char *blacklist = survive_configs(ctx, "blacklist-devs", SC_GET, "-"); + SV_INFO("Blacklisting %s", blacklist); + #ifdef HIDAPI SV_INFO( "Vive starting in HIDAPI mode." ); if( !GlobalRXUSBMutx ) @@ -370,6 +373,8 @@ int survive_usb_init( SurviveViveData * sv, SurviveObject * hmd, SurviveObject * for( i = 0; i < MAX_USB_DEVS; i++ ) { + if (strstr(blacklist, devnames[i])) + continue; int enumid = vidpids[i*3+2]; int vendor_id = vidpids[i*3+0]; int product_id = vidpids[i*3+1]; @@ -443,6 +448,8 @@ int survive_usb_init( SurviveViveData * sv, SurviveObject * hmd, SurviveObject * //Open all interfaces. for( i = 0; i < MAX_USB_DEVS; i++ ) { + if (strstr(blacklist, devnames[i])) + continue; libusb_device * d; int vid = vidpids[i*3+0]; int pid = vidpids[i*3+1]; @@ -515,16 +522,25 @@ int survive_usb_init( SurviveViveData * sv, SurviveObject * hmd, SurviveObject * libusb_free_device_list( devs, 1 ); #endif - - const char * blacklist = survive_configs(ctx, "blacklist-devs", SC_GET, "-"); - //Add the drivers - this must happen BEFORE we actually attach interfaces. - if( !strstr( blacklist, "HMD" ) && sv->udev[USB_DEV_HMD_IMU_LH] ) { survive_add_object( ctx, hmd ); } - if( !strstr( blacklist, "WM0" ) && sv->udev[USB_DEV_WATCHMAN1] ) { survive_add_object( ctx, wm0 ); } - if( !strstr( blacklist, "WM1" ) && sv->udev[USB_DEV_WATCHMAN2] ) { survive_add_object( ctx, wm1 ); } - if( !strstr( blacklist, "TR0" ) && sv->udev[USB_DEV_TRACKER0] ) { survive_add_object( ctx, tr0 ); } - if( !strstr( blacklist, "TR1" ) && sv->udev[USB_DEV_TRACKER1] ) { survive_add_object( ctx, tr1 ); } - if( !strstr( blacklist, "WW0" ) && sv->udev[USB_DEV_W_WATCHMAN1] ) { survive_add_object( ctx, ww0 ); } + if (sv->udev[USB_DEV_HMD_IMU_LH]) { + survive_add_object(ctx, hmd); + } + if (sv->udev[USB_DEV_WATCHMAN1]) { + survive_add_object(ctx, wm0); + } + if (sv->udev[USB_DEV_WATCHMAN2]) { + survive_add_object(ctx, wm1); + } + if (sv->udev[USB_DEV_TRACKER0]) { + survive_add_object(ctx, tr0); + } + if (sv->udev[USB_DEV_TRACKER1]) { + survive_add_object(ctx, tr1); + } + if (sv->udev[USB_DEV_W_WATCHMAN1]) { + survive_add_object(ctx, ww0); + } if( sv->udev[USB_DEV_HMD] && AttachInterface( sv, hmd, USB_IF_HMD, sv->udev[USB_DEV_HMD], 0x81, survive_data_cb, "Mainboard" ) ) { return -6; } if( sv->udev[USB_DEV_HMD_IMU_LH] && AttachInterface( sv, hmd, USB_IF_HMD_IMU_LH, sv->udev[USB_DEV_HMD_IMU_LH], 0x81, survive_data_cb, "Lighthouse" ) ) { return -7; } -- cgit v1.2.3