Ardour  8.7-14-g57a6773833
m2device.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Robin Gareus <robin@gareus.org>
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_surfaces_maschine2hardware_h_
20 #define _ardour_surfaces_maschine2hardware_h_
21 
22 #include <hidapi.h>
23 #include <cairomm/refptr.h>
24 #include <cairomm/surface.h>
25 #include "pbd/signals.h"
26 
27 namespace ArdourSurface {
28 
29 class M2Contols;
30 
37 class M2Device
38 {
39  public:
41  : _splashcnt (0)
42  , _blink_counter (0)
43  , _blink_shade (0.f)
44  {}
45  virtual ~M2Device () {}
46 
47  virtual void clear (bool splash = false) {
48  if (splash) {
49  _splashcnt = 0;
50  } else {
52  }
53  _blink_counter = 0;
54  _blink_shade = 0.f;
55  }
56 
57  virtual void read (hid_device*, M2Contols*) = 0;
58  virtual void write (hid_device*, M2Contols*) = 0;
59  virtual Cairo::RefPtr<Cairo::ImageSurface> surface () = 0;
60 
61  PBD::Signal0<bool> vblank;
62 
63  protected:
64  void bump_blink () {
65  _blink_counter = (_blink_counter + 1) % 12;
66  _blink_shade = fabsf (1.f - _blink_counter / 6.f);
67  }
68 
69  uint32_t _splashcnt;
70  static const uint32_t _splashtime = 25 * 3;
71  unsigned int _blink_counter;
72  float _blink_shade;
73 };
74 
75 } /* namespace */
76 #endif /* _ardour_surfaces_maschine2_h_*/
virtual void read(hid_device *, M2Contols *)=0
unsigned int _blink_counter
Definition: m2device.h:71
virtual Cairo::RefPtr< Cairo::ImageSurface > surface()=0
virtual void clear(bool splash=false)
Definition: m2device.h:47
PBD::Signal0< bool > vblank
Definition: m2device.h:61
static const uint32_t _splashtime
Definition: m2device.h:70
virtual void write(hid_device *, M2Contols *)=0