streamdeck

package module
v0.0.0-...-fe8d402 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2024 License: MIT Imports: 14 Imported by: 3

README

streamdeck

The driver for streamdeckd

If you're looking for a complete Linux service to control your StreamDeck, check out Streamdeckd, which is based on this library.

Installation

Make sure you have a working Go environment (Go 1.12 or higher is required). See the install instructions.

To install streamdeck, simply run:

go get github.com/unix-streamdeck/driver

Configuration

On Linux you need to set up some udev rules to be able to access the device as a regular user. Edit /etc/udev/rules.d/99-streamdeck.rules and add these lines:

SUBSYSTEM=="usb", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="0060", MODE:="666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="0063", MODE:="666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="006c", MODE:="666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="006d", MODE:="666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="0080", MODE:="666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="0090", MODE:="666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="0086", MODE:="666", GROUP="plugdev"

Make sure your user is part of the plugdev group and reload the rules with sudo udevadm control --reload-rules. Unplug and replug the device and you should be good to go.

Documentation

Index

Constants

View Source
const (
	VID_ELGATO              = 0x0fd9
	PID_STREAMDECK          = 0x0060
	PID_STREAMDECK_V2       = 0x006d
	PID_STREAMDECK_MK2      = 0x0080
	PID_STREAMDECK_MINI     = 0x0063
	PID_STREAMDECK_MINI_MK2 = 0x0090
	PID_STREAMDECK_XL       = 0x006c
	PID_STREAMDECK_PEDAL    = 0x0086
	PID_STREAMDECK_PLUS     = 0x0084
)

Stream Deck Vendor & Product IDs.

Variables

This section is empty.

Functions

func PlusInputHandler

func PlusInputHandler(d *Device, cback func(event InputEvent))

Types

type Device

type Device struct {
	ID     string
	Serial string

	Columns    uint8
	Rows       uint8
	LcdColumns uint8
	Keys       uint8
	Knobs      uint8
	Pixels     uint
	LcdWidth   uint
	LcdHeight  uint
	DPI        uint
	Padding    uint

	KeyStateOffset    int
	TranslateKeyIndex func(index, columns uint8) uint8

	KeyState []byte

	Device IHidDevice

	HasScreen bool
	HasLCD    bool
	HasKnobs  bool
	LCDBuffer image.Image
	WriteSem  *semaphore.Weighted

	InputHandler func(device *Device, cback func(event InputEvent))
	// contains filtered or unexported fields
}

Device represents a single Stream Deck device.

func Devices

func Devices() ([]Device, error)

Devices returns all attached Stream Decks.

func GetDevInfo

func GetDevInfo(d hid.DeviceInfo) Device

func (Device) Clear

func (d Device) Clear() error

Clears the Stream Deck, setting a black image on all buttons.

func (*Device) Close

func (d *Device) Close() error

Close the connection with the device.

func (*Device) Fade

func (d *Device) Fade(start uint8, end uint8, duration time.Duration) error

Fade fades the brightness in or out.

func (Device) FirmwareVersion

func (d Device) FirmwareVersion() (string, error)

FirmwareVersion returns the firmware version of the device.

func (*Device) HandleInput

func (d *Device) HandleInput(cback func(event InputEvent))

func (*Device) Open

func (d *Device) Open() error

Open the device for input/output. This must be called before trying to communicate with the device.

func (Device) Reset

func (d Device) Reset() error

Resets the Stream Deck, clears all button images and shows the standby image.

func (*Device) SetBrightness

func (d *Device) SetBrightness(percent uint8) error

SetBrightness sets the background lighting brightness from 0 to 100 percent.

func (Device) SetImage

func (d Device) SetImage(index uint8, img image.Image) error

SetImage sets the image of a button on the Stream Deck. The provided image needs to be in the correct resolution for the device. The index starts with 0 being the top-left button.

func (Device) SetLcdImage

func (d Device) SetLcdImage(index int, img image.Image) error

func (*Device) SetSleepFadeDuration

func (d *Device) SetSleepFadeDuration(t time.Duration)

SetSleepFadeDuration sets the duration of the fading animation when the device is put to sleep or wakes up.

type HidDevice

type HidDevice struct {
	Device *hid.Device

	WriteSem *semaphore.Weighted
	// contains filtered or unexported fields
}

func (*HidDevice) Close

func (h *HidDevice) Close() error

func (*HidDevice) GetFeatureReport

func (h *HidDevice) GetFeatureReport(payload []byte) (int, error)

func (*HidDevice) GetManufacturer

func (h *HidDevice) GetManufacturer() (string, error)

func (*HidDevice) GetProduct

func (h *HidDevice) GetProduct() (string, error)

func (*HidDevice) GetSerial

func (h *HidDevice) GetSerial() (string, error)

func (*HidDevice) Open

func (h *HidDevice) Open() (*hid.Device, error)

func (*HidDevice) Read

func (h *HidDevice) Read(payload []byte) (int, error)

func (*HidDevice) SendFeatureReport

func (h *HidDevice) SendFeatureReport(payload []byte) (int, error)

func (*HidDevice) Write

func (h *HidDevice) Write(payload []byte) (int, error)

type IHidDevice

type IHidDevice interface {
	Open() (*hid.Device, error)
	Close() error
	GetFeatureReport(payload []byte) (int, error)
	SendFeatureReport(payload []byte) (int, error)
	Write(payload []byte) (int, error)
	Read(payload []byte) (int, error)
	GetManufacturer() (string, error)
	GetProduct() (string, error)
	GetSerial() (string, error)
}

type InputEvent

type InputEvent struct {
	EventType     InputEventType
	Index         uint8
	RotateNotches uint8
	ScreenX       uint16
	ScreenY       uint16
	ScreenEndX    uint16
	ScreenEndY    uint16
}

type InputEventType

type InputEventType uint8
const (
	KNOB_CCW InputEventType = iota
	KNOB_CW
	KNOB_PRESS
	SCREEN_SHORT_TAP
	SCREEN_LONG_TAP
	SCREEN_SWIPE
	KEY_PRESS
	KEY_RELEASE
)

type Key

type Key struct {
	Index   uint8
	Pressed bool
}

Key holds the current status of a key on the device.

Jump to

Keyboard shortcuts

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