Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Mutually exclusive actions, or 'negating' composite modifiers?

Discussion in 'Input System' started by vecima, Apr 6, 2020.

  1. vecima

    vecima

    Joined:
    Jun 6, 2017
    Posts:
    16
    I'm trying to make UI tab navigation happen by creating "navigate next" and "navigate previous" actions.

    This is how I would (ideally) like them bound:
    UI (The action map)
    - NavigateNext (an Action)
    -- Right Shoulder [Gamepad]
    -- Tab [Keyboard]
    - NavigatePrevious (another Action)
    -- Left Shoulder [Gamepad]
    -- Button With One Modifier
    --- Modifier: Shift [Keyboard]
    --- Button: Tab [Keybaord]

    The gamepad portion of this works fine. The problem is that when I press Shift + Tab, both of these actions trigger. I understand why this is happening, as I am also pressing Tab, however this makes the desired result tricky to implement.

    I do have a manager class that defines methods like:
    /* NAVIGATE NEXT */
    public bool GetNavigateNext()
    {
    return this.navigateNextAction.triggered && !this.navigatePreviousAction.triggered;
    }

    /* NAVIGATE PREVIOUS */
    public bool GetNavigatePrevious()
    {
    return this.navigatePreviousAction.triggered;
    }

    This is not optimal, and only works when I use these calls - in any other place where I might map actions using an InputActionReference I would need to add similar logic. I did attempt to configure NavigateNext as a Button With One Modifier and on the Modifier (Shift) apply an "Invert" processor, but that did not work. It does work if I set it up so that NavigateNext is Ctrl+Tab and NavigatePrevoius is Shift+Tab, but this is not the desired outcome.

    Is there a way to map my NavigateNext action such that the Shift key must not be pressed in order for it to trigger? In other words "don't trigger if shift is held"? Or is there some other way to define my NavigateNext and NavigatePrevious actions as mutually exclusive?
     
  2. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Actions are currently not able to "pre-empt" each other's input. This is high up on the list for after 1.0 and probably one of the first things to get worked on. This will make it possible to deal with setups involving shortcut modifiers but also deal with the common problem of having the UI consuming input from actions preventing it from triggering input on game actions, too.
     
  3. Stephanommg

    Stephanommg

    Joined:
    Aug 18, 2014
    Posts:
    88
    Is this implemented now?
     
  4. Stephanommg

    Stephanommg

    Joined:
    Aug 18, 2014
    Posts:
    88
    For anyone interested, it is already implemented and is available in Project Settings -> Input System Package -> Enable Input Consumption