aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcnlohr <lohr85@gmail.com>2017-03-08 01:01:42 -0500
committercnlohr <lohr85@gmail.com>2017-03-08 01:01:42 -0500
commit2a4a803b2f162692ca11e700b32da0a77049bfd2 (patch)
tree0f4580ce91c8e43a1c692948010402abcfacf075
parenta087915c5dd8c356911453a019723ebaa9904a36 (diff)
downloadlibsurvive-2a4a803b2f162692ca11e700b32da0a77049bfd2.tar.gz
libsurvive-2a4a803b2f162692ca11e700b32da0a77049bfd2.tar.bz2
cleaning up more header stuff
-rw-r--r--include/libsurvive/survive.h18
-rw-r--r--src/survive.c1
-rw-r--r--src/survive_driverman.c2
-rw-r--r--src/survive_driverman.h22
-rw-r--r--src/survive_internal.h10
-rw-r--r--src/survive_vive.c8
6 files changed, 20 insertions, 41 deletions
diff --git a/include/libsurvive/survive.h b/include/libsurvive/survive.h
index 01b5e2b..c35e43c 100644
--- a/include/libsurvive/survive.h
+++ b/include/libsurvive/survive.h
@@ -103,6 +103,7 @@ struct SurviveContext
SurviveContext * survive_init( int headless );
//For any of these, you may pass in 0 for the function pointer to use default behavior.
+//In general unless you are doing wacky things like recording or playing back data, you won't need to use this.
void survive_install_info_fn( SurviveContext * ctx, text_feedback_func fbp );
void survive_install_error_fn( SurviveContext * ctx, text_feedback_func fbp );
void survive_install_light_fn( SurviveContext * ctx, light_process_func fbp );
@@ -120,7 +121,7 @@ int survive_simple_inflate( SurviveContext * ctx, const char * input, int inlen,
int survive_send_magic( SurviveContext * ctx, int magic_code, void * data, int datalen );
//Install the calibrator.
-void survive_cal_install( SurviveContext * ctx );
+void survive_cal_install( SurviveContext * ctx ); //XXX This will be removed if not already done so.
//Call these from your callback if overridden.
//Accept higher-level data.
@@ -132,18 +133,17 @@ void survive_default_angle_process( SurviveObject * so, int sensor_id, int acode
////////////////////// Survive Drivers ////////////////////////////
void RegisterDriver( const char * name, void * data );
-void * GetDriver( const char * name );
-const char * GetDriverNameMatching( const char * prefix, int place );
-void ListDrivers();
#define REGISTER_LINKTIME( func ) \
void __attribute__((constructor)) Register##func() { RegisterDriver( #func, &func ); }
-int survive_add_object( SurviveContext * ctx, SurviveObject * obj );
-void survive_add_driver( SurviveContext * ctx, void * payload, DeviceDriverCb poll, DeviceDriverCb close, DeviceDriverMagicCb magic );
-////////////////////// Lightcap driver data ///////////////////////
+///////////////////////// General stuff for writing drivers ///////
+
+//For device drivers to call. This actually attaches them.
+int survive_add_object( SurviveContext * ctx, SurviveObject * obj );
+void survive_add_driver( SurviveContext * ctx, void * payload, DeviceDriverCb poll, DeviceDriverCb close, DeviceDriverMagicCb magic );
//For lightcap, etc. Don't change this structure at all. Regular vive is dependent on it being exactly as-is.
//When you write drivers, you can use this to send survive lightcap data.
@@ -158,5 +158,9 @@ typedef struct
//This is the disambiguator function, for taking light timing and figuring out place-in-sweep for a given photodiode.
void handle_lightcap( SurviveObject * so, LightcapElement * le );
+#define SV_INFO( x... ) { char stbuff[1024]; sprintf( stbuff, x ); ctx->notefunction( ctx, stbuff ); }
+#define SV_ERROR( x... ) { char stbuff[1024]; sprintf( stbuff, x ); ctx->faultfunction( ctx, stbuff ); }
+#define SV_KILL() exit(0) //XXX This should likely be re-defined.
+
#endif
diff --git a/src/survive.c b/src/survive.c
index 9bc1a2c..e1ab943 100644
--- a/src/survive.c
+++ b/src/survive.c
@@ -3,7 +3,6 @@
#include <survive.h>
#include "survive_internal.h"
-#include "survive_driverman.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/src/survive_driverman.c b/src/survive_driverman.c
index 8cdfb71..d694e64 100644
--- a/src/survive_driverman.c
+++ b/src/survive_driverman.c
@@ -3,7 +3,7 @@
// See notice in survive_driverman.h
//
-#include "survive_driverman.h"
+#include "survive_internal.h"
#include <string.h>
#include <stdio.h>
diff --git a/src/survive_driverman.h b/src/survive_driverman.h
deleted file mode 100644
index 216333a..0000000
--- a/src/survive_driverman.h
+++ /dev/null
@@ -1,22 +0,0 @@
-// (C) 2017 <>< C. N. Lohr, Under MIT/x11 License.
-//
-// This file is intended to be used for self-registering functions. By using
-// this it means that you do not need to have complicated switch statements or
-// #defines for dfferent inclusion of drivers/other code. You can simply
-// register your function and it will be put into a list.
-//
-//
-
-#ifndef SURVIVE_DRIVERMAN_H
-#define SURVIVE_DRIVERMAN_H
-
-#include "survive.h"
-
-//Very little here. Mostly included in survive.h.
-
-//Driver registration
-#define MAX_DRIVERS 32
-
-
-#endif
-
diff --git a/src/survive_internal.h b/src/survive_internal.h
index ff156ad..392104a 100644
--- a/src/survive_internal.h
+++ b/src/survive_internal.h
@@ -7,16 +7,16 @@
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
-#include "survive_driverman.h"
#include <zlib.h>
#include <survive.h>
-#define SV_INFO( x... ) { char stbuff[1024]; sprintf( stbuff, x ); ctx->notefunction( ctx, stbuff ); }
-#define SV_ERROR( x... ) { char stbuff[1024]; sprintf( stbuff, x ); ctx->faultfunction( ctx, stbuff ); }
-//XXX TODO This one needs to be rewritten.
-#define SV_KILL() exit(0)
+//Driver registration
+#define MAX_DRIVERS 32
+void * GetDriver( const char * name );
+const char * GetDriverNameMatching( const char * prefix, int place );
+void ListDrivers();
#endif
diff --git a/src/survive_vive.c b/src/survive_vive.c
index 6be5114..61716d3 100644
--- a/src/survive_vive.c
+++ b/src/survive_vive.c
@@ -10,14 +10,12 @@
//If there are portions of the code too similar to the original, I would like to know so they can be re-written.
//All MIT/x11 Licensed Code in this file may be relicensed freely under the GPL or LGPL licenses.
-#include "survive_internal.h"
-#include "survive_driverman.h"
+#include <survive.h>
#include <jsmn.h>
-
-#include "survive_internal.h"
#include <libusb-1.0/libusb.h>
#include <stdio.h>
-#include <unistd.h> //sleep if I ever use it.
+#include <stdlib.h>
+#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/stat.h>