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 (
"context"
sdcontext "github.com/samwho/streamdeck/context"
sdcontext "code.encyclopediaofdaniel.com/dlprows/streamdeck-sdk/context"
)
type Action struct {

View File

@ -12,8 +12,8 @@ import (
"sync"
"time"
sdcontext "code.encyclopediaofdaniel.com/dlprows/streamdeck-sdk/context"
"github.com/gorilla/websocket"
sdcontext "github.com/samwho/streamdeck/context"
)
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}))
}
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 {
return client.send(NewEvent(ctx, ShowAlert, nil))
}

View File

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

View File

@ -4,7 +4,7 @@ import (
"context"
"encoding/json"
sdcontext "github.com/samwho/streamdeck/context"
sdcontext "code.encyclopediaofdaniel.com/dlprows/streamdeck-sdk/context"
)
type Event struct {
@ -35,9 +35,13 @@ const (
StreamDeckMini DeviceType = 1
StreamDeckXL DeviceType = 2
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)
if err != nil {
panic(err)

View File

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

View File

@ -11,8 +11,8 @@ import (
"os"
"time"
"github.com/samwho/streamdeck"
sdcontext "github.com/samwho/streamdeck/context"
"code.encyclopediaofdaniel.com/dlprows/streamdeck-sdk"
sdcontext "code.encyclopediaofdaniel.com/dlprows/streamdeck-sdk/context"
"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
import "encoding/json"
type LogMessagePayload struct {
Message string `json:"message"`
}
@ -28,10 +26,14 @@ type SwitchProfilePayload struct {
Profile string `json:"profile"`
}
type DidReceiveSettingsPayload struct {
Settings json.RawMessage `json:"settings,omitempty"`
Coordinates Coordinates `json:"coordinates,omitempty"`
IsInMultiAction bool `json:"isInMultiAction,omitempty"`
type SetFeedbackLayoutPayload struct {
Layout string `json:"layout"`
}
type DidReceiveSettingsPayload[T any] struct {
Settings T `json:"settings,omitempty"`
Coordinates Coordinates `json:"coordinates,omitempty"`
IsInMultiAction bool `json:"isInMultiAction,omitempty"`
}
type Coordinates struct {
@ -39,42 +41,69 @@ type Coordinates struct {
Row int `json:"row,omitempty"`
}
type DidReceiveGlobalSettingsPayload struct {
Settings json.RawMessage `json:"settings,omitempty"`
type DidReceiveGlobalSettingsPayload[T any] struct {
Settings T `json:"settings,omitempty"`
}
type KeyDownPayload struct {
Settings json.RawMessage `json:"settings,omitempty"`
Coordinates Coordinates `json:"coordinates,omitempty"`
State int `json:"state,omitempty"`
UserDesiredState int `json:"userDesiredState,omitempty"`
IsInMultiAction bool `json:"isInMultiAction,omitempty"`
type KeyDownPayload[T any] struct {
Settings T `json:"settings,omitempty"`
Coordinates Coordinates `json:"coordinates,omitempty"`
State int `json:"state,omitempty"`
UserDesiredState int `json:"userDesiredState,omitempty"`
IsInMultiAction bool `json:"isInMultiAction,omitempty"`
}
type KeyUpPayload struct {
Settings json.RawMessage `json:"settings,omitempty"`
Coordinates Coordinates `json:"coordinates,omitempty"`
State int `json:"state,omitempty"`
UserDesiredState int `json:"userDesiredState,omitempty"`
IsInMultiAction bool `json:"isInMultiAction,omitempty"`
type KeyUpPayload[T any] struct {
Settings T `json:"settings,omitempty"`
Coordinates Coordinates `json:"coordinates,omitempty"`
State int `json:"state,omitempty"`
UserDesiredState int `json:"userDesiredState,omitempty"`
IsInMultiAction bool `json:"isInMultiAction,omitempty"`
}
type WillAppearPayload struct {
Settings json.RawMessage `json:"settings,omitempty"`
Coordinates Coordinates `json:"coordinates,omitempty"`
State int `json:"state,omitempty"`
IsInMultiAction bool `json:"isInMultiAction,omitempty"`
// TouchTapPayload A json object
type TouchTapPayload[T any] struct {
Settings T `json:"settings,omitempty"`
Coordinates Coordinates `json:"coordinates,omitempty"`
TapPos [2]int `json:"tapPos,omitempty"`
Hold bool `json:"hold,omitempty"`
}
type WillDisappearPayload struct {
Settings json.RawMessage `json:"settings,omitempty"`
Coordinates Coordinates `json:"coordinates,omitempty"`
State int `json:"state,omitempty"`
IsInMultiAction bool `json:"isInMultiAction,omitempty"`
type DialDownPayload[T any] struct {
Settings T `json:"settings,omitempty"`
Coordinates Coordinates `json:"coordinates,omitempty"`
Controller string `json:"controller,omitempty"`
}
type TitleParametersDidChangePayload struct {
Settings json.RawMessage `json:"settings,omitempty"`
type DialUpPayload[T any] struct {
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"`
State int `json:"state,omitempty"`
Title string `json:"title,omitempty"`