Lots + MIDI implementation
This commit is contained in:
34
src/input.rs
34
src/input.rs
@@ -1270,6 +1270,40 @@ fn handle_options_page(ctx: &mut InputContext, key: KeyEvent) -> InputResult {
|
||||
let delta = if key.code == KeyCode::Left { -1.0 } else { 1.0 };
|
||||
ctx.link.set_quantum(ctx.link.quantum() + delta);
|
||||
}
|
||||
OptionsFocus::MidiOutput => {
|
||||
let devices = crate::midi::list_midi_outputs();
|
||||
if !devices.is_empty() {
|
||||
let current = ctx.app.midi.selected_output.unwrap_or(0);
|
||||
let new_idx = if key.code == KeyCode::Left {
|
||||
if current == 0 { devices.len() - 1 } else { current - 1 }
|
||||
} else {
|
||||
(current + 1) % devices.len()
|
||||
};
|
||||
if ctx.app.midi.connect_output(new_idx).is_ok() {
|
||||
ctx.dispatch(AppCommand::SetStatus(format!(
|
||||
"MIDI output: {}",
|
||||
devices[new_idx].name
|
||||
)));
|
||||
}
|
||||
}
|
||||
}
|
||||
OptionsFocus::MidiInput => {
|
||||
let devices = crate::midi::list_midi_inputs();
|
||||
if !devices.is_empty() {
|
||||
let current = ctx.app.midi.selected_input.unwrap_or(0);
|
||||
let new_idx = if key.code == KeyCode::Left {
|
||||
if current == 0 { devices.len() - 1 } else { current - 1 }
|
||||
} else {
|
||||
(current + 1) % devices.len()
|
||||
};
|
||||
if ctx.app.midi.connect_input(new_idx).is_ok() {
|
||||
ctx.dispatch(AppCommand::SetStatus(format!(
|
||||
"MIDI input: {}",
|
||||
devices[new_idx].name
|
||||
)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ctx.app.save_settings(ctx.link);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user