This project integrates OBS Studio with Nintendo Switch controller inputs via Kafka messaging. It allows for automated control of both OBS scenes/recording and Nintendo Switch controller inputs based on events received through Kafka.
- OBS Controller: Connects to OBS Studio via WebSocket protocol to control scenes and recording.
- Switch Controller: Connects to NXBT webapp to send controller inputs to Nintendo Switch.
- Kafka Integration: Uses Kafka to receive events that trigger actions on either OBS or Switch controller.
- Runner: Coordinates between all components, listening for Kafka messages and executing appropriate actions.
- Python 3.8+
- OBS Studio with WebSocket plugin (v4.9.0+)
- NXBT webapp running (for Nintendo Switch controller emulation)
- Kafka server running
- Clone the repository
- Install the package in development mode:
pip install -e .pip install obs-switchStart the runner with default settings:
obs-switchOr customize the connection parameters:
obs-switch --obs-host localhost --obs-port 4455 --switch-url http://localhost:8000 --kafka-topics spl_replay_serviceIf you've installed the package in development mode, you can also run it directly:
python -m obs_switch.cliThe runner listens for Kafka messages in the following formats:
{
"event_type": "obs_scene_change",
"scene_name": "Scene Name"
}{
"event_type": "obs_recording",
"action": "start|stop|toggle"
}{
"event_type": "switch_button",
"buttons": ["A", "B", "X", "Y"],
"delay": 0.1
}{
"event_type": "switch_stick",
"stick": "L_STICK",
"x_value": 100,
"y_value": 0,
"delay": 0.1
}{
"event_type": "switch_replay_code",
"code": "1234-5678-9012"
}The system uses a modular architecture with the following components:
- OBS Controller (
obs_controller.py): Handles communication with OBS Studio via WebSocket. - Switch Controller (
switch_controller.py): Manages Nintendo Switch controller inputs via NXBT. - Kafka Consumer (
async_consumer.py): Listens for events from Kafka topics. - Switch Handler (
switch_handler.py): Processes complex Switch input sequences like replay codes. - Runner (
runner.py): Coordinates all components and processes incoming Kafka messages. - Macros (
obs_switch.macros): Provides a set of helper functions for fixed in-game actions. - Actions (
obs_switch.actions): Provides a set of helper functions for complex actions that involves OBS and Switch.
Tesseract is used for OCR (Optical Character Recognition) to extract text from images, will be used to extract information from OBS screenshots.
Ensure that you have the tesseract executable in your PATH.
Tesseract docs: https://tesseract-ocr.github.io/tessdoc/Installation.html
PyTesseract docs: https://pypi.org/project/pytesseract/
ControlNotebook.ipynb and HandlerPlaybook.ipynb contain Jupyter notebooks
that can be used to test and debug the integration without using Kafka.
To add support for new event types:
- Modify the
_process_kafka_messagemethod inrunner.py - Add a new condition for your event type
- Implement the corresponding action logic
To add new controller actions:
- Implement the new functionality in the appropriate controller class
- Update the runner to expose the new functionality via Kafka messages
- Ensure OBS Studio is running with the WebSocket plugin enabled
- Verify the NXBT webapp is running and accessible
- Check that Kafka server is running and the topics exist
- Review logs for connection errors or message processing issues
This project is licensed under the MIT License - see the LICENSE file for details.