Documentation
¶
Overview ¶
Package streamdeck provides support for interacting with Elgato Stream Deck devices connected to a computer without using vendor-provided software.
It is written in pure Go and works on Linux, macOS and Windows.
Index ¶
- Variables
- type Device
- func (d *Device) AddDialRotateHandler(di DialID, fn DialRotateHandler) error
- func (d *Device) AddDialSwitchHandler(di DialID, fn DialSwitchHandler) error
- func (d *Device) AddKeyHandler(key KeyID, fn KeyHandler) error
- func (d *Device) AddTouchPointHandler(tp TouchPointID, fn TouchPointHandler) error
- func (d *Device) AddTouchStripSwipeHandler(fn TouchStripSwipeHandler) error
- func (d *Device) AddTouchStripTouchHandler(fn TouchStripTouchHandler) error
- func (d *Device) ClearInfoBar() error
- func (d *Device) ClearKey(key KeyID) error
- func (d *Device) ClearTouchPoint(tp TouchPointID) error
- func (d *Device) ClearTouchStrip() error
- func (d *Device) ClearTouchStripWithRectangle(rect image.Rectangle) error
- func (d *Device) Close() error
- func (d *Device) ForEachDial(cb func(di DialID) error) error
- func (d *Device) ForEachKey(cb func(k KeyID) error) error
- func (d *Device) ForEachTouchPoint(cb func(tp TouchPointID) error) error
- func (d *Device) GetDialCount() byte
- func (d *Device) GetFirmwareVersion() (string, error)
- func (d *Device) GetInfoBarImageRectangle() (image.Rectangle, error)
- func (d *Device) GetInfoBarSupported() bool
- func (d *Device) GetKeyCount() byte
- func (d *Device) GetKeyImageRectangle() (image.Rectangle, error)
- func (d *Device) GetModelID() string
- func (d *Device) GetModelName() string
- func (d *Device) GetSerialNumber() string
- func (d *Device) GetTouchPointCount() byte
- func (d *Device) GetTouchStripImageRectangle() (image.Rectangle, error)
- func (d *Device) GetTouchStripSupported() bool
- func (d *Device) IsOpen() bool
- func (d *Device) Listen(errCh chan error) error
- func (d *Device) Open() error
- func (d *Device) Reset() error
- func (d *Device) SetBrightness(perc byte) error
- func (d *Device) SetInfoBarColor(c color.Color) error
- func (d *Device) SetInfoBarImage(img image.Image) error
- func (d *Device) SetInfoBarImageFromFS(ffs fs.FS, name string) error
- func (d *Device) SetInfoBarImageFromFile(name string) error
- func (d *Device) SetInfoBarImageFromReadCloser(r io.ReadCloser) error
- func (d *Device) SetInfoBarImageFromReader(r io.Reader) error
- func (d *Device) SetKeyColor(key KeyID, c color.Color) error
- func (d *Device) SetKeyImage(key KeyID, img image.Image) error
- func (d *Device) SetKeyImageFromFS(key KeyID, ffs fs.FS, name string) error
- func (d *Device) SetKeyImageFromFile(key KeyID, name string) error
- func (d *Device) SetKeyImageFromReadCloser(key KeyID, r io.ReadCloser) error
- func (d *Device) SetKeyImageFromReader(key KeyID, r io.Reader) error
- func (d *Device) SetTouchPointColor(tp TouchPointID, c color.Color) error
- func (d *Device) SetTouchStripColor(c color.Color) error
- func (d *Device) SetTouchStripColorWithRectangle(c color.Color, rect image.Rectangle) error
- func (d *Device) SetTouchStripImage(img image.Image) error
- func (d *Device) SetTouchStripImageFromFS(ffs fs.FS, name string) error
- func (d *Device) SetTouchStripImageFromFSWithRectangle(ffs fs.FS, name string, rect image.Rectangle) error
- func (d *Device) SetTouchStripImageFromFile(name string) error
- func (d *Device) SetTouchStripImageFromFileWithRectangle(name string, rect image.Rectangle) error
- func (d *Device) SetTouchStripImageFromReadCloser(r io.ReadCloser) error
- func (d *Device) SetTouchStripImageFromReadCloserWithRectangle(r io.ReadCloser, rect image.Rectangle) error
- func (d *Device) SetTouchStripImageFromReader(r io.Reader) error
- func (d *Device) SetTouchStripImageFromReaderWithRectangle(r io.Reader, rect image.Rectangle) error
- func (d *Device) SetTouchStripImageWithRectangle(img image.Image, rect image.Rectangle) error
- type Dial
- type DialHandlerError
- type DialID
- type DialRotateHandler
- type DialSwitchHandler
- type Key
- type KeyHandler
- type KeyHandlerError
- type KeyID
- type TouchPoint
- type TouchPointHandler
- type TouchPointHandlerError
- type TouchPointID
- type TouchStripImageRectangleError
- type TouchStripSwipeHandler
- type TouchStripSwipeHandlerError
- type TouchStripTouchHandler
- type TouchStripTouchHandlerError
- type TouchStripTouchType
Constants ¶
This section is empty.
Variables ¶
var ( ErrDeviceEnumerationFailed = usbhid.ErrDeviceEnumerationFailed ErrDeviceFailedToClose = usbhid.ErrDeviceFailedToClose ErrDeviceFailedToOpen = usbhid.ErrDeviceFailedToOpen ErrDeviceInfoBarNotSupported = errors.New("device hardware does not includes an info bar") ErrDeviceIsClosed = usbhid.ErrDeviceIsClosed ErrDeviceIsOpen = usbhid.ErrDeviceIsOpen ErrDeviceLocked = usbhid.ErrDeviceLocked ErrDeviceTouchPointNotSupported = errors.New("device hardware does not includes touch points") ErrDeviceTouchStripNotSupported = errors.New("device hardware does not includes a touch strip") ErrDialHandlerInvalid = errors.New("dial handler is not valid") ErrDialInvalid = errors.New("dial is not valid") ErrGetFeatureReportFailed = usbhid.ErrGetFeatureReportFailed ErrGetInputReportFailed = usbhid.ErrGetInputReportFailed ErrImageInvalid = errors.New("image is not valid") ErrKeyHandlerInvalid = errors.New("key handler is not valid") ErrKeyInvalid = errors.New("key is not valid") ErrMoreThanOneDeviceFound = usbhid.ErrMoreThanOneDeviceFound ErrNoDeviceFound = usbhid.ErrNoDeviceFound ErrReportBufferOverflow = usbhid.ErrReportBufferOverflow ErrSetFeatureReportFailed = usbhid.ErrSetFeatureReportFailed ErrSetOutputReportFailed = usbhid.ErrSetOutputReportFailed ErrTouchPointHandlerInvalid = errors.New("touch point handler is not valid") ErrTouchPointInvalid = errors.New("touch point is not valid") ErrTouchStripHandlerInvalid = errors.New("touch strip handler is not valid") )
Errors returned from streamdeck package may be tested against these errors with errors.Is.
Functions ¶
This section is empty.
Types ¶
type Device ¶
type Device struct {
// contains filtered or unexported fields
}
Device represents an Elgato Stream Deck device and provides methods to interact with it, including setting key images, handling input events, and controlling device settings.
func Enumerate ¶
Enumerate lists the supported Elgato Stream Deck devices connected to the computer.
func GetDevice ¶
GetDevice returns an Elgato Stream Deck device found connected to the machine that matches the provided serial number. If serial number is empty and only one device is connected, this device is returned, otherwise an error is returned.
func (*Device) AddDialRotateHandler ¶
func (d *Device) AddDialRotateHandler(di DialID, fn DialRotateHandler) error
AddDialRotateHandler registers a DialSwitchHandler callback to be called whenever the given dial is rotated.
func (*Device) AddDialSwitchHandler ¶
func (d *Device) AddDialSwitchHandler(di DialID, fn DialSwitchHandler) error
AddDialSwitchHandler registers a DialSwitchHandler callback to be called whenever the given dial is pressed.
func (*Device) AddKeyHandler ¶
func (d *Device) AddKeyHandler(key KeyID, fn KeyHandler) error
AddKeyHandler registers a KeyHandler callback to be called whenever the given key is pressed.
func (*Device) AddTouchPointHandler ¶
func (d *Device) AddTouchPointHandler(tp TouchPointID, fn TouchPointHandler) error
AddTouchPointHandler registers a TouchPointHandler callback to be called whenever the given touch point is pressed.
func (*Device) AddTouchStripSwipeHandler ¶
func (d *Device) AddTouchStripSwipeHandler(fn TouchStripSwipeHandler) error
AddTouchStripSwipeHandler registers a TouchStripSwipeHandler callback to be called whenever the touch strip is swiped.
func (*Device) AddTouchStripTouchHandler ¶
func (d *Device) AddTouchStripTouchHandler(fn TouchStripTouchHandler) error
AddTouchStripTouchHandler registers a TouchStripTouchHandler callback to be called whenever the touch strip is touched.
func (*Device) ClearInfoBar ¶
ClearInfoBar clears the info bar display available on some Elgato Stream Deck models.
func (*Device) ClearTouchPoint ¶
func (d *Device) ClearTouchPoint(tp TouchPointID) error
ClearTouchPoint clears the color set to a touch point strip available in some Elgato Stream Deck models.
func (*Device) ClearTouchStrip ¶
ClearTouchStrip clears the touch strip display available on some Elgato Stream Deck models.
func (*Device) ClearTouchStripWithRectangle ¶
ClearTouchStripWithRectangle clears the provided rectangle of the touch strip display available on some Elgato Stream Deck models.
func (*Device) ForEachDial ¶
ForEachDial calls the provided callback function for each dial available on the Elgato Stream Deck device, passing the DialID as an argument.
func (*Device) ForEachKey ¶
ForEachKey calls the provided callback function for each key available on the Elgato Stream Deck device, passing the KeyID as an argument.
func (*Device) ForEachTouchPoint ¶
func (d *Device) ForEachTouchPoint(cb func(tp TouchPointID) error) error
ForEachTouchPoint calls the provided callback function for each touch point available on the Elgato Stream Deck device, passing the TouchPointID as an argument.
func (*Device) GetDialCount ¶
GetDialCount returns the number of dials available on the Elgato Stream Deck device.
func (*Device) GetFirmwareVersion ¶
GetFirmwareVersion returns the firmware version of the Elgato Stream Deck device.
func (*Device) GetInfoBarImageRectangle ¶
GetInfoBarImageRectangle returns an image.Rectangle representing the geometry of the info bar display available on some Elgato Stream Deck models.
func (*Device) GetInfoBarSupported ¶
GetInfoBarSupported returns a boolean reporting if the Elgato Stream Deck device includes an info bar display.
func (*Device) GetKeyCount ¶
GetKeyCount returns the number of keys available on the Elgato Stream Deck device.
func (*Device) GetKeyImageRectangle ¶
GetKeyImageRectangle returns an image.Rectangle representing the geometry of the Elgato Stream Deck key background displays.
func (*Device) GetModelID ¶
GetModelID returns a string identifier of the Elgato Stream Deck device model.
func (*Device) GetModelName ¶
GetModelName returns the Elgato Stream Deck device model name.
func (*Device) GetSerialNumber ¶
GetSerialNumber returns the serial number of the Elgato Stream Deck device.
func (*Device) GetTouchPointCount ¶
GetTouchPointCount returns the number of touch points available on the Elgato Stream Deck device, if supported.
func (*Device) GetTouchStripImageRectangle ¶
GetTouchStripImageRectangle returns an image.Rectangle representing the geometry of the touch strip display available on some Elgato Stream Deck models.
func (*Device) GetTouchStripSupported ¶
GetTouchStripSupported returns a boolean reporting if the Elgato Stream Deck device includes an touch strip display.
func (*Device) IsOpen ¶
IsOpen checks if the Elgato Stream Deck device is open and available for usage.
func (*Device) Listen ¶
Listen listens to input events from the Elgato Stream Deck device and calls handler callbacks as required.
errCh is an error channel to receive errors from the input handlers. If set to a nil channel, errors are sent to standard logger. Errors are sent non-blocking.
func (*Device) Reset ¶
Reset resets the Elgato Stream Deck device.
Please note that this will close the connection, because this is similar to power cycling the device. This function won't try to reconnect.
func (*Device) SetBrightness ¶
SetBrightness sets the Elgato Stream Deck device brightness, in percent.
func (*Device) SetInfoBarColor ¶
SetInfoBarColor sets a color to an Elgato Stream Deck info bar display available on some Elgato Stream Deck models.
func (*Device) SetInfoBarImage ¶
SetInfoBarImage draws a given image.Image to the info bar display available on some Elgato Stream Deck models. The image is scaled as needed.
func (*Device) SetInfoBarImageFromFS ¶
SetInfoBarImageFromFS draws an image from a filesystem to the info bar display available on some Elgato Stream Deck models. The image is loaded from a filesystem, decoded and scaled as needed.
func (*Device) SetInfoBarImageFromFile ¶
SetInfoBarImageFromFile draws an image from a file to the info bar display available on some Elgato Stream Deck models. The image is loaded, decoded and scaled as needed.
func (*Device) SetInfoBarImageFromReadCloser ¶
func (d *Device) SetInfoBarImageFromReadCloser(r io.ReadCloser) error
SetInfoBarImageFromReadCloser draws an image from an io.ReadCloser to the info bar display available on some Elgato Stream Deck models. The ReadCloser is automatically closed after reading.
func (*Device) SetInfoBarImageFromReader ¶
SetInfoBarImageFromReader draws an image from an io.Reader to the info bar display available on some Elgato Stream Deck models. The image is decoded and scaled as needed.
func (*Device) SetKeyColor ¶
SetKeyColor sets a color to an Elgato Stream Deck key background display.
func (*Device) SetKeyImage ¶
SetKeyImage draws a given image.Image to an Elgato Stream Deck key background display. The image is scaled as needed.
func (*Device) SetKeyImageFromFS ¶
SetKeyImageFromFS draws an image from a filesystem to an Elgato Stream Deck key background display. The image is loaded from a filesystem, decoded and scaled as needed.
func (*Device) SetKeyImageFromFile ¶
SetKeyImageFromFile draws an image from a file to an Elgato Stream Deck key background display. The image is loaded, decoded and scaled as needed.
func (*Device) SetKeyImageFromReadCloser ¶
func (d *Device) SetKeyImageFromReadCloser(key KeyID, r io.ReadCloser) error
SetKeyImageFromReadCloser draws an image from an io.ReadCloser to an Elgato Stream Deck key background display. The ReadCloser is automatically closed after reading.
func (*Device) SetKeyImageFromReader ¶
SetKeyImageFromReader draws an image from an io.Reader to an Elgato Stream Deck key background display. The image is decoded and scaled as needed.
func (*Device) SetTouchPointColor ¶
func (d *Device) SetTouchPointColor(tp TouchPointID, c color.Color) error
SetTouchPointColor sets a color to the touch point strip available in some Elgato Stream Deck models.
func (*Device) SetTouchStripColor ¶
SetTouchStripColor sets a color to the whole touch strip display available on some Elgato Stream Deck models.
func (*Device) SetTouchStripColorWithRectangle ¶
SetTouchStripColorWithRectangle sets a color to the provided rectangle of the touch strip display available on some Elgato Stream Deck models.
func (*Device) SetTouchStripImage ¶
SetTouchStripImage draws a given image.Image to the touch strip display available on some Elgato Stream Deck models. The image is scaled as needed to fit the whole display.
func (*Device) SetTouchStripImageFromFS ¶
SetTouchStripImageFromFS draws an image from a filesystem to the touch strip display available on some Elgato Stream Deck models. The image is loaded from a filesystem, decoded and scaled as needed to fit the whole display.
func (*Device) SetTouchStripImageFromFSWithRectangle ¶
func (d *Device) SetTouchStripImageFromFSWithRectangle(ffs fs.FS, name string, rect image.Rectangle) error
SetTouchStripImageFromFSWithRectangle draws an image from a filesystem to the touch strip display available on some Elgato Stream Deck models. The image is loaded from a filesystem, decoded and scaled as needed to fit the provided rectangle.
func (*Device) SetTouchStripImageFromFile ¶
SetTouchStripImageFromFile draws an image from a file to the touch strip display available on some Elgato Stream Deck models. The image is loaded, decoded and scaled as needed to fit the whole display.
func (*Device) SetTouchStripImageFromFileWithRectangle ¶
SetTouchStripImageFromFileWithRectangle draws an image from a file to the touch strip display available on some Elgato Stream Deck models. The image is loaded, decoded and scaled as needed to fit the provided rectangle.
func (*Device) SetTouchStripImageFromReadCloser ¶
func (d *Device) SetTouchStripImageFromReadCloser(r io.ReadCloser) error
SetTouchStripImageFromReadCloser draws an image from an io.ReadCloser to the touch strip display available on some Elgato Stream Deck models. The ReadCloser is automatically closed after reading. The image is decoded and scaled as needed to fit the whole display.
func (*Device) SetTouchStripImageFromReadCloserWithRectangle ¶
func (d *Device) SetTouchStripImageFromReadCloserWithRectangle(r io.ReadCloser, rect image.Rectangle) error
SetTouchStripImageFromReadCloserWithRectangle draws an image from an io.ReadCloser to the touch strip display available on some Elgato Stream Deck models. The ReadCloser is automatically closed after reading. The image is decoded and scaled as needed to fit the provided rectangle.
func (*Device) SetTouchStripImageFromReader ¶
SetTouchStripImageFromReader draws an image from an io.Reader to the touch strip display available on some Elgato Stream Deck models. The image is decoded and scaled as needed to fit the whole display.
func (*Device) SetTouchStripImageFromReaderWithRectangle ¶
SetTouchStripImageFromReaderWithRectangle draws an image from an io.Reader to the touch strip display available on some Elgato Stream Deck models. The image is decoded and scaled as needed to fit the provided rectangle.
func (*Device) SetTouchStripImageWithRectangle ¶
SetTouchStripImageWithRectangle draws an image.Image to the touch strip display available on some Elgato Stream Deck models. The image is scaled as needed to fit the provided rectangle.
type Dial ¶
type Dial struct {
// contains filtered or unexported fields
}
Dial represents a rotative encoder with switch available on some Elgato Stream Deck devices.
func (*Dial) WaitForRelease ¶
WaitForRelease blocks until the dial switch is released and returns the duration the dial switch was held closed. This method should be called from within a DialSwitchHandler.
type DialHandlerError ¶
DialSwitchHandlerError represents an error returned by a dial switch handler including the dial identifier.
func (DialHandlerError) Error ¶
func (b DialHandlerError) Error() string
Error returns a string representation of a dial handler error.
func (DialHandlerError) Unwrap ¶
func (b DialHandlerError) Unwrap() error
Unwrap returns the underlying dial handler error.
type DialID ¶
type DialID byte
DialID represents a physical Elgato Stream Deck device dial.
Elgato Stream Deck dial identifiers. These constants represent the dials on the device depending on the supported models.
type DialRotateHandler ¶
DialRotateHandler represents a callback function that is called when a dial is rotated. It receives the Device, the Dial instance and the rotation delta as parameters.
type DialSwitchHandler ¶
DialSwitchHandler represents a callback function that is called when a dial switch is activated. It receives the Device and Dial instances as parameters.
type Key ¶
type Key struct {
// contains filtered or unexported fields
}
Key represents a physical key on the Elgato Stream Deck device.
func (*Key) WaitForRelease ¶
WaitForRelease blocks until the key is released and returns the duration the key was held down. This method should be called from within a KeyHandler.
type KeyHandler ¶
KeyHandler represents a callback function that is called when a key is pressed. It receives the Device and Key instances as parameters.
type KeyHandlerError ¶
KeyHandlerError represents an error returned by a key handler including the key identifier.
func (KeyHandlerError) Error ¶
func (b KeyHandlerError) Error() string
Error returns a string representation of a key handler error.
func (KeyHandlerError) Unwrap ¶
func (b KeyHandlerError) Unwrap() error
Unwrap returns the underlying key handler error.
type KeyID ¶
type KeyID byte
KeyID represents a physical Elgato Stream Deck device key.
type TouchPoint ¶
type TouchPoint struct {
// contains filtered or unexported fields
}
TouchPoint represents a touch-sensitive area on supported Elgato Stream Deck devices.
func (*TouchPoint) GetID ¶
func (tp *TouchPoint) GetID() TouchPointID
GetID returns the TouchPointID identifier for this touch point.
func (*TouchPoint) String ¶
func (tp *TouchPoint) String() string
String returns a string representation of the TouchPoint.
func (*TouchPoint) WaitForRelease ¶
func (tp *TouchPoint) WaitForRelease() time.Duration
WaitForRelease blocks until the touch point is released and returns the duration the touch point was held down. This method should be called from within a TouchPointHandler.
type TouchPointHandler ¶
type TouchPointHandler func(d *Device, tp *TouchPoint) error
TouchPointHandler represents a callback function that is called when a touch point is activated. It receives the Device and TouchPoint instances as parameters.
type TouchPointHandlerError ¶
type TouchPointHandlerError struct {
TouchPointID TouchPointID
Err error
}
TouchPointHandlerError represents an error returned by a touch point handler including the touch point identifier.
func (TouchPointHandlerError) Error ¶
func (b TouchPointHandlerError) Error() string
Error returns a string representation of a touch point handler error.
func (TouchPointHandlerError) Unwrap ¶
func (b TouchPointHandlerError) Unwrap() error
Unwrap returns the underlying touch point handler error.
type TouchPointID ¶
type TouchPointID byte
TouchPointID represents a physical Elgato Stream Deck device touch point.
const ( TOUCH_POINT_1 TouchPointID = iota + 1 TOUCH_POINT_2 )
Elgato Stream Deck touch point identifiers. These constants represent the touch points on the device, depending on the supported models.
func (TouchPointID) String ¶
func (id TouchPointID) String() string
String returns a string representation of the TouchPointID.
type TouchStripImageRectangleError ¶
TouchStripImageRectangleError represents an error when a provided image rectangle would not fit the touch strip display available on some Elgato Stream Deck devices.
func (TouchStripImageRectangleError) Error ¶
func (b TouchStripImageRectangleError) Error() string
Error returns a string representation of a touch strip image rectangle error.
type TouchStripSwipeHandler ¶
TouchStripSwipeHandler represents a callback function that is called when a touch strip is swiped. It receives the Device instance, the origin point and the destination point as parameters.
type TouchStripSwipeHandlerError ¶
TouchStripSwipeHandlerError represents an error returned by a touch strip swipe handler including the swipe origin and destination points.
func (TouchStripSwipeHandlerError) Error ¶
func (b TouchStripSwipeHandlerError) Error() string
Error returns a string representation of a touch strip swipe handler error.
func (TouchStripSwipeHandlerError) Unwrap ¶
func (b TouchStripSwipeHandlerError) Unwrap() error
Unwrap returns the underlying touch strip swipe handler error.
type TouchStripTouchHandler ¶
type TouchStripTouchHandler func(d *Device, t TouchStripTouchType, p image.Point) error
TouchStripTouchHandler represents a callback function that is called when a touch strip is touched. It receives the Device instance, the touch strip touch type and point as parameters.
type TouchStripTouchHandlerError ¶
type TouchStripTouchHandlerError struct {
Type TouchStripTouchType
Point image.Point
Err error
}
TouchStripTouchHandlerError represents an error returned by a touch strip touch handler including the touch type and touched point.
func (TouchStripTouchHandlerError) Error ¶
func (b TouchStripTouchHandlerError) Error() string
Error returns a string representation of a touch strip touch handler error.
func (TouchStripTouchHandlerError) Unwrap ¶
func (b TouchStripTouchHandlerError) Unwrap() error
Unwrap returns the underlying touch strip touch handler error.
type TouchStripTouchType ¶
type TouchStripTouchType byte
TouchStripTouchType represents a touch strip touch type
const ( TOUCH_STRIP_TOUCH_TYPE_SHORT TouchStripTouchType = iota + 1 TOUCH_STRIP_TOUCH_TYPE_LONG )
Elgato Stream Deck touch strip touch types. These constants represent the duration while the touch strip was touched.
func (TouchStripTouchType) String ¶
func (t TouchStripTouchType) String() string
String returns a string representation of the TouchStripTouchType.
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
advanced
command
|
|
|
basic
command
|
|
|
device-info
command
|
|
|
images
command
|
|
|
multi-device
command
|