More keyboard refactor.
This commit is contained in:
@@ -128,11 +128,7 @@ func (b *Barnard) OnTimestampToggle(ui *uiterm.Ui, key uiterm.Key) {
|
||||
}
|
||||
|
||||
func (b *Barnard) OnNoiseSuppressionToggle(ui *uiterm.Ui, key uiterm.Key) {
|
||||
enabled := !b.UserConfig.GetNoiseSuppressionEnabled()
|
||||
if err := b.UserConfig.SetNoiseSuppressionEnabled(enabled); err != nil {
|
||||
b.AddOutputLine("Noise suppression: could not save setting: " + err.Error())
|
||||
}
|
||||
b.NoiseSuppressor.SetEnabled(enabled)
|
||||
enabled := b.toggleNoiseSuppression()
|
||||
|
||||
if enabled {
|
||||
b.UpdateGeneralStatus("Noise suppression: ON", false)
|
||||
@@ -141,6 +137,15 @@ func (b *Barnard) OnNoiseSuppressionToggle(ui *uiterm.Ui, key uiterm.Key) {
|
||||
}
|
||||
}
|
||||
|
||||
func (b *Barnard) toggleNoiseSuppression() bool {
|
||||
enabled := !b.UserConfig.GetNoiseSuppressionEnabled()
|
||||
if err := b.UserConfig.SetNoiseSuppressionEnabled(enabled); err != nil {
|
||||
b.AddOutputLine("Noise suppression: could not save setting: " + err.Error())
|
||||
}
|
||||
b.NoiseSuppressor.SetEnabled(enabled)
|
||||
return enabled
|
||||
}
|
||||
|
||||
func (b *Barnard) OnAGCToggle(ui *uiterm.Ui, key uiterm.Key) {
|
||||
enabled := b.toggleAGC()
|
||||
|
||||
@@ -466,26 +471,35 @@ func (b *Barnard) OnMicVolumeDown(ui *uiterm.Ui, key uiterm.Key) {
|
||||
if b.ToneTest {
|
||||
return
|
||||
}
|
||||
b.withStream(func(stream *gumbleopenal.Stream) {
|
||||
stream.SetMicVolume(-0.1, true)
|
||||
b.UserConfig.SetMicVolume(stream.GetMicVolume())
|
||||
if err := b.UserConfig.SaveConfig(); err != nil {
|
||||
b.AddOutputLine("Microphone: could not save volume: " + err.Error())
|
||||
}
|
||||
})
|
||||
b.adjustMicVolume(-0.1)
|
||||
}
|
||||
|
||||
func (b *Barnard) OnMicVolumeUp(ui *uiterm.Ui, key uiterm.Key) {
|
||||
if b.ToneTest {
|
||||
return
|
||||
}
|
||||
b.adjustMicVolume(0.1)
|
||||
}
|
||||
|
||||
func (b *Barnard) adjustMicVolume(change float32) float32 {
|
||||
return b.setMicVolume(b.UserConfig.GetMicVolume() + change)
|
||||
}
|
||||
|
||||
func (b *Barnard) setMicVolume(volume float32) float32 {
|
||||
if volume < 0 {
|
||||
volume = 0
|
||||
}
|
||||
if volume > 1 {
|
||||
volume = 1
|
||||
}
|
||||
b.UserConfig.SetMicVolume(volume)
|
||||
b.withStream(func(stream *gumbleopenal.Stream) {
|
||||
stream.SetMicVolume(0.1, true)
|
||||
b.UserConfig.SetMicVolume(stream.GetMicVolume())
|
||||
if err := b.UserConfig.SaveConfig(); err != nil {
|
||||
b.AddOutputLine("Microphone: could not save volume: " + err.Error())
|
||||
}
|
||||
stream.SetMicVolume(volume, false)
|
||||
})
|
||||
if err := b.UserConfig.SaveConfig(); err != nil {
|
||||
b.AddOutputLine("Microphone: could not save volume: " + err.Error())
|
||||
}
|
||||
return volume
|
||||
}
|
||||
|
||||
func (b *Barnard) OnQuitPress(ui *uiterm.Ui, key uiterm.Key) {
|
||||
@@ -527,13 +541,23 @@ func (b *Barnard) OnScrollOutputDown(ui *uiterm.Ui, key uiterm.Key) {
|
||||
}
|
||||
|
||||
func (b *Barnard) OnScrollOutputTop(ui *uiterm.Ui, key uiterm.Key) {
|
||||
if !outputScrollAllowed(ui.Active()) {
|
||||
return
|
||||
}
|
||||
b.UiOutput.ScrollTop()
|
||||
}
|
||||
|
||||
func (b *Barnard) OnScrollOutputBottom(ui *uiterm.Ui, key uiterm.Key) {
|
||||
if !outputScrollAllowed(ui.Active()) {
|
||||
return
|
||||
}
|
||||
b.UiOutput.ScrollBottom()
|
||||
}
|
||||
|
||||
func outputScrollAllowed(activeView string) bool {
|
||||
return activeView != uiViewInput
|
||||
}
|
||||
|
||||
func (b *Barnard) OnFocusPress(ui *uiterm.Ui, key uiterm.Key) {
|
||||
active := b.Ui.Active()
|
||||
if active == uiViewInput {
|
||||
@@ -683,6 +707,7 @@ func (b *Barnard) OnUiInitialize(ui *uiterm.Ui) {
|
||||
b.Ui.AddCommandListener(b.CommandAdmin, "admin")
|
||||
b.Ui.AddKeyListener(b.OnFocusPress, b.Hotkeys.SwitchViews)
|
||||
b.Ui.AddKeyListener(b.OnAdminMenuPress, b.Hotkeys.AdminMenu)
|
||||
b.Ui.AddKeyListener(b.OnHelpMenuPress, b.Hotkeys.HelpMenu)
|
||||
b.Ui.AddKeyListener(b.OnVoiceToggle, b.Hotkeys.Talk)
|
||||
b.Ui.AddKeyListener(b.OnSelfMuteToggle, b.Hotkeys.SelfMuteToggle)
|
||||
b.Ui.AddKeyListener(b.OnTimestampToggle, b.Hotkeys.ToggleTimestamps)
|
||||
|
||||
Reference in New Issue
Block a user