Action denied

InputMapper.lua

InputMapper is responsible for managing in-game input, as well as for remapping input. It is possible to add and remap new keys in mods.

InputMapper:setup()

Is called while the game is initialising. The keys listed below are all keys that are registered in the vanilla game.

You can add new keys or axes yourself by calling InputMapper:addKey() or InputMapper.addAxis() as demonstrated below.

  35  
  36  function InputMapper:setup()
  37      -- setup default keys
  38  
  39      InputMapper:addKey("Ingame",    "Hotkey_IngameMenu",                    "Escape");
  40      InputMapper:addKey("Ingame",    "IngameMenu_refresh",                   "F5");
  41      InputMapper:addKey("Ingame",    "Hotkey_DashboardMenu",                 "Backspace");
  42      InputMapper:addKey("Ingame",    "TakeScreenshot",                       "SysReq");
  43      InputMapper:addKey("Ingame",    "HideHUDAndUI",                         "");
  44      InputMapper:addKey("Ingame",    "UI_Scroll_Up",                         "PageUp");
  45      InputMapper:addKey("Ingame",    "UI_Scroll_Down",                       "PageDown");
  46      InputMapper:addKey("Ingame",    "Interaction",                          "Q");
  47  
  48      -- scrolling UP is positive, scrolling DOWN is negative
  49      InputMapper:addAxis("Ingame",   "Axis_UI_Scroll",                       "UI_Scroll_Up",             "UI_Scroll_Down",       "Mouse ScrollWheel",    false,  false,  true, true);
  50  
  51      InputMapper:addKey("Ingame",    "Look_Up",                              "UpArrow");
  52      InputMapper:addKey("Ingame",    "Look_Down",                            "DownArrow");
  53      InputMapper:addKey("Ingame",    "Look_Left",                            "LeftArrow");
  54      InputMapper:addKey("Ingame",    "Look_Right",                           "RightArrow");
  55      InputMapper:addKey("Ingame",    "Look_Zoom_In",                         "PageUp");
  56      InputMapper:addKey("Ingame",    "Look_Zoom_Out",                        "PageDown");
  57      InputMapper:addKey("Ingame",    "Spectator_Faster",                     "LeftShift");
  58      InputMapper:addKey("Ingame",    "Spectator_Slower",                     "LeftControl");
  59      InputMapper:addKey("Ingame",    "Walk_Forward",                         "W");
  60      InputMapper:addKey("Ingame",    "Walk_Backward",                        "S");
  61      InputMapper:addKey("Ingame",    "Walk_Left",                            "A");
  62      InputMapper:addKey("Ingame",    "Walk_Right",                           "D");
  63      InputMapper:addKey("Ingame",    "Walk_Up",                              "Q");
  64      InputMapper:addKey("Ingame",    "Walk_Down",                            "E");
  65  
  66      InputMapper:addAxis("Ingame",   "Axis_Look_UpDown",                     "Look_Up",                  "Look_Down",            "Mouse Y",          false,      false);
  67      InputMapper:addAxis("Ingame",   "Axis_Look_LeftRight",                  "Look_Left",                "Look_Right",           "Mouse X",          false,      false,  true);
  68      InputMapper:addAxis("Ingame",   "Axis_Look_Zoom",                       "Look_Zoom_In",             "Look_Zoom_Out",        "Mouse ScrollWheel",false,      false,  false,  true);
  69      InputMapper:addAxis("Ingame",   "Axis_Walk_Forward",                    "Walk_Forward",             "Walk_Backward",        nil,                false,      false);
  70      InputMapper:addAxis("Ingame",   "Axis_Walk_Sideways",                   "Walk_Left",                "Walk_Right",           nil,                false,      false,  true);
  71      InputMapper:addAxis("Ingame",   "Axis_Walk_UpDown",                     "Walk_Up",                  "Walk_Down",            nil,                false,      false);
  72  
  73      InputMapper:addKey("Ingame",    "Sprint",                               "LeftShift");
  74      InputMapper:addKey("Ingame",    "Jump",                                 "Space");
  75      InputMapper:addKey("Ingame",    "PocketLamp",                           "L");
  76      InputMapper:addKey("Ingame",    "EnterSeat",                            "E");
  77      InputMapper:addKey("Ingame",    "InterieurCamera",                      "Alpha1");
  78      InputMapper:addKey("Ingame",    "ExterieurCamera",                      "Alpha2");
  79      InputMapper:addKey("Ingame",    "CustomCamera1",                        "Alpha3");
  80      InputMapper:addKey("Ingame",    "CustomCamera2",                        "Alpha4");
  81      InputMapper:addKey("Ingame",    "Scenario_TimescaleFaster",             "KeypadPlus");
  82      InputMapper:addKey("Ingame",    "Scenario_TimescaleSlower",             "KeypadMinus");
  83      InputMapper:addKey("Ingame",    "Scenario_TimescaleBoost",              "");
  84      
  85      
  86      InputMapper:addKey("Vehicle",   "Vehicle_Accelerate_Key",               "W");
  87      InputMapper:addKey("Vehicle",   "Vehicle_Brake_Key",                    "S");
  88      InputMapper:addKey("Vehicle",   "Vehicle_Steer_Left",                   "A");
  89      InputMapper:addKey("Vehicle",   "Vehicle_Steer_Right",                  "D");
  90  
  91      InputMapper:addAxis("Vehicle",  "Axis_Vehicle_Throttle_Brake_Combined", "Vehicle_Accelerate_Key",   "Vehicle_Brake_Key",    nil,                false,      true);
  92      InputMapper:addAxis("Vehicle",  "Axis_Vehicle_Throttle",                "Vehicle_Accelerate_Key",   "",                     nil,                true,       true);
  93      InputMapper:addAxis("Vehicle",  "Axis_Vehicle_Brake",                   "Vehicle_Brake_Key",        "",                     nil,                true,       true);
  94      InputMapper:addAxis("Vehicle",  "Axis_Vehicle_Steer",                   "Vehicle_Steer_Left",       "Vehicle_Steer_Right",  nil,                false,      false,  true);
  95  
  96      InputMapper:addKey("Vehicle",   "Vehicle_Switch",                       "Tab");
  97      InputMapper:addKey("Vehicle",   "Vehicle_Switch_Inverse",               "LeftShift Tab");
  98      InputMapper:addKey("Vehicle",   "Vehicle_Attach",                       "Q");
  99      InputMapper:addKey("Vehicle",   "Vehicle_RefillFuel",                   "T");
 100      InputMapper:addKey("Vehicle",   "Vehicle_AutomaticDrive",               "G");
 101      InputMapper:addKey("Vehicle",   "Vehicle_StartMotor",                   "KeypadEnter");
 102      InputMapper:addKey("Vehicle",   "Vehicle_GearUp",                       "F");
 103      InputMapper:addKey("Vehicle",   "Vehicle_GearDown",                     "R");
 104      InputMapper:addKey("Vehicle",   "Vehicle_ParkingBrake",                 "B");
 105      InputMapper:addKey("Vehicle",   "Vehicle_Lights",                       "L");
 106      InputMapper:addKey("Vehicle",   "Vehicle_BeaconLight",                  "Home");
 107      InputMapper:addKey("Vehicle",   "Vehicle_WorkLight1",                   "Keypad4");
 108      InputMapper:addKey("Vehicle",   "Vehicle_WorkLight2",                   "Keypad5");
 109      InputMapper:addKey("Vehicle",   "Vehicle_WorkLight3",                   "Keypad6");
 110      InputMapper:addKey("Vehicle",   "Vehicle_WarningSound",                 "Space");
 111      InputMapper:addKey("Vehicle",   "VehicleCar_IndicatorLeft",             "Keypad1");
 112      InputMapper:addKey("Vehicle",   "VehicleCar_HazardLights",              "Keypad2");
 113      InputMapper:addKey("Vehicle",   "VehicleCar_IndicatorRight",            "Keypad3");
 114      InputMapper:addKey("Vehicle",   "VehicleSnowcat_InverseDirection",      "LeftShift W",      "Mouse2");
 115      InputMapper:addKey("Vehicle",   "VehicleSnowcat_LowerGroomer",          "V");
 116      InputMapper:addKey("Vehicle",   "VehicleSnowcat_LockTrail",             "C");
 117      InputMapper:addKey("Vehicle",   "VehicleSnowcat_LeftFlap",              "Y");
 118      InputMapper:addKey("Vehicle",   "VehicleSnowcat_RightFlap",             "X");
 119      InputMapper:addKey("Vehicle",   "VehicleSnowcat_TenseWinch",            "P");
 120      InputMapper:addKey("Vehicle",   "VehicleSnowcat_TurnWinchLeft",         "N");
 121      InputMapper:addKey("Vehicle",   "VehicleSnowcat_TurnWinchRight",        "M");
 122      InputMapper:addKey("Vehicle",   "SnowCannon_TurnOnOff",                 "B");
 123      InputMapper:addKey("Vehicle",   "SnowCannon_RotateLeft",                "C");
 124      InputMapper:addKey("Vehicle",   "SnowCannon_RotateRight",               "V");
 125      InputMapper:addKey("Vehicle",   "SnowCannon_RotateUp",                  "R");
 126      InputMapper:addKey("Vehicle",   "SnowCannon_RotateDown",                "F");
 127  
 128      InputMapper:addAxis("Vehicle",  "Axis_Snowcat_Blade_UpDown",            nil, nil, nil,  false,      false);
 129      InputMapper:addAxis("Vehicle",  "Axis_Snowcat_Blade_LeftRight",         nil, nil, nil,  false,      false);
 130      InputMapper:addAxis("Vehicle",  "Axis_Snowcat_Blade_Tilt",              nil, nil, nil,  false,      false);
 131      InputMapper:addAxis("Vehicle",  "Axis_Snowcat_Blade_AttackAngle",       nil, nil, nil,  false,      false);
 132      InputMapper:addAxis("Vehicle",  "Axis_Snowcat_Blade_LeftWing",          nil, nil, nil,  false,      false);
 133      InputMapper:addAxis("Vehicle",  "Axis_Snowcat_Blade_RightWing",         nil, nil, nil,  false,      false);
 134      
 135      InputMapper:addKey("Ropeway",   "RW_PushCarrier",                       "R");
 136      InputMapper:addKey("Ropeway",   "RW_PullCarrier",                       "F");
 137      InputMapper:addKey("Ropeway",   "RW_StopCarrier",                       "G");
 138      InputMapper:addKey("Ropeway",   "RW_Bar",                               "N");
 139      InputMapper:addKey("Ropeway",   "RW_Bubble",                            "M");
 140      
 141      InputMapper:addKey("Ropeway",   "RW_Remote_Stop",                       "H");
 142      InputMapper:addKey("Ropeway",   "RW_Remote_EmergencyStop",              "G");
 143      InputMapper:addKey("Ropeway",   "RW_Remote_Forward",                    "R");
 144      InputMapper:addKey("Ropeway",   "RW_Remote_Backward",                   "F");
 145      InputMapper:addKey("Ropeway",   "RW_Remote_Reset",                      "J");
 146      InputMapper:addKey("Ropeway",   "RW_Remote_Start",                      "K");
 147      InputMapper:addKey("Ropeway",   "RW_Remote_Faster",                     "W");
 148      InputMapper:addKey("Ropeway",   "RW_Remote_Slower",                     "S");
 149  
 150      InputMapper:addKey("Skiing",    "SK_RotateLeft",                        "A");
 151      InputMapper:addKey("Skiing",    "SK_RotateRight",                       "D");
 152      InputMapper:addKey("Skiing",    "SK_SlowDown",                          "S");
 153      InputMapper:addKey("Skiing",    "SK_PushLeft",                          "Q");
 154      InputMapper:addKey("Skiing",    "SK_PushRight",                         "E");
 155  
 156      InputMapper:addKey("Editor",    "Editor_Brush_Larger",                  "V");
 157      InputMapper:addKey("Editor",    "Editor_Brush_Smaller",                 "C");
 158      InputMapper:addKey("Editor",    "Editor_Brush_Strength_Up",             "R");
 159      InputMapper:addKey("Editor",    "Editor_Brush_Strength_Dn",             "F");
 160  
 161      -- refresh input
 162      -- do not call this from mods
 163      SettingsManager:loadInput();
 164  end;

