Documentation
¶
Index ¶
- Constants
- Variables
- type Controller
- type Device
- type EventName
- type Handler
- type HandlerFunc
- type Info
- type Option
- type ReceivedEvent
- type ReceivedEventPayload
- type SendEvent
- type SendEventPayload
- type SendEventSetFeedbackLayoutPayload
- type SendEventSetFeedbackPayload
- type SendEventSetTriggerDescriptionPayload
- type StreamDeck
- func (s *StreamDeck) Alert(context string)
- func (s *StreamDeck) GetGlobalSettings(context string)
- func (s *StreamDeck) GetSettings(context string)
- func (s *StreamDeck) Handler(h ...Handler)
- func (s *StreamDeck) HandlerFunc(h ...HandlerFunc)
- func (s *StreamDeck) Log(message string)
- func (s *StreamDeck) Logf(format string, a ...interface{})
- func (s *StreamDeck) OpenURL(u string)
- func (s *StreamDeck) SetFeedback(context string, payload *SendEventSetFeedbackPayload)
- func (s *StreamDeck) SetFeedbackLayout(context string, layout string)
- func (s *StreamDeck) SetGlobalSettings(context string, settings map[string]interface{})
- func (s *StreamDeck) SetImage(context string, image string)
- func (s *StreamDeck) SetSettings(context string, settings map[string]interface{})
- func (s *StreamDeck) SetState(context string, state uint8)
- func (s *StreamDeck) SetTitle(context string, title string, target Target)
- func (s *StreamDeck) SetTriggerDescription(context string, payload *SendEventSetTriggerDescriptionPayload)
- func (s *StreamDeck) ShowOK(context string)
- func (s *StreamDeck) Start()
- type Target
Constants ¶
const ( // IconLayout is a layout that displays an icon on the Stream Deck + touch display. // See [Icon Layout](https://docs.elgato.com/sdk/plugins/layouts-sd+#icon-layout-usdx1) IconLayout = "$X1" // CanvasLayout is a layout that displays a canvas on the Stream Deck + touch display. // See [Canvas Layout](https://docs.elgato.com/sdk/plugins/layouts-sd+#canvas-layout-usda0) CanvasLayout = "$A0" // ValueLayout is a layout that displays a value on the Stream Deck + touch display. // See [Value Layout](https://docs.elgato.com/sdk/plugins/layouts-sd+#value-layout-usda1) ValueLayout = "$A0" // IndicatorLayout is a layout that displays an indicator on the Stream Deck + touch display. // See [Indicator Layout](https://docs.elgato.com/sdk/plugins/layouts-sd+#indicator-layout-usdb1) IndicatorLayout = "$B1" // GradientIndicatorLayout is a layout that displays a gradient indicator on the Stream Deck + touch display. // See [Gradient Indicator Layout](https://docs.elgato.com/sdk/plugins/layouts-sd+#gradient-indicator-layout-usdb2) GradientIndicatorLayout = "$B2" // DoubleIndicatorLayout is a layout that displays a double indicator on the Stream Deck + touch display. // See [Double Indicator Layout](https://docs.elgato.com/sdk/plugins/layouts-sd+#double-indicator-layout-usdc1) DoubleIndicatorLayout = "$C1" )
Layouts used with StreamDeck.
Variables ¶
var ( // ErrMissingPort is returned when the port is not set. ErrMissingPort = errors.New("missing -port") // ErrMissingUUID is returned when the UUID is not set. ErrMissingUUID = errors.New("missing -pluginUUID") // ErrMissingRegisterEvent is returned when the registerEvent is not set. ErrMissingRegisterEvent = errors.New("missing -registerEvent") // ErrMissingOrInvalidInfo is returned when the info is not set or is not a valid json. ErrMissingOrInvalidInfo = errors.New("missing or invalid -info") )
Functions ¶
This section is empty.
Types ¶
type Controller ¶
type Controller string
Controller used with StreamDeck.
const ( Encoder Controller = "Encoder" KeyPad Controller = "KeyPad" )
type Device ¶
type Device uint8
Device used with StreamDeck.
const ( // KESDSDKDeviceTypeStreamDeck Device type: Stream Deck. KESDSDKDeviceTypeStreamDeck Device = iota // KESDSDKDeviceTypeStreamDeckMini Device type: Stream Deck Mini. KESDSDKDeviceTypeStreamDeckMini // KESDSDKDeviceTypeStreamDeckXL Device type: Stream Deck XL. KESDSDKDeviceTypeStreamDeckXL // KESDSDKDeviceTypeStreamDeckMobile Device type: Stream Deck Mobile. KESDSDKDeviceTypeStreamDeckMobile // KESDSDKDeviceTypeCorsairGKeys Device type: Corsair G-Keys. KESDSDKDeviceTypeCorsairGKeys )
type EventName ¶
type EventName string
EventName is simply the name of the received event.
const ( // DidReceiveSettings Event received after calling the GetSettings API // to retrieve the persistent data stored for the action. DidReceiveSettings EventName = "didReceiveSettings" // DidReceiveGlobalSettings Event received after calling the GetGlobalSettings API // to retrieve the global persistent data. DidReceiveGlobalSettings EventName = "didReceiveGlobalSettings" // KeyDown When the user presses a key, the plugin will receive the KeyDown event. KeyDown EventName = "keyDown" // KeyUp When the user releases a key, the plugin will receive the keyUp event. KeyUp EventName = "keyUp" // When the user touches the display, the plugin will receive the touchTap event (SD+). TouchTap EventName = "touchTap" // When the user presses the encoder down, the plugin will receive the dialDown event (SD+). DialDown EventName = "dialDown" // When the user releases a pressed encoder, the plugin will receive the dialUp event (SD+). DialUp EventName = "dialUp" // When the user rotates the encoder, the plugin will receive the dialRotate event (SD+). DialRotate EventName = "dialRotate" // WillAppear When an instance of an action is displayed on the Stream Deck, // for example when the hardware is first plugged in, // or when a folder containing that action is entered, the plugin will receive a willAppear event. WillAppear EventName = "willAppear" // WillDisappear When an instance of an action ceases to be displayed on Stream Deck, // for example when switching profiles or folders, // the plugin will receive a willDisappear event. WillDisappear EventName = "willDisappear" // TitleParametersDidChange When the user changes the title or title parameters, // the plugin will receive a titleParametersDidChange event. TitleParametersDidChange EventName = "titleParametersDidChange" // DeviceDidConnect When a device is plugged to the computer, // the plugin will receive a deviceDidConnect event. DeviceDidConnect EventName = "deviceDidConnect" // DeviceDidDisconnect When a device is unplugged from the computer, // the plugin will receive a deviceDidDisconnect event. DeviceDidDisconnect EventName = "deviceDidDisconnect" // ApplicationDidLaunch When a monitored application is launched, // the plugin will be notified and will receive the applicationDidLaunch event. ApplicationDidLaunch EventName = "applicationDidLaunch" // ApplicationDidTerminate When a monitored application is terminated, // the plugin will be notified and will receive the applicationDidTerminate event. ApplicationDidTerminate EventName = "applicationDidTerminate" // SystemDidWakeUp When the computer is wake up, // the plugin will be notified and will receive the systemDidWakeUp event. SystemDidWakeUp EventName = "systemDidWakeUp" // Occurs when Stream Deck receives a deep-link message intended for the plugin. // The message is re-routed to the plugin, and provided as part of the payload. DidReceiveDeepLink EventName = "didReceiveDeepLink" // PropertyInspectorDidAppear Event received when the Property Inspector appears // in the Stream Deck software user interface, // for example when selecting a new instance. PropertyInspectorDidAppear EventName = "propertyInspectorDidAppear" // PropertyInspectorDidDisappear Event received when the Property Inspector for an instance is removed // from the Stream Deck software user interface, // for example when selecting a different instance. PropertyInspectorDidDisappear EventName = "propertyInspectorDidDisappear" // SendToPlugin (from the Property Inspector) Send a payload to the plugin. SendToPlugin EventName = "sendToPlugin" // SetSettings Save data persistently for the action's instance. SetSettings EventName = "setSettings" // GetSettings Request the persistent data for the action's instance. GetSettings EventName = "getSettings" // SetGlobalSettings Save data securely and globally for the plugin. SetGlobalSettings EventName = "setGlobalSettings" // GetGlobalSettings Request the global persistent data. GetGlobalSettings EventName = "getGlobalSettings" // OpenURL Open a URL in the default browser. OpenURL EventName = "openUrl" // LogMessage Write a debug log to the logs file. LogMessage EventName = "logMessage" // SetTitle Dynamically change the title of an instance of an action. SetTitle EventName = "setTitle" // SetImage Dynamically change the image displayed by an instance of an action. SetImage EventName = "setImage" // Dynamically change properties of items on the Stream Deck + touch display. SetFeedback EventName = "setFeedback" // Dynamically change the current layout for the Stream Deck + touch display. SetFeedbackLayout EventName = "setFeedbackLayout" // Sets the trigger descriptions associated with an encoder (touch display + dial) action instance. // All descriptions are optional; when one or more descriptions are defined all descriptions are updated, // with undefined values having their description hidden in Stream Deck. // To reset the descriptions to the default values defined within the manifest, // an empty payload can be sent as part of the event. SetTriggerDescription EventName = "setTriggerDescription" // ShowAlert Temporarily show an alert icon on the image displayed by an instance of an action. ShowAlert EventName = "showAlert" // ShowOk Temporarily show an OK checkmark icon on the image displayed by an instance of an action. ShowOk EventName = "showOk" // SetState Change the state of the action's instance supporting multiple states. SetState EventName = "setState" // SwitchToProfile Switch to one of the preconfigured read-only profiles. SwitchToProfile EventName = "switchToProfile" // SendToPropertyInspector Send a payload to the Property Inspector. SendToPropertyInspector EventName = "sendToPropertyInspector" )
type Handler ¶
type Handler interface {
Handle(event *ReceivedEvent) error
}
Handler same as HandlerFunc but with interface.
type HandlerFunc ¶
type HandlerFunc func(event *ReceivedEvent) error
HandlerFunc receive event from StreamDeck SDK.
type Info ¶
type Info struct { Application struct { Font string `json:"font"` Language string `json:"language"` 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"` Devices []struct { ID string `json:"id"` Name string `json:"name"` Size struct { Columns int `json:"columns"` Rows int `json:"rows"` } `json:"size"` Type int `json:"type"` } `json:"devices"` }
Info is sent to the plugin on registration process.
type ReceivedEvent ¶
type ReceivedEvent struct { // The action's unique identifier. If your plugin supports multiple actions, // you should use this value to see which action was triggered. Action string `json:"action"` // The event name Event EventName `json:"event"` // An opaque value identifying the instance's action Context string `json:"context"` // An opaque value identifying the device. Device string `json:"device"` // A json object containing information about the device. Used on deviceDidConnect DeviceInfo struct { // The name of the device set by the user. Name string `json:"name"` // Type of device. Type Device `json:"type"` // The number of columns and rows of keys that the device owns. Size struct { Columns uint8 `json:"columns"` Rows uint8 `json:"rows"` } `json:"size"` } `json:"deviceInfo"` // A json object containing context about received event Payload *ReceivedEventPayload `json:"payload"` }
ReceivedEvent describes a received event from StreamDeck SDK.
type ReceivedEventPayload ¶
type ReceivedEventPayload struct { // This json object contains data that you can set and is stored persistently. Settings map[string]interface{} `json:"settings"` // Contain value: 'Encoder' or 'KeyPad'. // Used on events: touchTap, dialDown, dialUp, dialRotate Controller Controller `json:"controller"` // The coordinates of the action triggered. Coordinates struct { Column uint8 `json:"column"` Row uint8 `json:"row"` } `json:"coordinates"` // The array which holds (x, y) coordinates as a position of tap inside of LCD slot associated with action. // Used on events: touchTap TapPos [2]int `json:"tapPos"` // Boolean which is true when long tap happened. // Used on events: touchTap Hold bool `json:"hold"` // The integer which holds the number of "ticks" on encoder rotation. // Positive values are for clockwise rotation, negative values are for counterclockwise rotation, zero value is never happen // Used on events: dialRotate Ticks int `json:"ticks"` // Boolean which is true on rotation when encoder pressed // Used on events: dialRotate Pressed bool `json:"pressed"` // This is a parameter that is only set when the action has multiple states defined in its manifest.json. // The 0-based value contains the current state of the action. State uint8 `json:"state"` // Boolean indicating if the action is inside a Multi Action. IsInMultiAction bool `json:"isInMultiAction"` // This is a parameter that is only set when the action is triggered with a specific value from a Multi Action. // For example if the user sets the Game Capture Record action to be disabled in a Multi Action, you would see the value 1. // Only the value 0 and 1 are valid. UserDesiredState uint8 `json:"userDesiredState"` // The new title. Used on events: titleParametersDidChange Title string `json:"title"` // A json object describing the new title parameters. Used on events: titleParametersDidChange 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"` // The identifier of the application that has been launched. // Used on events: applicationDidLaunch, applicationDidTerminate Application string `json:"application"` }
ReceivedEventPayload describes a payload received from StreamDeck SDK.
type SendEvent ¶
type SendEvent struct { // The action unique identifier. // Used on events: sendToPropertyInspector, sendToPlugin Action string `json:"action,omitempty"` // Used to register this plugin UUID string `json:"uuid,omitempty"` // The event name Event EventName `json:"event"` // An opaque value identifying the instance's action Context string `json:"context,omitempty"` // An opaque value identifying the device. Device string `json:"device,omitempty"` // A json object Payload interface{} `json:"payload,omitempty"` }
SendEvent describes a event to send to StreamDeck SDK.
type SendEventPayload ¶
type SendEventPayload struct { // A URL to open in the default browser. // Used on events: openUrl URL string `json:"url,omitempty"` // A string to write to the logs file. // Used on events: logMessage Message string `json:"message,omitempty"` // The title to display. If there is no title parameter, the title is reset to the title set by the user. // Used on events: setTitle Title string `json:"title,omitempty"` // Specify where you want to display the title. // Used on events: setTitle, setImage Target Target `json:"target,omitempty"` // A 0-based integer value representing the state of an action with multiple states. // This is an optional parameter. // If not specified, the title is set to all states. // Used on events: setTitle, setImage, setState State uint8 `json:"state,omitempty"` // The image to display encoded in base64 with the image format declared in the mime type (PNG, JPEG, BMP, ...). // svg is also supported. // If no image is passed, the image is reset to the default image from the manifest. // Used on events: setImage Image string `json:"image,omitempty"` // The name of the profile to switch to. The name should be identical to the name provided in the manifest.json file. // Used on events: switchToProfile Profile string `json:"profile,omitempty"` }
SendEventPayload describes a payload to send to StreamDeck SDK.
type SendEventSetFeedbackLayoutPayload ¶
type SendEventSetFeedbackLayoutPayload struct { // The layout to display on the Stream Deck + touch display. // See [Layouts](https://docs.elgato.com/sdk/plugins/layouts-sd+) Layout string `json:"layout"` }
SendEventSetFeedbackLayoutPayload describes a payload for setFeedbackLayout event to send to StreamDeck SDK.
type SendEventSetFeedbackPayload ¶
type SendEventSetFeedbackPayload map[string]interface{}
SendEventSetFeedbackPayload describes a payload for setFeedback event to send to StreamDeck SDK.
type SendEventSetTriggerDescriptionPayload ¶
type SendEventSetTriggerDescriptionPayload struct { // Optional value that describes the long-touch interaction with the touch display. // When undefined the description will be hidden. LongTouch string `json:"longTouch,omitempty"` // Optional value that describes the push interaction with the dial. // When undefined the description will be hidden. Push string `json:"push,omitempty"` // Optional value that describes the rotate interaction with the dial. // When undefined the description will be hidden. Rotate string `json:"rotate,omitempty"` // Optional value that describes the touch interaction with the touch display. // When undefined the description will be hidden. Touch string `json:"touch,omitempty"` }
SendEventSetTriggerDescriptionPayload describes a payload for setTriggerDescription event to send to StreamDeck SDK.
type StreamDeck ¶
type StreamDeck struct { // UUID is a unique identifier string that should be used to register the plugin once the WebSocket is opened UUID string // Info containing the Stream Deck application information and devices information. Info *Info // contains filtered or unexported fields }
StreamDeck will handle events to send/received to/from the StreamDeck application.
func New ¶
func New(opts ...Option) (*StreamDeck, error)
New create our plugin, listen to websocket events and register handlers.
func (*StreamDeck) Alert ¶
func (s *StreamDeck) Alert(context string)
Alert sends an alert on the StreamDeck of action with given context.
func (*StreamDeck) GetGlobalSettings ¶
func (s *StreamDeck) GetGlobalSettings(context string)
GetGlobalSettings get the global settings of an action with given context. Global settings will be sent back to the plugin as a ReceivedEvent with the event name DidReceiveGlobalSettings.
func (*StreamDeck) GetSettings ¶
func (s *StreamDeck) GetSettings(context string)
GetSettings get the settings of an action with given context. Settings will be sent back to the plugin as a ReceivedEvent with the event name DidReceiveSettings.
func (*StreamDeck) Handler ¶
func (s *StreamDeck) Handler(h ...Handler)
Handler register given handlers.
func (*StreamDeck) HandlerFunc ¶
func (s *StreamDeck) HandlerFunc(h ...HandlerFunc)
HandlerFunc register given HandlerFunc.
func (*StreamDeck) Log ¶
func (s *StreamDeck) Log(message string)
Log send log message to StreamDeck SDK.
func (*StreamDeck) Logf ¶
func (s *StreamDeck) Logf(format string, a ...interface{})
Logf send formatted log message to StreamDeck SDK.
func (*StreamDeck) OpenURL ¶
func (s *StreamDeck) OpenURL(u string)
OpenURL tell the Stream Deck application to open an URL in the default browser.
func (*StreamDeck) SetFeedback ¶
func (s *StreamDeck) SetFeedback(context string, payload *SendEventSetFeedbackPayload)
SetFeedback change the feedback of an action with given context.
func (*StreamDeck) SetFeedbackLayout ¶
func (s *StreamDeck) SetFeedbackLayout(context string, layout string)
SetFeedbackLayout change the feedback layout of an action with given context.
func (*StreamDeck) SetGlobalSettings ¶
func (s *StreamDeck) SetGlobalSettings(context string, settings map[string]interface{})
SetGlobalSettings change the global settings of an action with given context.
func (*StreamDeck) SetImage ¶
func (s *StreamDeck) SetImage(context string, image string)
SetImage change the image of an action with given context.
func (*StreamDeck) SetSettings ¶
func (s *StreamDeck) SetSettings(context string, settings map[string]interface{})
SetSettings change the settings of an action with given context.
func (*StreamDeck) SetState ¶
func (s *StreamDeck) SetState(context string, state uint8)
SetState change the state of an action supporting multiple states.
func (*StreamDeck) SetTitle ¶
func (s *StreamDeck) SetTitle(context string, title string, target Target)
SetTitle tell StreamDeck to dynamically change the title of action with given context.
func (*StreamDeck) SetTriggerDescription ¶
func (s *StreamDeck) SetTriggerDescription(context string, payload *SendEventSetTriggerDescriptionPayload)
SetTriggerDescription change the trigger description of an action with given context.
func (*StreamDeck) ShowOK ¶
func (s *StreamDeck) ShowOK(context string)
ShowOK temporarily show an OK checkmark icon of action with given context.
func (*StreamDeck) Start ¶
func (s *StreamDeck) Start()
Start to serve the plugin Ensure you call Handler before.