Changes

Jump to navigation Jump to search

Documentation/Engine/Advanced input configuration

3,147 bytes added, 11:43, 23 February 2023
Expressions
==Advanced Input Configuration==
The game UI supports use of up to three five controllers. The game itself is able to simultaneously use of more than three five controllers, however such setup can not be configured through the game user interface and manual tweaking of the game's configuration files is required.
This section describes how an advanced user can manually tweak the configuration file to be able to use more than three controllers or create even more complex. By manual tweaking of the configuration it is possible to add some features not directly supported by the game UI such as
*Use a TrackIR compatible head tracker to control movement of the truck for people with some disabilities.
=Configration Configuration file=
The controller configuration is stored in profile directory (remember to replace the PROFILE_ID with your real profile identifier):
'''User-creatable:''' Yes
The device alias defines a new name ("joy") which can be used in other parts of the configuration file as a shortcut to reference a specific input device without having to always use its full identification. Defining and using the device alias also allows simple switch to a different compatible device by changing the alias target without having to update the rest of the configuration. By default the game creates three aliases for keyboard, mouse and joy joy1-6 to identify keyboard, mouse and joystick device supported by the UI. Five joysticks can be directly selected in the UI, the sixth one is supported by binding UI if manually set in the config file.
==Input alias==
*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.Since 1.35 the expression also supports logical operators with a full evaluation (&&, ||). While the short-circuit variants are preferred for most uses, the full evaluation variants should typically be used when using memory based functions. Memory based functions preserve some state between evaluations as long the mix expression (i.e. the expression string, not the result of the evaluation) does not change. Changing the expression (e.g. because of config load) will reset the memory to default state. 
Following set of functions is also available. The range in brackets indicate allowed number of parameters to the function:
{| class="wikitable" width="100%"
!style="width: 150px"|Function
!|Version
!|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.
|-
|abs_max(1..)
|1.43+
|Returns value of parameter with the biggest absolute value from all parameters. (e.g. abs_max(2, -5, -1, 4) returns -5). If there are multiple values with the same absolute value and a different sign, the value of the parameter with the lower index is returned.
|-
|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.
|-
|memory(2)
|1.35+
|Simple single-value memory. The memory starts at zero. If the first parameter evaluates to true, the second parameter is evaluated and its value is stored in the memory. Otherwise the second parameter is not evaluated and the memory is unchanged. The function returns the current value of the memory after the processing (i.e. the new value if the memory was updated).
|-
|modifier(2)
|1.35+
|Supports implementation of modifier-like keys. The first parameter represents "modifier" expression and the second parameter represents "button" expression. The function starts with returning 0.0. If it detects false to true transition on the "button" parameter while the "modifier" parameter is true, it will start returning 1.0 until the "button" parameter reverts to false after which it returns back to 0.0. Please note that the function detects changes only while it is being evaluated. If something, such as short-circuit logical operator, prevents the call, the function might miss some changes. Function evaluates the "modifier" parameter only during the leading edge (false => true) on the "button" parameter. Because of this, avoid using memory based elements within the "modifier" parameter to avoid risk of unexpected behavior.
|-
|short_press(1-2)
|1.41+
|Supports detection of short press. If the first input is temporarily >= 0.5 for interval shorter than a threshold, the function will return 1.0 until end of the frame it detected that in. The value of the threshold in milliseconds is configured by the second parameter and uses default value (200ms as of 1.46) if the second parameter is not provided. The detection only happens if the function is being evaluated (i.e. do not use it with short-circuit logical operators).
|-
|long_press(1-2)
|1.41+
|Supports detection of long press. If the first input is >= 0.5 for interval longer than a threshold, the function will return 1.0 until the input goes back to < 0.5. The value of the threshold in milliseconds is configured by the second parameter and uses default value (200ms as of 1.46) if the second parameter is not provided. The detection only happens if the function is being evaluated (i.e. do not use it with short-circuit logical operators).
|}
 
[[Category:Documentation]]
[[Category:Engine]]

Navigation menu