-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathconfig.go
More file actions
91 lines (79 loc) · 2.03 KB
/
config.go
File metadata and controls
91 lines (79 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package streamdeck
import (
"github.com/bearsh/hid"
)
type Config struct {
ProductID uint16 // ProductID is the USB ProductID
NumButtonColumns int
NumButtonRows int
Spacer int // Spacer is the spacing distance (in pixel) of two buttons on the Stream Deck.
ButtonSize int
ImageFormat string
ImageRotate bool
ConvertKey bool
}
func (c Config) NumButtons() int {
return c.NumButtonRows * c.NumButtonColumns
}
// PanelWidth is the total screen width of the Stream Deck (including spacers).
func (c *Config) PanelWidth() int {
return c.NumButtonColumns*c.ButtonSize + c.Spacer*(c.NumButtonColumns-1)
}
// PanelHeight is the total screen height of the stream deck (including spacers).
func (c *Config) PanelHeight() int {
return c.NumButtonRows*c.ButtonSize + c.Spacer*(c.NumButtonRows-1)
}
func (c *Config) fixKey(key int) int {
if c.ConvertKey {
keyCol := key % c.NumButtonColumns
return 1 + ((key - keyCol) + ((c.NumButtonColumns - 1) - keyCol))
}
return key
}
// Model 20GAA9901
var Original = Config{
ProductID: 0x60,
NumButtonColumns: 5,
NumButtonRows: 3,
Spacer: 19,
ButtonSize: 72,
ImageFormat: "bmp",
ConvertKey: true,
}
// Model 20GAA9902
var OriginalMk1 = Config{
ProductID: 0x6d,
NumButtonColumns: 5,
NumButtonRows: 3,
Spacer: 19,
ButtonSize: 72,
ImageFormat: "jpg",
ImageRotate: true,
}
var Original2 = Config{
ProductID: 0x80,
NumButtonColumns: 5,
NumButtonRows: 3,
Spacer: 19,
ButtonSize: 72,
ImageFormat: "jpg",
ImageRotate: true,
}
var Plus = Config{
ProductID: 0x0084,
NumButtonColumns: 4,
NumButtonRows: 2,
Spacer: 19,
ButtonSize: 120,
ImageFormat: "jpg",
}
var AllConfigs = []Config{Original, OriginalMk1, Original2, Plus}
func FindConnectedConfig() (Config, bool) {
for _, c := range AllConfigs {
devices := hid.Enumerate(VendorID, c.ProductID)
if len(devices) > 0 {
return c, true
}
}
return Config{}, false
}