2008-06-02 17:41:35 -04:00
|
|
|
/*
|
|
|
|
Copyright (C) 2006,2007 John Anderson
|
2012-04-08 11:16:34 -04:00
|
|
|
Copyright (C) 2012 Paul Davis
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
2012-04-08 11:16:34 -04:00
|
|
|
|
|
|
|
#ifndef __mackie_controls_h__
|
|
|
|
#define __mackie_controls_h__
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
2012-04-08 10:11:00 -04:00
|
|
|
#include <stdint.h>
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2009-12-19 15:26:31 -05:00
|
|
|
#include "pbd/signals.h"
|
2009-12-17 13:24:23 -05:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
#include "mackie_control_exception.h"
|
|
|
|
|
|
|
|
namespace Mackie
|
|
|
|
{
|
|
|
|
|
|
|
|
class Control;
|
2012-04-08 10:11:00 -04:00
|
|
|
class Surface;
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
This is a loose group of controls, eg cursor buttons,
|
|
|
|
transport buttons, functions buttons etc.
|
|
|
|
*/
|
|
|
|
class Group
|
|
|
|
{
|
|
|
|
public:
|
2012-04-07 14:43:06 -04:00
|
|
|
Group (const std::string & name)
|
2012-04-08 10:11:00 -04:00
|
|
|
: _name (name) {}
|
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
virtual ~Group() {}
|
|
|
|
|
2012-04-08 10:11:00 -04:00
|
|
|
virtual bool is_strip() const { return false; }
|
|
|
|
virtual bool is_master() const { return false; }
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2012-04-07 14:43:06 -04:00
|
|
|
virtual void add (Control & control);
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2012-04-08 10:11:00 -04:00
|
|
|
const std::string & name() const { return _name; }
|
|
|
|
void set_name (const std::string & rhs) { _name = rhs; }
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
typedef std::vector<Control*> Controls;
|
|
|
|
const Controls & controls() const { return _controls; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
Controls _controls;
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string _name;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Button;
|
|
|
|
class Pot;
|
|
|
|
class Fader;
|
|
|
|
|
2012-04-08 10:11:00 -04:00
|
|
|
struct StripControlDefinition {
|
|
|
|
const char* name;
|
|
|
|
uint32_t base_id;
|
|
|
|
Control* (*factory)(Surface&, int index, int ordinal, const char* name, Group&);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct GlobalControlDefinition {
|
|
|
|
const char* name;
|
|
|
|
uint32_t id;
|
|
|
|
Control* (*factory)(Surface&, int index, int ordinal, const char* name, Group&);
|
|
|
|
const char* group_name;
|
|
|
|
};
|
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
/**
|
|
|
|
This is the set of controls that make up a strip.
|
|
|
|
*/
|
|
|
|
class Strip : public Group
|
|
|
|
{
|
|
|
|
public:
|
2012-04-08 10:11:00 -04:00
|
|
|
Strip (const std::string& name, int index); /* master strip only */
|
|
|
|
Strip (Surface&, const std::string & name, int index, int unit_index, StripControlDefinition* ctls);
|
2012-04-07 14:43:06 -04:00
|
|
|
|
2012-04-08 10:11:00 -04:00
|
|
|
virtual bool is_strip() const { return true; }
|
2012-04-07 14:43:06 -04:00
|
|
|
virtual void add (Control & control);
|
2012-04-08 10:11:00 -04:00
|
|
|
int index() const { return _index; } // zero based
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
Button & solo();
|
|
|
|
Button & recenable();
|
|
|
|
Button & mute();
|
|
|
|
Button & select();
|
|
|
|
Button & vselect();
|
|
|
|
Button & fader_touch();
|
|
|
|
Pot & vpot();
|
|
|
|
Fader & gain();
|
|
|
|
|
2008-12-12 17:55:03 -05:00
|
|
|
bool has_solo() const { return _solo != 0; }
|
|
|
|
bool has_recenable() const { return _recenable != 0; }
|
|
|
|
bool has_mute() const { return _mute != 0; }
|
|
|
|
bool has_select() const { return _select != 0; }
|
|
|
|
bool has_vselect() const { return _vselect != 0; }
|
|
|
|
bool has_fader_touch() const { return _fader_touch != 0; }
|
|
|
|
bool has_vpot() const { return _vpot != 0; }
|
|
|
|
bool has_gain() const { return _gain != 0; }
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
private:
|
2012-04-08 10:11:00 -04:00
|
|
|
Button* _solo;
|
|
|
|
Button* _recenable;
|
|
|
|
Button* _mute;
|
|
|
|
Button* _select;
|
|
|
|
Button* _vselect;
|
|
|
|
Button* _fader_touch;
|
|
|
|
Pot* _vpot;
|
|
|
|
Fader* _gain;
|
|
|
|
int _index;
|
2008-06-02 17:41:35 -04:00
|
|
|
};
|
|
|
|
|
2012-04-07 14:43:06 -04:00
|
|
|
std::ostream & operator << (std::ostream &, const Strip &);
|
2008-12-12 17:55:03 -05:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
class MasterStrip : public Strip
|
|
|
|
{
|
|
|
|
public:
|
2012-04-07 14:43:06 -04:00
|
|
|
MasterStrip (const std::string & name, int index)
|
|
|
|
: Strip (name, index) {}
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2012-04-07 14:43:06 -04:00
|
|
|
virtual bool is_master() const { return true; }
|
2008-06-02 17:41:35 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
class Led;
|
|
|
|
|
|
|
|
/**
|
|
|
|
The base class for controls on the surface. They deliberately
|
|
|
|
don't know the midi protocol for updating them.
|
|
|
|
*/
|
|
|
|
class Control
|
|
|
|
{
|
|
|
|
public:
|
2012-04-07 14:43:06 -04:00
|
|
|
enum type_t {
|
|
|
|
type_led,
|
|
|
|
type_led_ring,
|
|
|
|
type_fader = 0xe0,
|
|
|
|
type_button = 0x90,
|
2012-04-08 19:14:36 -04:00
|
|
|
type_pot = 0xb0,
|
|
|
|
type_meter = 0xd0
|
2012-04-07 14:43:06 -04:00
|
|
|
};
|
2012-04-08 10:11:00 -04:00
|
|
|
|
|
|
|
enum base_id_t {
|
|
|
|
fader_base_id = 0x0,
|
|
|
|
pot_base_id = 0x10,
|
2012-04-08 17:22:21 -04:00
|
|
|
jog_base_id = 0x3c,
|
2012-04-08 10:11:00 -04:00
|
|
|
fader_touch_button_base_id = 0x68,
|
|
|
|
vselect_button_base_id = 0x20,
|
|
|
|
select_button_base_id = 0x18,
|
|
|
|
mute_button_base_id = 0x10,
|
|
|
|
solo_button_base_id = 0x08,
|
|
|
|
recenable_button_base_id = 0x0,
|
2012-04-08 19:14:36 -04:00
|
|
|
meter_base_id = 0xd0,
|
2012-04-08 10:11:00 -04:00
|
|
|
};
|
2012-04-07 14:43:06 -04:00
|
|
|
|
2012-04-07 14:54:31 -04:00
|
|
|
Control (int id, int ordinal, std::string name, Group& group);
|
2008-06-02 17:41:35 -04:00
|
|
|
virtual ~Control() {}
|
|
|
|
|
2012-04-07 14:43:06 -04:00
|
|
|
virtual const Led & led() const { throw MackieControlException ("no led available"); }
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2008-12-12 17:55:03 -05:00
|
|
|
/// type() << 8 + midi id of the control. This
|
|
|
|
/// provides a unique id for any control on the surface.
|
2012-04-07 14:43:06 -04:00
|
|
|
int id() const { return (type() << 8) + _id; }
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2008-12-12 17:55:03 -05:00
|
|
|
/// the value of the second bytes of the message. It's
|
|
|
|
/// the id of the control, but only guaranteed to be
|
|
|
|
/// unique within the control type.
|
|
|
|
int raw_id() const { return _id; }
|
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
/// The 1-based number of the control
|
2008-12-12 17:55:03 -05:00
|
|
|
int ordinal() const { return _ordinal; }
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2012-04-07 14:43:06 -04:00
|
|
|
const std::string & name() const { return _name; }
|
|
|
|
const Group & group() const { return _group; }
|
|
|
|
const Strip & strip() const { return dynamic_cast<const Strip&> (_group); }
|
|
|
|
Strip & strip() { return dynamic_cast<Strip&> (_group); }
|
|
|
|
virtual bool accepts_feedback() const { return true; }
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
virtual type_t type() const = 0;
|
|
|
|
|
2008-12-12 17:55:03 -05:00
|
|
|
/// Return true if this control is the one and only Jog Wheel
|
|
|
|
virtual bool is_jog() const { return false; }
|
|
|
|
|
2011-05-04 05:22:32 -04:00
|
|
|
bool in_use () const;
|
|
|
|
void set_in_use (bool);
|
2008-12-12 17:55:03 -05:00
|
|
|
|
|
|
|
/// Keep track of the timeout so it can be updated with more incoming events
|
2009-12-20 11:49:55 -05:00
|
|
|
sigc::connection in_use_connection;
|
2011-05-04 05:22:32 -04:00
|
|
|
|
|
|
|
/** If we are doing an in_use timeout for a fader without touch, this
|
|
|
|
* is its touch button control; otherwise 0.
|
|
|
|
*/
|
|
|
|
Control* in_use_touch_control;
|
2012-04-07 14:43:06 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
private:
|
|
|
|
int _id;
|
|
|
|
int _ordinal;
|
|
|
|
std::string _name;
|
2012-04-07 14:54:31 -04:00
|
|
|
Group& _group;
|
2008-12-12 17:55:03 -05:00
|
|
|
bool _in_use;
|
2008-06-02 17:41:35 -04:00
|
|
|
};
|
|
|
|
|
2012-04-07 14:43:06 -04:00
|
|
|
std::ostream & operator << (std::ostream & os, const Control & control);
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
class Fader : public Control
|
|
|
|
{
|
|
|
|
public:
|
2012-04-08 10:11:00 -04:00
|
|
|
Fader (int id, int ordinal, std::string name, Group & group)
|
|
|
|
: Control (id, ordinal, name, group)
|
2008-06-02 17:41:35 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual type_t type() const { return type_fader; }
|
2012-04-08 10:11:00 -04:00
|
|
|
|
|
|
|
static Control* factory (Surface&, int id, int ordinal, const char*, Group&);
|
2008-06-02 17:41:35 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
class Led : public Control
|
|
|
|
{
|
|
|
|
public:
|
2012-04-08 10:11:00 -04:00
|
|
|
Led (int id, int ordinal, std::string name, Group & group)
|
|
|
|
: Control (id, ordinal, name, group)
|
2008-06-02 17:41:35 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual const Led & led() const { return *this; }
|
|
|
|
|
|
|
|
virtual type_t type() const { return type_led; }
|
2012-04-08 10:11:00 -04:00
|
|
|
|
|
|
|
static Control* factory (Surface&, int id, int ordinal, const char*, Group&);
|
2008-06-02 17:41:35 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
class Button : public Control
|
|
|
|
{
|
|
|
|
public:
|
2012-04-08 10:11:00 -04:00
|
|
|
Button (int id, int ordinal, std::string name, Group & group)
|
|
|
|
: Control (id, ordinal, name, group)
|
|
|
|
, _led (id, ordinal, name + "_led", group) {}
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2012-04-07 14:43:06 -04:00
|
|
|
virtual const Led & led() const { return _led; }
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
virtual type_t type() const { return type_button; };
|
2012-04-08 10:11:00 -04:00
|
|
|
|
|
|
|
static Control* factory (Surface&, int id, int ordinal, const char*, Group&);
|
2008-12-12 17:55:03 -05:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
private:
|
|
|
|
Led _led;
|
|
|
|
};
|
|
|
|
|
|
|
|
class LedRing : public Led
|
|
|
|
{
|
|
|
|
public:
|
2012-04-08 10:11:00 -04:00
|
|
|
LedRing (int id, int ordinal, std::string name, Group & group)
|
|
|
|
: Led (id, ordinal, name, group)
|
2008-06-02 17:41:35 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual type_t type() const { return type_led_ring; }
|
|
|
|
};
|
|
|
|
|
|
|
|
class Pot : public Control
|
|
|
|
{
|
|
|
|
public:
|
2012-04-07 14:43:06 -04:00
|
|
|
Pot (int id, int ordinal, std::string name, Group & group)
|
|
|
|
: Control (id, ordinal, name, group)
|
2012-04-08 10:11:00 -04:00
|
|
|
, _led_ring (id, ordinal, name + "_ring", group) {}
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
virtual type_t type() const { return type_pot; }
|
|
|
|
|
2012-04-07 14:43:06 -04:00
|
|
|
virtual const LedRing & led_ring() const {return _led_ring; }
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2012-04-08 10:11:00 -04:00
|
|
|
static Control* factory (Surface&, int id, int ordinal, const char*, Group&);
|
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
private:
|
|
|
|
LedRing _led_ring;
|
|
|
|
};
|
|
|
|
|
2008-12-12 17:55:03 -05:00
|
|
|
class Jog : public Pot
|
|
|
|
{
|
|
|
|
public:
|
2012-04-08 10:11:00 -04:00
|
|
|
Jog (int id, int ordinal, std::string name, Group & group)
|
|
|
|
: Pot (id, ordinal, name, group)
|
2008-12-12 17:55:03 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool is_jog() const { return true; }
|
2012-04-08 10:11:00 -04:00
|
|
|
|
|
|
|
static Control* factory (Surface&, int id, int ordinal, const char*, Group&);
|
2008-12-12 17:55:03 -05:00
|
|
|
};
|
|
|
|
|
2012-04-08 19:14:36 -04:00
|
|
|
class Meter : public Control
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Meter (int id, int ordinal, std::string name, Group & group)
|
|
|
|
: Control (id, ordinal, name, group) {}
|
|
|
|
|
|
|
|
virtual type_t type() const { return type_meter; }
|
|
|
|
|
|
|
|
static Control* factory (Surface&, int id, int ordinal, const char*, Group&);
|
|
|
|
};
|
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
2012-04-08 11:16:34 -04:00
|
|
|
#endif /* __mackie_controls_h__ */
|