Skip to content

5.e Controller | Configurate a XInput controller

Maschell edited this page Apr 23, 2017 · 4 revisions

Overview

The controller patcher engine has built in support for XInput devices when you use the Network Client.

Default button mapping

When you provide no config file, the following button mapping will be used:

Gamepad A                   =   XInput B Button
Gamepad B                   =   XInput A Button
Gamepad X                   =   XInput Y Button
Gamepad Y                   =   XInput X Button

Gamepad DPAD                =   XInput DPAD
Gamepad left stick          =   XInput left stick
Gamepad right stick         =   XInput right stick

Gamepad Plus                =   XInput Start button
Gamepad Minus               =   XInput Menu/Back button

Gamepad L                   =   XInput LB
Gamepad R                   =   XInput RB

Gamepad ZL                  =   XInput LT
Gamepad ZR                  =   XInput RT

Gamepad Left stick press    =   XInput L3 (left stick press)
Gamepad right stick press   =   XInput R3 (right stick press)

Configfile

Identify line

The vid of the XInput is "0x7331", the pid "0x1337". The identify is this:

[vid=0x7331,pid=0x1337]

Ignoring default values

You can either complety overwrite the default configuration or just modifying parts of it. When you put the following as the second line in the config, the default values will be ignored.

[IgnoreDefault]

Configuration

Setting the buttons

Like metioned earlier in this wiki, the built in controller have an "easy" way to map the buttons and sticks. The following buttons and trigger can be mapped:

Buttons:
A                   =   VPAD_BUTTON_A
B                   =   VPAD_BUTTON_B
X                   =   VPAD_BUTTON_X
Y                   =   VPAD_BUTTON_Y
Plus                =   VPAD_BUTTON_PLUS
Minus               =   VPAD_BUTTON_MINUS
Home                =   VPAD_BUTTON_HOME
Sync                =   VPAD_BUTTON_SYNC
TV                  =   VPAD_BUTTON_TV

DPAD:
DPAD left           =   VPAD_BUTTON_LEFT
DPAD left           =   VPAD_BUTTON_RIGHT
DPAD left           =   VPAD_BUTTON_UP
DPAD left           =   VPAD_BUTTON_DOWN

Trigger:
ZR                  =   VPAD_BUTTON_ZR
ZL                  =   VPAD_BUTTON_ZL
L                   =   VPAD_BUTTON_L
R                   =   VPAD_BUTTON_R

Sticks:
Stick press left    =   VPAD_BUTTON_STICK_L
Stick press right   =   VPAD_BUTTON_STICK_R

These can be mapped to the following XInput Buttons:

//Buttons
XInput A           =   XINPUT_BUTTON_A
XInput B           =   XINPUT_BUTTON_B
XInput X           =   XINPUT_BUTTON_X
XInput Y           =   XINPUT_BUTTON_Y
XInput Start       =   XINPUT_BUTTON_START
XInput Back/Menu   =   XINPUT_BUTTON_BACK
XInput Guide       =   XINPUT_BUTTON_GUIDE

//DPAD
XInput DPAD UP     =   XINPUT_BUTTON_DPAD_UP
XInput DPAD DOWN   =   XINPUT_BUTTON_DPAD_DOWN
XInput DPAD LEFT   =   XINPUT_BUTTON_DPAD_LEFT
XInput DPAD RIGHT  =   XINPUT_BUTTON_DPAD_RIGHT

//Trigger
XInput LB          =   XINPUT_BUTTON_LB
XInput LT          =   XINPUT_BUTTON_LT
XInput L3          =   XINPUT_BUTTON_L3

XInput RB          =   XINPUT_BUTTON_RB
XInput RT          =   XINPUT_BUTTON_RT
XInput R3          =   XINPUT_BUTTON_R3

Setting the DPAD

In order to able to use the DPAD in config, the dpad mode needs to be set. The a predefined value that can be used.

DPAD_MODE        =   XINPUT_DPAD_MODE

Setting the Sticks

The gamepad has two sticks with axis that can be mapped to the XInput controller:

Gamepad left stick, X Axis      =   VPAD_BUTTON_L_STICK_X
Gamepad left stick, Y Axis      =   VPAD_BUTTON_L_STICK_Y
Gamepad right stick, X Axis     =   VPAD_BUTTON_R_STICK_X
Gamepad right stick, Y Axis     =   VPAD_BUTTON_R_STICK_Y

The XInput controller has predefines values that can be used.

