Search Unity

Find control scheme that matches temporary device

Discussion in 'Input System' started by Hertzole, Aug 31, 2022.

  1. Hertzole

    Hertzole

    Joined:
    Jul 27, 2013
    Posts:
    422
    Hello

    I'm doing some kind of glyph system and want to force my system to show glyphs for a specific input device type, regardless of whether it exists or not. How would I go about this?

    I have my method like this
    Code (CSharp):
    1. public string ReplacePrompts(string text, InputDevice device, InputActionAsset actions)
    2. {
    3.   string controlScheme = null;
    4.   ReadOnlyArray<InputControlScheme> controlSchemes = actions.controlSchemes;
    5.   for (int i = 0; i < controlSchemes.Count; i++)
    6.   {
    7.      if (controlSchemes[i].SupportsDevice(device))
    8.      {
    9.        controlScheme = controlSchemes[i].name;
    10.        break;
    11.      }
    12.   }
    13.  
    14.   // more code
    15. }
    and I usually use it like
    Code (CSharp):
    1. label.text = ReplacePrompts(label.text, playerInput.devices[0]);
    But to force it to use a specific input device, let's say a DualShock3 device, I'd ideally like to do
    Code (CSharp):
    1. label.text = ReplacePrompts(label.text, new DualShock3HID());
    But that does not work because it can associate this new gamepad with the gamepad control scheme.

    How should I go about creating a device I'd like to ONLY use for matching a control scheme?

    Thanks