summaryrefslogtreecommitdiff
path: root/libs/surfaces/mackie/button.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2015-10-07 15:12:09 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2015-10-07 15:13:03 -0400
commitc9658134cebe307f7628fc2631f4d9528c5bbb99 (patch)
treea9b73771f1ea990fb99481976a870427b3b3628c /libs/surfaces/mackie/button.cc
parent5762ee114d085c25043887b490bccc803a90d59b (diff)
add button time and explicit bank switching to MCP support
Diffstat (limited to 'libs/surfaces/mackie/button.cc')
-rw-r--r--libs/surfaces/mackie/button.cc33
1 files changed, 32 insertions, 1 deletions
diff --git a/libs/surfaces/mackie/button.cc b/libs/surfaces/mackie/button.cc
index 53a43de5ba..ab1e198874 100644
--- a/libs/surfaces/mackie/button.cc
+++ b/libs/surfaces/mackie/button.cc
@@ -19,6 +19,8 @@
#include <glib.h>
+#include "ardour/ardour.h"
+
#include "button.h"
#include "surface.h"
#include "control_group.h"
@@ -29,7 +31,7 @@ using namespace Mackie;
Control*
Button::factory (Surface& surface, Button::ID bid, int id, const std::string& name, Group& group)
{
- Button* b = new Button (bid, id, name, group);
+ Button* b = new Button (surface, bid, id, name, group);
/* store button with the device-specific ID */
surface.buttons[id] = b;
surface.controls.push_back (b);
@@ -37,6 +39,35 @@ Button::factory (Surface& surface, Button::ID bid, int id, const std::string& na
return b;
}
+void
+Button::pressed ()
+{
+ press_time = ARDOUR::get_microseconds ();
+}
+
+void
+Button::released ()
+{
+ press_time = 0;
+}
+
+int32_t
+Button::long_press_count ()
+{
+ if (press_time == 0) {
+ return -1; /* button is not pressed */
+ }
+
+ const ARDOUR::microseconds_t delta = ARDOUR::get_microseconds () - press_time;
+
+ if (delta < 500000) {
+ return 0;
+ } else if (delta < 1000000) {
+ return 1;
+ }
+
+ return 2;
+}
int
Button::name_to_id (const std::string& name)
{