2012-04-08 10:11:00 -04:00
|
|
|
/*
|
2008-06-02 17:41:35 -04:00
|
|
|
Copyright (C) 2006,2007 John Anderson
|
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <iomanip>
|
|
|
|
#include <sstream>
|
|
|
|
|
2012-04-08 10:11:00 -04:00
|
|
|
#include "controls.h"
|
|
|
|
#include "types.h"
|
|
|
|
#include "surface.h"
|
2012-04-09 09:59:35 -04:00
|
|
|
#include "control_group.h"
|
|
|
|
|
|
|
|
#include "button.h"
|
|
|
|
#include "led.h"
|
|
|
|
#include "pot.h"
|
|
|
|
#include "fader.h"
|
|
|
|
#include "jog.h"
|
|
|
|
#include "meter.h"
|
|
|
|
|
2012-04-08 10:11:00 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
using namespace Mackie;
|
|
|
|
using namespace std;
|
|
|
|
|
2012-04-08 10:11:00 -04:00
|
|
|
void Group::add (Control& control)
|
2008-06-02 17:41:35 -04:00
|
|
|
{
|
2012-04-08 10:11:00 -04:00
|
|
|
_controls.push_back (&control);
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
2012-04-10 10:27:44 -04:00
|
|
|
Control::Control (int id, std::string name, Group & group)
|
2012-04-08 10:11:00 -04:00
|
|
|
: _id (id)
|
|
|
|
, _name (name)
|
|
|
|
, _group (group)
|
|
|
|
, _in_use (false)
|
2008-12-12 17:55:03 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-05-04 05:22:32 -04:00
|
|
|
/** @return true if the control is in use, or false otherwise.
|
|
|
|
Buttons are `in use' when they are held down.
|
|
|
|
Faders with touch support are `in use' when they are being touched.
|
|
|
|
Pots, or faders without touch support, are `in use' from the first move
|
|
|
|
event until a timeout after the last move event.
|
|
|
|
*/
|
|
|
|
bool
|
|
|
|
Control::in_use () const
|
2008-12-12 17:55:03 -05:00
|
|
|
{
|
|
|
|
return _in_use;
|
|
|
|
}
|
|
|
|
|
2011-05-04 05:22:32 -04:00
|
|
|
void
|
|
|
|
Control::set_in_use (bool in_use)
|
2008-12-12 17:55:03 -05:00
|
|
|
{
|
2011-05-04 05:22:32 -04:00
|
|
|
_in_use = in_use;
|
2008-12-12 17:55:03 -05:00
|
|
|
}
|
|
|
|
|
2012-04-08 10:11:00 -04:00
|
|
|
ostream & Mackie::operator << (ostream & os, const Mackie::Control & control)
|
2008-12-12 17:55:03 -05:00
|
|
|
{
|
2012-04-08 10:11:00 -04:00
|
|
|
os << typeid (control).name();
|
2008-12-12 17:55:03 -05:00
|
|
|
os << " { ";
|
|
|
|
os << "name: " << control.name();
|
|
|
|
os << ", ";
|
2012-04-11 12:31:23 -04:00
|
|
|
os << "id: " << "0x" << setw(2) << setfill('0') << hex << control.id() << setfill(' ');
|
2008-12-12 17:55:03 -05:00
|
|
|
os << ", ";
|
|
|
|
os << "group: " << control.group().name();
|
|
|
|
os << " }";
|
|
|
|
|
|
|
|
return os;
|
|
|
|
}
|
|
|
|
|
2012-04-08 10:11:00 -04:00
|
|
|
Control*
|
2012-04-10 10:27:44 -04:00
|
|
|
Jog::factory (Surface& surface, int id, const char* name, Group& group)
|
2012-04-08 10:11:00 -04:00
|
|
|
{
|
2012-04-10 10:27:44 -04:00
|
|
|
Jog* j = new Jog (id, name, group);
|
2012-04-08 10:11:00 -04:00
|
|
|
surface.controls.push_back (j);
|
2012-04-08 17:22:21 -04:00
|
|
|
surface.controls_by_name["jog"] = j;
|
2012-04-08 10:11:00 -04:00
|
|
|
group.add (*j);
|
|
|
|
return j;
|
|
|
|
}
|
2012-04-08 19:14:36 -04:00
|
|
|
|