Skip to content

Commit 4f822b9

Browse files
committed
Fix missing devices definition and add some descriptive comments
1 parent 4de9a5e commit 4f822b9

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

examples/client2/client2.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,36 @@ import (
99
"github.com/magicmonkey/go-streamdeck/actionhandlers"
1010
"github.com/magicmonkey/go-streamdeck/buttons"
1111
"github.com/magicmonkey/go-streamdeck/decorators"
12+
_ "github.com/magicmonkey/go-streamdeck/devices"
1213
)
1314

1415
func main() {
16+
// store the currently selected button
1517
var current int
1618

19+
// initialise the streamdeck
1720
sd, err := streamdeck.New()
1821
if err != nil {
1922
panic(err)
2023
}
2124

25+
// put a number onto each button
2226
btns := make([]*buttons.TextButton, 32)
2327
for i := 0; i < 32; i++ {
2428
btns[i] = buttons.NewTextButton(strconv.Itoa(i))
2529
sd.AddButton(i, btns[i])
2630
}
2731

32+
// create some decorators for later use
2833
greenBorder := decorators.NewBorder(10, color.RGBA{0, 255, 0, 255})
29-
3034
redBorder := decorators.NewBorder(5, color.RGBA{255, 0, 0, 255})
35+
36+
// add red borders to all buttons
3137
for i := 0; i < 32; i++ {
3238
sd.SetDecorator(i, redBorder)
3339
}
3440

41+
// add action handlers as an inline function
3542
for i := 0; i < 32; i++ {
3643
h := actionhandlers.NewCustomAction(func(btn streamdeck.Button) {
3744
sd.SetDecorator(current, redBorder)
@@ -41,8 +48,8 @@ func main() {
4148
btns[i].SetActionHandler(h)
4249
}
4350

51+
// don't end the program, keep running
4452
var wg sync.WaitGroup
4553
wg.Add(1)
4654
wg.Wait()
47-
4855
}

0 commit comments

Comments
 (0)