From 5457cfc0af921efbd1cd5544a92cad530bde8d35 Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Sat, 8 Jul 2023 20:39:24 +0100 Subject: [PATCH] move streamlabs hotkeys into register_hotkeys() move duckypad hotkeys register_hotkeys() --- __main__.py | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/__main__.py b/__main__.py index 621ed4a..63b7224 100644 --- a/__main__.py +++ b/__main__.py @@ -3,7 +3,6 @@ import logging import keyboard import voicemeeterlib import xair_api -from slobs_websocket import StreamlabsOBS import duckypad_twitch from duckypad_twitch import configuration @@ -39,7 +38,27 @@ def register_hotkeys(duckypad): keyboard.add_hotkey("ctrl+alt+F17", duckypad.obsws.toggle_mute_mic) keyboard.add_hotkey("ctrl+alt+F18", duckypad.obsws.toggle_stream) - [step() for step in (audio_hotkeys, scene_hotkeys, obsws_hotkeys)] + def streamlabs_hotkeys(): + keyboard.add_hotkey("ctrl+F22", duckypad.streamlabs_controller.begin_stream) + keyboard.add_hotkey("ctrl+F23", duckypad.streamlabs_controller.end_stream) + keyboard.add_hotkey( + "ctrl+alt+F23", duckypad.streamlabs_controller.launch, args=(8,) + ) + keyboard.add_hotkey("ctrl+alt+F24", duckypad.streamlabs_controller.shutdown) + + def duckypad_hotkeys(): + keyboard.add_hotkey("ctrl+F21", duckypad.reset) + + [ + step() + for step in ( + audio_hotkeys, + scene_hotkeys, + streamlabs_hotkeys, + obsws_hotkeys, + duckypad_hotkeys, + ) + ] def main(): @@ -47,26 +66,13 @@ def main(): with voicemeeterlib.api("potato") as vm: with xair_api.connect("MR18", **xair_config) as mixer: - sl = StreamlabsOBS() + with duckypad_twitch.connect(vm=vm, mixer=mixer) as duckypad: + vm.apply_config("streaming") - duckypad = duckypad_twitch.connect(vm=vm, mixer=mixer, sl=sl) + register_hotkeys(duckypad) - vm.apply_config("streaming") - - register_hotkeys(duckypad) - - keyboard.add_hotkey("ctrl+F21", duckypad.reset) - keyboard.add_hotkey("ctrl+F22", duckypad.streamlabs_controller.begin_stream) - keyboard.add_hotkey("ctrl+F23", duckypad.streamlabs_controller.end_stream) - keyboard.add_hotkey( - "ctrl+alt+F23", duckypad.streamlabs_controller.launch, args=(5,) - ) - keyboard.add_hotkey("ctrl+alt+F24", duckypad.streamlabs_controller.shutdown) - - print("press ctrl+m to quit") - keyboard.wait("ctrl+m") - - sl.disconnect() + print("press ctrl+m to quit") + keyboard.wait("ctrl+m") if __name__ == "__main__":