2 Copyright (C) 2006,2007 John Anderson
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.
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.
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
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 Generated by scripts/generate-surface.rb
22 #include "<%= sf.name.downcase %>_surface.h"
25 #include "mackie_button_handler.h"
27 using namespace Mackie;
29 void Mackie::<%= sf.name %>Surface::init_controls()
31 // intialise groups and strips
34 // make sure there are enough strips
35 strips.resize( <%= sf.groups.values.find_all{|x| x.name =~ /strip/}.size %> );
37 % sf.groups.values.each do |group|
38 <%- if group.class == Strip -%>
39 <%- if group.name == 'master' -%>
40 group = new MasterStrip ( "<%=group.name%>", 0 );
42 group = new <%= group.class.name %> ( "<%=group.name%>", <%=group.ordinal - 1%> );
45 group = new <%= group.class.name %> ( "<%=group.name%>" );
47 groups["<%=group.name%>"] = group;
48 <%- if group.class == Strip -%>
49 strips[<%=group.ordinal - 1%>] = dynamic_cast<Strip*>( group );
54 // initialise controls
55 Control * control = 0;
57 % sf.controls.each do |control|
58 group = groups["<%=control.group.name%>"];
59 control = new <%= control.class.name %> ( <%= control.id %>, <%= control.ordinal %>, "<%=control.name%>", *group );
60 <%=control.class.name.downcase%>s[0x<%=control.id.to_hex %>] = control;
61 controls.push_back( control );
62 <%- if control.group.class != Strip -%>
63 controls_by_name["<%= control.name %>"] = control;
65 group->add( *control );
70 void Mackie::<%= sf.name %>Surface::handle_button( MackieButtonHandler & mbh, ButtonState bs, Button & button )
72 if ( bs != press && bs != release )
74 mbh.update_led( button, none );
79 switch ( button.id() )
82 buttons = sf.controls.find_all{|x| x.class == Button && x.group.class != Strip}
83 buttons.each do |button|
85 case 0x<%= button.id.to_hex %>: // <%= button.name %>
87 case press: ls = mbh.<%= button.name %>_press( button ); break;
88 case release: ls = mbh.<%= button.name %>_release( button ); break;
94 mbh.update_led( button, ls );