Changes

Jump to navigation Jump to search

Documentation/Engine/Advanced input configuration

6,134 bytes added, 13:40, 14 January 2016
no edit summary
The gearbox simulated in the game has twelve forward gears and one reverse gear. In the default configuration the in-game H-shifter gearbox behaves as a "Range transmission" (see link above) where the "Shifter Toggle 1" button switches between gear set 1-6 and gear set 7-12. (see Controller options in the game, on the G27 it is mapped to the leftmost red button on the H-shifter by default).
==GEAR SHIFTING EXAMPLEGear Shifting Example==
You have a gear 6 selected and you want to shift up to the gear 7 - you need to press the "Shifter Toggle 1" button to switch to gear set 7-12 and then move the H-shifter stick to the position 1.
In similar way, to shift down from gear 7 to gear 6, press the "Shifter Toggle 1" to switch to gear set 1-6 and move the H-shifter stick to the position 6.
==Input alias==
 
'''Example format:''' input j_steer `joy.x`
 
'''User-creatable:''' Yes
 
The input alias defines a new name ("j_steer") which can be used in other parts of the configuration file as a shortcut to reference a specific input (axis, button) from input device without having to specify the longer name. Same as with the device aliases case, input aliases also allow easy configuration changes. The game axis configuration UI works by changing input aliases to point to the selected axes.
==Constant==
 
'''Example format:''' constant c_steer_dz 0.000000
 
'''User-creatable:''' Yes
 
The constant defines a named ("c_steer_dz") numeric value which might be used by calculations in other parts of the configuration file or directly by the game itself (e.g. FF strength).
==Mix==
 
'''Example format:''' mix dsteerleft `keyboard.larrow?0 | keyboard.a?0`
 
'''User-creatable:''' No
 
The mix defines an expression which is used to calculate value of a single game input. The game can use this value as an analog input (e.g. fraction of the rotation of the steering wheel) or as a logical value (e.g. wipers toggle).
The interpretation and additional configuration of the individual mixes (in what situations they are evaluated) is hardcoded in the game and it is currently not possible to create additional mixes in the configuration file.
In the simplest form the expression returns value of a single input. The more complex forms can use several mathematical and logical functions (see below) to derive the results from more than one input. Note that the UI input configuration screens directly supports only a very limited subset of the expressions and will display "Complex" message if they can not handle the expression.
Generally there are two types of mix evaluation.
*Event based - this mix evaluates whenever there is change in any input (or other mix) it depends on. Mixes which read to individual presses (e.g. gear change, any_cmd) are usually of this type. As of 1.3.1. those mixes get duplicate evaluations whenever they react to button which generates characters (e.g. character key in keyboard). While usually not issue, this might be important when using the mix in loopback mode (e.g. it references old value of itself).
*Frame based - this mix evaluates at end of the frame. Mixes which react to hold (e.g. horn) or provide analog values (e.g. steering) are usually of this type.
=User-created components=
 
For some component types it is possible to create additional components simply by using additional component definition line in the configuration file. Names of such components must meet following requirements:
 
*Must be unique within the configuration file.
*Must have at most 12 characters.
*Only alphanumeric characters and underscore character are allowed.
=Expressions=
 
The expressions are used to combine device inputs and apply deadzones or a non-linear functions to them. Several types of values can be used in the expression:
 
*A reference to a constant value (e.g. 2.0)
*A reference to a named constant (e.g. c_steer_dz).
*A reference to a controller inputs using its full (e.g. di8.keyboard.space) or aliased form (e.g. keyboard.space). In cases of some special inputs an additional component selector (.x, .y, .z, .yaw, .pitch, .roll) might be needed. In the default configuration file you will see that alternative keyboard.space?0 syntax is used. That syntax indicates that if the input can not be found, the sub-expression should behave as if a constant 0 was returned from the device instead of reporting error and failing entire expression.
*A reference to some other mix (e.g. dforward). Note that circular references are not allowed, however it is possible to reference the mix this expression belongs to. In that case a previous value is returned. Note that there are no guarantees on frequency or time between calls however it might be used to implement simple counters or toggles when used with the event-based mixes.
*A special name unbound which resolves to constant zero. It is used to preserve information if no key is assigned to the primary binding slot.
 
The values can be combined using arithmetical (+, -, *, /) and logical (&, |, !) operators. Note that operator precedence rules are very simple so use of the brackets is highly recommended. When a value is interpreted in a logical context (e.g. during logical OR or AND operations or when it is used as logical value by the game), values greater than or equal to 0.5 evaluate to true and other values evaluate to false. Logical operators return 1.0 for true and 0.0 for false and have a short-circuit evaluation.
Following set of functions is also available. The range in brackets indicate allowed number of parameters to the function:
 
{| class="wikitable" width="100%"
!|Function
!|Description
|-
|max(1..)
|Returns biggest from the parameters.
|-
|min(1..)
|Returns smallest from the parameters.
|-
|pow(2..)
|(p0^p1)^p2)...
|-
|abs(1)
|Absolute value of the parameter.
|-
|sign(1)
|Returns -1 if parameter is negative number, 1 if the parameter is positive number and 0 for zero.
|-
|gt(2)
|Returns 1.0 if the first parameter is greater than the second one.
|-
|gte(2)
|Returns 1.0 if the first parameter is greater than or equal to the second one.
|-
|lt(2)
|Returns 1.0 if the first parameter is lower than the second one.
|-
|lte(2)
|Returns 1.0 if the first parameter is lower than or equal to the second one.
|-
|sel(3)
|Returns the second parameter if the first parameter evaluates to true (see above), for false returns the third parameter.
|-
|bool(1)
|Returns 1.0 if the first parameter evaluates to true (see above) and zero otherwise.
|-
|normalize(2-3)
|Returns normalized position of the first parameter in the range formed by <second parameter, third parameter>. If the value is outside of the range, it will be clamped to it. If third parameter is not provided, 1.0 will be used. If the second and third parameter do not form valid non-empty range, zero will be returned.
|-
|deadzone(2-3)
|Applies a zero-symmetrical deadzone. Similar to the normalize, however it applies symmetrically to the negative values as well. If the second parameter is negative, it is set to zero.
|}
developer
1,626
edits

Navigation menu