+ using namespace MIDI::Name;
+ boost::shared_ptr<MasterDeviceNames> device_names = get_device_names();
+
+ if (device_names && !device_names->controls().empty()) {
+ /* Controllers names available in midnam file, generate fancy menu */
+ unsigned n_items = 0;
+ unsigned n_groups = 0;
+
+ /* TODO: This is not correct, should look up the currently applicable ControlNameList
+ and only build a menu for that one. */
+ for (MasterDeviceNames::ControlNameLists::const_iterator l = device_names->controls().begin();
+ l != device_names->controls().end(); ++l) {
+ boost::shared_ptr<ControlNameList> name_list = l->second;
+ Menu* ctl_menu = NULL;
+
+ for (ControlNameList::Controls::const_iterator c = name_list->controls().begin();
+ c != name_list->controls().end();) {
+ const uint16_t ctl = c->second->number();
+ if (ctl != MIDI_CTL_MSB_BANK && ctl != MIDI_CTL_LSB_BANK) {
+ /* Skip bank select controllers since they're handled specially */
+ if (n_items == 0) {
+ /* Create a new submenu */
+ ctl_menu = manage (new Menu);
+ }
+
+ MenuList& ctl_items (ctl_menu->items());
+ if (chn_cnt > 1) {
+ add_multi_channel_controller_item(ctl_items, ctl, c->second->name());
+ } else {
+ add_single_channel_controller_item(ctl_items, ctl, c->second->name());