Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved Determine gamepad type (xbox/playstation)

Discussion in 'Input System' started by Twin-Stick, Jan 21, 2021.

  1. Twin-Stick

    Twin-Stick

    Joined:
    Mar 9, 2016
    Posts:
    111
    Is there a way I can determine what type of controller the player is using within the gamepad class (Gamepad.current).

    If I'd like to differentiate between someone using a playstation controller and xbox controller on PC (win/mac/lin) how can I do this? Would I need to create a seperate control scheme for each device rather than the generic 'gamepad' device?

    I notice there is a 'description' text property - I'm happy to compare against this, however where might I find the different device descriptions failing getting each device myself and outputting the values? My xbox one controller outputs "Microsoft Corp. DCP-J4215N (SDL)" (I am running linux) - would this be different in windows and mac?
     
  2. Twin-Stick

    Twin-Stick

    Joined:
    Mar 9, 2016
    Posts:
    111
    Unity had responded to me via discord, so if anyone else was curious - here is the response...

    "There are text strings, but please do not use them. I assume this is a question wrt PC, on PC USB HID vendor strings are very loose: here is how we match dual shocks https://github.com/Unity-Technologi...Plugins/DualShock/DualShockSupport.cs#L30-L48
    So if they wanted to check for string that would need to check for Sony Entertainment. and Wireless controller. which is will be very error prone.
    I would recommend using Gamepad.current is DualShockGamepad and leave heavy lifting of string/id matching to our code."