diff --git a/Assets/Samples/InGameHints/InGameHintsActions.cs b/Assets/Samples/InGameHints/InGameHintsActions.cs index 8ee2cd9fe4..ea4324ebaa 100644 --- a/Assets/Samples/InGameHints/InGameHintsActions.cs +++ b/Assets/Samples/InGameHints/InGameHintsActions.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was auto-generated by com.unity.inputsystem:InputActionCodeGenerator -// version 1.11.3 +// version 1.12.0 // from Assets/Samples/InGameHints/InGameHintsActions.inputactions // // Changes to this file may cause incorrect behavior and will be lost if diff --git a/Assets/Samples/SimpleDemo/SimpleControls.cs b/Assets/Samples/SimpleDemo/SimpleControls.cs index 7499985262..8d761da00d 100644 --- a/Assets/Samples/SimpleDemo/SimpleControls.cs +++ b/Assets/Samples/SimpleDemo/SimpleControls.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was auto-generated by com.unity.inputsystem:InputActionCodeGenerator -// version 1.11.3 +// version 1.12.0 // from Assets/Samples/SimpleDemo/SimpleControls.inputactions // // Changes to this file may cause incorrect behavior and will be lost if 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/Assets/Tests/InputSystem/InputActionCodeGeneratorActions.cs b/Assets/Tests/InputSystem/InputActionCodeGeneratorActions.cs index e0e7b91261..2b4f542eac 100644 --- a/Assets/Tests/InputSystem/InputActionCodeGeneratorActions.cs +++ b/Assets/Tests/InputSystem/InputActionCodeGeneratorActions.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was auto-generated by com.unity.inputsystem:InputActionCodeGenerator -// version 1.11.3 +// version 1.12.0 // from Assets/Tests/InputSystem/InputActionCodeGeneratorActions.inputactions // // Changes to this file may cause incorrect behavior and will be lost if diff --git a/Packages/com.unity.inputsystem/CHANGELOG.md b/Packages/com.unity.inputsystem/CHANGELOG.md index b0debbc1ef..63f3cc33e4 100644 --- a/Packages/com.unity.inputsystem/CHANGELOG.md +++ b/Packages/com.unity.inputsystem/CHANGELOG.md @@ -27,10 +27,13 @@ however, it has to be formatted properly to pass verification tests. - Fixed an issue where removing the InputSystem package could lead to invalid input handling settings. - Fixed `ArgumentOutOfRangeException` when adding a new Control Scheme with any Device selected. [ISXB-1129](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1129) - Fixed a CS0105 compiler warning due to duplicate using statement in test source code (ISXB-1247). +- 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 favour 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..75d6f333a3 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,72 @@ 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 follows 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 +164,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 +187,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..fcce470071 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,71 @@ 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. + /// for example, Ctrl+Shift+B, the ctrl and shift keys have to be pressed, in any order, 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 and shift keys have to be pressed, in any order, 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 and shift keys have to be pressed, in any order, 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 and shift keys have to be pressed, in any order, 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 follows 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 +178,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 +202,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..15c720145b 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,69 @@ 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, + + /// + /// 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 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 follows 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 +189,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 +205,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..8044a628e4 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Actions/Composites/TwoModifiersComposite.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Actions/Composites/TwoModifiersComposite.cs @@ -90,9 +90,10 @@ 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 + /// This means that binding to, for example, Ctrl+Shift+B, the ctrl and shift keys have to be pressed, in any order, /// before pressing the B key. This is the behavior usually expected with keyboard shortcuts. /// /// However, when binding, for example, Ctrl+Shift+MouseDelta, it should be possible to press ctrl and shift @@ -102,9 +103,66 @@ 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, in any order, + /// 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, + + /// + /// 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, in any order, + /// 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, in any order, + /// 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 follows 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 +198,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 +215,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/AssemblyInfo.cs b/Packages/com.unity.inputsystem/InputSystem/AssemblyInfo.cs index 764e03333b..b15c0de969 100644 --- a/Packages/com.unity.inputsystem/InputSystem/AssemblyInfo.cs +++ b/Packages/com.unity.inputsystem/InputSystem/AssemblyInfo.cs @@ -16,7 +16,7 @@ public static partial class InputSystem // Keep this in sync with "Packages/com.unity.inputsystem/package.json". // NOTE: Unfortunately, System.Version doesn't use semantic versioning so we can't include // "-preview" suffixes here. - internal const string kAssemblyVersion = "1.11.3"; - internal const string kDocUrl = "https://docs.unity3d.com/Packages/com.unity.inputsystem@1.11"; + internal const string kAssemblyVersion = "1.12.0"; + internal const string kDocUrl = "https://docs.unity3d.com/Packages/com.unity.inputsystem@1.12"; } } diff --git a/Packages/com.unity.inputsystem/InputSystem/Devices/Precompiled/FastKeyboard.cs b/Packages/com.unity.inputsystem/InputSystem/Devices/Precompiled/FastKeyboard.cs index a88bd0784b..8f7b888534 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Devices/Precompiled/FastKeyboard.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Devices/Precompiled/FastKeyboard.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was auto-generated by com.unity.inputsystem:InputLayoutCodeGenerator -// version 1.11.3 +// version 1.12.0 // from "Keyboard" layout // // Changes to this file may cause incorrect behavior and will be lost if diff --git a/Packages/com.unity.inputsystem/InputSystem/Devices/Precompiled/FastMouse.cs b/Packages/com.unity.inputsystem/InputSystem/Devices/Precompiled/FastMouse.cs index cde3f67046..98fa06543a 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Devices/Precompiled/FastMouse.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Devices/Precompiled/FastMouse.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was auto-generated by com.unity.inputsystem:InputLayoutCodeGenerator -// version 1.11.3 +// version 1.12.0 // from "Mouse" layout // // Changes to this file may cause incorrect behavior and will be lost if diff --git a/Packages/com.unity.inputsystem/InputSystem/Devices/Precompiled/FastTouchscreen.cs b/Packages/com.unity.inputsystem/InputSystem/Devices/Precompiled/FastTouchscreen.cs index e563c51633..c899aeda76 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Devices/Precompiled/FastTouchscreen.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Devices/Precompiled/FastTouchscreen.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was auto-generated by com.unity.inputsystem:InputLayoutCodeGenerator -// version 1.11.3 +// version 1.12.0 // from "Touchscreen" layout // // Changes to this file may cause incorrect behavior and will be lost if 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); diff --git a/Packages/com.unity.inputsystem/Tests/TestFixture/AssemblyInfo.cs b/Packages/com.unity.inputsystem/Tests/TestFixture/AssemblyInfo.cs index f8e6d4dd32..3e9571c222 100644 --- a/Packages/com.unity.inputsystem/Tests/TestFixture/AssemblyInfo.cs +++ b/Packages/com.unity.inputsystem/Tests/TestFixture/AssemblyInfo.cs @@ -4,7 +4,7 @@ // Keep this in sync with "Packages/com.unity.inputsystem/package.json". // NOTE: Unfortunately, System.Version doesn't use semantic versioning so we can't include // "-preview" suffixes here. -[assembly: AssemblyVersion("1.11.3")] +[assembly: AssemblyVersion("1.12.0")] [assembly: InternalsVisibleTo("Unity.InputSystem.Tests.Editor")] [assembly: InternalsVisibleTo("Unity.InputSystem.Tests")] [assembly: InternalsVisibleTo("Unity.InputSystem.IntegrationTests")] diff --git a/Packages/com.unity.inputsystem/package.json b/Packages/com.unity.inputsystem/package.json index 30751e47ba..988027fcde 100755 --- a/Packages/com.unity.inputsystem/package.json +++ b/Packages/com.unity.inputsystem/package.json @@ -1,7 +1,7 @@ { "name": "com.unity.inputsystem", "displayName": "Input System", - "version": "1.11.3", + "version": "1.12.0", "unity": "2019.4", "description": "A new input system which can be used as a more extensible and customizable alternative to Unity's classic input system in UnityEngine.Input.", "keywords": [