diff options
author | Joshua Allen <axlecrusher@gmail.com> | 2017-02-25 16:21:34 -0500 |
---|---|---|
committer | Joshua Allen <axlecrusher@gmail.com> | 2017-02-25 16:21:34 -0500 |
commit | 7176d6099e27d07d5801b2ac04d17035b694ca66 (patch) | |
tree | 65182fe7e25659b0f2ec1f661529abb17177cc5a /src/survive.c | |
parent | c2ee02ce28a7c7a9bebe9b69f214e8e441d60cc8 (diff) | |
parent | fe31e600d890004f0f255a20fe056e0e8a54209b (diff) | |
download | libsurvive-7176d6099e27d07d5801b2ac04d17035b694ca66.tar.gz libsurvive-7176d6099e27d07d5801b2ac04d17035b694ca66.tar.bz2 |
Merge branch 'master' of github.com:cnlohr/libsurvive
Diffstat (limited to 'src/survive.c')
-rw-r--r-- | src/survive.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/src/survive.c b/src/survive.c index aab2ae6..473a26d 100644 --- a/src/survive.c +++ b/src/survive.c @@ -134,7 +134,7 @@ static int LoadConfig( struct SurviveContext * ctx, struct SurviveObject * so, i return 0; } -struct SurviveContext * survive_init() +struct SurviveContext * survive_init( int headless ) { int r = 0; struct SurviveContext * ctx = calloc( 1, sizeof( struct SurviveContext ) ); @@ -153,17 +153,20 @@ struct SurviveContext * survive_init() ctx->watchman[1].ctx = ctx; memcpy( ctx->watchman[1].codename, "WM1", 4 ); - //USB must happen last. - if( r = survive_usb_init( ctx ) ) - { - //TODO: Cleanup any libUSB stuff sitting around. - goto fail_gracefully; - } - - //Next, pull out the config stuff. - if( LoadConfig( ctx, &ctx->headset, 1, 0, 0 ) ) goto fail_gracefully; - if( LoadConfig( ctx, &ctx->watchman[0], 2, 0, 1 ) ) { SV_INFO( "Watchman 0 config issue." ); } - if( LoadConfig( ctx, &ctx->watchman[1], 3, 0, 1 ) ) { SV_INFO( "Watchman 1 config issue." ); } + if( !headless ) + { + //USB must happen last. + if( r = survive_usb_init( ctx ) ) + { + //TODO: Cleanup any libUSB stuff sitting around. + goto fail_gracefully; + } + + //Next, pull out the config stuff. + if( LoadConfig( ctx, &ctx->headset, 1, 0, 0 ) ) goto fail_gracefully; + if( LoadConfig( ctx, &ctx->watchman[0], 2, 0, 1 ) ) { SV_INFO( "Watchman 0 config issue." ); } + if( LoadConfig( ctx, &ctx->watchman[1], 3, 0, 1 ) ) { SV_INFO( "Watchman 1 config issue." ); } + } ctx->headset.timebase_hz = ctx->watchman[0].timebase_hz = ctx->watchman[1].timebase_hz = 48000000; ctx->headset.pulsedist_max_ticks = ctx->watchman[0].pulsedist_max_ticks = ctx->watchman[1].pulsedist_max_ticks = 500000; @@ -253,12 +256,14 @@ void survive_install_angle_fn( struct SurviveContext * ctx, angle_process_func void survive_close( struct SurviveContext * ctx ) { - survive_usb_close( ctx ); + if( ctx->usbctx ) + survive_usb_close( ctx ); } int survive_poll( struct SurviveContext * ctx ) { - survive_usb_poll( ctx ); + if( ctx->usbctx ) + survive_usb_poll( ctx ); } int survive_simple_inflate( struct SurviveContext * ctx, const char * input, int inlen, char * output, int outlen ) |