streamdeck

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var WsClient *websocket.Conn

Functions

func DispatchEvent

func DispatchEvent(event StreamDeckEvent)

func HandleEvent

func HandleEvent(data []byte)

func RegisterAction

func RegisterAction(action Action)

func SendEventToStreamDeck

func SendEventToStreamDeck(response interface{}) error

func StartPlugin

func StartPlugin()

Types

type Action

type Action interface {
	GetUUID() string
}

type ActionAssociatedEvent

type ActionAssociatedEvent struct {
	Event   string `json:"event"`
	Action  string `json:"action"`
	Context string `json:"context"`
	Device  string `json:"device,omitempty"`
}

func (*ActionAssociatedEvent) GetAction

func (e *ActionAssociatedEvent) GetAction() (string, bool)

func (*ActionAssociatedEvent) GetContext added in v0.2.0

func (e *ActionAssociatedEvent) GetContext() string

func (*ActionAssociatedEvent) GetEventType

func (e *ActionAssociatedEvent) GetEventType() string

func (*ActionAssociatedEvent) GetGlobalSettings added in v0.2.0

func (e *ActionAssociatedEvent) GetGlobalSettings() (GlobalSettings, error)

Gets the global settings associated with the plugin. Causes DidReceiveGlobalSettings to be emitted.

Usage:

globalSettings, err := e.GetGlobalSettings()

Docs: https://docs.elgato.com/sdk/plugins/events-sent#getglobalsettings

func (*ActionAssociatedEvent) GetSettings

func (e *ActionAssociatedEvent) GetSettings() (ActionSettings, error)

Gets the settings associated with an instance of an action. Causes DidReceiveSettings to be emitted.

Usage:

settings, err := e.GetSettings()

Docs: https://docs.elgato.com/sdk/plugins/events-sent#getsettings

func (*ActionAssociatedEvent) IsActionAssociated

func (e *ActionAssociatedEvent) IsActionAssociated() bool

func (*ActionAssociatedEvent) LogMessage

func (e *ActionAssociatedEvent) LogMessage(message string) error

Logs a message to the file-system.

Usage:

e.LogMessage("Button was clicked!")

Docs: https://docs.elgato.com/sdk/plugins/events-sent#logmessage

func (*ActionAssociatedEvent) OpenUrl

func (e *ActionAssociatedEvent) OpenUrl(url string) error

Opens the URL in the user's default browser.

Usage:

e.OpenUrl("https://www.example.com")

Docs: https://docs.elgato.com/sdk/plugins/events-sent#openurl

func (*ActionAssociatedEvent) SendToPropertyInspector

func (e *ActionAssociatedEvent) SendToPropertyInspector(payload map[string]any) error

Sends a message to the property inspector.

Usage:

e.SetState(map[string]any{}{
	"arbitrary": "value",
})

Docs: https://docs.elgato.com/sdk/plugins/events-sent#sendtopropertyinspector

func (*ActionAssociatedEvent) SetGlobalSettings added in v0.2.0

func (e *ActionAssociatedEvent) SetGlobalSettings(settings map[string]any) error

Update settings associated with action The plugin and Property Inspector can save persistent data globally. The data will be saved securely to the Keychain on macOS and the Credential Store on Windows. This API can be used to save tokens that should be available to every action in the plugin.

Parameters: - settings: A map[string]any which is persistently saved persistently saved globally.

Usage:

newSettings := map[string]any{
	"apikey": "mX8ulcBHYmMniSshmB59"
}
e.setGlobalSettings(newSettings)

Docs: https://docs.elgato.com/sdk/plugins/events-sent#setglobalsettings

func (*ActionAssociatedEvent) SetImage

func (e *ActionAssociatedEvent) SetImage(base64image string, options ...uint8) error

Sets the image associated with an action instance.

Usage:

e.SetImage("Button was clicked!")

Docs: https://docs.elgato.com/sdk/plugins/events-sent#setimage

