New input system: differentiate action coming from composite and normal

Hello, I have a question about the new input system 1.1.0-prev3

Given two actions ActionOne and ActionTwo

  • ActionOne is a button type with a bidding to Keyboard Y
  • ActionTwo is also a button type with a composite “One Modifier”
    binding to Keyboard Y + modifier Keybaord Shift

I use Unity Events in my code,
I have two unity events:

- public void ActionTwo(CallbackContext context)```

In play mode, when I push the Y key, I get a call to ActionOne method,
but when I push Shift + Y keys, I get a call to both ActionOne and ActionTwo

How can I get only the ActionTwo call for Shift + Y

Am I missing something?
1 Like

That should be easy? anyone?

Of course the goal is not to add a condition in ActionOne asking if ! shift pressed

US based timezone up

Also struggling with this question.

ATM there’s no support in there for having actions “preempt” each other’s input (described here in docs). It’s high on the wishlist of things to add.

I see, thanks for prompt answer. In the meantime I ended up using the script provided by @_s_e_r in this thread (AxisModifierComposite ) but modified it by adding this boolean flag to check for an Inverted state of the modifier key. That is, whether the state of the modifier key NOT being pressed should gate the action in question.

public bool invertModifier;
   
    // This method computes the resulting input value of the composite based
    // on the input from its part bindings but gated by the modifier key.
    public override float ReadValue(ref InputBindingCompositeContext context)
    {
        float baseValue = base.ReadValue(ref context);
       
        if (!invertModifier)
        {
            if (context.ReadValueAsButton(modifier))
                return base.ReadValue(ref context);
            return default;
        }

        if (!context.ReadValueAsButton(modifier))
            return base.ReadValue(ref context);
        return default;
    }