Skip to content

This is a simple API that allows you to control an emulator using Twitch chat.

License

Notifications You must be signed in to change notification settings

open-octave/TwitchKeyboardAPI

Repository files navigation

TwitchKeyboardAPI - Windows

TwitchKeyboardAPI is an API that will monitor incoming commands from a Twitch chat and send them to a game emulator.

Table of Contents

Getting Started

Optional Automated Setup Script for Windows

If you already have a development environment set up, you can skip this step. But for those who don't, you can use the setup.ps1 script to install the necessary dependencies. This script will install the following:

  • Pyenv - Python 3.11.9
  • Poetry
  • Git
  • GitHub CLI

Note: You wll run the script about 3 times total if you do not have any of the dependencies installed. This is because the terminal needs to be restarted after installing some of the dependencies.

Prerequisites

  • Python 3.11.9
  • Poetry
  • Windows 10 / Windows 11

Step 1: Emulator Installation

Note: For the sake of this example, assume you are downloading a Nintendo DS game but the process is similar for other consoles.

  1. Download the RetroArch game emulator from the official website.
  2. Open the RetroArch emulator.
  3. Go to Load Core.
  4. Select Download a Core.
  5. Select the Nintendo - Nintendo DS (melonDS) core.
  6. Download the .nds ROM of the game you want to play. You can find a list of games here.
  7. Go to Load Content.
  8. Select Start Directory.
  9. Find and select the folder where the .nds ROM is located.
  10. You should now be able to play the game using the emulator.

Step 2: API Initialization

  1. Clone the repository
git clone [email protected]:open-octave/TwitchKeyboardAPI.git
  1. Run the API
./run.bat

Step 3: Using the API

  1. Go to the Twitch chat.
  2. It's recommended that you use the mod commands /uniquechatoff and /slowoff in chat to allow viewers to send commands without being blocked by Twitch.
  3. Type one of the commands listed in the Commands section.
  4. The API will receive the command and send it to the emulator.
On Start Example Command Example

Commands

Note: The command mapping is designed based on the default key bindings of the RetroArch emulator.

General Commands

Command Description
up Simulates a up arrow key press
down Simulates a down arrow key press
left Simulates a left arrow key press
right Simulates a right arrow key press
a Simulates an X key press
b Simulates a Z key press
x Simulates an S key press
y Simulates an A key press
start Simulates an Enter key press
select Simulates a Shift key press
!hold <direction> or !move <direction> Holds the provided directional key until released
!release or !stop Releases the held directional key
!toggle-fast-forward or !tff Toggles RetroArch's fast forward mode on/off

Broadcaster And Mod Only Commands

Command Description
!mod-kill-api Kills the API process in case of an emergency

FAQ

How can I still use my computer while the API is running since the program focuses on RetroArch for every command?

You can run the API and RetroArch inside of VMWare or VirtualBox. I honestly recommend this method since it also gives the streamer an extra layer of security since the API does not have access to the files, folders, or applications on the streamer's computer. This should never be possible due to a few security measures in place but it is always better to be safe than sorry.

Windows Virtual Machines

Development

Support

If you have any questions or need help, please open an issue in the repository or message me on discord:

Discord: Project Channel

License

Distributed under the GNU General Public License. See LICENSE for more information.

About

This is a simple API that allows you to control an emulator using Twitch chat.

Resources

License

Stars

Watchers

Forks

Packages

No packages published