All Projects → kevinhughes27 → Mupen64plus Input Bot

kevinhughes27 / Mupen64plus Input Bot

An input driver for mupen64plus that consumes from a python web server

Programming Languages

c
50402 projects - #5 most used programming language

Labels

Projects that are alternatives of or similar to Mupen64plus Input Bot

ANMP
multi-channel loopable video game music player for nerds and audiophiles
Stars: ✭ 16 (-91.3%)
Mutual labels:  n64
Mupen64plus Video Rice
Video plugin for the Mupen64Plus v2.0 project, using OpenGL. This plugin is based on the RiceVideoLinux plugin from earlier versions of Mupen64Plus.
Stars: ✭ 26 (-85.87%)
Mutual labels:  n64
Acse
A Save Editor for the Animal Crossing main series games written in C#
Stars: ✭ 99 (-46.2%)
Mutual labels:  n64
save-file-converter
Converter for retro console save files found around the Internet. All common formats for NES/SNES/GBA/N64/TG16/SMS/Genesis/Neo Geo/PS1 supported. Decrypts PSP saves. Converts to and from Retron 5 and MiSTer
Stars: ✭ 56 (-69.57%)
Mutual labels:  n64
Cartreader
A shield for the Arduino Mega that can back up video game cartridges.
Stars: ✭ 590 (+220.65%)
Mutual labels:  n64
Mupen64plus Video Glide64mk2
Video plugin for Mupen64Plus 2.0 based on 10th anniversary release code from gonetz
Stars: ✭ 21 (-88.59%)
Mutual labels:  n64
n64
experimental low-level n64 emulator
Stars: ✭ 94 (-48.91%)
Mutual labels:  n64
Sm64tools
Collection of tools for Super Mario 64 ROM hacking
Stars: ✭ 129 (-29.89%)
Mutual labels:  n64
Mm
Majora's Mask scripts, with some Ocarina of Time on the side.
Stars: ✭ 24 (-86.96%)
Mutual labels:  n64
Partyplanner64
Mario Party N64 board editor
Stars: ✭ 77 (-58.15%)
Mutual labels:  n64
mupen64plus-ui-console
Console (command-line) front-end user interface for Mupen64Plus v2.0 project
Stars: ✭ 36 (-80.43%)
Mutual labels:  n64
Gel
An N64-like software renderer
Stars: ✭ 491 (+166.85%)
Mutual labels:  n64
Ryu64
A Nintendo 64 Emulator made in C#!
Stars: ✭ 36 (-80.43%)
Mutual labels:  n64
mupen64plus-input-sdl
Input plugin for Mupen64Plus v2.0 project using SDL. This is derived from the original Mupen64 blight_input plugin.
Stars: ✭ 36 (-80.43%)
Mutual labels:  n64
Papermario
Decompilation of Paper Mario
Stars: ✭ 105 (-42.93%)
Mutual labels:  n64
mupen64plus-rsp-cxd4
Exemplary MSP communications simulator using a normalized VU.
Stars: ✭ 26 (-85.87%)
Mutual labels:  n64
Mupen64plus Core
Core module of the Mupen64Plus project
Stars: ✭ 845 (+359.24%)
Mutual labels:  n64
Mupen64plus Ui Python
A frontend for Mupen64Plus
Stars: ✭ 165 (-10.33%)
Mutual labels:  n64
Emukit
WebXR immersive console emulator w/ Retroach, Javascript, and WASM
Stars: ✭ 123 (-33.15%)
Mutual labels:  n64
Pseultra
N64 library
Stars: ✭ 60 (-67.39%)
Mutual labels:  n64

mupen64plus-input-bot

An input driver for mupen64plus that consumes a JSON response from a web server. Intended for use with my TensorKart project that trains an AI using TensorFlow to play the classic N64 title MarioKart 64.

Building

make all

The project uses essentially a copy and paste of the Makefile from the regular input plugin for mupen64plus with the SDL dependencies removed. It includes flags to link libjson-c, which it assumes has been installed into /usr/lib and /usr/include. You can get this library on Ubuntu by installing the following packages (or if you prefer, you can build the latest from source here):