func (*ActionAssociatedEvent) SetSettings

func (e *ActionAssociatedEvent) SetSettings(settings map[string]any) error

Sets the settings associated with an instance of an action. Parameters: - settings: A map[string]any which is persistently saved as a json for the action's instance.

Usage:

newSettings := map[string]any{
	"apikey": "mX8ulcBHYmMniSshmB59"
}
e.SetSettings(newSettings)

Docs: https://docs.elgato.com/sdk/plugins/events-sent#setsettings

func (*ActionAssociatedEvent) SetState

func (e *ActionAssociatedEvent) SetState(state uint8) error

Sets the current state of an action instance.

Usage:

e.SetState(1)

Docs: https://docs.elgato.com/sdk/plugins/events-sent#setstate

func (*ActionAssociatedEvent) SetTitle

func (e *ActionAssociatedEvent) SetTitle(title string, options ...uint8) error

Sets the title displayed for an instance of an action.

Parameters:

  • title: The new title to be displayed on the button.
  • options: Optional integers where the first value is the target and the second is the state. Both default to 0 if not provided.

Usage:

e.SetTitle("New Title")                // Default target and state
e.SetTitle("New Title", 1)             // Specified target, default state
e.SetTitle("New Title", 1, 2)          // Specified target and state

Docs: https://docs.elgato.com/sdk/plugins/events-sent#settitle

func (*ActionAssociatedEvent) ShowAlert

func (e *ActionAssociatedEvent) ShowAlert() error

Temporarily shows an alert (i.e. warning), in the form of an exclamation mark in a yellow triangle, on the action instance. Used to provide visual feedback when an action failed.

Usage:

e.ShowAlert()

Docs: https://docs.elgato.com/sdk/plugins/events-sent#showalert

func (*ActionAssociatedEvent) ShowOk

func (e *ActionAssociatedEvent) ShowOk() error

Temporarily shows an "OK" (i.e. success), in the form of a check-mark in a green circle, on the action instance. Used to provide visual feedback when an action successfully executed.

Usage:

e.ShowOk()

Docs: https://docs.elgato.com/sdk/plugins/events-sent#showok

func (*ActionAssociatedEvent) SwitchToProfile added in v0.2.0

func (e *ActionAssociatedEvent) SwitchToProfile(profile string, page ...uint8) error

Switches to the profile, as distributed by the plugin, on the specified device.

NB: Plugins may only switch to profiles distributed with the plugin, as defined within the manifest, and cannot access user-defined profiles.

Usage:

e.SwitchToProfile("MyPluginProfile")
e.SwitchToProfile("MyPluginProfile", 1)

Docs: https://docs.elgato.com/sdk/plugins/events-sent#switchtoprofile

type ActionConfig

type ActionConfig struct {
	UUID string
}

func (*ActionConfig) GetUUID

func (a *ActionConfig) GetUUID() string

type ActionCoordinates

type ActionCoordinates struct {
	Column int `json:"column"`
	Row    int `json:"row"`
}

type ActionSettings

type ActionSettings map[string]any

type ApplicationDidLaunchEvent

type ApplicationDidLaunchEvent struct {
	GlobalEvent
	Payload struct {
		Application string `json:"application"`
	} `json:"payload"`
}

type ApplicationDidTerminateEvent

type ApplicationDidTerminateEvent struct {
	GlobalEvent
	Payload struct {
		Application string `json:"application"`
	} `json:"payload"`
}

type DeviceDidConnectEvent

type DeviceDidConnectEvent struct {
	GlobalEvent
	DeviceInfo struct {
		Name string `json:"name"`
		Type int    `json:"type"`
		Size struct {
			Columns int `json:"columns"`
			Rows    int `json:"rows"`
		} `json:"size"`
	} `json:"deviceInfo"`
}

type DeviceDidDisconnectEvent

type DeviceDidDisconnectEvent struct {
	GlobalEvent
}

