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.
|
|
|
|
*/
|
|
|
|
#ifndef mackie_types_h
|
|
|
|
#define mackie_types_h
|
|
|
|
|
2008-12-12 17:55:03 -05:00
|
|
|
#include <iostream>
|
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
namespace Mackie
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
This started off as an enum, but it got really annoying
|
|
|
|
typing ? on : off
|
|
|
|
*/
|
|
|
|
class LedState
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum state_t { none, off, flashing, on };
|
|
|
|
LedState() : _state( none ) {}
|
|
|
|
LedState( bool yn ): _state( yn ? on : off ) {}
|
|
|
|
LedState( state_t state ): _state( state ) {}
|
|
|
|
|
|
|
|
bool operator == ( const LedState & other ) const
|
|
|
|
{
|
|
|
|
return state() == other.state();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator != ( const LedState & other ) const
|
|
|
|
{
|
|
|
|
return state() != other.state();
|
|
|
|
}
|
|
|
|
|
|
|
|
state_t state() const { return _state; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
state_t _state;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern LedState on;
|
|
|
|
extern LedState off;
|
|
|
|
extern LedState flashing;
|
|
|
|
extern LedState none;
|
|
|
|
|
|
|
|
enum ButtonState { neither = -1, release = 0, press = 1 };
|
|
|
|
|
|
|
|
/**
|
|
|
|
Contains the state for a control, with some convenience
|
|
|
|
constructors
|
|
|
|
*/
|
|
|
|
struct ControlState
|
|
|
|
{
|
2008-12-12 17:55:03 -05:00
|
|
|
ControlState(): pos(0.0), sign(0), delta(0.0), ticks(0), led_state(off), button_state(neither) {}
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
ControlState( LedState ls ): pos(0.0), delta(0.0), led_state(ls), button_state(neither) {}
|
|
|
|
|
|
|
|
// Note that this sets both pos and delta to the flt value
|
|
|
|
ControlState( LedState ls, float flt ): pos(flt), delta(flt), ticks(0), led_state(ls), button_state(neither) {}
|
|
|
|
ControlState( float flt ): pos(flt), delta(flt), ticks(0), led_state(none), button_state(neither) {}
|
2008-12-12 17:55:03 -05:00
|
|
|
ControlState( float flt, unsigned int tcks ): pos(flt), delta(flt), ticks(tcks), led_state(none), button_state(neither) {}
|
2008-06-02 17:41:35 -04:00
|
|
|
ControlState( ButtonState bs ): pos(0.0), delta(0.0), ticks(0), led_state(none), button_state(bs) {}
|
|
|
|
|
2008-12-12 17:55:03 -05:00
|
|
|
/// For faders. Between 0 and 1.
|
2008-06-02 17:41:35 -04:00
|
|
|
float pos;
|
2008-12-12 17:55:03 -05:00
|
|
|
|
|
|
|
/// For pots. Sign. Either -1 or 1;
|
|
|
|
int sign;
|
|
|
|
|
|
|
|
/// For pots. Signed value of total movement. Between 0 and 1
|
2008-06-02 17:41:35 -04:00
|
|
|
float delta;
|
2008-12-12 17:55:03 -05:00
|
|
|
|
|
|
|
/// For pots. Unsigned number of ticks. Usually between 1 and 16.
|
|
|
|
unsigned int ticks;
|
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
LedState led_state;
|
|
|
|
ButtonState button_state;
|
|
|
|
};
|
|
|
|
|
2008-12-12 17:55:03 -05:00
|
|
|
std::ostream & operator << ( std::ostream &, const ControlState & );
|
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
class Control;
|
|
|
|
class Fader;
|
|
|
|
class Button;
|
|
|
|
class Strip;
|
|
|
|
class Group;
|
|
|
|
class Pot;
|
|
|
|
class Led;
|
|
|
|
class LedRing;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|