Game.Settings.InputSettings
Assembly: Assembly-CSharp (Game)
Namespace: Game.Settings
Type: class
Base: Setting
Summary:
InputSettings defines and exposes all configurable input-related settings for Cities: Skylines 2 (keyboard, mouse, gamepad and miscellaneous input options). It provides UI metadata (via attributes) used by the automatic settings system, implements default values, generates the settings page sections and key binding widgets from the runtime InputManager and Unity InputSystem devices, and provides reset functionality for device binding groups. This class depends on Game.Input.InputManager (for device & binding info) and UnityEngine.InputSystem (for device enumeration).
Fields
-
public const string kName = "Input"
{{ Identifies this settings object's name used by the settings system. }} -
public const string kMiscTab = "Misc"
{{ Constant used to refer to the miscellaneous tab/group label in the settings UI. }}
Properties
-
public bool elevationDraggingEnabled { get; set; }
{{ Enables/disables elevation dragging in the UI. Marked with [SettingsUIHideByCondition(typeof(Game.Input.InputManager), "IsGamepadActive")] and appears in the "Misc -> General" settings section. Default: false. }} -
public float mouseScrollSensitivity { get; set; }
{{ Mouse scroll sensitivity. Shown under "Mouse -> Navigation" with slider attributes (min=0.1, max=5, step=0.1) and custom format (1 fraction digit). Hidden if no mouse is connected (SettingsUIHideByCondition). Default: 1.0. }} -
public float finalScrollSensitivity
(read-only)
{{ Returns the effective scroll sensitivity. In this implementation it returns mouseScrollSensitivity. Useful for code that consumes the final computed value. }} -
public float keyboardMoveSensitivity { get; set; }
{{ Keyboard camera move sensitivity. Slider UI (0.1–5, step 0.1). Hidden if no keyboard is connected. Default: 1.0. }} -
public float keyboardRotateSensitivity { get; set; }
{{ Keyboard camera rotate sensitivity. Slider UI (0.1–5, step 0.1). Hidden if no keyboard. Default: 1.0. }} -
public float keyboardZoomSensitivity { get; set; }
{{ Keyboard camera zoom sensitivity. Slider UI (0.1–5, step 0.1). Hidden if no keyboard. Default: 1.0. }} -
public float mouseMoveSensitivity { get; set; }
{{ Mouse camera move sensitivity. Slider UI (0.1–5, step 0.1). Hidden if no mouse. Default: 1.0. }} -
public float mouseRotateSensitivity { get; set; }
{{ Mouse camera rotate sensitivity. Slider UI (0.1–5, step 0.1). Hidden if no mouse. Default: 1.0. }} -
public float mouseZoomSensitivity { get; set; }
{{ Mouse camera zoom sensitivity. Slider UI (0.1–5, step 0.1). Hidden if no mouse. Default: 1.0. }} -
public bool mouseInvertX { get; set; }
{{ Invert mouse X axis for camera. Hidden if no mouse. Default: false. }} -
public bool mouseInvertY { get; set; }
{{ Invert mouse Y axis for camera. Hidden if no mouse. Default: false. }} -
public float gamepadMoveSensitivity { get; set; }
{{ Gamepad camera move sensitivity. Slider UI (0.1–5, step 0.1). Hidden if no gamepad. Default: 1.0. }} -
public float gamepadRotateSensitivity { get; set; }
{{ Gamepad camera rotate sensitivity. Slider UI (0.1–5, step 0.1). Hidden if no gamepad. Default: 1.0. }} -
public float gamepadZoomSensitivity { get; set; }
{{ Gamepad camera zoom sensitivity. Slider UI (0.1–5, step 0.1). Hidden if no gamepad. Default: 1.0. }} -
public bool gamepadInvertX { get; set; }
{{ Invert gamepad X axis for camera. Hidden if no gamepad. Default: false. }} -
public bool gamepadInvertY { get; set; }
{{ Invert gamepad Y axis for camera. Hidden if no gamepad. Default: false. }} -
private bool isKeyboardConflict
(private read-only)
{{ Computed flag indicating whether there are binding conflicts involving the keyboard. Uses Game.Input.InputManager.instance.bindingConflicts. }} -
private bool isMouseConflict
(private read-only)
{{ Computed flag indicating whether there are binding conflicts involving the mouse. }} -
private bool isGamepadConflict
(private read-only)
{{ Computed flag indicating whether there are binding conflicts involving the gamepad. }}
Constructors
public InputSettings()
{{ Default constructor. Calls SetDefaults() to initialize all properties to their default values. }}
Methods
-
public override void SetDefaults()
{{ Resets settings to their defaults for all supported devices and misc flags. Sets elevationDraggingEnabled to false and calls SetDefaultsForDevice for Keyboard, Mouse and Gamepad. }} -
private void SetDefaultsForDevice(Game.Input.InputManager.DeviceType device)
{{ Helper that initializes device-specific properties to defaults depending on the device enum (Keyboard, Mouse, Gamepad). For keyboard: move/zoom/rotate = 1. For mouse: move/rotate/zoom/scroll = 1 and invert flags false. For gamepad: move/zoom/rotate = 1 and invert flags false. Handles DeviceType combinations but primarily used for single device values. }} -
public override AutomaticSettings.SettingPageData GetPageData(string id, bool addPrefix)
{{ Builds and returns the settings page data used by the automatic settings UI. It first gets the base page data, then queries UnityEngine.InputSystem.InputSystem.devices to detect connected Keyboard/Mouse/Gamepad devices and includes the corresponding sections. This method drives what device sections are shown to the user at runtime. }} -
private void GetPageSection(AutomaticSettings.SettingPageData pageData, Game.Input.InputManager.DeviceType device)
{{ Core routine that populates a device-specific page section: - Adds a Reset button (ManualProperty) that calls InputManager.instance.ResetGroupBindings(device), re-applies defaults for that device and saves.
- Iterates Game.Input.InputManager.instance.actions, inspects action composites and bindings, and creates AutomaticSettings.ManualProperty + SettingItemData entries for each binding (built-in, non-dummy, matching device).
- Also adds alias bindings for UI aliases (UIBaseInputAction) that are visible in options and whose transform mask matches the binding.
-
Groups and group display names are added to pageData based on binding options groups. This method effectively turns the runtime action/binding definitions into visible/editable key-binding widgets. }}
-
private string[] GetTabOrder()
{{ Returns the ordering of tabs for the settings UI depending on the active control scheme in Game.Input.InputManager.instance.activeControlScheme. If Gamepad is active it returns ["Gamepad","Keyboard","Mouse","Misc"], otherwise ["Keyboard","Mouse","Gamepad","Misc"]. Used by the SettingsUITabOrder attribute. }}
Usage Example
// Example: programmatically change mouse sensitivity and save settings.
var inputSettings = new Game.Settings.InputSettings();
inputSettings.mouseMoveSensitivity = 1.5f;
inputSettings.mouseZoomSensitivity = 0.9f;
// If the base Setting class exposes ApplyAndSave (used in GetPageSection),
// call it to persist settings. (ApplyAndSave is implemented in the base Setting.)
inputSettings.ApplyAndSave();
Notes / Implementation details: - The class is annotated with several settings UI attributes: - [FileLocation("Settings")] — where the settings file is stored. - [SettingsUITabOrder(typeof(InputSettings), "GetTabOrder")] — dynamic tab ordering. - [SettingsUIGroupOrder(...)] — default group ordering. - [SettingsUITabWarning(...)] — shows warnings per device tab when binding conflicts exist (uses isKeyboardConflict/isMouseConflict/isGamepadConflict). - The automatic generation of key-binding widgets relies on Game.Input.InputManager.instance.actions and UnityEngine.InputSystem device enumeration; therefore the runtime state of InputManager and InputSystem determines which options and devices are shown. - Reset behavior for a device calls Game.Input.InputManager.instance.ResetGroupBindings(device) then re-applies defaults and saves.