File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,7 @@ auto update_flatbuffer_from_osc_message(
66
66
) == 0
67
67
)
68
68
{
69
+ // Parse the field name from the OSC message address
69
70
auto field_name = string_view (tosc_getAddress (&osc));
70
71
if (not field_name.empty ())
71
72
{
@@ -75,20 +76,24 @@ auto update_flatbuffer_from_osc_message(
75
76
tosc_getFormat (&osc)
76
77
);
77
78
79
+ // Strip a leading / from the address
78
80
if (field_name[0 ] == ' /' )
79
81
{
80
82
field_name = field_name.substr (1 );
81
83
}
82
84
85
+ // Search for a matching field name in the flatbuffer root table
83
86
const auto * field = root_table_fields->LookupByKey (
84
87
field_name.data ()
85
88
);
86
89
if (field)
87
90
{
91
+ // Find the integer/float/... type of the field, set it
88
92
for (auto i = 0 ; osc.format [i] != ' \0 ' ; ++i)
89
93
{
90
94
switch (osc.format [i])
91
95
{
96
+ // float
92
97
case ' f' :
93
98
{
94
99
flatbuffers::SetAnyFieldF (
@@ -99,6 +104,7 @@ auto update_flatbuffer_from_osc_message(
99
104
did_update_flatbuffer = true ;
100
105
break ;
101
106
}
107
+ // integer
102
108
case ' i' :
103
109
{
104
110
flatbuffers::SetAnyFieldI (
@@ -118,7 +124,10 @@ auto update_flatbuffer_from_osc_message(
118
124
119
125
if (did_update_flatbuffer)
120
126
{
121
- printf (" woot!\n " );
127
+ printf (
128
+ " Updated flatbuffer field: %.*s\n " ,
129
+ field_name.size (), field_name.data ()
130
+ );
122
131
}
123
132
}
124
133
}
You can’t perform that action at this time.
0 commit comments