type DialDownEvent

type DialDownEvent struct {
	ActionAssociatedEvent
	Payload struct {
		Controller  string            `json:"controller"`
		Settings    ActionSettings    `json:"settings"`
		Coordinates ActionCoordinates `json:"coordinates"`
	} `json:"payload"`
}

type DialRotateEvent

type DialRotateEvent struct {
	ActionAssociatedEvent
	Payload struct {
		Settings    ActionSettings    `json:"settings"`
		Controller  string            `json:"controller"`
		Coordinates ActionCoordinates `json:"coordinates"`
		Ticks       int               `json:"ticks"`
		Pressed     bool              `json:"pressed"`
	} `json:"payload"`
}

type DialUpEvent

type DialUpEvent struct {
	ActionAssociatedEvent
	Payload struct {
		Controller  string            `json:"controller"`
		Settings    ActionSettings    `json:"settings"`
		Coordinates ActionCoordinates `json:"coordinates"`
	} `json:"payload"`
}

type DidReceiveDeepLinkEvent

type DidReceiveDeepLinkEvent struct {
	GlobalEvent
	Payload struct {
		Url string `json:"url"`
	} `json:"payload"`
}

type DidReceiveGlobalSettingsEvent

type DidReceiveGlobalSettingsEvent struct {
	GlobalEvent
	Payload struct {
		Settings GlobalSettings `json:"settings"`
	} `json:"payload"`
}

type DidReceiveSettingsEvent

type DidReceiveSettingsEvent struct {
	ActionAssociatedEvent
	Payload struct {
		Settings        ActionSettings    `json:"settings"`
		Coordinates     ActionCoordinates `json:"coordinates"`
		IsInMultiAction bool              `json:"isInMultiAction"`
	} `json:"payload"`
}

type GetGlobalSettingsCommand added in v0.3.0

type GetGlobalSettingsCommand struct {
	Event   string `json:"event"`
	Context string `json:"context"`
}

type GetSettingsCommand added in v0.3.0

type GetSettingsCommand struct {
	Event   string `json:"event"`
	Context string `json:"context"`
}

type GlobalEvent

type GlobalEvent struct {
	Event  string `json:"event"`
	Device string `json:"device,omitempty"`
}

func (*GlobalEvent) GetEventType

func (e *GlobalEvent) GetEventType() string

func (*GlobalEvent) IsActionAssociated

func (e *GlobalEvent) IsActionAssociated() bool

type GlobalSettings

type GlobalSettings map[string]any

func GetGlobalSettings added in v0.3.0

func GetGlobalSettings() (GlobalSettings, error)

type KeyDownEvent

type KeyDownEvent struct {
	ActionAssociatedEvent
	Payload struct {
		Settings         ActionSettings    `json:"settings"`
		Coordinates      ActionCoordinates `json:"coordinates"`
		State            int               `json:"states"`
		UserDesiredState int               `json:"userDesiredState"`
		IsInMultiAction  bool              `json:"isInMultiAction"`
	} `json:"payload"`
}

type KeyUpEvent

type KeyUpEvent struct {
	ActionAssociatedEvent
	Payload struct {
		Settings         ActionSettings    `json:"settings"`
		Coordinates      ActionCoordinates `json:"coordinates"`
		State            int               `json:"state"`
		UserDesiredState int               `json:"userDesiredState"`
		IsInMultiAction  bool              `json:"isInMultiAction"`
	} `json:"payload"`
}

type LogMessageCommand added in v0.3.0

type LogMessageCommand struct {
	Event   string `json:"event"`
	Payload struct {
		Message string `json:"message"`
	} `json:"payload"`
}

type OpenUrlCommand added in v0.3.0

type OpenUrlCommand struct {
	Event   string `json:"event"`
	Payload struct {
		Url string `json:"url"`
	} `json:"payload"`
}

type PluginConfigType

