X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=shared%2Fmidi_mapper_util.h;h=39ccd84e43f7d1ec1e707e2de730ea1d08ad59d9;hb=09b27ab32073dba2c565cdda43fcf2c37ea04a7b;hp=bc9b1bf164c83921a44c74b897eb52d7f2005e45;hpb=09f6cb41070d746115bbb4ca12325622b564c025;p=nageru diff --git a/shared/midi_mapper_util.h b/shared/midi_mapper_util.h index bc9b1bf..39ccd84 100644 --- a/shared/midi_mapper_util.h +++ b/shared/midi_mapper_util.h @@ -46,4 +46,19 @@ inline bool match_bank_helper(const Proto &msg, int bank_field_number, int bank) return reflection->GetInt32(msg, bank_descriptor) == bank; } +// Find what MIDI note the given light (as given by field_number) is mapped to, and enable it. +template +void activate_mapped_light(const Proto &msg, int field_number, std::set *active_lights) +{ + using namespace google::protobuf; + const FieldDescriptor *descriptor = msg.GetDescriptor()->FindFieldByNumber(field_number); + const Reflection *reflection = msg.GetReflection(); + if (!reflection->HasField(msg, descriptor)) { + return; + } + const MIDILightProto &light_proto = + static_cast(reflection->GetMessage(msg, descriptor)); + active_lights->insert(light_proto.note_number()); +} + #endif // !defined(_MIDI_MAPPER_UTIL_H)