push2: port registration, LED setup
[ardour.git] / libs / surfaces / push2 / push2.h
index fb301a62a7c9e1e3f0d0e0ff8f60844ad5332fe7..1b8c948986e4debe8149a7961dea8e7810b27172 100644 (file)
 #include "ardour/types.h"
 #include "control_protocol/control_protocol.h"
 
+#include "midi_byte_array.h"
+
 namespace Cairo {
        class ImageSurface;
 }
 
+namespace MIDI {
+       class Parser;
+       class Port;
+}
+
+namespace ARDOUR {
+       class AsyncMIDIPort;
+       class Port;
+}
+
 namespace ArdourSurface {
 
 struct Push2Request : public BaseUI::BaseRequestObject {
@@ -78,6 +90,63 @@ class Push2 : public ARDOUR::ControlProtocol
        int close ();
        int render ();
        bool vblank ();
+
+       struct LED
+       {
+               enum State {
+                       Off,
+                       OneShot24th,
+                       OneShot16th,
+                       OneShot8th,
+                       OneShot4th,
+                       OneShot2th,
+                       Pulsing24th,
+                       Pulsing16th,
+                       Pulsing8th,
+                       Pulsing4th,
+                       Pulsing2th,
+                       Blinking24th,
+                       Blinking16th,
+                       Blinking8th,
+                       Blinking4th,
+                       Blinking2th
+               };
+
+               enum Type {
+                       Pad,
+                       ColorButton,
+                       WhiteButton,
+                       TouchStrip,
+               };
+
+
+
+               uint8_t id;
+               Type    type;
+               uint8_t extra;
+               uint8_t color_index;
+               uint8_t state;
+
+               LED (uint8_t i, Type t, uint8_t e) : id (i), type (t), extra (e), color_index (0), state (Off) {}
+               LED () : id (0), type (Pad), extra (0), color_index (0), state (Off) {}
+
+               MidiByteArray update ();
+
+               void set_color (uint8_t color_index);
+               void set_state (State state);
+       };
+
+       std::map<int,LED> leds;
+       void set_led_color (uint32_t id, uint8_t color_index);
+       void set_led_state (uint32_t id, LED::State);
+       void build_led_map ();
+
+       MIDI::Port* _input_port[2];
+       MIDI::Port* _output_port[2];
+       boost::shared_ptr<ARDOUR::Port> _async_in[2];
+       boost::shared_ptr<ARDOUR::Port> _async_out[2];
+
+       void write (int port, const MidiByteArray&);
 };