Mackie Control: Need signal from session if group parameters change so strips redispl...
[ardour.git] / libs / surfaces / mackie / button.h
index 270245275076abac34f161586b91c7fc319272ef..e9cbdd7b4be517765425e4ffb8080856c8248681 100644 (file)
 #ifndef __ardour_mackie_control_protocol_button_h__
 #define __ardour_mackie_control_protocol_button_h__
 
+#include "ardour/types.h"
+
 #include "controls.h"
 #include "led.h"
 
+namespace ArdourSurface {
+
 namespace Mackie {
 
 class Surface;
@@ -30,95 +34,130 @@ class Surface;
 class Button : public Control
 {
 public:
-       enum base_id_t {
-               recenable_base_id = 0x0,
-               solo_base_id = 0x08,
-               mute_base_id = 0x10,
-               select_base_id = 0x18,
-               vselect_base_id = 0x20,
-               fader_touch_base_id = 0x68, // 0xe0,
-       };
+/* These values uniquely identify each possible button that an MCP device may
+   send. Each DeviceInfo object contains its own set of button definitions that
+   define what device ID will be sent for each button, and there is no reason
+   for them to be the same.  */
+
+       enum ID {
+               /* Global Buttons */
+
+               Track,
+               Send,
+               Pan,
+               Plugin,
+               Eq,
+               Dyn,
+               Left,
+               Right,
+               ChannelLeft,
+               ChannelRight,
+               Flip,
+               View,
+               NameValue,
+               TimecodeBeats,
+               F1,
+               F2,
+               F3,
+               F4,
+               F5,
+               F6,
+               F7,
+               F8,
+               MidiTracks,
+               Inputs,
+               AudioTracks,
+               AudioInstruments,
+               Aux,
+               Busses,
+               Outputs,
+               User,
+               Read,
+               Write,
+               Trim,
+               Touch,
+               Latch,
+               Grp,
+               Save,
+               Undo,
+               Cancel,
+               Enter,
+               Marker,
+               Nudge,
+               Loop,
+               Drop,
+               Replace,
+               Click,
+               ClearSolo,
+               Rewind,
+               Ffwd,
+               Stop,
+               Play,
+               Record,
+               CursorUp,
+               CursorDown,
+               CursorLeft,
+               CursorRight,
+               Zoom,
+               Scrub,
+               UserA,
+               UserB,
+
+               FinalGlobalButton,
+
+               /* Global buttons that users should not redefine */
+
+               Shift,
+               Option,
+               Ctrl,
+               CmdAlt,
+
+               /* Strip buttons */
 
-       enum ButtonID {
-               Io = 0x28,
-               Sends = 0x29,
-               Pan = 0x2a,
-               Plugin = 0x2b,
-               Eq = 0x2c,
-               Dyn = 0x2d,
-               Left = 0x2e,
-               Right = 0x2f,
-               ChannelLeft = 0x30,
-               ChannelRight = 0x31,
-               Flip = 0x32,
-               Edit = 0x33,
-               NameValue = 0x34,
-               TimecodeBeats = 0x35,
-               F1 = 0x36,
-               F2 = 0x37,
-               F3 = 0x38,
-               F4 = 0x39,
-               F5 = 0x3a,
-               F6 = 0x3b,
-               F7 = 0x3c,
-               F8 = 0x3d,
-               F9 = 0x3e,
-               F10 = 0x3f,
-               F11 = 0x40,
-               F12 = 0x41,
-               F13 = 0x42,
-               F14 = 0x43,
-               F15 = 0x44,
-               F16 = 0x45,
-               Shift = 0x46,
-               Option = 0x47,
-               Ctrl = 0x48,
-               CmdAlt = 0x49,
-               On = 0x4a,
-               RecReady = 0x4b,
-               Undo = 0x4c,
-               Save = 0x4d,
-               Touch = 0x4e,
-               Redo = 0x4f,
-               Marker = 0x50,
-               Enter = 0x51,
-               Cancel = 0x52,
-               Mixer = 0x53,
-               FrmLeft = 0x54,
-               FrmRight = 0x55,
-               Loop = 0x56,
-               PunchIn = 0x57,
-               PunchOut = 0x58,
-               Home = 0x59,
-               End = 0x5a,
-               Rewind = 0x5b,
-               Ffwd = 0x5c,
-               Stop = 0x5d,
-               Play = 0x5e,
-               Record = 0x5f,
-               CursorUp = 0x60,
-               CursorDown = 0x61,
-               CursorLeft = 0x62,
-               CursorRight = 0x63,
-               Zoom = 0x64,
-               Scrub = 0x65,
-               UserA = 0x66,
-               UserB = 0x67,
+               RecEnable,
+               Solo,
+               Mute,
+               Select,
+               VSelect,
+               FaderTouch,
+
+               /* Master fader */
+
+               MasterFaderTouch,
        };
 
-       Button (int id, std::string name, Group & group)
-               : Control (id, name, group)
-               , _led  (id, name + "_led", group) {}
-       
+
+       Button (Surface& s, ID bid, int did, std::string name, Group & group)
+               : Control (did, name, group)
+               , _surface (s)
+               , _bid (bid)
+               , _led  (did, name + "_led", group)
+               , press_time (0) {}
+
        MidiByteArray zero() { return _led.zero (); }
        MidiByteArray set_state (LedState ls) { return _led.set_state (ls); }
 
-       static Control* factory (Surface&, int id, const char*, Group&);
-       
+       ID bid() const { return _bid; }
+
+       static Control* factory (Surface& surface, Button::ID bid, int id, const std::string&, Group& group);
+       static int name_to_id (const std::string& name);
+       static std::string id_to_name (Button::ID);
+
+       Surface& surface() const { return _surface; }
+
+       void pressed ();
+       void released ();
+
+       int32_t long_press_count ();
+
 private:
+       Surface& _surface;
+       ID  _bid; /* device independent button ID */
        Led _led;
+       ARDOUR::microseconds_t press_time;
 };
 
-}
+} // Mackie namespace
+} // ArdourSurface namespace
 
 #endif