Ardour  9.0-pre0-427-gd2a3450e2f
surfaces/us2400/button.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Ben Loftis <ben@harrisonconsoles.com>
3  *
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.
8  *
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.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #ifndef __ardour_us2400_control_protocol_button_h__
20 #define __ardour_us2400_control_protocol_button_h__
21 
22 #include "ardour/types.h"
23 
24 #include "controls.h"
25 #include "led.h"
26 
27 namespace ArdourSurface {
28 
29 namespace US2400 {
30 
31 class Surface;
32 
33 class Button : public Control
34 {
35 public:
36 /* These values uniquely identify each possible button that an MCP device may
37  send. Each DeviceInfo object contains its own set of button definitions that
38  define what device ID will be sent for each button, and there is no reason
39  for them to be the same. */
40 
41  enum ID {
42  /* Global Buttons */
43 
45  F1,
46  F2,
47  F3,
48  F4,
49  F5,
50  F6,
60 
62 
63 
64  /* Global buttons that users should not redefine */
65 
68  Pan,
74 
75  /* Strip buttons */
76 
81 
82  /* Master fader */
83 
85  };
86 
87 
88  Button (Surface& s, ID bid, int did, std::string name, Group & group)
89  : Control (did, name, group)
90  , _surface (s)
91  , _bid (bid)
92  , _led (did, name + "_led", group)
93  , press_time (0) {}
94 
95  MidiByteArray zero() { return _led.zero (); }
97 
98  ID bid() const { return _bid; }
99 
100  static Control* factory (Surface& surface, Button::ID bid, int id, const std::string&, Group& group);
101  static int name_to_id (const std::string& name);
102  static std::string id_to_name (Button::ID);
103 
104  Surface& surface() const { return _surface; }
105 
106  void mark_dirty() { _led.mark_dirty(); }
107 
108  void pressed ();
109  void released ();
110 
111  int32_t long_press_count ();
112 
113 private:
115  ID _bid; /* device independent button ID */
118 };
119 
120 } // US2400 namespace
121 } // ArdourSurface namespace
122 
123 #endif
Button(Surface &s, ID bid, int did, std::string name, Group &group)
static std::string id_to_name(Button::ID)
static Control * factory(Surface &surface, Button::ID bid, int id, const std::string &, Group &group)
static int name_to_id(const std::string &name)
MidiByteArray set_state(LedState ls)
const std::string & name() const
MidiByteArray set_state(LedState)
DebugBits US2400
int64_t microseconds_t
Definition: microseconds.h:28