Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question 'Shift' displays as 'Left Shift' on Gamepad Scheme

Discussion in 'Input System' started by CoderDev8758, Feb 11, 2024.

  1. CoderDev8758

    CoderDev8758

    Joined:
    Dec 14, 2022
    Posts:
    1
    I am using the new unity input system package, which contains a method for finding the display name of an action. When I use a keyboard scheme the shift, control, alt, or left meta key all display differently on keyboard versus gamepad. "Shift" on keyboard displays as "Left Shift" on gamepad, "Ctrl" as "Left Control" on gamepad, "Alt" as "Left Alt" on gamepad, etc, etc. I am using the rebinding template from the input system, and heres the method:

    Code (CSharp):
    1. public void UpdateBindingDisplay()
    2.   {
    3.     var displayString = string.Empty;
    4.     var deviceLayoutName = default(string);
    5.     var controlPath = default(string);
    6.  
    7.     var action = m_Action?.action;
    8.  
    9.     if (action != null)
    10.     {
    11.         var bindingIndex = action.bindings.IndexOf(x => x.id.ToString() == m_BindingId);
    12.         if (bindingIndex != -1)
    13.             displayString = action.GetBindingDisplayString(bindingIndex, InputBinding.DisplayStringOptions.DontUseShortDisplayNames);
    14.     }
    15.  
    16.     if (m_BindingText != null)
    17.                 m_BindingText.text = displayString;
    18.  
    19.     m_UpdateBindingUIEvent?.Invoke(this, displayString, deviceLayoutName, controlPath);
    20. }
    21.  
    22.