diff --git a/Assets/Tests/InputSystem/CoreTests_Actions.cs b/Assets/Tests/InputSystem/CoreTests_Actions.cs index 0aa3d09fbe..02c7cc8fb6 100644 --- a/Assets/Tests/InputSystem/CoreTests_Actions.cs +++ b/Assets/Tests/InputSystem/CoreTests_Actions.cs @@ -319,22 +319,67 @@ public void Actions_WhenShortcutsEnabled_PressingShortcutSequenceInWrongOrder_Do [TestCase("leftShift", "leftAlt", "space", true)] [TestCase("leftShift", null, "space", false)] [TestCase("leftShift", "leftAlt", "space", false)] - public void Actions_PressingShortcutSequenceInWrongOrder_DoesNotTriggerShortcut_ExceptIfOverridden(string modifier1, string modifier2, string binding, - bool legacyComposites) + public void Actions_WhenShortcutsDisabled_PressingShortcutSequenceInWrongOrder_DoesNotTriggerShortcutIfOverridden(string modifier1, string modifier2, string binding, bool legacyComposites) { var keyboard = InputSystem.AddDevice(); var action = new InputAction(); if (!string.IsNullOrEmpty(modifier2)) { - action.AddCompositeBinding((legacyComposites ? "ButtonWithTwoModifiers" : "TwoModifiers") + "(overrideModifiersNeedToBePressedFirst)") + action.AddCompositeBinding((legacyComposites ? "ButtonWithTwoModifiers" : "TwoModifiers") + "(modifiersOrder=1)") .With("Modifier1", "/" + modifier1) .With("Modifier2", "/" + modifier2) .With(legacyComposites ? "Button" : "Binding", "/" + binding); } else { - action.AddCompositeBinding((legacyComposites ? "ButtonWithOneModifier" : "OneModifier") + "(overrideModifiersNeedToBePressedFirst)") + action.AddCompositeBinding((legacyComposites ? "ButtonWithOneModifier" : "OneModifier") + "(modifiersOrder=1)") + .With("Modifier", "/" + modifier1) + .With(legacyComposites ? "Button" : "Binding", "/" + binding); + } + + action.Enable(); + + var wasPerformed = false; + action.performed += _ => wasPerformed = true; + + // Press binding first, then modifiers. + Press((ButtonControl)keyboard[binding]); + Press((ButtonControl)keyboard[modifier1]); + if (!string.IsNullOrEmpty(modifier2)) + Press((ButtonControl)keyboard[modifier2]); + + Assert.That(wasPerformed, Is.False); + } + + [Test] + [Category("Actions")] + [TestCase("leftShift", null, "space", true, true)] + [TestCase("leftShift", "leftAlt", "space", true, true)] + [TestCase("leftShift", null, "space", false, true)] + [TestCase("leftShift", "leftAlt", "space", false, true)] + [TestCase("leftShift", null, "space", true, false)] + [TestCase("leftShift", "leftAlt", "space", true, false)] + [TestCase("leftShift", null, "space", false, false)] + [TestCase("leftShift", "leftAlt", "space", false, false)] + public void Actions_WhenShortcutsAreEnabled_PressingShortcutSequenceInWrongOrder_DoesNotTriggerShortcut_ExceptIfOverridden(string modifier1, string modifier2, string binding, + bool legacyComposites, bool overrideModifiersNeedToBePressedFirst) + { + InputSystem.settings.shortcutKeysConsumeInput = true; + + var keyboard = InputSystem.AddDevice(); + + var action = new InputAction(); + if (!string.IsNullOrEmpty(modifier2)) + { + action.AddCompositeBinding((legacyComposites ? "ButtonWithTwoModifiers" : "TwoModifiers") + (overrideModifiersNeedToBePressedFirst ? "(overrideModifiersNeedToBePressedFirst)" : "(modifiersOrder=2)")) + .With("Modifier1", "/" + modifier1) + .With("Modifier2", "/" + modifier2) + .With(legacyComposites ? "Button" : "Binding", "/" + binding); + } + else + { + action.AddCompositeBinding((legacyComposites ? "ButtonWithOneModifier" : "OneModifier") + (overrideModifiersNeedToBePressedFirst ? "(overrideModifiersNeedToBePressedFirst)" : "(modifiersOrder=2)")) .With("Modifier", "/" + modifier1) .With(legacyComposites ? "Button" : "Binding", "/" + binding); } diff --git a/Packages/com.unity.inputsystem/CHANGELOG.md b/Packages/com.unity.inputsystem/CHANGELOG.md index a1969a7bd0..729a9f5106 100644 --- a/Packages/com.unity.inputsystem/CHANGELOG.md +++ b/Packages/com.unity.inputsystem/CHANGELOG.md @@ -22,10 +22,13 @@ however, it has to be formatted properly to pass verification tests. - Fixed missing documentation for source generated Input Action Assets. This is now generated as part of the source code generation step when "Generate C# Class" is checked in the importer inspector settings. - Fixed pasting into an empty map list raising an exception. [ISXB-1150](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1150) - Fixed pasting bindings into empty Input Action asset. [ISXB-1180](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1180) +- Fixed tooltip support in the UI Toolkit version of the Input Actions Asset editor. +- Fixed documentation to clarify bindings with modifiers `overrideModifiersNeedToBePressedFirst` configuration [ISXB-806](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-806). ### Changed - Added back the InputManager to InputSystem project-wide asset migration code with performance improvement (ISX-2086). - Changed `OnScreenControl` to automaticaly switch, in Single Player with autoswitch enabled, to the target device control scheme when the first component is enabled to prevent bad interactions when it start. +- Changed paremeter `overrideModifiersNeedToBePressedFirst` to obsolete for `ButtonWithOneModifier`, `ButtonWithTwoModifiers`, `OneModifierComposite` and `TwoModifiersComposite` in flavor the the new `modifiersOrder` parameter which is more explicit. ## [1.11.2] - 2024-10-16 diff --git a/Packages/com.unity.inputsystem/InputSystem/Actions/Composites/ButtonWithOneModifier.cs b/Packages/com.unity.inputsystem/InputSystem/Actions/Composites/ButtonWithOneModifier.cs index bca3936068..86598db994 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Actions/Composites/ButtonWithOneModifier.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Actions/Composites/ButtonWithOneModifier.cs @@ -1,3 +1,4 @@ +using System; using System.ComponentModel; using UnityEngine.InputSystem.Layouts; using UnityEngine.InputSystem.Utilities; @@ -79,16 +80,71 @@ public class ButtonWithOneModifier : InputBindingComposite /// still trigger. Default is false. /// /// - /// By default, is required to be in pressed state before or at the same time that + /// By default, if the setting is enabled, + /// is required to be in pressed state before or at the same time that /// goes into pressed state for the composite as a whole to trigger. This means that binding to, for example, Shift+B, /// the shift key has to be pressed before pressing the B key. This is the behavior usually expected with /// keyboard shortcuts. /// /// This parameter can be used to bypass this behavior and allow any timing between and . /// The only requirement is for them both to concurrently be in pressed state. + /// + /// To don't depends on the setting please consider using instead. /// + [Tooltip("Obsolete please use modifiers Order. If enabled, this will override the Input Consumption setting, allowing the modifier keys to be pressed after the button and the composite will still trigger.")] + [Obsolete("Use ModifiersOrder.Unordered with 'modifiersOrder' instead")] public bool overrideModifiersNeedToBePressedFirst; + /// + /// Determines how a modifiers keys need to be pressed in order or not. + /// + public enum ModifiersOrder + { + /// + /// By default, if the setting is enabled, + /// is required to be in pressed state before or at the same time that + /// goes into pressed state for the composite as a whole to trigger. This means that binding to, for example, Shift+B, + /// the shift key has to be pressed before pressing the B key. This is the behavior usually expected with + /// keyboard shortcuts. + /// + /// If the setting is disabled, + /// modifiers can be pressed after the button and the composite will still trigger. + /// + Default = 0, + + /// + /// is required to be in pressed state before or at the same + /// time that goes into pressed state for the composite as a whole to trigger. This means that binding to, + /// for example, Ctrl+B, the ctrl key have to be pressed before pressing the B key. + /// This is the behavior usually expected with keyboard shortcuts. + /// + Ordered = 1, + + /// + /// can be pressed after + /// and the composite will still trigger. The only requirement is for all of them to concurrently be in pressed state. + /// + Unordered = 2 + } + + /// + /// If set to Ordered or Unordered, the built-in logic to determine if modifiers need to be pressed first is overridden. + /// + /// By default, if the setting is enabled, + /// is required to be in pressed state before or at the same time that + /// goes into pressed state for the composite as a whole to trigger. This means that binding to, for example, Shift+B, + /// the shift key has to be pressed before pressing the B key. This is the behavior usually expected with + /// keyboard shortcuts. + /// + /// If the setting is disabled, + /// modifiers can be pressed after the button and the composite will still trigger. + /// + /// This parameter can be used to bypass this behavior and enforce the timing order or allow any timing between and . + /// The only requirement is for them both to concurrently be in pressed state. + /// + [Tooltip("By default it follow the Input Consumption setting to determine if the modifers keys need to be pressed first.")] + public ModifiersOrder modifiersOrder = ModifiersOrder.Default; + /// /// Return the value of the part if is pressed. Otherwise /// return 0. @@ -107,7 +163,7 @@ private bool ModifierIsPressed(ref InputBindingCompositeContext context) { var modifierDown = context.ReadValueAsButton(modifier); - if (modifierDown && !overrideModifiersNeedToBePressedFirst) + if (modifierDown && modifiersOrder == ModifiersOrder.Ordered) { var timestamp = context.GetPressTime(button); var timestamp1 = context.GetPressTime(modifier); @@ -130,8 +186,17 @@ public override float EvaluateMagnitude(ref InputBindingCompositeContext context protected override void FinishSetup(ref InputBindingCompositeContext context) { - if (!overrideModifiersNeedToBePressedFirst) - overrideModifiersNeedToBePressedFirst = !InputSystem.settings.shortcutKeysConsumeInput; + if (modifiersOrder == ModifiersOrder.Default) + { + // Legacy. We need to reference the obsolete member here so temporarily + // turn off the warning. +#pragma warning disable CS0618 + if (overrideModifiersNeedToBePressedFirst) +#pragma warning restore CS0618 + modifiersOrder = ModifiersOrder.Unordered; + else + modifiersOrder = InputSystem.settings.shortcutKeysConsumeInput ? ModifiersOrder.Ordered : ModifiersOrder.Unordered; + } } } } diff --git a/Packages/com.unity.inputsystem/InputSystem/Actions/Composites/ButtonWithTwoModifiers.cs b/Packages/com.unity.inputsystem/InputSystem/Actions/Composites/ButtonWithTwoModifiers.cs index 3d930d07bc..73d04d40ef 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Actions/Composites/ButtonWithTwoModifiers.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Actions/Composites/ButtonWithTwoModifiers.cs @@ -1,3 +1,4 @@ +using System; using System.ComponentModel; using UnityEngine.InputSystem.Layouts; using UnityEngine.InputSystem.Utilities; @@ -94,16 +95,70 @@ public class ButtonWithTwoModifiers : InputBindingComposite /// and the composite will still trigger. Default is false. /// /// - /// By default, and are required to be in pressed state before or at the same + /// By default, if the setting is enabled, + /// and are required to be in pressed state before or at the same /// time that goes into pressed state for the composite as a whole to trigger. This means that binding to, /// for example, Ctrl+Shift+B, the ctrl shift keys have to be pressed before pressing the B key. /// This is the behavior usually expected with keyboard shortcuts. /// /// This parameter can be used to bypass this behavior and allow any timing between , , /// and . The only requirement is for all of them to concurrently be in pressed state. + /// + /// To don't depends on the setting please consider using instead. /// + [Tooltip("Obsolete please use modifiers Order. If enabled, this will override the Input Consumption setting, allowing the modifier keys to be pressed after the button and the composite will still trigger.")] + [Obsolete("Use ModifiersOrder.Unordered with 'modifiersOrder' instead")] public bool overrideModifiersNeedToBePressedFirst; + /// + /// Determines how a modifiers keys need to be pressed in order or not. + /// + public enum ModifiersOrder + { + /// + /// By default, if the setting is enabled, + /// and are required to be in pressed state before or at the same + /// time that goes into pressed state for the composite as a whole to trigger. This means that binding to, + /// for example, Ctrl+Shift+B, the ctrl shift keys have to be pressed before pressing the B key. + /// This is the behavior usually expected with keyboard shortcuts. + /// + /// If the setting is disabled, + /// modifiers can be pressed after the button and the composite will still trigger. + /// + Default = 0, + + /// + /// and are required to be in pressed state before or at the same + /// time that goes into pressed state for the composite as a whole to trigger. This means that binding to, + /// for example, Ctrl+Shift+B, the ctrl shift keys have to be pressed before pressing the B key. + /// This is the behavior usually expected with keyboard shortcuts. + /// + Ordered = 1, + + /// + /// and/or can be pressed after + /// and the composite will still trigger. The only requirement is for all of them to concurrently be in pressed state. + /// + Unordered = 2 + } + + /// + /// If set to Ordered or Unordered, the built-in logic to determine if modifiers need to be pressed first is overridden. + /// + /// By default, if the setting is enabled, + /// and are required to be in pressed state before or at the same + /// time that goes into pressed state for the composite as a whole to trigger. This means that binding to, + /// for example, Ctrl+Shift+B, the ctrl shift keys have to be pressed before pressing the B key. + /// This is the behavior usually expected with keyboard shortcuts. + /// + /// If the setting is disabled, + /// modifiers can be pressed after the button and the composite will still trigger. + /// + /// This field allows you to explicitly override this default inference. + /// + [Tooltip("By default it follow the Input Consumption setting to determine if the modifers keys need to be pressed first.")] + public ModifiersOrder modifiersOrder = ModifiersOrder.Default; + /// /// Return the value of the part while both and /// are pressed. Otherwise return 0. @@ -122,7 +177,7 @@ private bool ModifiersArePressed(ref InputBindingCompositeContext context) { var modifiersDown = context.ReadValueAsButton(modifier1) && context.ReadValueAsButton(modifier2); - if (modifiersDown && !overrideModifiersNeedToBePressedFirst) + if (modifiersDown && modifiersOrder == ModifiersOrder.Ordered) { var timestamp = context.GetPressTime(button); var timestamp1 = context.GetPressTime(modifier1); @@ -146,8 +201,17 @@ public override float EvaluateMagnitude(ref InputBindingCompositeContext context protected override void FinishSetup(ref InputBindingCompositeContext context) { - if (!overrideModifiersNeedToBePressedFirst) - overrideModifiersNeedToBePressedFirst = !InputSystem.settings.shortcutKeysConsumeInput; + if (modifiersOrder == ModifiersOrder.Default) + { + // Legacy. We need to reference the obsolete member here so temporarily + // turn off the warning. +#pragma warning disable CS0618 + if (overrideModifiersNeedToBePressedFirst) +#pragma warning restore CS0618 + modifiersOrder = ModifiersOrder.Unordered; + else + modifiersOrder = InputSystem.settings.shortcutKeysConsumeInput ? ModifiersOrder.Ordered : ModifiersOrder.Unordered; + } } } } diff --git a/Packages/com.unity.inputsystem/InputSystem/Actions/Composites/OneModifierComposite.cs b/Packages/com.unity.inputsystem/InputSystem/Actions/Composites/OneModifierComposite.cs index dfd7f6486b..4786a58a44 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Actions/Composites/OneModifierComposite.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Actions/Composites/OneModifierComposite.cs @@ -88,7 +88,8 @@ public class OneModifierComposite : InputBindingComposite /// Default value is false. /// /// - /// By default, if is bound to only s, then the composite requires + /// By default, if the setting is enabled, + /// if is bound to only s, then the composite requires /// to be pressed before pressing . This means that binding to, for example, /// Ctrl+B, the ctrl keys have to be pressed before pressing the B key. This is the behavior usually expected /// with keyboard shortcuts. @@ -100,9 +101,68 @@ public class OneModifierComposite : InputBindingComposite /// This field allows you to explicitly override this default inference and make it so that regardless of what /// is bound to, any press sequence is acceptable. For the example binding to Ctrl+B, it would mean that pressing B and /// only then pressing Ctrl will still trigger the binding. + /// + /// To don't depends on the setting please consider using instead. /// + [Tooltip("Obsolete please use modifiers Order. If enabled, this will override the Input Consumption setting, allowing the modifier keys to be pressed after the button and the composite will still trigger.")] + [Obsolete("Use ModifiersOrder.Unordered with 'modifiersOrder' instead")] public bool overrideModifiersNeedToBePressedFirst; + /// + /// Determines how a modifiers keys need to be pressed in order or not. + /// + public enum ModifiersOrder + { + /// + /// By default, if the setting is enabled, + /// if is bound to only s, then the composite requires + /// to be pressed before pressing . This means that binding to, for example, + /// Ctrl+B, the ctrl keys have to be pressed before pressing the B key. This is the behavior usually expected + /// with keyboard shortcuts. + /// + /// If the setting is disabled, + /// modifiers can be pressed after the button and the composite will still trigger. + /// + Default = 0, + + /// + /// is required to be in pressed state before or at the same + /// time that goes into pressed state for the composite as a whole to trigger. This means that binding to, + /// for example, Ctrl+B, the ctrl key have to be pressed before pressing the B key. + /// This is the behavior usually expected with keyboard shortcuts. + /// + Ordered = 1, + + /// + /// can be pressed after + /// and the composite will still trigger. The only requirement is for all of them to concurrently be in pressed state. + /// + Unordered = 2 + } + + /// + /// If set to Ordered or Unordered, the built-in logic to determine if modifiers need to be pressed first is overridden. + /// + /// By default, if the setting is enabled, + /// if is bound to only s, then the composite requires + /// to be pressed before pressing . This means that binding to, for example, + /// Ctrl+B, the ctrl keys have to be pressed before pressing the B key. This is the behavior usually expected + /// with keyboard shortcuts. + /// + /// If the setting is disabled, + /// modifiers can be pressed after the button and the composite will still trigger. + /// + /// However, when binding, for example, Ctrl+MouseDelta, it should be possible to press ctrl at any time. The default + /// logic will automatically detect the difference between this binding and the button binding in the example above and behave + /// accordingly. + /// + /// This field allows you to explicitly override this default inference and make the order mandatory or make it so that regardless of what + /// is bound to, any press sequence is acceptable. For the example binding to Ctrl+B, it would mean that pressing B and + /// only then pressing Ctrl will still trigger the binding. + /// + [Tooltip("By default it follow the Input Consumption setting to determine if the modifers keys need to be pressed first.")] + public ModifiersOrder modifiersOrder = ModifiersOrder.Default; + private int m_ValueSizeInBytes; private Type m_ValueType; private bool m_BindingIsButton; @@ -128,7 +188,7 @@ private bool ModifierIsPressed(ref InputBindingCompositeContext context) var modifierDown = context.ReadValueAsButton(modifier); // When the modifiers are gating a button, we require the modifiers to be pressed *first*. - if (modifierDown && m_BindingIsButton && !overrideModifiersNeedToBePressedFirst) + if (modifierDown && m_BindingIsButton && modifiersOrder == ModifiersOrder.Ordered) { var timestamp = context.GetPressTime(binding); var timestamp1 = context.GetPressTime(modifier); @@ -144,8 +204,17 @@ protected override void FinishSetup(ref InputBindingCompositeContext context) { DetermineValueTypeAndSize(ref context, binding, out m_ValueType, out m_ValueSizeInBytes, out m_BindingIsButton); - if (!overrideModifiersNeedToBePressedFirst) - overrideModifiersNeedToBePressedFirst = !InputSystem.settings.shortcutKeysConsumeInput; + if (modifiersOrder == ModifiersOrder.Default) + { + // Legacy. We need to reference the obsolete member here so temporarily + // turn off the warning. +#pragma warning disable CS0618 + if (overrideModifiersNeedToBePressedFirst) +#pragma warning restore CS0618 + modifiersOrder = ModifiersOrder.Unordered; + else + modifiersOrder = InputSystem.settings.shortcutKeysConsumeInput ? ModifiersOrder.Ordered : ModifiersOrder.Unordered; + } } public override object ReadValueAsObject(ref InputBindingCompositeContext context) diff --git a/Packages/com.unity.inputsystem/InputSystem/Actions/Composites/TwoModifiersComposite.cs b/Packages/com.unity.inputsystem/InputSystem/Actions/Composites/TwoModifiersComposite.cs index b4f8d928d9..cc90be4a90 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Actions/Composites/TwoModifiersComposite.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Actions/Composites/TwoModifiersComposite.cs @@ -90,7 +90,8 @@ public class TwoModifiersComposite : InputBindingComposite /// Default value is false. /// /// - /// By default, if is bound to only s, then the composite requires + /// By default, if the setting is enabled, + /// if is bound to only s, then the composite requires /// both and to be pressed before pressing . /// This means that binding to, for example, Ctrl+Shift+B, the ctrl and shift keys have to be pressed /// before pressing the B key. This is the behavior usually expected with keyboard shortcuts. @@ -102,9 +103,65 @@ public class TwoModifiersComposite : InputBindingComposite /// This field allows you to explicitly override this default inference and make it so that regardless of what /// is bound to, any press sequence is acceptable. For the example binding to Ctrl+Shift+B, it would mean that pressing /// B and only then pressing Ctrl and Shift will still trigger the binding. + /// + /// To don't depends on the setting please consider using instead. /// + [Tooltip("Obsolete please use modifiers Order. If enabled, this will override the Input Consumption setting, allowing the modifier keys to be pressed after the button and the composite will still trigger.")] + [Obsolete("Use ModifiersOrder.Unordered with 'modifiersOrder' instead")] public bool overrideModifiersNeedToBePressedFirst; + /// + /// Determines how a modifiers keys need to be pressed in order or not. + /// + public enum ModifiersOrder + { + /// + /// By default, if the setting is enabled, + /// if is bound to only s, then the composite requires + /// both and to be pressed before pressing . + /// This means that binding to, for example, Ctrl+Shift+B, the ctrl and shift keys have to be pressed + /// before pressing the B key. This is the behavior usually expected with keyboard shortcuts. + /// + /// If the setting is disabled, + /// modifiers can be pressed after the button and the composite will still trigger. + /// + Default = 0, + + /// + /// and are required to be in pressed state before or at the same + /// time that goes into pressed state for the composite as a whole to trigger. This means that binding to, + /// for example, Ctrl+Shift+B, the ctrl shift keys have to be pressed before pressing the B key. + /// This is the behavior usually expected with keyboard shortcuts. + /// + Ordered = 1, + + /// + /// and/or can be pressed after + /// and the composite will still trigger. The only requirement is for all of them to concurrently be in pressed state. + /// + Unordered = 2 + } + + /// + /// If set to Ordered or Unordered, the built-in logic to determine if modifiers need to be pressed first is overridden. + /// + /// By default, if the setting is enabled, + /// if is bound to only s, then the composite requires + /// both and to be pressed before pressing . + /// This means that binding to, for example, Ctrl+Shift+B, the ctrl and shift keys have to be pressed + /// before pressing the B key. This is the behavior usually expected with keyboard shortcuts. + /// + /// If the setting is disabled, + /// modifiers can be pressed after the button and the composite will still trigger. + /// + /// This field allows you to explicitly override this default inference and make the order mandatory or make it so that regardless of what + /// is bound to, any press sequence is acceptable. For the example binding to Ctrl+Shift+B, it would mean that pressing + /// B and only then pressing Ctrl and Shift will still trigger the binding. + /// + /// + [Tooltip("By default it follow the Input Consumption setting to determine if the modifers keys need to be pressed first.")] + public ModifiersOrder modifiersOrder = ModifiersOrder.Default; + /// /// Type of values read from controls bound to . /// @@ -140,7 +197,7 @@ private bool ModifiersArePressed(ref InputBindingCompositeContext context) var modifiersDown = context.ReadValueAsButton(modifier1) && context.ReadValueAsButton(modifier2); // When the modifiers are gating a button, we require the modifiers to be pressed *first*. - if (modifiersDown && m_BindingIsButton && !overrideModifiersNeedToBePressedFirst) + if (modifiersDown && m_BindingIsButton && modifiersOrder == ModifiersOrder.Ordered) { var timestamp = context.GetPressTime(binding); var timestamp1 = context.GetPressTime(modifier1); @@ -157,8 +214,17 @@ protected override void FinishSetup(ref InputBindingCompositeContext context) { OneModifierComposite.DetermineValueTypeAndSize(ref context, binding, out m_ValueType, out m_ValueSizeInBytes, out m_BindingIsButton); - if (!overrideModifiersNeedToBePressedFirst) - overrideModifiersNeedToBePressedFirst = !InputSystem.settings.shortcutKeysConsumeInput; + if (modifiersOrder == ModifiersOrder.Default) + { + // Legacy. We need to reference the obsolete member here so temporarily + // turn off the warning. +#pragma warning disable CS0618 + if (overrideModifiersNeedToBePressedFirst) +#pragma warning restore CS0618 + modifiersOrder = ModifiersOrder.Unordered; + else + modifiersOrder = InputSystem.settings.shortcutKeysConsumeInput ? ModifiersOrder.Ordered : ModifiersOrder.Unordered; + } } public override object ReadValueAsObject(ref InputBindingCompositeContext context) diff --git a/Packages/com.unity.inputsystem/InputSystem/Actions/Composites/Vector2Composite.cs b/Packages/com.unity.inputsystem/InputSystem/Actions/Composites/Vector2Composite.cs index dd7a462628..0d01a73b3d 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Actions/Composites/Vector2Composite.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Actions/Composites/Vector2Composite.cs @@ -145,7 +145,7 @@ public override Vector2 ReadValue(ref InputBindingCompositeContext context) var rightIsPressed = context.ReadValueAsButton(right); // Legacy. We need to reference the obsolete member here so temporarily - // turn of the warning. + // turn off the warning. #pragma warning disable CS0618 if (!normalize) // Was on by default. mode = Mode.Digital; diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/AssetEditor/ParameterListView.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/AssetEditor/ParameterListView.cs index d7bf20c47c..e3d9a8a978 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/AssetEditor/ParameterListView.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/AssetEditor/ParameterListView.cs @@ -280,6 +280,7 @@ void OnEditEnd() { var intValue = parameter.value.value.ToInt32(); var field = new DropdownField(label.text, parameter.enumNames.Select(x => x.text).ToList(), intValue); + field.tooltip = label.tooltip; field.RegisterValueChangedCallback(evt => OnValueChanged(ref parameter, field.index, closedIndex)); field.RegisterCallback(_ => OnEditEnd()); root.Add(field); @@ -287,7 +288,7 @@ void OnEditEnd() else if (parameter.value.type == TypeCode.Int64 || parameter.value.type == TypeCode.UInt64) { var longValue = parameter.value.value.ToInt64(); - var field = new LongField(label.text) { value = longValue }; + var field = new LongField(label.text) { value = longValue, tooltip = label.tooltip }; field.RegisterValueChangedCallback(evt => OnValueChanged(ref parameter, evt.newValue, closedIndex)); field.RegisterCallback(_ => OnEditEnd()); root.Add(field); @@ -295,7 +296,7 @@ void OnEditEnd() else if (parameter.value.type.IsInt()) { var intValue = parameter.value.value.ToInt32(); - var field = new IntegerField(label.text) { value = intValue }; + var field = new IntegerField(label.text) { value = intValue, tooltip = label.tooltip }; field.RegisterValueChangedCallback(evt => OnValueChanged(ref parameter, evt.newValue, closedIndex)); field.RegisterCallback(_ => OnEditEnd()); root.Add(field); @@ -303,7 +304,7 @@ void OnEditEnd() else if (parameter.value.type == TypeCode.Single) { var floatValue = parameter.value.value.ToSingle(); - var field = new FloatField(label.text) { value = floatValue }; + var field = new FloatField(label.text) { value = floatValue, tooltip = label.tooltip }; field.RegisterValueChangedCallback(evt => OnValueChanged(ref parameter, evt.newValue, closedIndex)); field.RegisterCallback(_ => OnEditEnd()); root.Add(field); @@ -311,7 +312,7 @@ void OnEditEnd() else if (parameter.value.type == TypeCode.Double) { var floatValue = parameter.value.value.ToDouble(); - var field = new DoubleField(label.text) { value = floatValue }; + var field = new DoubleField(label.text) { value = floatValue, tooltip = label.tooltip }; field.RegisterValueChangedCallback(evt => OnValueChanged(ref parameter, evt.newValue, closedIndex)); field.RegisterCallback(_ => OnEditEnd()); root.Add(field); @@ -319,7 +320,7 @@ void OnEditEnd() else if (parameter.value.type == TypeCode.Boolean) { var boolValue = parameter.value.value.ToBoolean(); - var field = new Toggle(label.text) { value = boolValue }; + var field = new Toggle(label.text) { value = boolValue, tooltip = label.tooltip }; field.RegisterValueChangedCallback(evt => OnValueChanged(ref parameter, evt.newValue, closedIndex)); field.RegisterValueChangedCallback(_ => OnEditEnd()); root.Add(field);