diff options
| author | XANTRONIX Development | 2022-03-05 20:33:42 -0500 | 
|---|---|---|
| committer | XANTRONIX Development | 2022-03-05 20:33:42 -0500 | 
| commit | 79886752ce99eab7f6e659aa99f0a416b1928b9d (patch) | |
| tree | f16440b3b2aba9de5c79b37464ed995a9197c1a1 | |
| parent | 2894d2f9e4e2a646116836aa2b471c33fbba85f5 (diff) | |
| download | xas-79886752ce99eab7f6e659aa99f0a416b1928b9d.tar.gz xas-79886752ce99eab7f6e659aa99f0a416b1928b9d.tar.bz2 xas-79886752ce99eab7f6e659aa99f0a416b1928b9d.zip | |
Add heading, speed event events to spatial objects
| -rw-r--r-- | include/xas/seq.h | 16 | ||||
| -rw-r--r-- | src/seq.c | 60 | 
2 files changed, 75 insertions, 1 deletions
| diff --git a/include/xas/seq.h b/include/xas/seq.h index 74b198f..3aece2f 100644 --- a/include/xas/seq.h +++ b/include/xas/seq.h @@ -11,6 +11,8 @@ enum xas_seq_event_type {      XAS_SEQ_EVENT_OFF,      XAS_SEQ_EVENT_ON,      XAS_SEQ_EVENT_SET_POSITION, +    XAS_SEQ_EVENT_SET_HEADING, +    XAS_SEQ_EVENT_SET_SPEED,      XAS_SEQ_EVENT_SET_GAIN,      XAS_SEQ_EVENT_SET_FREQUENCY,      XAS_SEQ_EVENT_SET_BANK_INDEX, @@ -35,8 +37,10 @@ struct _xas_seq_event {      struct timeval timestamp;      union { -        float gain;          xas_spatial_coord point; +        xas_spatial_coord heading; +        float speed; +        float gain;          size_t index;          size_t frequency;          const char *phrase; @@ -70,6 +74,16 @@ int xas_seq_add_set_position(xas_seq *seq,                                 struct timeval timestamp,                                 xas_spatial_coord point); +int xas_seq_add_set_heading(xas_seq *seq, +                              xas_spatial_object *object, +                              struct timeval timestamp, +                              xas_spatial_coord heading); + +int xas_seq_add_set_speed(xas_seq *seq, +                            xas_spatial_object *object, +                            struct timeval timestamp, +                            float speed); +  int xas_seq_add_set_gain(xas_seq *seq,                             xas_spatial_object *object,                             struct timeval timestamp, @@ -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); | 
 
    