sdk

package module
v0.0.0-...-68fe819 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2020 License: BSD-3-Clause Imports: 8 Imported by: 0

README

Stream Deck SDK for Golang

An implementation of Elgato's Stream Deck SDK to enable writing simple, lightweight plugins in Go.

Credits and Licensing

Events are handled in a similar way to bwmarrin/discordgo, and in fact uses the same base code. This is the most reasonable way to handle events in this scope.

Usage and importing

This package requires github.com/valyala/fastjson. Sometimes, this will be installed for you or resolved by go module/import managers.

go get meow.tf/streamdeck/sdk

Examples

See the examples directory for a basic example

Documentation

Index

Constants

View Source
const (
	CommonAction     = "action"
	CommonEvent      = "event"
	CommonContext    = "context"
	CommonPayload    = "payload"
	CommonDevice     = "device"
	CommonDeviceInfo = "deviceInfo"

	EventKeyDown                       = "keyDown"
	EventKeyUp                         = "keyUp"
	EventWillAppear                    = "willAppear"
	EventWillDisappear                 = "willDisappear"
	EventDeviceDidConnect              = "deviceDidConnect"
	EventDeviceDidDisconnect           = "deviceDidDisconnect"
	EventApplicationDidLaunch          = "applicationDidLaunch"
	EventApplicationDidTerminate       = "applicationDidTerminate"
	EventTitleParametersDidChange      = "titleParametersDidChange"
	EventDidReceiveSettings            = "didReceiveSettings"
	EventDidReceiveGlobalSettings      = "didReceiveGlobalSettings"
	EventPropertyInspectorDidAppear    = "propertyInspectorDidAppear"
	EventPropertyInspectorDidDisappear = "propertyInspectorDidDisappear"

	EventSetTitle                = "setTitle"
	EventSetImage                = "setImage"
	EventShowAlert               = "showAlert"
	EventShowOK                  = "showOk"
	EventGetSettings             = "getSettings"
	EventSetSettings             = "setSettings"
	EventGetGlobalSettings       = "getGlobalSettings"
	EventSetGlobalSettings       = "setGlobalSettings"
	EventSetState                = "setState"
	EventSwitchToProfile         = "switchToProfile"
	EventSendToPropertyInspector = "sendToPropertyInspector"
	EventSendToPlugin            = "sendToPlugin"
	EventOpenURL                 = "openUrl"
	EventLogMessage              = "logMessage"

	TargetBoth     = 0
	TargetHardware = 1
	TargetSoftware = 2
)

Variables

View Source
var (
	PluginUUID string
)

Functions

func AddHandler

func AddHandler(handler interface{}) func()

AddHandler allows you to add an event handler that will be fired anytime the Stream Deck event the function matches is received The second parameter is a pointer to a struct corresponding to the event for which you want to listen.

eg:

AddHandler(func(e *sdk.KeyDownEvent) {
})

or:

AddHandler(func(e *sdk.SendToPluginEvent) {
})

The return value of this method is a function, that when called will remove the event handler.

func AddHandlerOnce

func AddHandlerOnce(handler interface{}) func()

AddHandlerOnce allows you to add an event handler that will be fired the next time the Discord WSAPI event that matches the function fire See AddHandler for more detail

func GetGlobalSettings

func GetGlobalSettings()

func GetSettings

func GetSettings(context string)

func JsonStringValue

func JsonStringValue(v *fastjson.Value, keys ...string) string

func Log

func Log(message string)

func Open

func Open() error

func OpenURL

func OpenURL(url string)

func RegisterAction

func RegisterAction(actionName string, f ActionHandler)

func SendToPropertyInspector

func SendToPropertyInspector(context string, object interface{})

func SetGlobalSettings

func SetGlobalSettings(v interface{})

func SetImage

func SetImage(context, imageData string, target int)

func SetSettings

func SetSettings(context string, v interface{})

func SetState

func SetState(context string, state int)

func SetTitle

func SetTitle(context, title string, target int)

func ShowAlert

func ShowAlert(context string)

func ShowOk

func ShowOk(context string)

func Wait

func Wait()

Waits for either the socket to close, or SIGINT/SIGTERM. Stream Deck closes the connection as a way to close the plugin, but will also SIGTERM/SIGINT as a final resort.

Types

type ActionHandler

type ActionHandler func(action, context string, payload *fastjson.Value, deviceId string)

type ApplicationLaunchEvent

type ApplicationLaunchEvent struct {
	Application string
}

type ApplicationTerminateEvent

type ApplicationTerminateEvent struct {
	Application string
}

type DeviceConnectEvent

type DeviceConnectEvent struct {
	DeviceId string
	Info     *fastjson.Value
}

type DeviceDisconnectEvent

type DeviceDisconnectEvent struct {
	DeviceId string
}

type EventHandler

type EventHandler interface {
	// Type returns the type of event this handler belongs to.
	Type() string

	// Handle is called whenever an event of Type() happen
	// It is the receivers responsibility to type assert that the interface
	// is the expected struct.
	Handle(interface{})
}

EventHandler is an interface for Discord event

type EventInterfaceProvider

type EventInterfaceProvider interface {
	// Type is the type of event this handler belongs to.
	Type() string

	// New returns a new instance of the struct this event handler handle
	// This is called once per event.
	// The struct is provided to all handlers of the same Type().
	New() interface{}
}

EventInterfaceProvider is an interface for providing empty interfaces for Discord event

type GlobalSettingsEvent

type GlobalSettingsEvent struct {
	Settings *fastjson.Value
}

type KeyDownEvent

type KeyDownEvent struct {
	Action   string
	Context  string
	Payload  *fastjson.Value
	DeviceId string
}

type KeyUpEvent

type KeyUpEvent struct {
	Action   string
	Context  string
	Payload  *fastjson.Value
	DeviceId string
}

type ReceiveSettingsEvent

type ReceiveSettingsEvent struct {
	Action   string
	Context  string
	DeviceId string
	Settings *fastjson.Value
}

type SendToPluginEvent

type SendToPluginEvent struct {
	Action   string
	Context  string
	Payload  *fastjson.Value
	DeviceId string
}

type WillAppearEvent

type WillAppearEvent struct {
	Action   string
	Context  string
	Payload  *fastjson.Value
	DeviceId string
}

type WillDisappearEvent

type WillDisappearEvent struct {
	Action   string
	Context  string
	Payload  *fastjson.Value
	DeviceId string
}

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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