return strip_count;
}
-void
+int
MackieControlProtocol::switch_banks (uint32_t initial, bool force)
{
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("switch banking to start at %1 force ? %2 current = %3\n", initial, force, _current_initial_bank));
if (initial == _current_initial_bank && !force) {
- return;
+ /* everything is as it should be */
+ return 0;
}
Sorted sorted = get_sorted_routes();
uint32_t strip_cnt = n_strips (false); // do not include locked strips
// in this count
+ if (initial >= sorted.size()) {
+ /* too high, we can't get there */
+ return -1;
+ }
+
if (sorted.size() <= strip_cnt && _current_initial_bank == 0 && !force) {
/* no banking - not enough routes to fill all strips and we're
* not at the first one.
*/
- return;
+ return -1;
}
+
_current_initial_bank = initial;
_current_selected_track = -1;
// Map current bank of routes onto each surface(+strip)
- if (_current_initial_bank <= sorted.size()) {
+ if (_current_initial_bank < sorted.size()) {
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("switch to %1, %2, available routes %3 on %4 surfaces\n",
_current_initial_bank, strip_cnt, sorted.size(),
(*si)->map_routes (routes);
}
+
+ } else {
+ return -1;
}
/* make sure selection is correct */
/* current bank has not been saved */
session->set_dirty();
+
+ return 0;
}
int
// do the initial bank switch to connect signals
// _current_initial_bank is initialised by set_state
- switch_banks (_current_initial_bank, true);
+ (void) switch_banks (_current_initial_bank, true);
DEBUG_TRACE (DEBUG::MackieControl, "MackieControlProtocol::update_surfaces() finished\n");
}
state_version = version;
}
- switch_banks (bank, true);
+ (void) switch_banks (bank, true);
DEBUG_TRACE (DEBUG::MackieControl, "MackieControlProtocol::set_state done\n");
if (sorted.size() - _current_initial_bank < sz) {
// but don't shift backwards past the zeroth channel
if (sorted.size() < sz) { // avoid unsigned math mistake below
- switch_banks(0, true);
+ (void) switch_banks(0, true);
} else {
- switch_banks (max((Sorted::size_type) 0, sorted.size() - sz), true);
+ (void) switch_banks (max((Sorted::size_type) 0, sorted.size() - sz), true);
}
} else {
// Otherwise just refresh the current bank
void
MackieControlProtocol::set_view_mode (ViewMode m)
{
- _last_bank[_view_mode] = _current_initial_bank;
+ ViewMode old_view_mode = _view_mode;
_view_mode = m;
+ if (switch_banks(_last_bank[m], true)) {
+ _view_mode = old_view_mode;
+ return;
+ }
+
+ _last_bank[_view_mode] = _current_initial_bank;
/* leave subview mode, whatever it was */
set_subview_mode (None, boost::shared_ptr<Route>());
-
- switch_banks(_last_bank[_view_mode], true);
display_view_mode ();
}
if (create_surfaces ()) {
return -1;
}
- switch_banks (_current_initial_bank, true);
+ (void) switch_banks (_current_initial_bank, true);
needs_ipmidi_restart = false;
return 0;
}
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("bank left with current initial = %1 nstrips = %2 tracks/busses = %3\n",
_current_initial_bank, strip_cnt, sorted.size()));
if (_current_initial_bank > 0) {
- switch_banks ((_current_initial_bank - 1) / strip_cnt * strip_cnt);
+ (void) switch_banks ((_current_initial_bank - 1) / strip_cnt * strip_cnt);
} else {
- switch_banks (0);
+ (void) switch_banks (0);
}
LedState
MackieControlProtocol::left_release (Button &)
{
- return off;
+ return none;
}
LedState
if (_current_initial_bank < max_bank) {
uint32_t new_initial = (_current_initial_bank / strip_cnt * strip_cnt) + strip_cnt;
-
- switch_banks (new_initial);
- } else {
- switch_banks (max_bank);
+ (void) switch_banks (new_initial);
}
- return on;
+ return none;
}
LedState
MackieControlProtocol::right_release (Button &)
{
- if (zoom_mode()) {
-
- }
-
- return off;
+ return none;
}
LedState
bank_num = 8 + basic_bank_num;
}
- switch_banks (n_strips() * bank_num);
+ (void) switch_banks (n_strips() * bank_num);
return on;
}