InputMapper:addKey(category, key, keyCode1, keyCode2, keyCode3)

Adds a key to Input mapper using following parameters:

  • category (string): category, in which the key belongs. See above for examples.
  • key (string): name of the key. Should be descriptive but not too long.
  • keyCode1 (string): default mapped key code. See this list from the Unity documentation to find out which key codes are allowed.
  • keyCode2 = nil (string): same, but optional.
  • keyCode3 = nil (string): same, but optional.

If one of the three key codes is hit, the key will be considered as pressed.

Tip: KeyCode A B will require the user to press the keys A and B simultaneously.

function InputMapper:addKey(category, key, keyCode1, keyCode2, keyCode3)

InputMapper:addAxis(category, axis, keyHigh, keyLow, axisCode, singleSided, invert, invertKeys, onlyOnKeyDown)

Adds an axis to Input mapper using following parameters:

  • category (string): category, in which the axis belongs. See above for examples.
  • key (string): name of the axis. Should be descriptive but not too long, and should start with Axis_.
  • keyHigh (string): if this key is pressed, the axis will return 1. (You have to register the key beforehand using InputMapper:addKey()). Use nil to disable.
  • keyLow (string): same again, but this time the axis will return -1. Use nil to deactivate.
  • axisCode (string): default mapped axis code. Can be either “Mouse X”, “Mouse Y”, “Mouse ScrollWheel” or one of “Joy1Axis1” to “Joy16Axis29”.
  • singleSided = false (bool, optional): true if the axis is single sided, i.e. ranges from 0 to 1 (instead of -1 to 1, which is two-sided).
  • invert = false (bool, optional): true if the joystick axis shall be inverted by default.
  • invertKeys = false (bool, optional): true if keyHigh and keyLow shall be swapped internally.
  • onlyOnKeyDown = false (bool, optional): true if the key shall only be considered in the frame the player starts pressing it. This is a very rare use case.

