-
Notifications
You must be signed in to change notification settings - Fork 2
/
button.go
68 lines (56 loc) · 1.37 KB
/
button.go
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
package voicemeeter
import "fmt"
// button represents a single macrobuttton
type button struct {
index int
}
// newButton returns a button type
func newButton(i int) button {
return button{i}
}
// getter returns the value of a macrobutton parameter
func (m *button) getter(mode int) bool {
val, err := getMacroStatus(m.index, mode)
if err != nil {
fmt.Println(err)
}
return val == 1
}
// setter sets the value of a macrobutton parameter
func (m *button) setter(v bool, mode int) {
var value int
if v {
value = 1
} else {
value = 0
}
setMacroStatus(m.index, value, mode)
}
// String implements the fmt.stringer interface
func (m *button) String() string {
return fmt.Sprintf("MacroButton%d", m.index)
}
// State returns the value of the State parameter
func (m *button) State() bool {
return m.getter(1)
}
// SetState sets the value of the State parameter
func (m *button) SetState(val bool) {
m.setter(val, 1)
}
// StateOnly returns the value of the StateOnly parameter
func (m *button) StateOnly() bool {
return m.getter(2)
}
// SetStateOnly sets the value of the StateOnly parameter
func (m *button) SetStateOnly(val bool) {
m.setter(val, 2)
}
// Trigger returns the value of the Trigger parameter
func (m *button) Trigger() bool {
return m.getter(2)
}
// SetTrigger returns the value of the Trigger parameter
func (m *button) SetTrigger(val bool) {
m.setter(val, 2)
}