XInput left stick, X Axis  =   XINPUT_STICK_L_X
XInput left stick, Y Axis  =   XINPUT_STICK_L_Y
XInput right stick, X Axis =   XINPUT_STICK_R_X
XInput right stick, Y Axis =   XINPUT_STICK_R_Y

Default Stick Values

Each axis of each stick has his own neutral/min/max value,deadzone and can be inverted. These are the default values for the XInput sticks:

XInput left stick, X Axis     =       Neutral: 0x80, Min: 0x00, Max: 0xFF, Deadzone: 0x10, inverted: no
XInput left stick, Y Axis     =       Neutral: 0x80, Min: 0x00, Max: 0xFF, Deadzone: 0x10, inverted: no
XInput right stick, X Axis    =       Neutral: 0x80, Min: 0x00, Max: 0xFF, Deadzone: 0x10, inverted: no
XInput right stick, Y Axis    =       Neutral: 0x80, Min: 0x00, Max: 0xFF, Deadzone: 0x10, inverted: no

Adjusting Stick values

Each value (exept the neutral postision) can be adjusting through the config file. NOTE: When you use the VPAD_BUTTON_L_STICK_X, VPAD_BUTTON_L_STICK_Y, VPAD_BUTTON_R_STICK_X, VPAD_BUTTON_R_STICK_Y to change/set the sticks, use the following options only AFTER them.


To change the value for the min/max value use a line simliar like this:

VPAD_L_STICK_X_MINMAX        =   0x01,0xFE

In this example you would change the values of left stick X axis. The min value is set to 0x01, the max value to 0xFE. This works similar for other gamepad sticks/axis


To change the value for the deadzone use a line simliar like this:

VPAD_L_STICK_X_DEADZONE      =   0x07

In this example you would change the deadzone of left stick X axis. The deadzone is set to 0x09.


To change the value for the deadzone use a line simliar like this:

VPAD_L_STICK_X_INVERT       =   true

In this example you would invert the left stick X axis. When you don't want to invert it, you can set the value to "no" or "false".


Examples

Example 1

Keeping the default settings, just adjust the deadzones of left stick.

[vid=0x7331,pid=0x1337]
VPAD_L_STICK_X_DEADZONE      =   0x10
VPAD_L_STICK_Y_DEADZONE      =   0x11

Example 2

Keeping the default settings, just don't invert the Y axis of right stick.

[vid=0x7331,pid=0x1337]
VPAD_R_STICK_Y_INVERT      =   no

Example 3

Overwriting the default setting. Loading the default setting completly from the config

[vid=0x57e,pid=0x2009]
[IgnoreDefault] //Ignoring the built in default values
VPAD_BUTTON_A = XINPUT_BUTTON_B
VPAD_BUTTON_B = XINPUT_BUTTON_A
VPAD_BUTTON_X = XINPUT_BUTTON_Y
VPAD_BUTTON_Y = XINPUT_BUTTON_X

VPAD_BUTTON_PLUS = XINPUT_BUTTON_START
VPAD_BUTTON_MINUS = XINPUT_BUTTON_BACK
VPAD_BUTTON_HOME = XINPUT_BUTTON_GUIDE

VPAD_BUTTON_L = XINPUT_BUTTON_LB
VPAD_BUTTON_R = XINPUT_BUTTON_RB

VPAD_BUTTON_STICK_L = XINPUT_BUTTON_L3
VPAD_BUTTON_STICK_R = XINPUT_BUTTON_R3

VPAD_BUTTON_ZL = XINPUT_BUTTON_LT
VPAD_BUTTON_ZR = XINPUT_BUTTON_RT


DPAD_MODE = XINPUT_DPAD_MODE
VPAD_BUTTON_UP =    XINPUT_BUTTON_DPAD_UP
VPAD_BUTTON_DOWN =  XINPUT_BUTTON_DPAD_DOWN
VPAD_BUTTON_LEFT =  XINPUT_BUTTON_DPAD_LEFT
VPAD_BUTTON_RIGHT = XINPUT_BUTTON_DPAD_RIGHT

VPAD_L_STICK_X           =   XINPUT_STICK_L_X
VPAD_L_STICK_Y           =   XINPUT_STICK_L_Y
VPAD_R_STICK_X           =   XINPUT_STICK_R_X
VPAD_R_STICK_Y           =   XINPUT_STICK_R_Y
//This device is no adapter that can't have more than 1 pads.
PAD_COUNT                       =   0x01