If one of the keys is hit, the axis will take their respective value. Otherwise, the joystick's value will be returned.

function InputMapper:addAxis(category, axis, keyHigh, keyLow, axisCode, singleSided, invert, invertKeys, onlyOnKeyDown)

InputMapper:getKey(keyData)

Returns whether the key keyData (table) is currently being pressed. keyData should always be something like InputMapper.Hotkey_IngameMenu or any other key.

This is comparable to Unity's Input.GetKey (but extended by some remapping features).

function InputMapper:getKey(keyData)

InputMapper:getKeyDown(keyData)

Returns true only in the frame in which the key keyData (table) starts to be pressed. In most cases, this is a safe option for keys that toggle some features on/off. Again, keyData should always be something like InputMapper.Hotkey_IngameMenu or any other key.

This is comparable to Unity's Input.GetKeyDown (but extended by some remapping features).

function InputMapper:getKeyDown(keyData)

InputMapper:getKeyUp(keyData)

Returns true only in the frame in which the key keyData (table) is released. This will usually be in use only rarely. One more time, keyData should always be something like InputMapper.Hotkey_IngameMenu or any other key.

This is comparable to Unity's Input.GetKeyDown (but extended by some remapping features).

function InputMapper:getKeyUp(keyData)

InputMapper:getAxis(axis, joystickOnly)

