Compare commits
2 Commits
c73cf88081
...
f85551ae02
Author | SHA1 | Date | |
---|---|---|---|
|
f85551ae02 | ||
|
2811d3f042 |
22
src/main.go
22
src/main.go
@ -95,7 +95,7 @@ func setup(client *streamdeck.Client) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return setFeedbackIfNeeded(ctx, client, newSettings)
|
return setFeedback(ctx, client, newSettings)
|
||||||
})
|
})
|
||||||
|
|
||||||
action.RegisterHandler(streamdeck.WillDisappear, func(ctx context.Context, client *streamdeck.Client, event streamdeck.Event) error {
|
action.RegisterHandler(streamdeck.WillDisappear, func(ctx context.Context, client *streamdeck.Client, event streamdeck.Event) error {
|
||||||
@ -119,17 +119,14 @@ func setup(client *streamdeck.Client) {
|
|||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx = sdcontext.WithContext(ctx, ctxStr)
|
ctx = sdcontext.WithContext(ctx, ctxStr)
|
||||||
|
|
||||||
setFeedbackIfNeeded(ctx, client, newSettings)
|
setFeedback(ctx, client, newSettings)
|
||||||
}
|
}
|
||||||
|
_currentSettings = newSettings
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
func setFeedbackIfNeeded(ctx context.Context, client *streamdeck.Client, newSettings *volume.VolumeSettings) error {
|
func setFeedback(ctx context.Context, client *streamdeck.Client, newSettings *volume.VolumeSettings) error {
|
||||||
|
|
||||||
if _currentSettings.OutputVolume == newSettings.OutputVolume && _currentSettings.OutputMuted == newSettings.OutputMuted {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
payload := FeedbackPayload{}
|
payload := FeedbackPayload{}
|
||||||
|
|
||||||
@ -151,10 +148,19 @@ func setFeedbackIfNeeded(ctx context.Context, client *streamdeck.Client, newSett
|
|||||||
|
|
||||||
payload.Icon = ValueWithOpacity[any]{nil, opacity}
|
payload.Icon = ValueWithOpacity[any]{nil, opacity}
|
||||||
|
|
||||||
_currentSettings = newSettings
|
|
||||||
return client.SetFeedback(ctx, payload)
|
return client.SetFeedback(ctx, payload)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func setFeedbackIfNeeded(ctx context.Context, client *streamdeck.Client, newSettings *volume.VolumeSettings) error {
|
||||||
|
|
||||||
|
if _currentSettings.OutputVolume == newSettings.OutputVolume && _currentSettings.OutputMuted == newSettings.OutputMuted {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
_currentSettings = newSettings
|
||||||
|
return setFeedback(ctx, client, newSettings)
|
||||||
|
}
|
||||||
|
|
||||||
type FeedbackPayload struct {
|
type FeedbackPayload struct {
|
||||||
Value ValueWithOpacity[string] `json:"value"`
|
Value ValueWithOpacity[string] `json:"value"`
|
||||||
Indicator ValueWithOpacity[int] `json:"indicator"`
|
Indicator ValueWithOpacity[int] `json:"indicator"`
|
||||||
|
Loading…
Reference in New Issue
Block a user