libjson-c2
libjson-c-dev

Note that all builds expect the mupen64plus-core source code to be available in the same directory.

eg.

src \
  mupen64plus-core \
    ...
  mupen64plus-input-bot \
    ...

There is a Makefile argument (APIDIR) to specify this directory path if you prefer.

Installing

After building, run sudo make install to copy the driver to the default location.

/usr/local/lib/mupen64plus/mupen64plus-input-bot.so

Installing the driver to a standard system location allows downstream applications to configure mupen64plus automatically (for example the mupen64plus OpenAI gym)

Usage

mupen64plus --input /usr/local/lib/mupen64plus/mupen64plus-input-bot.so MarioKart64.z64

By default, the driver specifies the HTTP server as localhost:8082 with a single controller connected. This can be overridden per controller via configuration.

Configuration

Parameters can be specified via the Mupen64plus config file, or via command line switches (--set). There are currently three values which can be configured:

Parameter Description
plugged deterimines whether or not the controller is connected (values: 0 or 1)
host the hostname of the controller server (max length: 256 chars)
port the port for the controller server (type: int)

Mupen64plus config file:

# Default unix path:
# ~/.config/mupen64plus/mupen64plus.cfg

# [...]

[Input-Bot-Control0]

plugged = "1"
host = "contr_srv_1.example.com"
port = "8082"

[Input-Bot-Control1]

plugged = "1"
host = "contr_srv_1.example.com"
port = "8083"

[Input-Bot-Control2]

plugged = "1"
host = "contr_srv_2.example.com"
port = "8084"

[Input-Bot-Control3]

plugged = "0"
host = "contr_srv_2.example.com"
port = "8085"

# [...]

Command line:

mupen64plus                                                    \
  --input /usr/local/lib/mupen64plus/mupen64plus-input-bot.so  \
                                                               \
  --set Input-Bot-Control0[plugged]=1                          \
  --set Input-Bot-Control0[host]=contr_srv_1.example.com       \
  --set Input-Bot-Control0[port]=8082                          \
                                                               \
  --set Input-Bot-Control1[plugged]=1                          \
  --set Input-Bot-Control1[host]=contr_srv_1.example.com       \
  --set Input-Bot-Control1[port]=8083                          \
                                                               \
  MarioKart64.z64

Protocol

This driver supports all 4 controllers. When it issues requests for the controller data, it makes a GET request to the path of the controller index (0-3). This allows server implementations to handle requests for each of the 4 controllers. Alternatively, separate web servers could be used for each controller (see the Configuration section above for details).

Example requests:

GET /0 HTTP/1.1
GET /1 HTTP/1.1
GET /2 HTTP/1.1
GET /3 HTTP/1.1

The plugin attempts to deserialize the web response as a JSON object. It expects the JSON object to contain properties that represent each of the controller button states (as integers). If any buttons are not included in the response, their values will default to 0.

Example JSON response:

{
  "START_BUTTON": 0,
  "U_CBUTTON": 0,
  "L_DPAD": 0,
  "A_BUTTON": 1,
  "B_BUTTON": 0,
  "X_AXIS": -80,
  "L_CBUTTON": 0,
  "R_CBUTTON": 0,
  "R_TRIG": 0,
  "R_DPAD": 0,
  "D_CBUTTON": 0,
  "Z_TRIG": 0,
  "Y_AXIS": 80,
  "L_TRIG": 0,
  "U_DPAD": 0,
  "D_DPAD": 0
}

Testing

An example server is included in /test/server.py. This file is a minimal example that allows you to hard code the joystick input. This example is intended to be extracted into a program that determines the appropriate input somehow.

Future Work / Ideas

  • controller.c could be refactored into smaller functions
  • I'm sure my c code can be optimized and improved
  • This plugin might be useful for implementing network play with mupen64plus

Contributing

Open a PR! I'm friendly I promise :)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].