Engine:FNA
Developers | |
---|---|
Ethan Lee | |
Website | |
https://github.com/flibitijibibo/MonoGame |
Information
FNA is an open source reimplementation of the Microsoft XNA Framework, specifically the 4.0 Refresh revision. It started as a branch of MonoGame called "MonoGame-SDL2".
The goal of the project is to recreate a fast, portable, and accurate XNA4 runtime library that prevents the need for code/content changes on the part of the XNA game developer. The currently supported platforms include Windows, Mac OS X and GNU/Linux, with further platform support including those supported by SDL2.
Joysticks
About XNA Joystick Support
XNA, being a Microsoft technology, centered its controller input around the Xbox 360 Controller. Because of this, the XNA API is not cleanly compatible with custom controllers, including the Xbox 360 Controller when not being read by XInput. However, a config format was developed to allow binding of joystick input values to a virtual 360 controller, which then gets read by XNA games.
About GUIDs
In addition to expanded configuration support, FNA provides a GUID extension that allows XNA devs to pull in a trimmed/standardized GUID string to determine the controller hardware and react accordingly. TowerFall Ascension uses this for button icon support, for example.
Consider this GUID from the PlayStation 4 controller:
// These are the strings reported by SDL2's SDL_JoystickGetGUIDString: // https://wiki.libsdl.org/SDL_JoystickGetGUIDString 4c05c405000000000000504944564944 // Windows. Note characters 1-8. 4c05000000000000c405000000000000 // OSX. Note characters 1-4 and 17-20. 030000004c050000c405000011010000 // Linux. Note characters 9-12 and 17-20. 4c05c405 // This is the GUID string returned by FNA. Get it?
For XInput controllers on Windows, the GUID string is simply 'xinput'.
Automatic Configuration: SDL_GameController
Since FNA uses SDL2 as its base library, we also get the benefit of SDL_GameController, a new subsystem added by Alfred Reynolds at Valve. This takes configurations for known controllers and automatically configures them for the virtual 360 controller, so if your controller is recognized, manual configuration is not necessary. If you run an FNA title through Steam, your controller will automatically be configured using the Big Picture Mode configuration.
Manual Configuration: MonoGameJoystick.cfg
Originally designed as a standard format for MonoGame joystick configuration, FNA provides a standard, low-level XML configuration file to allow users to configure their joystick for XNA games with a single file, in the event that their hardware is not recognized by SDL_GameController.
Configuration file location
- This game follows the XDG Base Directory Specification on Linux.
How to configure
Consider this single value, from MonoGameJoystick.cfg:
<BUTTON_START> <INPUT_TYPE>Button</INPUT_TYPE> <INPUT_ID>9</INPUT_ID> <INPUT_INVERT>false</INPUT_INVERT> </BUTTON_START>
This structure represents the 360 controller value. In this case, we're configuring the start button.
INPUT_TYPE refers to the type of controller input we will be reading. It can be the following values:
- None
- Button
- Axis
- PovUp
- PovDown
- PovLeft
- PovRight
NOTE THAT THESE ARE CASE SENSITIVE!
If you want to ignore a button, just use None. Buttons and axes are, of course, Button and Axis, respectively. For DPad input, we read from each direction individually; the PovUp, PovDown, PovLeft and PovRight values.
INPUT_ID refers to the value of the controller input as identified by SDL. This is best identified with the MonoGame Joystick Detector Thing.
INPUT_INVERT is available in the event that you need to flip the values given by the joystick. For example, if your left control stick's Y axis is flipped, just set INPUT_INVERT to "true".
Configurations
Null Configuration
If you are experiencing problems with Joystick input and simply wish to disable the input altogether, you can use this config to ignore all joystick input.
<?xml version="1.0" encoding="utf-8"?> <MonoGameJoystickConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <BUTTON_START> <INPUT_TYPE>None</INPUT_TYPE> <INPUT_ID>-1</INPUT_ID> <INPUT_INVERT>false</INPUT_INVERT> </BUTTON_START> <BUTTON_BACK> <INPUT_TYPE>None</INPUT_TYPE> <INPUT_ID>-1</INPUT_ID> <INPUT_INVERT>false</INPUT_INVERT> </BUTTON_BACK> <BUTTON_A> <INPUT_TYPE>None</INPUT_TYPE> <INPUT_ID>-1</INPUT_ID> <INPUT_INVERT>false</INPUT_INVERT> </BUTTON_A> <BUTTON_B> <INPUT_TYPE>None</INPUT_TYPE> <INPUT_ID>-1</INPUT_ID> <INPUT_INVERT>false</INPUT_INVERT> </BUTTON_B> <BUTTON_X> <INPUT_TYPE>None</INPUT_TYPE> <INPUT_ID>-1</INPUT_ID> <INPUT_INVERT>false</INPUT_INVERT> </BUTTON_X> <BUTTON_Y> <INPUT_TYPE>None</INPUT_TYPE> <INPUT_ID>-1</INPUT_ID> <INPUT_INVERT>false</INPUT_INVERT> </BUTTON_Y> <SHOULDER_LB> <INPUT_TYPE>None</INPUT_TYPE> <INPUT_ID>-1</INPUT_ID> <INPUT_INVERT>false</INPUT_INVERT> </SHOULDER_LB> <SHOULDER_RB> <INPUT_TYPE>None</INPUT_TYPE> <INPUT_ID>-1</INPUT_ID> <INPUT_INVERT>false</INPUT_INVERT> </SHOULDER_RB> <TRIGGER_RT> <INPUT_TYPE>None</INPUT_TYPE> <INPUT_ID>-1</INPUT_ID> <INPUT_INVERT>false</INPUT_INVERT> </TRIGGER_RT> <TRIGGER_LT> <INPUT_TYPE>None</INPUT_TYPE> <INPUT_ID>-1</INPUT_ID> <INPUT_INVERT>false</INPUT_INVERT> </TRIGGER_LT> <BUTTON_LSTICK> <INPUT_TYPE>None</INPUT_TYPE> <INPUT_ID>-1</INPUT_ID> <INPUT_INVERT>false</INPUT_INVERT> </BUTTON_LSTICK> <BUTTON_RSTICK> <INPUT_TYPE>None</INPUT_TYPE> <INPUT_ID>-1</INPUT_ID> <INPUT_INVERT>false</INPUT_INVERT> </BUTTON_RSTICK> <DPAD_UP> <INPUT_TYPE>None</INPUT_TYPE> <INPUT_ID>-1</INPUT_ID> <INPUT_INVERT>false</INPUT_INVERT> </DPAD_UP> <DPAD_DOWN> <INPUT_TYPE>None</INPUT_TYPE> <INPUT_ID>-1</INPUT_ID> <INPUT_INVERT>false</INPUT_INVERT> </DPAD_DOWN> <DPAD_LEFT> <INPUT_TYPE>None</INPUT_TYPE> <INPUT_ID>-1</INPUT_ID> <INPUT_INVERT>false</INPUT_INVERT> </DPAD_LEFT> <DPAD_RIGHT> <INPUT_TYPE>None</INPUT_TYPE> <INPUT_ID>-1</INPUT_ID> <INPUT_INVERT>false</INPUT_INVERT> </DPAD_RIGHT> <AXIS_LX> <INPUT_TYPE>None</INPUT_TYPE> <INPUT_ID>-1</INPUT_ID> <INPUT_INVERT>false</INPUT_INVERT> </AXIS_LX> <AXIS_LY> <INPUT_TYPE>None</INPUT_TYPE> <INPUT_ID>-1</INPUT_ID> <INPUT_INVERT>false</INPUT_INVERT> </AXIS_LY> <AXIS_RX> <INPUT_TYPE>None</INPUT_TYPE> <INPUT_ID>-1</INPUT_ID> <INPUT_INVERT>false</INPUT_INVERT> </AXIS_RX> <AXIS_RY> <INPUT_TYPE>None</INPUT_TYPE> <INPUT_ID>-1</INPUT_ID> <INPUT_INVERT>false</INPUT_INVERT> </AXIS_RY> </MonoGameJoystickConfig>