From 46e7ffe4783257bed6c19cbcdca52bb5fa5f6967 Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Sun, 23 Jul 2023 07:56:09 +0100 Subject: [PATCH] adds MacroButtonColorMixin. --- voicemeeterlib/device.py | 1 + voicemeeterlib/iremote.py | 1 + voicemeeterlib/macrobutton.py | 19 +++++++++++++++---- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/voicemeeterlib/device.py b/voicemeeterlib/device.py index 07e33c8..2485af5 100644 --- a/voicemeeterlib/device.py +++ b/voicemeeterlib/device.py @@ -23,6 +23,7 @@ class Adapter(IRemote): def output(self): pass + @property def identifier(self): pass diff --git a/voicemeeterlib/iremote.py b/voicemeeterlib/iremote.py index 4082493..716c016 100644 --- a/voicemeeterlib/iremote.py +++ b/voicemeeterlib/iremote.py @@ -33,6 +33,7 @@ class IRemote(metaclass=ABCMeta): cmd += (f".{param}",) return "".join(cmd) + @property @abstractmethod def identifier(self): pass diff --git a/voicemeeterlib/macrobutton.py b/voicemeeterlib/macrobutton.py index 006ac3f..1c21a7f 100644 --- a/voicemeeterlib/macrobutton.py +++ b/voicemeeterlib/macrobutton.py @@ -12,9 +12,6 @@ ButtonModes = IntEnum( class Adapter(IRemote): """Adapter to the common interface.""" - def identifier(self): - pass - def getter(self, mode): self.logger.debug(f"getter: button[{self.index}].{ButtonModes(mode).name}") return self._remote.get_buttonstatus(self.index, mode) @@ -26,7 +23,21 @@ class Adapter(IRemote): self._remote.set_buttonstatus(self.index, val, mode) -class MacroButton(Adapter): +class MacroButtonColorMixin(IRemote): + @property + def identifier(self): + return f"command.button[{self.index}]" + + @property + def color(self) -> int: + return int(IRemote.getter(self, "color")) + + @color.setter + def color(self, val: int): + IRemote.setter(self, "color", val) + + +class MacroButton(Adapter, MacroButtonColorMixin): """Defines concrete implementation for macrobutton""" def __str__(self):