adding support for stream deck plus

This commit is contained in:
Daniel Prows 2023-08-08 15:34:37 -06:00
parent 2b866fdcb4
commit afaa02f8b2
9 changed files with 94 additions and 39 deletions

View File

@ -3,7 +3,7 @@ package streamdeck
import ( import (
"context" "context"
sdcontext "github.com/samwho/streamdeck/context" sdcontext "code.encyclopediaofdaniel.com/dlprows/streamdeck-sdk/context"
) )
type Action struct { type Action struct {

View File

@ -12,8 +12,8 @@ import (
"sync" "sync"
"time" "time"
sdcontext "code.encyclopediaofdaniel.com/dlprows/streamdeck-sdk/context"
"github.com/gorilla/websocket" "github.com/gorilla/websocket"
sdcontext "github.com/samwho/streamdeck/context"
) )
var ( var (
@ -180,6 +180,15 @@ func (client *Client) SetImage(ctx context.Context, base64image string, target T
return client.send(NewEvent(ctx, SetImage, SetImagePayload{Base64Image: base64image, Target: target})) return client.send(NewEvent(ctx, SetImage, SetImagePayload{Base64Image: base64image, Target: target}))
} }
func (client *Client) SetFeedback(ctx context.Context, payload any) error {
return client.send(NewEvent(ctx, SetFeedback, payload))
}
// SetFeedbackLayout
func (client *Client) SetFeedbackLayout(ctx context.Context, layout string) error {
return client.send(NewEvent(ctx, SetImage, SetFeedbackLayoutPayload{Layout: layout}))
}
func (client *Client) ShowAlert(ctx context.Context) error { func (client *Client) ShowAlert(ctx context.Context) error {
return client.send(NewEvent(ctx, ShowAlert, nil)) return client.send(NewEvent(ctx, ShowAlert, nil))
} }

View File

@ -5,6 +5,10 @@ const (
DidReceiveGlobalSettings = "didReceiveGlobalSettings" DidReceiveGlobalSettings = "didReceiveGlobalSettings"
KeyDown = "keyDown" KeyDown = "keyDown"
KeyUp = "keyUp" KeyUp = "keyUp"
TouchTap = "touchTap"
DialDown = "dialDown"
DialUp = "dialUp"
DialRotate = "dialRotate"
WillAppear = "willAppear" WillAppear = "willAppear"
WillDisappear = "willDisappear" WillDisappear = "willDisappear"
TitleParametersDidChange = "titleParametersDidChange" TitleParametersDidChange = "titleParametersDidChange"
@ -26,6 +30,8 @@ const (
LogMessage = "logMessage" LogMessage = "logMessage"
SetTitle = "setTitle" SetTitle = "setTitle"
SetImage = "setImage" SetImage = "setImage"
SetFeedback = "setFeedback"
SetFeedbackLayout = "setFeedbackLayout"
ShowAlert = "showAlert" ShowAlert = "showAlert"
ShowOk = "showOk" ShowOk = "showOk"
SetState = "setState" SetState = "setState"

View File

@ -4,7 +4,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
sdcontext "github.com/samwho/streamdeck/context" sdcontext "code.encyclopediaofdaniel.com/dlprows/streamdeck-sdk/context"
) )
type Event struct { type Event struct {
@ -35,9 +35,13 @@ const (
StreamDeckMini DeviceType = 1 StreamDeckMini DeviceType = 1
StreamDeckXL DeviceType = 2 StreamDeckXL DeviceType = 2
StreamDeckMobile DeviceType = 3 StreamDeckMobile DeviceType = 3
CorsairGKeys DeviceType = 4
StreamDeckPedal DeviceType = 5
CorsairVoyager DeviceType = 6
StreamDeckPlus DeviceType = 7
) )
func NewEvent(ctx context.Context, name string, payload interface{}) Event { func NewEvent(ctx context.Context, name string, payload any) Event {
p, err := json.Marshal(payload) p, err := json.Marshal(payload)
if err != nil { if err != nil {
panic(err) panic(err)

View File

@ -11,7 +11,7 @@ import (
"os" "os"
"strconv" "strconv"
"github.com/samwho/streamdeck" "code.encyclopediaofdaniel.com/dlprows/streamdeck-sdk"
) )
type Settings struct { type Settings struct {

View File

@ -11,8 +11,8 @@ import (
"os" "os"
"time" "time"
"github.com/samwho/streamdeck" "code.encyclopediaofdaniel.com/dlprows/streamdeck-sdk"
sdcontext "github.com/samwho/streamdeck/context" sdcontext "code.encyclopediaofdaniel.com/dlprows/streamdeck-sdk/context"
"github.com/shirou/gopsutil/cpu" "github.com/shirou/gopsutil/cpu"
) )

5
go.mod Normal file
View File

@ -0,0 +1,5 @@
module code.encyclopediaofdaniel.com/dlprows/streamdeck-sdk
go 1.20
require github.com/gorilla/websocket v1.5.0 // indirect

2
go.sum Normal file
View File

@ -0,0 +1,2 @@
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=

View File

@ -1,7 +1,5 @@
package streamdeck package streamdeck
import "encoding/json"
type LogMessagePayload struct { type LogMessagePayload struct {
Message string `json:"message"` Message string `json:"message"`
} }
@ -28,10 +26,14 @@ type SwitchProfilePayload struct {
Profile string `json:"profile"` Profile string `json:"profile"`
} }
type DidReceiveSettingsPayload struct { type SetFeedbackLayoutPayload struct {
Settings json.RawMessage `json:"settings,omitempty"` Layout string `json:"layout"`
Coordinates Coordinates `json:"coordinates,omitempty"` }
IsInMultiAction bool `json:"isInMultiAction,omitempty"`
type DidReceiveSettingsPayload[T any] struct {
Settings T `json:"settings,omitempty"`
Coordinates Coordinates `json:"coordinates,omitempty"`
IsInMultiAction bool `json:"isInMultiAction,omitempty"`
} }
type Coordinates struct { type Coordinates struct {
@ -39,42 +41,69 @@ type Coordinates struct {
Row int `json:"row,omitempty"` Row int `json:"row,omitempty"`
} }
type DidReceiveGlobalSettingsPayload struct { type DidReceiveGlobalSettingsPayload[T any] struct {
Settings json.RawMessage `json:"settings,omitempty"` Settings T `json:"settings,omitempty"`
} }
type KeyDownPayload struct { type KeyDownPayload[T any] struct {
Settings json.RawMessage `json:"settings,omitempty"` Settings T `json:"settings,omitempty"`
Coordinates Coordinates `json:"coordinates,omitempty"` Coordinates Coordinates `json:"coordinates,omitempty"`
State int `json:"state,omitempty"` State int `json:"state,omitempty"`
UserDesiredState int `json:"userDesiredState,omitempty"` UserDesiredState int `json:"userDesiredState,omitempty"`
IsInMultiAction bool `json:"isInMultiAction,omitempty"` IsInMultiAction bool `json:"isInMultiAction,omitempty"`
} }
type KeyUpPayload struct { type KeyUpPayload[T any] struct {
Settings json.RawMessage `json:"settings,omitempty"` Settings T `json:"settings,omitempty"`
Coordinates Coordinates `json:"coordinates,omitempty"` Coordinates Coordinates `json:"coordinates,omitempty"`
State int `json:"state,omitempty"` State int `json:"state,omitempty"`
UserDesiredState int `json:"userDesiredState,omitempty"` UserDesiredState int `json:"userDesiredState,omitempty"`
IsInMultiAction bool `json:"isInMultiAction,omitempty"` IsInMultiAction bool `json:"isInMultiAction,omitempty"`
} }
type WillAppearPayload struct { // TouchTapPayload A json object
Settings json.RawMessage `json:"settings,omitempty"` type TouchTapPayload[T any] struct {
Coordinates Coordinates `json:"coordinates,omitempty"` Settings T `json:"settings,omitempty"`
State int `json:"state,omitempty"` Coordinates Coordinates `json:"coordinates,omitempty"`
IsInMultiAction bool `json:"isInMultiAction,omitempty"` TapPos [2]int `json:"tapPos,omitempty"`
Hold bool `json:"hold,omitempty"`
} }
type WillDisappearPayload struct { type DialDownPayload[T any] struct {
Settings json.RawMessage `json:"settings,omitempty"` Settings T `json:"settings,omitempty"`
Coordinates Coordinates `json:"coordinates,omitempty"` Coordinates Coordinates `json:"coordinates,omitempty"`
State int `json:"state,omitempty"` Controller string `json:"controller,omitempty"`
IsInMultiAction bool `json:"isInMultiAction,omitempty"`
} }
type TitleParametersDidChangePayload struct { type DialUpPayload[T any] struct {
Settings json.RawMessage `json:"settings,omitempty"` Settings T `json:"settings,omitempty"`
Coordinates Coordinates `json:"coordinates,omitempty"`
Controller string `json:"controller,omitempty"`
}
type DialRotatePayload[T any] struct {
Settings T `json:"settings,omitempty"`
Coordinates Coordinates `json:"coordinates,omitempty"`
Ticks int `json:"ticks,omitempty"`
Pressed bool `json:"pressed,omitempty"`
}
type WillAppearPayload[T any] struct {
Settings T `json:"settings,omitempty"`
Coordinates Coordinates `json:"coordinates,omitempty"`
State int `json:"state,omitempty"`
IsInMultiAction bool `json:"isInMultiAction,omitempty"`
}
type WillDisappearPayload[T any] struct {
Settings T `json:"settings,omitempty"`
Coordinates Coordinates `json:"coordinates,omitempty"`
State int `json:"state,omitempty"`
IsInMultiAction bool `json:"isInMultiAction,omitempty"`
}
type TitleParametersDidChangePayload[T any] struct {
Settings T `json:"settings,omitempty"`
Coordinates Coordinates `json:"coordinates,omitempty"` Coordinates Coordinates `json:"coordinates,omitempty"`
State int `json:"state,omitempty"` State int `json:"state,omitempty"`
Title string `json:"title,omitempty"` Title string `json:"title,omitempty"`