LESSONS LEARNED:
General:
- Post #7 below has examples of 3 files, inputbinding.xml, a controller file for an ELECOM MMO Controller, and a log file.
- When editing inputBindings.xml, if you do anything wrong the game replaces it with the default version. Always open the file in a browser first. It will check for obvious mistakes.
- The inputBindings.xml file works hand in hand with the game controller file found in the folder
..../FarmingSimulator2022/inputDevices/
If your controller/device is not supported by the input device xml's in that folder, you can edit an existing xml or create a new one for your controller/device. But do not place this new xml file in the /inputDevices folder as every update/verify action of the app will will wipe this folder and restore to a vanilla folder. Instead, place your new/own inputDevice xml in this folder:
..../FarmingSimulator2022/inputDevicesManual/ folder.
This "Manual" folder is for customized device xml's and is not affected by app updates or verification actions
- The next section defines the buttonmapping which has 3 attributes.
- physical: relates to the hardware assignment of the key pressed. All the buttons are numbered starting at 0.
- logical: defines the button number that shows up in the inputBindings.xml file. The name is always one more than the logical number. Logical 0 = Button_1.
- label: is the name that will show up on the games Options/Gamepad Controls menu.
<buttonMappings>
<buttonMapping physical="0" logical="0" label="Label0"/>
<buttonMapping physical="1" logical="1" label="Label1"/>
<buttonMapping physical="2" logical="2" label="Label2"/>
etc.
Then you can go into the games options menu and assign each button to an action. I recommend gears 1-8 so you can do 8 buttons at once. Save and then open the inputBindings.xml and search for GEAR_Select where you can see which buttons have been assigned. Once you know the physical assignment of each key you can then assign logical numbers and labels as you see fit.
- The next section defines axis definitions
- physical: relates to the hardware assignment of the Joystick axis. They do not follow a number system but use letters that represent the axis. I have not found a reference that explains them. Use other controller files as examples and experiment.
- logical: defines the variable name in the game. Logical 0 = AXIS_1, Logical 6 = AXIS_7
- Scale and offset: supposedly have to do with the values the hardware takes, but, I haven't experimented with them.
inputBindings.xml: This file is directly edited using the options menu in the game. The primary reason to break into this file (IMHO) is if you want to use your controller to navigate around the menus in the game. Those assignments are not in the options menu.
- The first section of the file is actionBinding where every action variable in the game is listed and the buttons that activate that action. The first action in the file is Jump so we will use that.
If this is what your file looks like, then you don't have any keys that can activate JUMP.
The game options menu has 5 columns for assigning keys. Two keyboard keys, a mouse key and two controller keys. (You might be able to assign more, but I had no reason to test that.)
Each key binding code looks like this: (and, you can have 5 of them inside each action)
<actionBinding action="JUMP">
<binding device="KB_MOUSE_DEFAULT" input="KEY_space" axisComponent="+" neutralInput="0" index="1"/>
<binding device="KB_MOUSE_DEFAULT" input="KEY_f12" axisComponent="+" neutralInput="0" index="2"/>
<binding device="KB_MOUSE_DEFAULT" input="MOUSE_BUTTON_LEFT" axisComponent="+" neutralInput="0" index="3"/>
<binding device="0_XINPUT_GAMEPAD" input="BUTTON_2" axisComponent="+" neutralInput="0" index="1"/>
<binding device="0_056E-200A" input="BUTTON_2" axisComponent="+" neutralInput="0" index="2"/>
</actionBinding>
I overpopulated this action so you can see how it works. <binding is the xml tag with the following attributes:
- device= the keyboard and the mouse are both part of the same device "KB_MOUSE_DEFAULT". Each game controller has its own identifier which you can discover by setting an action using the options menu and looking up its name here. This entry has two gamepads connected so there are two different devices. If you wanted two buttons to do the same action you would list the device name in both lines.
- input= specifies the name of the button. Keyboards and mice have predefined names and controller button names are defined based on the controler.xml file we just discussed.
- axisComponent= takes on the value of "+" or "-" and defines the direction the variable will take. Boolean variables (true false) only need a "+" which will toggle the value, but an integer variable (like which vehicle you are viewing) can be many values, so, you need to assign a button for "+" and a different button for "-", or you can assign an axis which does both up and down.
- neutralInput= is always equal to "0". I have an idea what it is for, but, since I never tested my theory, your guess is as good as mine.
- index= kind of represents which column in the options menu this key assignment will appear in. There are 3 columns on the keyboard tab and 2 on the gamepad tab. If you make two assignments on the same column the game will get confused.
<actionBinding action="MENU_AXIS_UP_DOWN">
<binding device="KB_MOUSE_DEFAULT" input="KEY_up" axisComponent="+" neutralInput="0" index="1"/>
<binding device="KB_MOUSE_DEFAULT" input="KEY_down" axisComponent="-" neutralInput="0" index="1"/>
<binding device="0_XINPUT_GAMEPAD" input="AXIS_2-" axisComponent="+" neutralInput="0" index="1"/>
<binding device="0_XINPUT_GAMEPAD" input="AXIS_2+" axisComponent="-" neutralInput="0" index="1"/>
</actionBinding>
This is one of the hidden actions that sets how you navigate around menus. Notice the first two are both keyboard index 1, but, one is for the up or "+" direction and the other is for the down or "-" direction and each has a different keyboard key assigned.
The gamepad has used a joystick to command the menu "+" or "-". AXIS_2 happens in this case to be the left joystick up down motion. (Remember that name is assigned by the logical attribute in the controller file.) The + and- on the end of the AXIS_2 tells the game which direction you moved the joystick. The joystick and axiscomponent "+" and "-" do not have to match. For example, when moving a loader bucket; joystick down means bucket goes up. (Which is how my tractor works.) Because this action is not a Boolean it must have a "+" and a "-". An axis variable can have as many as 10 entries.
- The next section is the devices section.
<devices>
<device id="0_XINPUT_GAMEPAD" name="XINPUT_GAMEPAD" category="1">
<attributes axis="0" deadzone="0.140000" sensitivity="1.000000"/>
<attributes axis="1" deadzone="0.140000" sensitivity="1.000000"/>
<attributes axis="2" deadzone="0.140000" sensitivity="1.000000"/>
etc.
Feel free to post more information about these two files. I will try to keep this first post updated with more knowledge as it comes available.