streamdeck

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 19 Imported by: 0

README

Go Streamdeck

A Go interface to an Elgato Streamdeck. Expanded to support all models.

Forked from https://github.com/magicmonkey/go-streamdeck

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Max

func Max(x, y int) int

func Min

func Min(x, y int) int

Golang Min/Max

func RegisterDevicetype

func RegisterDevicetype(
	name string,
	imageSize image.Point,
	usbProductID uint16,
	resetPacket []byte,
	numberOfButtons uint,
	buttonRows uint,
	buttonCols uint,
	brightnessPacket []byte,
	buttonReadOffset uint,
	imageFormat string,
	imagePayloadPerPage uint,
	buttonMap map[uint]int,
	imageHeaderFunc func(bytesRemaining uint, btnIndex uint, pageNumber uint) []byte,
	imageAreaHeaderFunc func(bytesRemaining uint, x, y, width, height uint, pageNumber uint) []byte,
)

RegisterDevicetype allows the declaration of a new type of device, intended for use by subpackage "devices"

func Search() []*deviceSearchResult

Search for streamdeck devices

Types

type Button

type Button interface {
	ButtonDisplay
}

Button is the interface to satisfy for being a button; currently this is a direct proxy for the `ButtonDisplay` interface as there isn't a requirement to handle being pressed

type ButtonActionHandler

type ButtonActionHandler interface {
	Pressed(Button)
}

ButtonActionHandler is the interface to satisfy for handling a button being pressed, generally via an `actionhandler`

type ButtonDecorator

type ButtonDecorator interface {
	Apply(image.Image, int) image.Image
}

ButtonDecorator represents a way to modify the button image, for example to add a highlight or an "on/off" hint

type ButtonDisplay

type ButtonDisplay interface {
	GetImageForButton(int) image.Image
	GetButtonIndex() int
	SetButtonIndex(int)
	RegisterUpdateHandler(func(Button))
	Pressed()
}

ButtonDisplay is the interface to satisfy for displaying on a button

type Device

type Device struct {
	// contains filtered or unexported fields
}

Device is a struct which represents an actual Streamdeck device, and holds its reference to the USB HID device

func Open

func Open() (*Device, error)

Open a Streamdeck device, the most common entry point

func OpenBySerial

func OpenBySerial(serial string) (*Device, error)

Open a Streamdeck device, the most common entry point

func OpenWithoutReset

func OpenWithoutReset() (*Device, error)

OpenWithoutReset will open a Streamdeck device, without resetting it

func (*Device) ButtonPress

func (d *Device) ButtonPress(f func(int, *Device, error, bool))

ButtonPress registers a callback to be called whenever a button is pressed (or connection is lost!)

func (*Device) ClearButtons

func (d *Device) ClearButtons()

ClearButtons writes a black square to all buttons

func (*Device) Close

func (d *Device) Close()

Close the device

func (*Device) EncoderPress

func (d *Device) EncoderPress(f func(int, *Device, bool))

EncoderPress registers a callback to be called whenever an encoder is pressed

func (*Device) EncoderRotate

func (d *Device) EncoderRotate(f func(int, *Device, int))

EncoderRotate registers a callback to be called whenever an encoder is rotated

func (*Device) GetImageSize

func (d *Device) GetImageSize() image.Point

GetImageSize returns the size of images on this Streamdeck

func (*Device) GetName

func (d *Device) GetName() string

GetName returns the name of the type of Streamdeck

func (*Device) GetNumberOfButtons

func (d *Device) GetNumberOfButtons() uint

func (*Device) GetSerial

func (d *Device) GetSerial() string

GetSerial returns the device serial

func (*Device) GetUSBProductId

func (d *Device) GetUSBProductId() int

func (*Device) HasImageCapability

func (d *Device) HasImageCapability() bool

func (*Device) ResetComms

func (d *Device) ResetComms()

ResetComms will reset the comms protocol to the StreamDeck; useful if things have gotten de-synced, but it will also reboot the StreamDeck

func (*Device) SetBrightness

func (d *Device) SetBrightness(pct int)

SetBrightness sets the button brightness pct is an integer between 0-100

func (*Device) TouchPush

func (d *Device) TouchPush(f func(*Device, uint16, uint16, bool))

TouchPush registers a callback to be called whenever the touch area is pushed (tap or hold)

func (*Device) TouchSwipe

func (d *Device) TouchSwipe(f func(*Device, uint16, uint16, uint16, uint16))

TouchSwipe registers a callback to be called whenever the touch area is swiped

func (*Device) WriteColorToButton

func (d *Device) WriteColorToButton(btnIndex int, colour color.Color) error

WriteColorToButton writes a specified color to the given button

func (*Device) WriteImageToButton

func (d *Device) WriteImageToButton(btnIndex int, filename string) error

WriteImageToButton writes a specified image file to the given button

func (*Device) WriteRawImageToAreaUnscaled

func (d *Device) WriteRawImageToAreaUnscaled(x, y int, rawImg image.Image) error

y doesn't work, keep it zero!

func (*Device) WriteRawImageToButton

func (d *Device) WriteRawImageToButton(btnIndex int, rawImg image.Image) error

WriteRawImageToButton takes an `image.Image` and writes it to the given button, after resizing and rotating the image to fit the button (for some reason the StreamDeck screens are all upside down)

func (*Device) WriteTextToButton

func (d *Device) WriteTextToButton(btnIndex int, text string, textColour color.Color, backgroundColour color.Color)

WriteTextToButton is a low-level way to write text directly onto a button on the StreamDeck

type StreamDeck

type StreamDeck struct {
	// contains filtered or unexported fields
}

StreamDeck is the main struct to represent a StreamDeck device, and internally contains the reference to a `Device`

func New

func New() (*StreamDeck, error)

New will return a new instance of a `StreamDeck`, and is the main entry point for the higher-level interface. It will return an error if there is no StreamDeck plugged in.

func (*StreamDeck) AddButton

func (sd *StreamDeck) AddButton(btnIndex int, b Button)

AddButton adds a `Button` object to the StreamDeck at the specified index

func (*StreamDeck) ButtonUpdateHandler

func (sd *StreamDeck) ButtonUpdateHandler(b Button)

ButtonUpdateHandler allows a user of this library to signal when something external has changed, such that this button should be update

func (*StreamDeck) GetButtonIndex

func (sd *StreamDeck) GetButtonIndex(btnIndex int) Button

GetButtonByIndex returns a button for the given index

func (*StreamDeck) GetName

func (sd *StreamDeck) GetName() string

GetName returns the name of the type of Streamdeck

func (*StreamDeck) SetBrightness

func (sd *StreamDeck) SetBrightness(brightness int)

func (*StreamDeck) SetDecorator

func (sd *StreamDeck) SetDecorator(btnIndex int, d ButtonDecorator)

SetDecorator imposes a ButtonDecorator onto a given button

func (*StreamDeck) UnsetDecorator

func (sd *StreamDeck) UnsetDecorator(btnIndex int)

UnsetDecorator removes a ButtonDecorator from a given button

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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