2019-07-14 14:44:00 -06:00
|
|
|
package streamdeck
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"encoding/json"
|
|
|
|
|
2023-08-08 15:34:37 -06:00
|
|
|
sdcontext "code.encyclopediaofdaniel.com/dlprows/streamdeck-sdk/context"
|
2019-07-14 14:44:00 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
type Event struct {
|
|
|
|
Action string `json:"action,omitempty"`
|
|
|
|
Event string `json:"event,omitempty"`
|
|
|
|
UUID string `json:"uuid,omitempty"`
|
|
|
|
Context string `json:"context,omitempty"`
|
|
|
|
Device string `json:"device,omitempty"`
|
|
|
|
DeviceInfo DeviceInfo `json:"deviceInfo,omitempty"`
|
|
|
|
Payload json.RawMessage `json:"payload,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type DeviceInfo struct {
|
|
|
|
DeviceName string `json:"deviceName,omitempty"`
|
|
|
|
Type DeviceType `json:"type,omitempty"`
|
|
|
|
Size DeviceSize `json:"size,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type DeviceSize struct {
|
|
|
|
Columns int `json:"columns,omitempty"`
|
|
|
|
Rows int `json:"rows,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type DeviceType int
|
|
|
|
|
|
|
|
const (
|
|
|
|
StreamDeck DeviceType = 0
|
|
|
|
StreamDeckMini DeviceType = 1
|
|
|
|
StreamDeckXL DeviceType = 2
|
|
|
|
StreamDeckMobile DeviceType = 3
|
2023-08-08 15:34:37 -06:00
|
|
|
CorsairGKeys DeviceType = 4
|
|
|
|
StreamDeckPedal DeviceType = 5
|
|
|
|
CorsairVoyager DeviceType = 6
|
|
|
|
StreamDeckPlus DeviceType = 7
|
2019-07-14 14:44:00 -06:00
|
|
|
)
|
|
|
|
|
2023-08-08 15:34:37 -06:00
|
|
|
func NewEvent(ctx context.Context, name string, payload any) Event {
|
2019-07-14 14:44:00 -06:00
|
|
|
p, err := json.Marshal(payload)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return Event{
|
|
|
|
Event: name,
|
|
|
|
Action: sdcontext.Action(ctx),
|
|
|
|
Context: sdcontext.Context(ctx),
|
|
|
|
Device: sdcontext.Device(ctx),
|
|
|
|
Payload: p,
|
|
|
|
}
|
|
|
|
}
|