type PluginConfigType struct {
	Port          string
	PluginUUID    string
	RegisterEvent string
	Info          StreamDeckInfo
}

PluginConfig holds the configuration passed via flags

var PluginConfig PluginConfigType

type PropertyInspectorDidAppearEvent

type PropertyInspectorDidAppearEvent struct {
	ActionAssociatedEvent
}

type PropertyInspectorDidDisappearEvent

type PropertyInspectorDidDisappearEvent struct {
	ActionAssociatedEvent
}

type ResponseChannel added in v0.2.0

type ResponseChannel chan StreamDeckEvent

type SendToPluginEvent

type SendToPluginEvent struct {
	ActionAssociatedEvent
	Payload map[string]any `json:"payload"`
}

type SendToPluginFromPluginEvent

type SendToPluginFromPluginEvent struct {
	Action  string         `json:"action"`
	Event   string         `json:"event"`
	Context string         `json:"context"`
	Payload map[string]any `json:"payload"`
}

type SendToPropertyInspectorEvent

type SendToPropertyInspectorEvent struct {
	ActionAssociatedEvent
	Payload map[string]any `json:"payload"`
}

type SendToPropertyInspectorFromPluginCommand added in v0.3.0

type SendToPropertyInspectorFromPluginCommand struct {
	Action  string         `json:"action"`
	Event   string         `json:"event"`
	Context string         `json:"context"`
	Payload map[string]any `json:"payload"`
}

Both of these events might not even be necessary

type SetFeedbackEvent

type SetFeedbackEvent struct {
	Event   string         `json:"event"`
	Context string         `json:"context"`
	Payload map[string]any `json:"payload"`

} //not really sure about this one

type SetFeedbackLayoutEvent

type SetFeedbackLayoutEvent struct {
	Event   string            `json:"event"`
	Context string            `json:"context"`
	Payload map[string]string `json:"payload"`

} //not really sure about this one

type SetGlobalSettingsCommand added in v0.3.0

type SetGlobalSettingsCommand struct {
	Event   string         `json:"event"`
	Context string         `json:"context"`
	Payload map[string]any `json:"payload"`
}

type SetImageCommand added in v0.3.0

type SetImageCommand struct {
	Event   string `json:"event"`
	Context string `json:"context"`
	Payload struct {
		Image  string `json:"image"` //this type might be wrong
		Target uint8  `json:"target"`
		State  uint8  `json:"state"`
	} `json:"payload"`
}

type SetSettingsCommand added in v0.3.0

type SetSettingsCommand struct {
	Event   string         `json:"event"`
	Context string         `json:"context"`
	Payload map[string]any `json:"payload"`
}

type SetStateCommand added in v0.3.0

type SetStateCommand struct {
	Event   string `json:"event"`
	Context string `json:"context"`
	Payload struct {
		State uint8 `json:"state"`
	} `json:"payload"`
}

type SetTitleCommand added in v0.3.0

type SetTitleCommand struct {
	Event   string `json:"event"`
	Context string `json:"context"`
	Payload struct {
		Title  string `json:"title"`
		Target uint8  `json:"target"`
		State  uint8  `json:"state"`
	} `json:"payload"`
}

type SetTriggerDescriptionEvent

type SetTriggerDescriptionEvent struct {
	Event   string `json:"event"`
	Context string `json:"context"`
	Payload struct {
		Rotate    string `json:"rotate"`
		Push      string `json:"push"`
		Touch     string `json:"touch"`
		LongTouch string `json:"longTouch"`
	} `json:"payload"`
}

type ShowAlertCommand added in v0.3.0

type ShowAlertCommand struct {
	Event   string `json:"event"`
	Context string `json:"context"`
}

type ShowOkCommand added in v0.3.0

type ShowOkCommand struct {
	Event   string `json:"event"`
	Context string `json:"context"`
}

type StreamDeckEvent

type StreamDeckEvent interface {
	GetEventType() string
	IsActionAssociated() bool
}

