summaryrefslogtreecommitdiff
path: root/libs/surfaces/maschine2/m2_dev_mk2.h
blob: a9adfa6b1aee057081afa2cee938d4ca25d84fa6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
 * Copyright (C) 2016 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, 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.
 */

#ifndef _ardour_surfaces_m2mk2_h_
#define _ardour_surfaces_m2mk2_h_

#include "m2device.h"

#include <cairomm/context.h>
#include <pangomm/layout.h>

namespace ArdourSurface {

class Maschine2Mk2 : public M2Device
{
	public:
		Maschine2Mk2 ();
		void clear (bool splash = false);
		void read (hid_device*, M2Contols*);
		void write (hid_device*, M2Contols*);
		Cairo::RefPtr<Cairo::ImageSurface> surface () { return _surface; }

	private:

#if defined(__GNUC__)
#define ATTRIBUTE_PACKED  __attribute__((__packed__))
#else
#define ATTRIBUTE_PACKED
#pragma pack(1)
#endif

		struct machine_mk2_input {
			unsigned int top_0           : 1; // 0
			unsigned int top_1           : 1;
			unsigned int top_2           : 1;
			unsigned int top_3           : 1;
			unsigned int top_4           : 1;
			unsigned int top_5           : 1;
			unsigned int top_6           : 1;
			unsigned int top_7           : 1;
			unsigned int top_control     : 1; // 8
			unsigned int top_step        : 1;
			unsigned int top_browse      : 1;
			unsigned int top_sampling    : 1;
			unsigned int top_left        : 1;
			unsigned int top_right       : 1;
			unsigned int top_all         : 1;
			unsigned int top_auto        : 1;
			unsigned int mst_volume      : 1; // 16
			unsigned int mst_swing       : 1;
			unsigned int mst_tempo       : 1;
			unsigned int mst_left        : 1;
			unsigned int mst_right       : 1;
			unsigned int mst_enter       : 1;
			unsigned int mst_note_repeat : 1;
			unsigned int mst_wheel       : 1;
			unsigned int groups_a        : 1; // 24
			unsigned int groups_b        : 1;
			unsigned int groups_c        : 1;
			unsigned int groups_d        : 1;
			unsigned int groups_e        : 1;
			unsigned int groups_f        : 1;
			unsigned int groups_g        : 1;
			unsigned int groups_h        : 1;
			unsigned int trs_restart     : 1; // 32
			unsigned int trs_left        : 1;
			unsigned int trs_right       : 1;
			unsigned int trs_grid        : 1;
			unsigned int trs_play        : 1;
			unsigned int trs_rec         : 1;
			unsigned int trs_erase       : 1;
			unsigned int trs_shift       : 1;
			unsigned int pads_scene      : 1; // 40
			unsigned int pads_pattern    : 1;
			unsigned int pads_mode       : 1;
			unsigned int pads_navigate   : 1;
			unsigned int pads_duplicate  : 1;
			unsigned int pads_select     : 1;
			unsigned int pads_solo       : 1;
			unsigned int pads_mute       : 1;
			unsigned int reserved        : 8; // 48
			unsigned int mst_wheel_pos   : 8; // 56  // range: 0..15
			uint16_t top_knobs[8];            // 64 ... 191 // range 0..999
		} ATTRIBUTE_PACKED ctrl_in;

#if (!defined __GNUC__)
#pragma pack()
#endif
		uint16_t pad[16];

		Cairo::RefPtr<Cairo::ImageSurface> _surface;

	private:
		void assign_controls (M2Contols*) const;

		void set_colors80 (M2Contols*, uint8_t*) const;
		void set_colors81 (M2Contols*, uint8_t*) const;
		void set_colors82 (M2Contols*, uint8_t*) const;

		uint8_t ctrl82[32];
		uint8_t ctrl81[57];
		uint8_t ctrl80[49];
		uint8_t _img[2][8][265];
};
} /* namespace */

#endif