2 Copyright (C) 2006,2007 John Anderson
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 #ifndef mackie_types_h
19 #define mackie_types_h
23 namespace ArdourSurface {
32 This started off as an enum, but it got really annoying
38 enum state_t { none, off, flashing, on };
39 LedState() : _state (none) {}
40 LedState (bool yn): _state (yn ? on : off) {}
41 LedState (state_t state): _state (state) {}
43 LedState& operator= (state_t s) { _state = s; return *this; }
45 bool operator == (const LedState & other) const
47 return state() == other.state();
50 bool operator != (const LedState & other) const
52 return state() != other.state();
55 state_t state() const { return _state; }
63 extern LedState flashing;
66 enum ButtonState { neither = -1, release = 0, press = 1 };
69 Contains the state for a control, with some convenience
74 ControlState(): pos(0.0), sign(0), delta(0.0), ticks(0), led_state(off), button_state(neither) {}
76 ControlState (LedState ls): pos(0.0), delta(0.0), led_state(ls), button_state(neither) {}
78 // Note that this sets both pos and delta to the flt value
79 ControlState (LedState ls, float flt): pos(flt), delta(flt), ticks(0), led_state(ls), button_state(neither) {}
80 ControlState (float flt): pos(flt), delta(flt), ticks(0), led_state(none), button_state(neither) {}
81 ControlState (float flt, unsigned int tcks): pos(flt), delta(flt), ticks(tcks), led_state(none), button_state(neither) {}
82 ControlState (ButtonState bs): pos(0.0), delta(0.0), ticks(0), led_state(none), button_state(bs) {}
84 /// For faders. Between 0 and 1.
87 /// For pots. Sign. Either -1 or 1;
90 /// For pots. Signed value of total movement. Between 0 and 1
93 /// For pots. Unsigned number of ticks. Usually between 1 and 16.
97 ButtonState button_state;
100 std::ostream & operator << (std::ostream &, const ControlState &);