Search Unity

Add a "ButtonControl" to an existing "AxisControl" at runtime?

Discussion in 'Input System' started by Domarius, May 8, 2020.

  1. Domarius

    Domarius

    Joined:
    Jan 5, 2013
    Posts:
    103
    I'm making an interface that allows the user to remap their controls. (Necessary in Windows due to anthing but an Xbox controller just being reported as a "Joystick") I want to let the user bind a thumbstick as dpad buttons.

    I can use ButtonControl for everything because Joystick comes with a "stick" device already detected, it provides ButtonControl objects for left, right, up and down, which is great.

    But the other thumbstick will show up as "rz" and "z" AxisControls, and don't come with ButtonControl's attached to them. I would like to make some ButtonControls for them, 2 each, for their positive and negative directions, like the stick device already does automatically for the first 2 axiis.

    Naturally I can't do this with a HID Input Report file, this needs to happen during runtime and work with any generic joystick, not a fixed layout for a specific device. I can always make my own generic "Button" class for the AxisControl but that seems like doubling up work already done by ButtonControl.
     
    Last edited: May 9, 2020