Skip to content

Commit

Permalink
better disconnected device handling
Browse files Browse the repository at this point in the history
  • Loading branch information
xaviergodart committed Dec 24, 2024
1 parent 451755e commit 8bc0af8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion midi/midi.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func (m *midi) NewDevice(device, fallback string) Device {
}
}
return Device{
Name: m.Devices()[defaultDevice].String(),
Name: device,
ID: defaultDevice,
Fallback: true,
}
Expand Down
14 changes: 11 additions & 3 deletions ui/param/default_device.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package param

import (
"fmt"
"signls/core/field"
)

Expand All @@ -13,12 +14,19 @@ func (d DefaultDevice) Name() string {
}

func (d DefaultDevice) Help() string {
return ""
if !d.grid.MidiDevice().Enabled() {
return ""
} else if d.grid.MidiDevice().Fallback {
return fmt.Sprintf("disconnected: %s", d.grid.MidiDevice().Name)
}
return d.grid.MidiDevice().Name
}

func (d DefaultDevice) Display() string {
// TODO: handle disconnected as well
return d.grid.MidiDevice().Name
if d.grid.MidiDevice().Fallback {
return "??"
}
return fmt.Sprintf("%d", d.grid.MidiDevice().ID)
}

func (d DefaultDevice) Value() int {
Expand Down
2 changes: 1 addition & 1 deletion ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ func (m mainModel) View() string {
Render(m.help.View(m.keymap))

paramHelp := ""
if m.mode == EDIT {
if m.mode == EDIT || m.mode == CONFIG {
paramHelp = m.help.Styles.ShortDesc.
MarginLeft(16).
Render(m.activeParam().Help())
Expand Down

0 comments on commit 8bc0af8

Please sign in to comment.