13
0
livetrax/libs/surfaces/mackie/scripts/surface-cc-template.erb
Paul Davis 45d3ec1437 merged with 1697 revision of trunk (which is post-rc1 but pre-rc2
git-svn-id: svn://localhost/ardour2/branches/2.1-staging@1698 d708f5d6-7413-0410-9779-e7cbd77b26cf
2007-04-11 13:07:51 +00:00

96 lines
2.7 KiB
Plaintext

<%#
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 );
}