summaryrefslogtreecommitdiff
path: root/libs/surfaces/mackie/scripts/surface-cc-template.erb
diff options
context:
space:
mode:
Diffstat (limited to 'libs/surfaces/mackie/scripts/surface-cc-template.erb')
-rw-r--r--libs/surfaces/mackie/scripts/surface-cc-template.erb95
1 files changed, 95 insertions, 0 deletions
diff --git a/libs/surfaces/mackie/scripts/surface-cc-template.erb b/libs/surfaces/mackie/scripts/surface-cc-template.erb
new file mode 100644
index 0000000000..3b29be3249
--- /dev/null
+++ b/libs/surfaces/mackie/scripts/surface-cc-template.erb
@@ -0,0 +1,95 @@
+<%#
+ Copyright (C) 2006,2007 John Anderson
+
+ 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+-%>
+/*
+ Generated by scripts/generate-surface.rb
+*/
+
+#include "<%= sf.name.downcase %>_surface.h"
+
+#include "controls.h"
+#include "mackie_button_handler.h"
+
+using namespace Mackie;
+
+void Mackie::<%= sf.name %>Surface::init_controls()
+{
+ // intialise groups and strips
+ Group * group = 0;
+
+ // make sure there are enough strips
+ strips.resize( <%= sf.groups.values.find_all{|x| x.name =~ /strip/}.size %> );
+
+% sf.groups.values.each do |group|
+ <%- if group.class == Strip -%>
+ <%- if group.name == 'master' -%>
+ group = new MasterStrip ( "<%=group.name%>", 0 );
+ <%- else -%>
+ group = new <%= group.class.name %> ( "<%=group.name%>", <%=group.ordinal - 1%> );
+ <%- end -%>
+ <%- else -%>
+ group = new <%= group.class.name %> ( "<%=group.name%>" );
+ <%- end -%>
+ groups["<%=group.name%>"] = group;
+ <%- if group.class == Strip -%>
+ strips[<%=group.ordinal - 1%>] = dynamic_cast<Strip*>( group );
+ <%- end -%>
+
+% end
+
+ // initialise controls
+ Control * control = 0;
+
+% sf.controls.each do |control|
+ group = groups["<%=control.group.name%>"];
+ control = new <%= control.class.name %> ( <%= control.id %>, <%= control.ordinal %>, "<%=control.name%>", *group );
+ <%=control.class.name.downcase%>s[0x<%=control.id.to_hex %>] = control;
+ controls.push_back( control );
+ <%- if control.group.class != Strip -%>
+ controls_by_name["<%= control.name %>"] = control;
+ <%- end -%>
+ group->add( *control );
+
+% end
+}
+
+void Mackie::<%= sf.name %>Surface::handle_button( MackieButtonHandler & mbh, ButtonState bs, Button & button )
+{
+ if ( bs != press && bs != release )
+ {
+ mbh.update_led( button, none );
+ return;
+ }
+
+ LedState ls;
+ switch ( button.id() )
+ {
+<%-
+buttons = sf.controls.find_all{|x| x.class == Button && x.group.class != Strip}
+buttons.each do |button|
+%>
+ case 0x<%= button.id.to_hex %>: // <%= button.name %>
+ switch ( bs ) {
+ case press: ls = mbh.<%= button.name %>_press( button ); break;
+ case release: ls = mbh.<%= button.name %>_release( button ); break;
+ case neither: break;
+ }
+ break;
+<% end %>
+ }
+ mbh.update_led( button, ls );
+}