Search Unity

Xbox controller extends generic Gamepad

Discussion in 'Input System' started by viatech, Dec 13, 2019.

  1. viatech

    viatech

    Joined:
    Dec 6, 2017
    Posts:
    56
    I have a few input actions bound to the generic gamepad button north, south east and west. Using an xbox gamepad on a PC these actions are fired by the A,B,X,Y buttons. All good and as expected. The xbox controller shows up as a device which Extends: Gamepad. How do I define a custom device which extends Gamepad? I’ve created a custom device in c# but the documentation talks about Json templates and I can’t find any of those. Also the InputSystem.RegisterTemplate method doesn’t exist?

    Could someone point me in the right direction please.
     
  2. viatech

    viatech

    Joined:
    Dec 6, 2017
    Posts:
    56
    I'll answer my own post.

    The docs don't seem to quite match the current API and as this is a work in progress that can be excused. I derived the custom device from the Gamepad class rather than the InputDevice class and added my own state class. The custom device then shows up as "Extends: Gamepad". Now any actions bound to the generic gamepad device are fired when I update the state of the custom device.