Reading Mouse Delta/Joystick on custom binding

Hi

Trying to look to find a way (if possible) to read a vector2 (from mouse delta for example) in a custom binding. currently have the below but are unabel to read into the vector2 as it does not have a icomparable and is throwing an error, have tried to make a custom vector2 struct with one and use that but getting an error. Looking to make it only track this input if the right mouse is down as a modifier as part of this input (for now ill just have a new binding for this but if anyone knows how to read mouse delta in a custom input binding that would be brilliant)

 [InputControl(layout = "Vector2")]
    public int binding;
   
    [InputControl(layout = "Button")] public int modifier;
   
    static Vector2BindingWithModifierComposite()
    {
        InputSystem.RegisterBindingComposite<Vector2BindingWithModifierComposite>();
    }
    [RuntimeInitializeOnLoadMethod]
    static void Init() {} // Trigger static constructor.

    public override Vector2 ReadValue(ref InputBindingCompositeContext context)
    {
//check modifier is on here
        return context.ReadValue<Vector2>(binding);
    }

Passing an IComparer to InputBindingComposite.ReadValue should solve the problem. There is a predefined Vector2MagnitudeComparer in the input system.

return context.ReadValue<Vector2, Vector2MagnitudeComparer>(binding);

(uses default instance above)

That looks like it did the job

Thanks :slight_smile: