Documentation ¶
Index ¶
- Constants
- type BrightnessPacketFunc
- type Device
- func (d *Device) Clear(ctx context.Context) error
- func (d *Device) Close(ctx context.Context) error
- func (d *Device) Reset(ctx context.Context) error
- func (d *Device) SetBrightness(ctx context.Context, brightness byte) error
- func (d *Device) SetButton(ctx context.Context, btnIndex int, rawImage []byte) error
- type DeviceType
- type ImageFlags
- type ImageFormat
- type ImageTextureFunc
- type ResetPacketFunc
- type StreamDeck
- func (s *StreamDeck) Brightness() uint8
- func (s *StreamDeck) Close(ctx context.Context) error
- func (s *StreamDeck) Device() *Device
- func (s *StreamDeck) IsSleeping() bool
- func (s *StreamDeck) ProcessImage(img image.Image) ([]byte, error)
- func (s *StreamDeck) SetBrightness(ctx context.Context, brightness uint8) error
- func (s *StreamDeck) SetHandler(fn func(context.Context, int) error)
- func (s *StreamDeck) SetSleeping(ctx context.Context, sleeping bool) error
- func (s *StreamDeck) ToggleSleep(ctx context.Context) (bool, error)
- type View
Constants ¶
const ( // BrightnessMin is the lowest brightness that can be set on a StreamDeck. BrightnessMin uint8 = 0 // BrightnessFull is the highest brightness that can be set on a StreamDeck. BrightnessFull uint8 = 100 )
const ( // ImageFlagFlipX flips an image horizontally. ImageFlagFlipX = 1 << iota // ImageFlagFlipY flips an image vertically. ImageFlagFlipY // ImageFlagRotate90 rotates an image 90 degrees counter-clockwise. ImageFlagRotate90 // ImageFlagRotate180 rotates an image 180 degrees counter-clockwise. ImageFlagRotate180 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BrightnessPacketFunc ¶
BrightnessPacketFunc is a function that returns a packet used to change the brightness of a Device.
type Device ¶
type Device struct { DeviceType // contains filtered or unexported fields }
Device represents a Stream Deck Device.
func (*Device) Close ¶
Close resets the Device and closes the USB HID connection to the Stream Deck.
func (*Device) Reset ¶
Reset resets the Device, restoring its initial state displaying the Elgato logo.
func (*Device) SetBrightness ¶
SetBrightness sets the brightness of all buttons on the Device.
type DeviceType ¶
type DeviceType struct { // Name of the Device Type. Name string // ProductID of the Device. This will be used to identify the DeviceType // alongside Elgato's Vendor ID. ProductID uint16 // Rows of buttons on the Device. Rows int // Cols of buttons on the Device. Cols int // ImageFormat used to encode images displayed on the Device. ImageFormat ImageFormat // ImageSize to use to transform images for the Device. ImageSize int // ImageFlags to apply to images before displaying them on the Device. ImageFlags ImageFlags // ButtonOffset is the offset to used to detect what physical button on the // device was pressed. This offset value varies by generation, but is // usually either `1` or `4`. ButtonOffset int // BrightnessPacketFunc returns a packet to change the brightness on the // Device. BrightnessPacketFunc // ResetPacketFunc returns a packet to reset the display on the Device. ResetPacketFunc // ImageTextureFunc sets an image on the Device. ImageTextureFunc }
DeviceType represents a type of Elgato Stream Deck.
func (DeviceType) ButtonCount ¶
func (t DeviceType) ButtonCount() int
ButtonCount returns the total number of buttons on the Device.
func (DeviceType) EncodeImage ¶
func (t DeviceType) EncodeImage(img image.Image) ([]byte, error)
EncodeImage encodes an image to be used with the Stream Deck.
func (DeviceType) GIFT ¶
func (t DeviceType) GIFT() *gift.GIFT
GIFT returns the GIFT instance used to transform images for the Device.
type ImageFlags ¶
type ImageFlags uint8
ImageFlags are used to apply translations to an image before displaying it on a Stream Deck.
func (ImageFlags) GIFT ¶
func (f ImageFlags) GIFT(size int) *gift.GIFT
GIFT returns the GIFT instance created by the flags.
func (ImageFlags) Has ¶
func (f ImageFlags) Has(v ImageFlags) bool
Has returns true if a specific image flag is set.
type ImageFormat ¶
type ImageFormat string
ImageFormat represents an Image Format used by a Stream Deck Device.
const ( // BMP is a BMP ImageFormat. BMP ImageFormat = "BMP" // JPEG is a JPEG ImageFormat. JPEG ImageFormat = "JPEG" )
type ImageTextureFunc ¶
type ImageTextureFunc func( ctx context.Context, w func(context.Context, []byte) (int, error), button byte, buffer []byte, ) error
ImageTextureFunc is a function that displays an image for the specified button on a Device.
type ResetPacketFunc ¶
type ResetPacketFunc func() []byte
ResetPacketFunc is a function that returns a packet used to reset the Device.
type StreamDeck ¶
type StreamDeck struct {
// contains filtered or unexported fields
}
StreamDeck represents an Elgato Stream Deck.
func New ¶
func New(ctx context.Context) (*StreamDeck, error)
New opens a connection to a Stream Deck and provides a user-friendly wrapper that makes interacting with the Stream Deck easier and more convenient.
func NewFromDevice ¶
func NewFromDevice(ctx context.Context, device *Device) (*StreamDeck, error)
NewFromDevice creates a new Stream Deck from an existing Device, most users should use the New function instead.
This function can be useful if you have a specific USB device you want to use like if you want to connect to multiple Stream Decks or use a specific device that is not auto-detected correctly.
func (*StreamDeck) Brightness ¶
func (s *StreamDeck) Brightness() uint8
Brightness returns the target brightness of the Stream Deck. This will not return 0 if the Stream Deck is sleeping. To check if the Stream Deck is sleeping use StreamDeck#IsSleeping().
func (*StreamDeck) Close ¶
func (s *StreamDeck) Close(ctx context.Context) error
Close stops the event listeners and closes the underlying connection to the Stream Deck device.
func (*StreamDeck) Device ¶
func (s *StreamDeck) Device() *Device
Device returns the underlying Stream Deck device.
func (*StreamDeck) IsSleeping ¶
func (s *StreamDeck) IsSleeping() bool
IsSleeping returns true if the Stream Deck is currently sleeping.
func (*StreamDeck) ProcessImage ¶
func (s *StreamDeck) ProcessImage(img image.Image) ([]byte, error)
ProcessImage processes an image to be used with the Stream Deck.
func (*StreamDeck) SetBrightness ¶
func (s *StreamDeck) SetBrightness(ctx context.Context, brightness uint8) error
SetBrightness sets the brightness of the Stream Deck.
func (*StreamDeck) SetHandler ¶
func (s *StreamDeck) SetHandler(fn func(context.Context, int) error)
SetHandler sets the button press handler used by the end-user to handle press events.
func (*StreamDeck) SetSleeping ¶
func (s *StreamDeck) SetSleeping(ctx context.Context, sleeping bool) error
SetSleeping sets whether the Stream Deck is sleeping or not.
func (*StreamDeck) ToggleSleep ¶
func (s *StreamDeck) ToggleSleep(ctx context.Context) (bool, error)
ToggleSleep toggles the sleep state for the Stream Deck.