-/* FaderPort8 Button Interface
- *
+/*
* Copyright (C) 2017 Robin Gareus <robin@gareus.org>
*
- * 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 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef _ardour_surfaces_fp8button_h_
#include "fp8_base.h"
-namespace ArdourSurface {
+namespace ArdourSurface { namespace FP_NAMESPACE {
/* virtual base-class and interface */
class FP8ButtonInterface
return true;
}
- void ignore_release () {
+ virtual void ignore_release () {
if (_pressed) {
_ignore_release = true;
}
}
+ bool blinking () const { return _blinking; }
+
void set_blinking (bool yes) {
if (yes && !_blinking) {
_blinking = true;
_base.BlinkIt.connect_same_thread (_blink_connection, boost::bind (&FP8ButtonBase::blink, this, _1));
} else if (!yes && _blinking) {
_blink_connection.disconnect ();
- blink (true);
_blinking = false;
+ blink (true);
}
}
// short press: activate in press, deactivate on release,
// long press + hold, activate on press, de-activate directly on release
// e.g. mute/solo press + hold => changed()
-class FP8MomentaryButton : public FP8ButtonInterface
+class FP8MomentaryButton : public FP8ButtonBase
{
public:
FP8MomentaryButton (FP8Base& b, uint8_t id)
- : _base (b)
+ : FP8ButtonBase (b)
, _midi_id (id)
- , _pressed (false)
- , _active (false)
{}
~FP8MomentaryButton () {
_hold_connection.disconnect ();
}
+ void ignore_release () { }
+
bool midi_event (bool a)
{
if (a == _pressed) {
}
protected:
- FP8Base& _base;
+ void blink (bool onoff)
+ {
+ if (!blinking ()) {
+ _base.tx_midi3 (0x90, _midi_id, _active ? 0x7f : 0x00);
+ return;
+ }
+ _base.tx_midi3 (0x90, _midi_id, onoff ? 0x7f : 0x00);
+ }
+
uint8_t _midi_id; // MIDI-note
- bool _pressed;
bool _momentaty;
bool _was_active_on_press;
- bool _active;
private:
bool hold_timeout ()
sigc::connection _press_timeout_connection;
};
-} /* namespace */
+} } /* namespace */
#endif /* _ardour_surfaces_fp8button_h_ */