aboutsummaryrefslogtreecommitdiff
path: root/src/survive.c
diff options
context:
space:
mode:
authorMike Turvey <mturvey6@gmail.com>2018-01-03 18:58:43 -0700
committerMike Turvey <mturvey6@gmail.com>2018-01-03 18:59:48 -0700
commitf183aa480c549695ac5b481fade04e62f71d1e0a (patch)
tree63e956b42d54b12f7d7c943023c4e587ebad50b1 /src/survive.c
parentffb879d7a69c3c38937ff0159de0a5d1db99b713 (diff)
downloadlibsurvive-f183aa480c549695ac5b481fade04e62f71d1e0a.tar.gz
libsurvive-f183aa480c549695ac5b481fade04e62f71d1e0a.tar.bz2
Controller Buttons Fully Implemented
Fully plumbed support for controller buttons Also, commented haptic call because it messed with the vive_magic calls, given where I had it.
Diffstat (limited to 'src/survive.c')
-rwxr-xr-xsrc/survive.c36
1 files changed, 29 insertions, 7 deletions
diff --git a/src/survive.c b/src/survive.c
index 99b6648..d3c0918 100755
--- a/src/survive.c
+++ b/src/survive.c
@@ -64,13 +64,25 @@ static void button_servicer(void * context)
return;
}
- printf("ButtonEntry: eventType:%x, buttonId:%d, axis1:%d, axis1Val:%8.8x, axis2:%d, axis2Val:%8.8x\n",
- entry->eventType,
- entry->buttonId,
- entry->axis1Id,
- entry->axis1Val,
- entry->axis2Id,
- entry->axis2Val);
+ //printf("ButtonEntry: eventType:%x, buttonId:%d, axis1:%d, axis1Val:%8.8x, axis2:%d, axis2Val:%8.8x\n",
+ // entry->eventType,
+ // entry->buttonId,
+ // entry->axis1Id,
+ // entry->axis1Val,
+ // entry->axis2Id,
+ // entry->axis2Val);
+
+ button_process_func butt_func = ctx->buttonproc;
+ if (butt_func)
+ {
+ butt_func(entry->so,
+ entry->eventType,
+ entry->buttonId,
+ entry->axis1Id,
+ entry->axis1Val,
+ entry->axis2Id,
+ entry->axis2Val);
+ }
ctx->buttonQueue.nextReadIndex++;
if (ctx->buttonQueue.nextReadIndex >= BUTTON_QUEUE_MAX_LEN)
@@ -171,6 +183,7 @@ SurviveContext * survive_init( int headless )
// start the thread to process button data
ctx->buttonservicethread = OGCreateThread(button_servicer, ctx);
+ survive_install_button_fn(ctx, NULL);
return ctx;
}
@@ -216,6 +229,15 @@ void survive_install_angle_fn( SurviveContext * ctx, angle_process_func fbp )
ctx->angleproc = survive_default_angle_process;
}
+void survive_install_button_fn(SurviveContext * ctx, button_process_func fbp)
+{
+ if (fbp)
+ ctx->buttonproc = fbp;
+ else
+ ctx->buttonproc = survive_default_button_process;
+
+}
+
int survive_add_object( SurviveContext * ctx, SurviveObject * obj )
{
int oldct = ctx->objs_ct;