From 6fc79035f4440be8b218a0ff91c3e6848a478dc4 Mon Sep 17 00:00:00 2001 From: njanssen Date: Thu, 24 Sep 2020 22:31:07 +0200 Subject: Set input index to -1 (no input device) instead of wrapping to 0 when we've reached the end of the `Midi.inputs` array. Now relying on `midi.selectInput` to do all the work, including setting `Midi.inputIndex` - this make sure an existing MIDI message handler is removed from the previous input device before we switch to the next one (or no input device in case of index -1) --- desktop/sources/scripts/core/io/midi.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/desktop/sources/scripts/core/io/midi.js b/desktop/sources/scripts/core/io/midi.js index a0574dd..0cdb100 100644 --- a/desktop/sources/scripts/core/io/midi.js +++ b/desktop/sources/scripts/core/io/midi.js @@ -176,8 +176,8 @@ function Midi (client) { } this.selectNextInput = () => { - this.inputIndex = this.inputIndex < this.inputs.length ? this.inputIndex + 1 : 0 - this.selectInput(this.inputIndex) + const id = this.inputIndex < this.inputs.length-1 ? this.inputIndex + 1 : -1 + this.selectInput(id) client.update() } -- cgit v1.2.3