13
0
livetrax/libs/surfaces/mackie/scripts/surface-cc-template.erb
Paul Davis 51625b2474 "merge" (i.e. wholesale import) 2.0-ongoing Mackie code and then fix to compile in 3.0 context
git-svn-id: svn://localhost/ardour2/branches/3.0@4315 d708f5d6-7413-0410-9779-e7cbd77b26cf
2008-12-12 22:55:03 +00:00

108 lines
3.0 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
Fader * fader = 0;
Pot * pot = 0;
Button * button = 0;
Led * led = 0;
% sf.controls.each do |control|
<%-
variable_name = control.class.name.downcase
class_name =
if control.name == 'jog'
'Jog'
else
control.class.name
end
-%>
group = groups["<%=control.group.name%>"];
<%= variable_name %> = new <%= class_name %> ( <%= control.id %>, <%= control.ordinal %>, "<%=control.name%>", *group );
<%= variable_name %>s[0x<%=control.id.to_hex %>] = <%= variable_name %>;
controls.push_back( <%= variable_name %> );
<%- if control.group.class != Strip -%>
controls_by_name["<%= control.name %>"] = <%= variable_name %>;
<%- end -%>
group->add( *<%= variable_name %> );
% 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.class.midi_zero_byte << 8 | 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 );
}