aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJustin Berger <jdavidberger@gmail.com>2018-03-23 14:42:53 +0000
committerJustin Berger <jdavidberger@gmail.com>2018-03-23 14:42:53 +0000
commit17e06b4822e60ccca865e77b45bf2b52a26852f2 (patch)
tree7245fcad9d6d80fdeae85f80efd1bef08a16e3d5 /src
parent3fd7b740119e86d404d06bceafb02267d6e539c4 (diff)
downloadlibsurvive-17e06b4822e60ccca865e77b45bf2b52a26852f2.tar.gz
libsurvive-17e06b4822e60ccca865e77b45bf2b52a26852f2.tar.bz2
Made picking posers more consistent / configposer can use short name
Diffstat (limited to 'src')
-rw-r--r--src/survive.c22
-rwxr-xr-xsrc/survive_cal.c26
-rw-r--r--src/survive_internal.h3
3 files changed, 18 insertions, 33 deletions
diff --git a/src/survive.c b/src/survive.c
index e6bf69f..a8e7b94 100644
--- a/src/survive.c
+++ b/src/survive.c
@@ -199,7 +199,8 @@ SurviveContext *survive_init_internal(int argc, char *const *argv) {
return ctx;
}
-static void *setup_func_by_name(SurviveContext *ctx, const char *name, const char *configname, const char *configdef) {
+void *GetDriverByConfig(SurviveContext *ctx, const char *name, const char *configname, const char *configdef,
+ int verbose) {
const char *Preferred = survive_configs(ctx, configname, SC_SETCONFIG, configdef);
const char *DriverName = 0;
const char *picked = 0;
@@ -207,12 +208,14 @@ static void *setup_func_by_name(SurviveContext *ctx, const char *name, const cha
void *func = 0;
int prefixLen = strlen(name);
- SV_INFO("Available %s:", name);
+ if (verbose > 1)
+ SV_INFO("Available %s:", name);
while ((DriverName = GetDriverNameMatching(name, i++))) {
void *p = GetDriver(DriverName);
bool match = strcmp(DriverName, Preferred) == 0 || strcmp(DriverName + prefixLen, Preferred) == 0;
- SV_INFO("\t%c%s", match ? '*' : ' ', DriverName + prefixLen);
+ if (verbose > 1)
+ SV_INFO("\t%c%s", match ? '*' : ' ', DriverName + prefixLen);
if (!func || match) {
func = p;
picked = (DriverName + prefixLen);
@@ -221,7 +224,10 @@ static void *setup_func_by_name(SurviveContext *ctx, const char *name, const cha
if (!func) {
SV_ERROR("Error. Cannot find any valid %s.", name);
}
- SV_INFO("Totals %d %ss. Using %s.", i - 1, name, picked);
+ if (verbose > 1)
+ SV_INFO("Totals %d %ss.", i - 1, name);
+ if (verbose > 0)
+ SV_INFO("Using %s for %s", name, configname);
return func;
}
@@ -230,6 +236,8 @@ int survive_startup(SurviveContext *ctx) {
int r = 0;
int i = 0;
+ survive_install_recording(ctx);
+
// initialize the button queue
memset(&(ctx->buttonQueue), 0, sizeof(ctx->buttonQueue));
ctx->buttonQueue.buttonservicesem = OGCreateSema();
@@ -237,15 +245,13 @@ int survive_startup(SurviveContext *ctx) {
// start the thread to process button data
ctx->buttonservicethread = OGCreateThread(button_servicer, ctx);
- PoserCB PreferredPoserCB = setup_func_by_name(ctx, "Poser", "defaultposer", "PoserTurveyTori");
- ctx->lightcapfunction = setup_func_by_name(ctx, "Disambiguator", "disambiguator", "Turvey");
+ PoserCB PreferredPoserCB = GetDriverByConfig(ctx, "Poser", "defaultposer", "TurveyTori", 2);
+ ctx->lightcapfunction = GetDriverByConfig(ctx, "Disambiguator", "disambiguator", "Turvey", 2);
const char *DriverName;
i = 0;
- survive_install_recording(ctx);
-
while ((DriverName = GetDriverNameMatching("DriverReg", i++))) {
DeviceDriver dd = GetDriver(DriverName);
SV_INFO("Loading driver %s (%p) (%d)", DriverName, dd, i);
diff --git a/src/survive_cal.c b/src/survive_cal.c
index 3367aa0..c94bd0d 100755
--- a/src/survive_cal.c
+++ b/src/survive_cal.c
@@ -184,30 +184,8 @@ void survive_cal_install( struct SurviveContext * ctx )
}
const char * DriverName;
-// const char * PreferredPoser = survive_configs(ctx, "configposer", "PoserCharlesSlow");
- const char * PreferredPoser = survive_configs(ctx, "configposer", SC_SETCONFIG, "PoserTurveyTori");
-
- SV_INFO( "Trying to load poser %s for cal.", PreferredPoser );
- PoserCB SelectedPoserCB = 0;
- const char * SelectedPoserName = 0;
- i = 0;
- while( ( DriverName = GetDriverNameMatching( "Poser", i++ ) ) )
- {
- PoserCB p = GetDriver( DriverName );
- if( !SelectedPoserCB )
- {
- SelectedPoserCB = p;
- SelectedPoserName = DriverName;
- }
- int ThisPoser = strcmp( DriverName, PreferredPoser ) == 0;
- if( ThisPoser )
- {
- SelectedPoserCB = p;
- SelectedPoserName = DriverName;
- }
- }
- cd->ConfigPoserFn = SelectedPoserCB;
- SV_INFO( "Got config poser: %s (%p)", SelectedPoserName, cd->ConfigPoserFn );
+ cd->ConfigPoserFn = GetDriverByConfig(ctx, "Poser", "configposer", "TurveyTori", 0);
+
ootx_packet_clbk = ootx_packet_clbk_d;
ctx->calptr = cd;
diff --git a/src/survive_internal.h b/src/survive_internal.h
index 86b119f..9120f41 100644
--- a/src/survive_internal.h
+++ b/src/survive_internal.h
@@ -16,7 +16,8 @@
void * GetDriver( const char * name );
const char * GetDriverNameMatching( const char * prefix, int place );
void ListDrivers();
-
+void *GetDriverByConfig(SurviveContext *ctx, const char *name, const char *configname, const char *configdef,
+ int verbose);
#endif