Returns the value of the input axis axis (table). The return value is a float between -1 and 1 or 0 and 1, depending on singleSided when calling InputMapper:addAxis(). Set joystickOnly (bool) to true if you only want to consider joysticks but not keys (rare use case).

axis should always be something like InputMapper.Axis_Walk_Forward or any other axis.

function InputMapper:getAxis(axis, joystickOnly)

InputMapper:getAxisRange(axis)

Returns the range of the axis axis (table), which will be either a tuple 0, 1 in case the axis is single sided or -1, 1 otherwise.

axis should always be something like InputMapper.Axis_Walk_Forward or any other axis.

function InputMapper:getAxisRange(axis)

InputMapper:replaceKeyCodesInText(text)

Returns the string text, but replaces all occurences of $Input(Hotkey_IngameMenu) in this text by the respective key assignment. In this case, this would be the key assigned to InputMapper.Hotkey_IngameMenu, which will usually be “Escape”.

The rest of the text stays unchanged.

function InputMapper:replaceKeyCodesInText(text)

InputMapper:getKeyCode(code)

Returns the assigned key to the code code (attention, this time a string!).

InputMapper:getKeyCode(“Hotkey_IngameMenu”) will usually return “Escape”.

function InputMapper:getKeyCode(code)

All contents of this page may be used for modding use for Winter Resort Simulator only. Any use exceeding this regulation is not permitted.

Copyright (C) HR Innoways, 2020. All Rights Reserved.