Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Question Controller Family

Discussion in 'Input System' started by xXApOXx, Jan 11, 2023.

  1. xXApOXx

    xXApOXx

    Joined:
    Feb 9, 2015
    Posts:
    76
    Hi,

    I'm new with the input system and I wish to know the type of my controller in order to draw the proper inputs in my UI between Sony, Xbox & Switch controllers.

    I found that an InputDevice contains a description but for my XboxSeries controller, it's mostly empty when playing in editor. Then I checked the layout string variable and it returns "XInputControllerWindows" but an XboxOne controller returns also the same result so I can't distinguish them if I need to.
    I have not tested the behavior in an build but I think the layout would be different with both of those controllers since the layout contains "Windows" in it.

    So I wonder what is the proper way to retrieve a controller family?
     
  2. xXApOXx

    xXApOXx

    Joined:
    Feb 9, 2015
    Posts:
    76
    I found my answer: you just need to use the current device type and iterate through its baseType to know its family.
    Also with XInput activated, it seems impossible to distinguish an XboxOne and an XboxSeriesX gamepad.