Skip to content

FIX: some actions not being triggered when other duplicate control bindings exist (ISXB-254).#1600

Merged
jamesmcgill merged 11 commits intodevelopfrom
ISXB-254_disable_shortcuts_by_default
Nov 1, 2022
Merged

FIX: some actions not being triggered when other duplicate control bindings exist (ISXB-254).#1600
jamesmcgill merged 11 commits intodevelopfrom
ISXB-254_disable_shortcuts_by_default

Conversation

@jamesmcgill
Copy link
Copy Markdown
Collaborator

@jamesmcgill jamesmcgill commented Oct 24, 2022

Description

In v1.4 we improved shortcut support by having actions consuming their inputs. This meant, for example, that SHIFT+B would trigger it's action but any action bound to the 'B' key would be blocked.
However we have been receiving many reports that users are not getting the expected behaviour in their projects that may have unknowingly (or knowingly) multiple actions bound to the same controls.
E.g. the issues with WASD keys, with the UIInputModule Navigate action conflicting with Player controls, if both action maps were enabled and many other similar cases that were reported.

This PR restores the previous behaviour by default and makes the the new event consumption behaviour (shortcut support) opt-in now and accessible as a toggle via project settings.

Changes made

Added a toggle in project settings with the default value false.
Modified the SetInternalFeatureFlag and IsFeatureEnabled to use this new value when queried for kDisableShortcutSupport. It was deliberately done this way to preserve the current (non-public) API, as users are aware of it now. Rather than doing the natural thing of changing kDisableShortcutSupport to kEnableShortcutSupport or removing it entirely, which would have been cleaner.

Notes

InputSystem.settings.SetInternalFeatureFlag("DISABLE_SHORTCUT_SUPPORT", true); is still available here as some users are aware of it now, but a deprecation warning is being emitted.
The setting a private field, but it does need to be saved in the asset.
I am preparing a v1.5 version of this with that removed and cleans up the settings code with proper api.

Checklist

Before review:

  • Changelog entry added.
    • Explains the change in Changed, Fixed, Added sections.
    • For API change contains an example snippet and/or migration example.
    • FogBugz ticket attached, example ([case %number%](https://issuetracker.unity3d.com/issues/...)).
    • FogBugz is marked as "Resolved" with next release version correctly set.
  • Tests added/changed, if applicable.
    • Functional tests Area_CanDoX, Area_CanDoX_EvenIfYIsTheCase, Area_WhenIDoX_AndYHappens_ThisIsTheResult.
    • Performance tests.
    • Integration tests.
  • Docs for new/changed API's.
    • Xmldoc cross references are set correctly.
    • Added explanation how the API works.
    • Usage code examples added.
    • The manual is updated, if needed.

During merge:

  • Commit message for squash-merge is prefixed with one of the list:
    • NEW: ___.
    • FIX: ___.
    • DOCS: ___.
    • CHANGE: ___.
    • RELEASE: 1.1.0-preview.3.

Comment thread Packages/com.unity.inputsystem/CHANGELOG.md Outdated
@jamesmcgill jamesmcgill changed the title CHANGE: shortcut support disabled by default FIX: some actions not being triggered when other duplicate control bindings exist. Oct 25, 2022
@jamesmcgill jamesmcgill changed the title FIX: some actions not being triggered when other duplicate control bindings exist. FIX: some actions not being triggered when other duplicate control bindings exist (ISXB-254). Oct 25, 2022
@andrew-oc
Copy link
Copy Markdown
Contributor

My take on this is that if we're making it opt-in now, we should make it part of the input system settings and add a checkbox to the project settings dialogue to allow switching it on globally. That also gives us a chance to put a little warning message in there about the repercussions should you have multiple action maps enabled at the same time with multiple actions using the same bindings.

If we don't go this way, then I'd suggest changing the wording in the changelog from "Reverted" to "Changed to opt-in" or similar. When I see reverted I think the behaviour has been removed entirely.

Copy link
Copy Markdown
Contributor

@jimon jimon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. input settings logic feels a bit error prone though

@jamesmcgill jamesmcgill requested review from ekcoh and jimon October 28, 2022 13:35

// REMOVE: this is a temporary crutch to disable shortcut support by default but while also preserving the
// existing flag name, as users are aware of that now.
if (featureName == InputFeatureNames.kDisableShortcutSupport)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would happen if we simply removed the internal feature flag? If users are using it, it's to turn off the feature, but now it's opt in, so if we remove it, their code will have the same behaviour.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true. I was thinking that there would be no programmatic way to enable/disable this until we add the public property. But your right, only users who were disabling it before should know about the existence of this and it won't hurt them that it does nothing now.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to leave it in for v1.4.4. There are some tests for shortcuts that I need to enable this programmatically somehow.

Comment on lines +153 to +157
EditorGUILayout.HelpBox("Please note that enabling Improved Shortcut Support will cause actions to consume and block any other actions which are enabled and sharing the same controls. "
+ "E.g. when pressing the 'Shift+B' keys, the associated action would trigger but any action bound to just the 'B' key would be prevented from triggering at the same time, which would be the expected result in this example. "
+ "However, in other cases this might not give the desired result. E.g. if the 'W', 'A', 'S' and 'D' keys are bound to different actions which are all enabled at the same time, then only one of those actions will trigger. "
+ "Therefore if you enable this feature, be sure to remove any of these duplicate control bindings so that controls are only ever bound to a single action. Alternatively, you can disable actions or action maps at runtime to remove these conflicts."
, MessageType.None);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions:

  • "Please note that enabling Improved Shortcut Support will cause actions with composite bindings to consume input and block..."
  • Could point out that blocking occurs even across action maps. I don't think users are really often aware of where the actions live and just enable entire assets.
  • I feel we can leave out the repeated instruction about Shift-B and B since that is more about the features intended purpose and is already in the tooltip.
  • Would this benefit from a more detailed worked example describing two action maps, one for UI and one for Gameplay, where both use the up, down, left, and right keys (pretty common one on the forums) and maybe some other action that will be lower priority and only uses left and right keys for example.
  • It would help users to know how priority is decided between actions. Should we include some instructions on that, i.e. number of composite parts determines priority but actions with the same number of parts are non-deterministic?
  • Is the advice really to remove duplicate controls? I like the second bit about disabling actions but maybe we could expand it to something like "Since event consumption only occurs for enabled actions, you can resolve most unexpected issues by ensuring that only those action maps that are relevant to your game's current context are enabled. Enable or disable actions as your game or application moves between different contexts."

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried to reword this incorporating your suggestions

@jamesmcgill jamesmcgill requested a review from andrew-oc October 31, 2022 12:21
@jamesmcgill jamesmcgill merged commit aff7a19 into develop Nov 1, 2022
@jamesmcgill jamesmcgill deleted the ISXB-254_disable_shortcuts_by_default branch November 1, 2022 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants