OBS Studio and Nintendo Switch controller integration via Kafka
Project description
OBS Switch Controller Integration
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.
Components
- 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.
Requirements
- Python 3.8+
- OBS Studio with WebSocket plugin (v4.9.0+)
- NXBT webapp running (for Nintendo Switch controller emulation)
- Kafka server running
Installation
From Source
- Clone the repository
- Install the package in development mode:
pip install -e .
Using pip
pip install obs-switch
Usage
Running the Integration
Start the runner with default settings:
obs-switch
Or customize the connection parameters:
obs-switch --obs-host localhost --obs-port 4455 --switch-url http://localhost:8000 --kafka-topics spl_replay_service
Running from Source
If you've installed the package in development mode, you can also run it directly:
python -m obs_switch.cli
Kafka Message Format
The runner listens for Kafka messages in the following formats:
Change OBS Scene
{
"event_type": "obs_scene_change",
"scene_name": "Scene Name"
}
Control OBS Recording
{
"event_type": "obs_recording",
"action": "start|stop|toggle"
}
Press Switch Buttons
{
"event_type": "switch_button",
"buttons": ["A", "B", "X", "Y"],
"delay": 0.1
}
Move Switch Stick
{
"event_type": "switch_stick",
"stick": "L_STICK",
"x_value": 100,
"y_value": 0,
"delay": 0.1
}
Enter Replay Code
{
"event_type": "switch_replay_code",
"code": "1234-5678-9012"
}
Architecture
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.
Development
Adding New Event Types
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
Extending Controller Functionality
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
Troubleshooting
- 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
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file obs_switch-0.0.2-py3-none-any.whl.
File metadata
- Download URL: obs_switch-0.0.2-py3-none-any.whl
- Upload date:
- Size: 16.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
26828def34fed24ce3a056e7fee79785c2393898de5e332c0ab5534f6ea7455a
|
|
| MD5 |
8ac596afe43b646c8f61ba87f93f49fd
|
|
| BLAKE2b-256 |
bafa1e12b2da941048ec416bf7c979a2b917386acfa5a29fa3e5749839c9395b
|