func ParseEvent

func ParseEvent(data []byte) (StreamDeckEvent, error)

type StreamDeckInfo

type StreamDeckInfo struct {
	Application struct {
		Font            string `json:"font"`
		Platform        string `json:"platform"`
		PlatformVersion string `json:"platformVersion"`
		Version         string `json:"version"`
	} `json:"application"`
	Plugin struct {
		UUID    string `json:"uuid"`
		Version string `json:"version"`
	} `json:"plugin"`
	DevicePixelRatio int `json:"devicePixelRatio"`
	Colors           struct {
		ButtonPressedBackgroundColor string `json:"buttonPressedBackgroundColor"`
		ButtonPressedBorderColor     string `json:"buttonPressedBorderColor"`
		ButtonPressedTextColor       string `json:"buttonPressedTextColor"`
		DisabledColor                string `json:"disabledColor"`
		HighlightColor               string `json:"highlightColor"`
		MouseDownColor               string `json:"mouseDownColor"`
	} `json:"colors"`
	Device []struct {
		Id   string `json:"id"`
		Name string `json:"name"`
		Size struct {
			Columns int    `json:"columns"`
			Rows    string `json:"rows"`
		} `json:"device"`
		Type int `json:"type"`
	} `json:"devices"`
}

StreamDeckInfo holds the parsed JSON data from the -info flag

type SwitchToProfileCommand added in v0.3.0

type SwitchToProfileCommand struct {
	Event   string `json:"event"`
	Context string `json:"context"`
	Device  string `json:"device"`
	Payload struct {
		Profile string `json:"profile"`
		Page    uint8  `json:"page"` //Maybe its possible to have over 256 pages????
	} `json:"payload"`
}

type SystemDidWakeUpEvent

type SystemDidWakeUpEvent struct {
	GlobalEvent
}

type TapPosition

type TapPosition [2]int

type TitleParametersDidChangeEvent

type TitleParametersDidChangeEvent struct {
	ActionAssociatedEvent
	Payload struct {
		Coordinates     ActionCoordinates `json:"coordinates"`
		Settings        ActionSettings    `json:"settings"`
		State           int               `json:"state"`
		Title           string            `json:"title"`
		TitleParameters struct {
			FontFamily     string `json:"fontFamily"`
			FontSize       int    `json:"fontSize"`
			FontStyle      string `json:"fontStyle"`
			FontUnderline  bool   `json:"fontUnderline"`
			ShowTitle      bool   `json:"showTitle"`
			TitleAlignment string `json:"titleAlignment"`
			TitleColor     string `json:"titleColor"`
		} `json:"titleParameters"`
	} `json:"payload"`
}

type TouchTapEvent

type TouchTapEvent struct {
	ActionAssociatedEvent
	Payload struct {
		Settings    ActionSettings    `json:"settings"`
		Controller  string            `json:"controller"`
		Coordinates ActionCoordinates `json:"coordinates"`
		TapPos      TapPosition       `json:"tapPos"`
		Hold        bool              `json:"hold"`
	} `json:"payload"`
}

type WillAppearEvent

type WillAppearEvent struct {
	ActionAssociatedEvent
	Payload struct {
		Settings        ActionSettings    `json:"settings"`
		Coordinates     ActionCoordinates `json:"coordinates"`
		Controller      string            `json:"controller"`
		State           int               `json:"state"`
		IsInMultiAction bool              `json:"isInMultiAction"`
	} `json:"payload"`
}

type WillDisappearEvent

type WillDisappearEvent struct {
	ActionAssociatedEvent
	Payload struct {
		Settings        ActionSettings    `json:"settings"`
		Coordinates     ActionCoordinates `json:"coordinates"`
		Controller      string            `json:"controller"`
		State           int               `json:"state"`
		IsInMultiAction bool              `json:"isInMultiAction"`
	} `json:"payload"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL