aboutsummaryrefslogtreecommitdiff
path: root/src/survive.c
diff options
context:
space:
mode:
authorJustin Berger <j.david.berger@gmail.com>2018-03-30 12:33:11 -0600
committerJustin Berger <j.david.berger@gmail.com>2018-03-30 12:33:11 -0600
commit053750ef27c996822512f75f55c0110f573eccd6 (patch)
tree6033f929f87fddff7bfb847b22c421e56600a1b2 /src/survive.c
parent030ec10de98b40750ed480499d84cf8b7bcd766c (diff)
downloadlibsurvive-053750ef27c996822512f75f55c0110f573eccd6.tar.gz
libsurvive-053750ef27c996822512f75f55c0110f573eccd6.tar.bz2
Made manual driver registration only ever happen once
Diffstat (limited to 'src/survive.c')
-rw-r--r--src/survive.c41
1 files changed, 23 insertions, 18 deletions
diff --git a/src/survive.c b/src/survive.c
index b359669..a15e0ed 100644
--- a/src/survive.c
+++ b/src/survive.c
@@ -36,8 +36,8 @@ static void survivefault(struct SurviveContext *ctx, const char *fault) {
}
static void survivenote(struct SurviveContext *ctx, const char *fault) {
- survive_recording_info_process(ctx, fault);
- fprintf(stderr, "Info: %s\n", fault);
+ survive_recording_info_process(ctx, fault);
+ fprintf(stderr, "Info: %s\n", fault);
}
static void *button_servicer(void *context) {
@@ -86,8 +86,9 @@ void survive_verify_FLT_size(uint32_t user_size) {
if (sizeof(FLT) != user_size) {
fprintf(stderr, "FLT type incompatible; the shared library libsurvive has FLT size %lu vs user program %u\n",
(unsigned long)sizeof(FLT), user_size);
- fprintf(stderr, "Add '#define FLT %s' before including survive.h or recompile the shared library with the "
- "appropriate flag. \n",
+ fprintf(stderr,
+ "Add '#define FLT %s' before including survive.h or recompile the shared library with the "
+ "appropriate flag. \n",
sizeof(FLT) == sizeof(double) ? "double" : "float");
exit(-1);
}
@@ -101,24 +102,28 @@ SurviveContext *survive_init_internal(int argc, char *const *argv) {
}
#endif
#ifdef MANUAL_REGISTRATION
-// note: this manual registration is currently only in use on builds using Visual Studio.
+ // note: this manual registration is currently only in use on builds using Visual Studio.
+ static int did_manual_driver_registration = 0;
+ if (did_manual_driver_registration == 0) {
#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(PoserEPNP)
- MANUAL_DRIVER_REGISTRATION(PoserSBA)
+ MANUAL_DRIVER_REGISTRATION(PoserCharlesSlow)
+ MANUAL_DRIVER_REGISTRATION(PoserDaveOrtho)
+ MANUAL_DRIVER_REGISTRATION(PoserDummy)
+ MANUAL_DRIVER_REGISTRATION(PoserEPNP)
+ MANUAL_DRIVER_REGISTRATION(PoserSBA)
- MANUAL_DRIVER_REGISTRATION(DriverRegHTCVive)
- MANUAL_DRIVER_REGISTRATION(DriverRegPlayback)
+ MANUAL_DRIVER_REGISTRATION(DriverRegHTCVive)
+ MANUAL_DRIVER_REGISTRATION(DriverRegPlayback)
- MANUAL_DRIVER_REGISTRATION(DisambiguatorCharles)
- MANUAL_DRIVER_REGISTRATION(DisambiguatorStateBased)
- MANUAL_DRIVER_REGISTRATION(DisambiguatorTurvey)
+ MANUAL_DRIVER_REGISTRATION(DisambiguatorCharles)
+ MANUAL_DRIVER_REGISTRATION(DisambiguatorStateBased)
+ MANUAL_DRIVER_REGISTRATION(DisambiguatorTurvey)
+ did_manual_driver_registration = 1;
+ }
#endif
SurviveContext *ctx = calloc(1, sizeof(SurviveContext));
@@ -316,9 +321,9 @@ int survive_startup(SurviveContext *ctx) {
// If lighthouse positions are known, broadcast them
for (int i = 0; i < ctx->activeLighthouses; i++) {
- if(ctx->bsd[i].PositionSet) {
- ctx->lighthouseposeproc(ctx, i, &ctx->bsd[i].Pose, 0);
- }
+ if (ctx->bsd[i].PositionSet) {
+ ctx->lighthouseposeproc(ctx, i, &ctx->bsd[i].Pose, 0);
+ }
}
return 0;