From 79886752ce99eab7f6e659aa99f0a416b1928b9d Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Sat, 5 Mar 2022 20:33:42 -0500 Subject: Add heading, speed event events to spatial objects --- src/seq.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'src') diff --git a/src/seq.c b/src/seq.c index 64b3544..ba9046c 100644 --- a/src/seq.c +++ b/src/seq.c @@ -139,6 +139,56 @@ error_malloc_ev: return -1; } +int xas_seq_add_set_heading(xas_seq *seq, + xas_spatial_object *object, + struct timeval timestamp, + xas_spatial_coord heading) { + xas_seq_event *ev; + + if ((ev = malloc(sizeof(*ev))) == NULL) { + goto error_malloc_ev; + } + + ev->type = XAS_SEQ_EVENT_SET_HEADING; + ev->objtype = XAS_SEQ_OBJECT_ANY; + ev->object = object; + ev->timestamp = timestamp; + ev->heading = heading; + ev->next = NULL; + + add_event(seq, ev); + + return 0; + +error_malloc_ev: + return -1; +} + +int xas_seq_add_set_speed(xas_seq *seq, + xas_spatial_object *object, + struct timeval timestamp, + float speed) { + xas_seq_event *ev; + + if ((ev = malloc(sizeof(*ev))) == NULL) { + goto error_malloc_ev; + } + + ev->type = XAS_SEQ_EVENT_SET_SPEED; + ev->objtype = XAS_SEQ_OBJECT_ANY; + ev->object = object; + ev->timestamp = timestamp; + ev->speed = speed; + ev->next = NULL; + + add_event(seq, ev); + + return 0; + +error_malloc_ev: + return -1; +} + int xas_seq_add_set_gain(xas_seq *seq, xas_spatial_object *object, struct timeval timestamp, @@ -254,6 +304,16 @@ static int event_trigger(xas_spatial_scene *scene, xas_seq_event *ev) { break; + case XAS_SEQ_EVENT_SET_HEADING: + ev->object->heading = ev->heading; + + break; + + case XAS_SEQ_EVENT_SET_SPEED: + ev->object->speed = ev->speed; + + break; + case XAS_SEQ_EVENT_SET_GAIN: xas_object_set_gain(ev->object->ctx, ev->gain); -- cgit v1.2.3