Skip to content

Commit 537e30b

Browse files
committed
Added a definition file for the original v2 device
1 parent 7f4bef1 commit 537e30b

File tree

2 files changed

+77
-20
lines changed

2 files changed

+77
-20
lines changed

devices/origv2.go

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package devices
2+
3+
import (
4+
"image"
5+
6+
streamdeck "github.com/magicmonkey/go-streamdeck"
7+
)
8+
9+
var (
10+
ov2Name string
11+
ov2ButtonWidth uint
12+
ov2ButtonHeight uint
13+
ov2ImageReportPayloadLength uint
14+
)
15+
16+
// GetImageHeaderOv2 returns the USB comms header for a button image for the XL
17+
func GetImageHeaderOv2(bytesRemaining uint, btnIndex uint, pageNumber uint) []byte {
18+
thisLength := uint(0)
19+
if ov2ImageReportPayloadLength < bytesRemaining {
20+
thisLength = ov2ImageReportPayloadLength
21+
} else {
22+
thisLength = bytesRemaining
23+
}
24+
header := []byte{'\x02', '\x07', byte(btnIndex)}
25+
if thisLength == bytesRemaining {
26+
header = append(header, '\x01')
27+
} else {
28+
header = append(header, '\x00')
29+
}
30+
31+
header = append(header, byte(thisLength&0xff))
32+
header = append(header, byte(thisLength>>8))
33+
34+
header = append(header, byte(pageNumber&0xff))
35+
header = append(header, byte(pageNumber>>8))
36+
37+
return header
38+
}
39+
40+
func init() {
41+
ov2Name = "Streamdeck (original v2)"
42+
ov2ButtonWidth = 72
43+
ov2ButtonHeight = 72
44+
ov2ImageReportPayloadLength = 1024
45+
streamdeck.RegisterDevicetype(
46+
ov2Name, // Name
47+
image.Point{X: int(ov2ButtonWidth), Y: int(ov2ButtonHeight)}, // Width/height of a button
48+
0x6d, // USB productID
49+
[]byte{'\x03', '\x02'}, // Reset packet
50+
15, // Number of buttons
51+
[]byte{'\x03', '\x08'}, // Set brightness packet preamble
52+
4, // Button read offset
53+
"JPEG", // Image format
54+
ov2ImageReportPayloadLength, // Amount of image payload allowed per USB packet
55+
GetImageHeaderOv2, // Function to get the comms image header
56+
)
57+
}

devices/xl.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ import (
77
)
88

99
var (
10-
name string
11-
buttonWidth uint
12-
buttonHeight uint
13-
imageReportPayloadLength uint
10+
xlName string
11+
xlButtonWidth uint
12+
xlButtonHeight uint
13+
xlImageReportPayloadLength uint
1414
)
1515

1616
// GetImageHeaderXl returns the USB comms header for a button image for the XL
1717
func GetImageHeaderXl(bytesRemaining uint, btnIndex uint, pageNumber uint) []byte {
1818
thisLength := uint(0)
19-
if imageReportPayloadLength < bytesRemaining {
20-
thisLength = imageReportPayloadLength
19+
if xlImageReportPayloadLength < bytesRemaining {
20+
thisLength = xlImageReportPayloadLength
2121
} else {
2222
thisLength = bytesRemaining
2323
}
@@ -38,20 +38,20 @@ func GetImageHeaderXl(bytesRemaining uint, btnIndex uint, pageNumber uint) []byt
3838
}
3939

4040
func init() {
41-
name = "Streamdeck XL"
42-
buttonWidth = 96
43-
buttonHeight = 96
44-
imageReportPayloadLength = 1024
41+
xlName = "Streamdeck XL"
42+
xlButtonWidth = 96
43+
xlButtonHeight = 96
44+
xlImageReportPayloadLength = 1024
4545
streamdeck.RegisterDevicetype(
46-
name, // Name
47-
image.Point{X: int(buttonWidth), Y: int(buttonHeight)}, // Width/height of a button
48-
0x6c, // USB productID
49-
[]byte{'\x03', '\x02'}, // Reset packet
50-
32, // Number of buttons
51-
[]byte{'\x03', '\x08'}, // Set brightness packet preamble
52-
4, // Button read offset
53-
"JPEG", // Image format
54-
imageReportPayloadLength, // Amount of image payload allowed per USB packet
55-
GetImageHeaderXl, // Function to get the comms image header
46+
xlName, // Name
47+
image.Point{X: int(xlButtonWidth), Y: int(xlButtonHeight)}, // Width/height of a button
48+
0x6c, // USB productID
49+
[]byte{'\x03', '\x02'}, // Reset packet
50+
32, // Number of buttons
51+
[]byte{'\x03', '\x08'}, // Set brightness packet preamble
52+
4, // Button read offset
53+
"JPEG", // Image format
54+
xlImageReportPayloadLength, // Amount of image payload allowed per USB packet
55+
GetImageHeaderXl, // Function to get the comms image header
5656
)
5757
}

0 commit comments

Comments
 (0)