voicemeeter-api-python/voicemeeterlib/macrobutton.py

46 lines
1018 B
Python
Raw Normal View History

2022-06-16 14:07:12 +01:00
from .iremote import IRemote
class Adapter(IRemote):
"""Adapter to the common interface."""
def identifier(self):
pass
2022-06-21 23:21:55 +01:00
def getter(self, mode):
return self._remote.get_buttonstatus(self.index, mode)
2022-06-16 14:07:12 +01:00
2022-06-21 23:21:55 +01:00
def setter(self, val, mode):
self._remote.set_buttonstatus(self.index, val, mode)
2022-06-16 14:07:12 +01:00
class MacroButton(Adapter):
"""Defines concrete implementation for macrobutton"""
def __str__(self):
return f"{type(self).__name__}{self._remote.kind}{self.index}"
@property
def state(self) -> bool:
2022-06-21 23:21:55 +01:00
return self.getter(1) == 1
2022-06-16 14:07:12 +01:00
@state.setter
def state(self, val):
2022-06-21 23:21:55 +01:00
self.setter(1 if val else 0, 1)
2022-06-16 14:07:12 +01:00
@property
def stateonly(self) -> bool:
2022-06-21 23:21:55 +01:00
return self.getter(2) == 1
2022-06-16 14:07:12 +01:00
@stateonly.setter
def stateonly(self, val):
2022-06-21 23:21:55 +01:00
self.setter(1 if val else 0, 2)
2022-06-16 14:07:12 +01:00
@property
def trigger(self) -> bool:
2022-06-21 23:21:55 +01:00
return self.getter(3) == 1
2022-06-16 14:07:12 +01:00
@trigger.setter
def trigger(self, val):
2022-06-21 23:21:55 +01:00
self.setter(1 if val else 0, 3)