]> git.sesse.net Git - nageru/blobdiff - futatabi/midi_mapper.cpp
Make the MIDI play button blinking when something is ready to play, and solid when...
[nageru] / futatabi / midi_mapper.cpp
index 1e26985a01537e226f21cedb7f9e789698648be6..63b21e44fa7c6fb53c089caa89d4a42686a51cd4 100644 (file)
@@ -16,6 +16,7 @@
 #include <unistd.h>
 #include <algorithm>
 #include <functional>
+#include <map>
 #include <thread>
 
 #include "defs.h"
@@ -141,6 +142,8 @@ void MIDIMapper::note_on_received(int note)
                bind(&ControllerReceiver::queue, receiver));
        match_button(note, MIDIMappingProto::kPlayFieldNumber, MIDIMappingProto::kPlayBankFieldNumber,
                bind(&ControllerReceiver::play, receiver));
+       match_button(note, MIDIMappingProto::kToggleLockFieldNumber, MIDIMappingProto::kToggleLockBankFieldNumber,
+               bind(&ControllerReceiver::toggle_lock, receiver));
 
        unsigned num_cameras = std::min(MAX_STREAMS, mapping_proto->camera_size());
        for (unsigned camera_idx = 0; camera_idx < num_cameras; ++camera_idx) {
@@ -203,7 +206,7 @@ void MIDIMapper::refresh_lights()
 
 void MIDIMapper::update_lights_lock_held()
 {
-       set<unsigned> active_lights;  // Desired state.
+       map<unsigned, uint8_t> active_lights;  // Desired state.
        if (current_controller_bank == 0) {
                activate_mapped_light(*mapping_proto, MIDIMappingProto::kBank1IsSelectedFieldNumber, &active_lights);
        }
@@ -225,8 +228,15 @@ void MIDIMapper::update_lights_lock_held()
        if (queue_enabled_light) {
                activate_mapped_light(*mapping_proto, MIDIMappingProto::kQueueEnabledFieldNumber, &active_lights);
        }
-       if (play_enabled_light) {
-               activate_mapped_light(*mapping_proto, MIDIMappingProto::kPlayEnabledFieldNumber, &active_lights);
+       if (play_enabled_light == On) {  // Playing.
+               activate_mapped_light(*mapping_proto, MIDIMappingProto::kPlayingFieldNumber, &active_lights);
+       } else if (play_enabled_light == Blinking) {  // Play ready.
+               activate_mapped_light(*mapping_proto, MIDIMappingProto::kPlayReadyFieldNumber, &active_lights);
+       }
+       if (locked_light == On) {
+               activate_mapped_light(*mapping_proto, MIDIMappingProto::kLockedFieldNumber, &active_lights);
+       } else if (locked_light == Blinking) {
+               activate_mapped_light(*mapping_proto, MIDIMappingProto::kLockedBlinkingFieldNumber, &active_lights);
        }
        if (current_highlighted_camera >= 0 && current_highlighted_camera < mapping_proto->camera_size()) {
                const CameraMIDIMappingProto &camera = mapping_proto->camera(current_highlighted_camera);