Skeleton for NI Maschine2 Surface
[ardour.git] / libs / surfaces / maschine2 / m2_dev_mikro.h
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, or (at your option)
7  * 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
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18
19 #ifndef _ardour_surfaces_m2mikro_h_
20 #define _ardour_surfaces_m2mikro_h_
21
22 #include "m2device.h"
23
24 #include <cairomm/context.h>
25 #include <pangomm/layout.h>
26
27 namespace ArdourSurface {
28
29 class Maschine2Mikro : public M2Device
30 {
31         public:
32                 Maschine2Mikro ();
33                 void clear (bool splash = false);
34                 void read (hid_device*, M2Contols*);
35                 void write (hid_device*, M2Contols*);
36                 Cairo::RefPtr<Cairo::ImageSurface> surface () { return _surface; }
37
38         private:
39
40 #if defined(__GNUC__)
41 #define ATTRIBUTE_PACKED  __attribute__((__packed__))
42 #else
43 #define ATTRIBUTE_PACKED
44 #pragma pack(1)
45 #endif
46
47                 struct machine_mk2_input {
48                         unsigned int trs_restart     : 1; // 0
49                         unsigned int trs_left        : 1;
50                         unsigned int trs_right       : 1;
51                         unsigned int trs_grid        : 1;
52                         unsigned int trs_play        : 1;
53                         unsigned int trs_rec         : 1;
54                         unsigned int trs_erase       : 1;
55                         unsigned int trs_shift       : 1;
56                         unsigned int group           : 1; // 8
57                         unsigned int browse          : 1;
58                         unsigned int sampling        : 1;
59                         unsigned int note_repeat     : 1;
60                         unsigned int mst_wheel       : 1;
61                         unsigned int reserved        : 3;
62                         unsigned int f1              : 1; // 16
63                         unsigned int f2              : 1;
64                         unsigned int f3              : 1;
65                         unsigned int control         : 1;
66                         unsigned int navigate        : 1;
67                         unsigned int nav_left        : 1;
68                         unsigned int nav_right       : 1;
69                         unsigned int main            : 1;
70                         unsigned int pads_scene      : 1; // 24
71                         unsigned int pads_pattern    : 1;
72                         unsigned int pads_mode       : 1;
73                         unsigned int pads_navigate   : 1;
74                         unsigned int pads_duplicate  : 1;
75                         unsigned int pads_select     : 1;
76                         unsigned int pads_solo       : 1;
77                         unsigned int pads_mute       : 1; // 31
78                         unsigned int mst_wheel_pos   : 8; // 32..40 // range: 0..15
79                 } ATTRIBUTE_PACKED ctrl_in;
80
81 #if (!defined __GNUC__)
82 #pragma pack()
83 #endif
84                 uint16_t pad[16];
85
86                 Cairo::RefPtr<Cairo::ImageSurface> _surface;
87
88         private:
89                 void assign_controls (M2Contols*) const;
90
91                 void set_lights (M2Contols*, uint8_t*) const;
92                 void set_pads (M2Contols*, uint8_t*) const;
93
94                 uint8_t _lights[79];
95                 uint8_t _img[4][265];
96 };
97 } /* namespace */
98
99 #endif