@@ -9,29 +9,36 @@ import (
9
9
"github.com/magicmonkey/go-streamdeck/actionhandlers"
10
10
"github.com/magicmonkey/go-streamdeck/buttons"
11
11
"github.com/magicmonkey/go-streamdeck/decorators"
12
+ _ "github.com/magicmonkey/go-streamdeck/devices"
12
13
)
13
14
14
15
func main () {
16
+ // store the currently selected button
15
17
var current int
16
18
19
+ // initialise the streamdeck
17
20
sd , err := streamdeck .New ()
18
21
if err != nil {
19
22
panic (err )
20
23
}
21
24
25
+ // put a number onto each button
22
26
btns := make ([]* buttons.TextButton , 32 )
23
27
for i := 0 ; i < 32 ; i ++ {
24
28
btns [i ] = buttons .NewTextButton (strconv .Itoa (i ))
25
29
sd .AddButton (i , btns [i ])
26
30
}
27
31
32
+ // create some decorators for later use
28
33
greenBorder := decorators .NewBorder (10 , color.RGBA {0 , 255 , 0 , 255 })
29
-
30
34
redBorder := decorators .NewBorder (5 , color.RGBA {255 , 0 , 0 , 255 })
35
+
36
+ // add red borders to all buttons
31
37
for i := 0 ; i < 32 ; i ++ {
32
38
sd .SetDecorator (i , redBorder )
33
39
}
34
40
41
+ // add action handlers as an inline function
35
42
for i := 0 ; i < 32 ; i ++ {
36
43
h := actionhandlers .NewCustomAction (func (btn streamdeck.Button ) {
37
44
sd .SetDecorator (current , redBorder )
@@ -41,8 +48,8 @@ func main() {
41
48
btns [i ].SetActionHandler (h )
42
49
}
43
50
51
+ // don't end the program, keep running
44
52
var wg sync.WaitGroup
45
53
wg .Add (1 )
46
54
wg .Wait ()
47
-
48
55
}
0 commit comments