Skeleton for NI Maschine2 Surface
[ardour.git] / libs / surfaces / maschine2 / m2_dev_mk2.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_m2mk2_h_
20 #define _ardour_surfaces_m2mk2_h_
21
22 #include "m2device.h"
23
24 #include <cairomm/context.h>
25 #include <pangomm/layout.h>
26
27 namespace ArdourSurface {
28
29 class Maschine2Mk2 : public M2Device
30 {
31         public:
32                 Maschine2Mk2 ();
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 top_0           : 1; // 0
49                         unsigned int top_1           : 1;
50                         unsigned int top_2           : 1;
51                         unsigned int top_3           : 1;
52                         unsigned int top_4           : 1;
53                         unsigned int top_5           : 1;
54                         unsigned int top_6           : 1;
55                         unsigned int top_7           : 1;
56                         unsigned int top_control     : 1; // 8
57                         unsigned int top_step        : 1;
58                         unsigned int top_browse      : 1;
59                         unsigned int top_sampling    : 1;
60                         unsigned int top_left        : 1;
61                         unsigned int top_right       : 1;
62                         unsigned int top_all         : 1;
63                         unsigned int top_auto        : 1;
64                         unsigned int mst_volume      : 1; // 16
65                         unsigned int mst_swing       : 1;
66                         unsigned int mst_tempo       : 1;
67                         unsigned int mst_left        : 1;
68                         unsigned int mst_right       : 1;
69                         unsigned int mst_enter       : 1;
70                         unsigned int mst_note_repeat : 1;
71                         unsigned int mst_wheel       : 1;
72                         unsigned int groups_a        : 1; // 24
73                         unsigned int groups_b        : 1;
74                         unsigned int groups_c        : 1;
75                         unsigned int groups_d        : 1;
76                         unsigned int groups_e        : 1;
77                         unsigned int groups_f        : 1;
78                         unsigned int groups_g        : 1;
79                         unsigned int groups_h        : 1;
80                         unsigned int trs_restart     : 1; // 32
81                         unsigned int trs_left        : 1;
82                         unsigned int trs_right       : 1;
83                         unsigned int trs_grid        : 1;
84                         unsigned int trs_play        : 1;
85                         unsigned int trs_rec         : 1;
86                         unsigned int trs_erase       : 1;
87                         unsigned int trs_shift       : 1;
88                         unsigned int pads_scene      : 1; // 40
89                         unsigned int pads_pattern    : 1;
90                         unsigned int pads_mode       : 1;
91                         unsigned int pads_navigate   : 1;
92                         unsigned int pads_duplicate  : 1;
93                         unsigned int pads_select     : 1;
94                         unsigned int pads_solo       : 1;
95                         unsigned int pads_mute       : 1;
96                         unsigned int reserved        : 8; // 48
97                         unsigned int mst_wheel_pos   : 8; // 56  // range: 0..15
98                         uint16_t top_knobs[8];            // 64 ... 191 // range 0..999
99                 } ATTRIBUTE_PACKED ctrl_in;
100
101 #if (!defined __GNUC__)
102 #pragma pack()
103 #endif
104                 uint16_t pad[16];
105
106                 Cairo::RefPtr<Cairo::ImageSurface> _surface;
107
108         private:
109                 void assign_controls (M2Contols*) const;
110
111                 void set_colors80 (M2Contols*, uint8_t*) const;
112                 void set_colors81 (M2Contols*, uint8_t*) const;
113                 void set_colors82 (M2Contols*, uint8_t*) const;
114
115                 uint8_t ctrl82[32];
116                 uint8_t ctrl81[57];
117                 uint8_t ctrl80[49];
118                 uint8_t _img[2][8][265];
119 };
120 } /* namespace */
121
122 #endif