2022-06-22 20:51:25 +01:00
|
|
|
package voicemeeter
|
|
|
|
|
|
|
|
import "fmt"
|
|
|
|
|
2022-07-10 23:08:14 +01:00
|
|
|
// button represents a single macrobuttton
|
2022-06-22 20:51:25 +01:00
|
|
|
type button struct {
|
|
|
|
index int
|
|
|
|
}
|
|
|
|
|
2022-06-23 14:04:57 +01:00
|
|
|
// newButton returns a button type
|
|
|
|
func newButton(i int) button {
|
|
|
|
return button{i}
|
|
|
|
}
|
|
|
|
|
2022-06-22 20:51:25 +01:00
|
|
|
// getter returns the value of a macrobutton parameter
|
|
|
|
func (m *button) getter(mode int) bool {
|
2022-09-07 20:59:55 +01:00
|
|
|
val, err := getMacroStatus(m.index, mode)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
}
|
|
|
|
return val == 1
|
2022-06-22 20:51:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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)
|
|
|
|
}
|
|
|
|
|
2022-06-26 01:36:32 +01:00
|
|
|
// String implements the fmt.stringer interface
|
2022-06-22 20:51:25 +01:00
|
|
|
func (m *button) String() string {
|
2022-06-25 01:18:20 +01:00
|
|
|
return fmt.Sprintf("MacroButton%d", m.index)
|
2022-06-22 20:51:25 +01:00
|
|
|
}
|
|
|
|
|
2022-12-08 10:24:52 +00:00
|
|
|
// State returns the value of the State parameter
|
|
|
|
func (m *button) State() bool {
|
2022-06-22 20:51:25 +01:00
|
|
|
return m.getter(1)
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetState sets the value of the State parameter
|
|
|
|
func (m *button) SetState(val bool) {
|
|
|
|
m.setter(val, 1)
|
|
|
|
}
|
|
|
|
|
2022-12-08 10:24:52 +00:00
|
|
|
// StateOnly returns the value of the StateOnly parameter
|
|
|
|
func (m *button) StateOnly() bool {
|
2022-06-22 20:51:25 +01:00
|
|
|
return m.getter(2)
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetStateOnly sets the value of the StateOnly parameter
|
|
|
|
func (m *button) SetStateOnly(val bool) {
|
|
|
|
m.setter(val, 2)
|
|
|
|
}
|
|
|
|
|
2022-12-08 10:24:52 +00:00
|
|
|
// Trigger returns the value of the Trigger parameter
|
|
|
|
func (m *button) Trigger() bool {
|
2022-06-22 20:51:25 +01:00
|
|
|
return m.getter(2)
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetTrigger returns the value of the Trigger parameter
|
|
|
|
func (m *button) SetTrigger(val bool) {
|
|
|
|
m.setter(val, 2)
|
|
|
|
}
|