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. Dismiss Notice

Rewired - Advanced Input for Unity

Discussion in 'Assets and Asset Store' started by guavaman, Sep 25, 2014.

  1. notagame

    notagame

    Joined:
    Sep 17, 2017
    Posts:
    17
    Good nose :). That's exactly what I did haha and I forgot about it until you mentioned it. Yeah I see the problem now. Thanks and indeed it's not the fault of Rewired this is just ambiguous so I need to think about the mapping again.
     
  2. HofiOne

    HofiOne

    Joined:
    Apr 19, 2021
    Posts:
    66
    I understand from your explanation that by design there is no option to pause processing input in Rewired Input Manager but as you can see there are multiple requests to support it.

    There are cases when much more easier to have a centralized control point than adding code that tries to check at multiple points, multiple different conditions to achieve one single goal.

    Having this option could lead to much clearer, simplified code in many cases.

    Could you please add enabling/disabling input processing as an option to Rewired Input Manager?
     
  3. Zante

    Zante

    Joined:
    Mar 29, 2008
    Posts:
    429
    Getting a weird error in Unity 2020.3.24f1

    Upon creating a prefab from a Rewired Input Manager in my scene it keeps deleting any new additions by way of actions and joystick maps. Upon reloading Unity, the changes previously deleted are visible.

    The full error appears as:
    Code (CSharp):
    1. Rewired: Error setting serialized property! Variable path: "_userData.joystickMaps.Array.data[0].actionElementMaps.Array.data[5]._elementIdentifierId" not found in object!
    2. UnityEngine.Logger:Log (string,object)
    3. Rewired.Logger:LogNow (object,bool)
    4. Rewired.Logger:Log (object,bool)
    5. Rewired.Logger:Log (object)
    6. VuNYBaKmXfZTeYozIwtYcnnxGEfc:WoOtMBkdBWjndKbxqlZsLIGDnyn (UnityEngine.Object,string,object)
    7. wSQDkUdjXrrxhEFGvgOojLIqlAZ:ZGNzrmOvFsenmnuQiCrSwkUWsgE (UnityEngine.Object,int,string,QWszMcHxaUgXPNOhAmHEzMKAEycd)
    8. Rewired.Editor.InputEditor:IQiYfiXdiOFurevkrLuEfTzbNTyE (ZNFOgkZDjrQvjlFUvnhCaoTZeTM<int>,single)
    9. Rewired.Editor.InputEditor:hCKWdVaRFqqFvpflaoqeJlaJcW (bool)
    10. Rewired.Editor.InputEditor:OnGUI ()
    11. UnityEditor.EditorGUI/PopupCallbackInfo:SetEnumValueDelegate (object,string[],int)
    Unpacking the prefab and editing it in scene seems to solve the problem but it isn't ideal. ;]
     
  4. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,500
    See the previous page on this forum thread:
    https://forum.unity.com/threads/rewired-advanced-input-for-unity.270693/page-155#post-7681810
    https://forum.unity.com/threads/rewired-advanced-input-for-unity.270693/page-155#post-7682464
    https://forum.unity.com/threads/rewired-advanced-input-for-unity.270693/page-155#post-7682620

    Known issue with new Unity releases. I haven't gotten the update with the workaround released yet. Workaround is to explicitly Open the prefab before editing in the prefab inspector.
     
  5. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,500
    I've had 2-3 people ask about this in all the years Rewired has been out. I don't think there is significant demand for this feature. Additionally, I do not consider this to be good design. I know of no other input API I've ever worked with (and that's many of them covering quite a few platforms) that gives the user the ability to globally toggle whether input works or not.

    Again, not the recommended way to prevent your scripts from processing input when they shouldn't be, but implementing your own code to do this is trivial:

    Code (csharp):
    1. public class InputToggle : MonoBehaviour {
    2.  
    3.     private static bool _inputEnabled = true;
    4.  
    5.     public void Awake() {
    6.         ReInput.ControllerConnectedEvent += x => x.controller.enabled = _inputEnabled;
    7.     }
    8.  
    9.     public static void SetInputEnabled(bool state) {
    10.         _inputEnabled = state;
    11.         foreach (var controller in ReInput.controllers.Controllers) {
    12.             controller.enabled = state;
    13.         }
    14.     }
    15. }
     
    Last edited: Dec 14, 2021
  6. idibil

    idibil

    Joined:
    Oct 10, 2015
    Posts:
    24
    Hi guys,

    For those who wish to localize keycodes using IL2 or other tools, you can do easily using LanguageDataBase.cs (Controller Rewired).

    For example:

    Code (CSharp):
    1.         public override string GetElementIdentifierName(Controller controller, int elementIdentifierId, AxisRange axisRange) {
    2.             if(controller == null) throw new ArgumentNullException("controller");
    3.             ControllerElementIdentifier eid = controller.GetElementIdentifierById(elementIdentifierId);
    4.             if(eid == null) throw new ArgumentException("Invalid element identifier id: " + elementIdentifierId);
    5.             Controller.Element element = controller.GetElementById(elementIdentifierId);
    6.             switch(element.type) {
    7.                 case ControllerElementType.Axis:
    8.                     keyNameString = "";
    9.                     if (eid.name == "Mouse Vertical")
    10.                     {
    11.                         keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyMouseVertical;
    12.                         return keyNameString;
    13.                     }
    14.                     else if (eid.name == "Mouse Horizontal")
    15.                     {
    16.                         keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyMouseHorizontal;
    17.                         return keyNameString;
    18.                     }
    19.                     else if (eid.name == "Mouse Wheel")
    20.                     {
    21.                         keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyMouseWheel;
    22.                         return keyNameString;
    23.                     }
    24.                     else if (eid.GetDisplayName(element.type, axisRange) == "Left Stick X")
    25.                     {
    26.                         keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyLeftStickX;
    27.                         return keyNameString;
    28.                         //  return eid.GetDisplayName(keyNameString, axisRange);
    29.                     }
    30.                     else if (eid.GetDisplayName(element.type, axisRange) == "Left Stick Y")
    31.                     {
    32.                         keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyLeftStickY;
    33.                         return keyNameString;
    34.                         //  return eid.GetDisplayName(keyNameString, axisRange);
    35.                     }
    36.                     else if (eid.GetDisplayName(element.type, axisRange) == "Right Stick X")
    37.                     {
    38.                         keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyRightStickX;
    39.                         return keyNameString;
    40.                         //  return eid.GetDisplayName(keyNameString, axisRange);
    41.                     }
    42.                     else if (eid.GetDisplayName(element.type, axisRange) == "Right Stick Y")
    43.                     {
    44.                         keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyRightStickY;
    45.                         return keyNameString;
    46.                         //  return eid.GetDisplayName(keyNameString, axisRange);
    47.                     }
    48.                     else if (eid.name == "Left Trigger")
    49.                     {
    50.                         keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyLeftTrigger;
    51.                         return keyNameString;
    52.                     }
    53.                     else if (eid.name == "Right Trigger")
    54.                     {
    55.                         keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyRightTrigger;
    56.                         return keyNameString;
    57.                     }
    58.                     else
    59.                     {
    60.                         return eid.GetDisplayName(element.type, axisRange);
    61.                     }
    62.                   //  return eid.GetDisplayName(element.type, axisRange);
    63.                 case ControllerElementType.Button:
    64.                     keyNameString = ""; //chief change from here.
    65.                     if (eid.name == "Left Mouse Button")
    66.                     {
    67.                         keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyMouse0;
    68.                     }
    69.                     else if (eid.name == "Right Mouse Button")
    70.                     {
    71.                         keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyMouse1;
    72.                     }
    73.                     else if (eid.name == "Mouse Button 3")
    74.                     {
    75.                         keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyMouse2;
    76.                     }
    77.                     else if (eid.name == "Start")
    78.                     {
    79.                         keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyStart;
    80.                     }
    81.                   /*  else if (eid.name == "Left Trigger")
    82.                     {
    83.                         keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyLeftTrigger;
    84.                     }
    85.                     else if (eid.name == "Right Trigger")
    86.                     {
    87.                         keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyRightTrigger;
    88.                     }*/
    89.                     else if (eid.name == "D-Pad Right")
    90.                     {
    91.                         keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyDPadRight;
    92.                     }
    93.                     else if (eid.name == "D-Pad Left")
    94.                     {
    95.                         keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyDPadLeft;
    96.                     }
    97.                     else if (eid.name == "D-Pad Up")
    98.                     {
    99.                         keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyDPadUp;
    100.                     }
    101.                     else if (eid.name == "D-Pad Down")
    102.                     {
    103.                         keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyDPadDown;
    104.                     }
    105.                     else if (eid.name == "Left Stick Button")
    106.                     {
    107.                         keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyLeftStickButton;
    108.                     }
    109.                     else if (eid.name == "Right Stick Button")
    110.                     {
    111.                         keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyRightStickButton;
    112.                     }
    113.                     else if (eid.name == "Right Shoulder")
    114.                     {
    115.                         keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyRightShoulder;
    116.                     }
    117.                     else if (eid.name == "Left Shoulder")
    118.                     {
    119.                         keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyLeftShoulder;
    120.                     }
    121.                     else if (eid.name == "Back")
    122.                     {
    123.                         keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyBack;
    124.                     }
    125.                     else
    126.                     {
    127.                         keyNameString = eid.name;
    128.                     }
    129.                     return keyNameString;
    130.                    // return eid.name;
    131.                 default:
    132.                     return eid.name;
    133.             }
    134.         }
    135.         public override string GetElementIdentifierName(KeyCode keyCode, ModifierKeyFlags modifierKeyFlags) {
    136.             if(modifierKeyFlags != ModifierKeyFlags.None)
    137.             {
    138.                     return string.Format(
    139.                         "{0}{1}{2}",
    140.                         ModifierKeyFlagsToString(modifierKeyFlags),
    141.                         _modifierKeys.separator,
    142.                         Keyboard.GetKeyName(keyCode));
    143.             } else {            
    144.                 keyNameString = "";
    145.                 if (Keyboard.GetKeyName(keyCode) == "Backspace")
    146.                 {
    147.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyBackspace;
    148.                 }
    149.                 else if (Keyboard.GetKeyName(keyCode) == "Delete")
    150.                 {
    151.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyDelete;
    152.                 }
    153.                 else if (Keyboard.GetKeyName(keyCode) == "Tab")
    154.                 {
    155.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyTab;
    156.                 }
    157.                 else if (Keyboard.GetKeyName(keyCode) == "Return")
    158.                 {
    159.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyReturn;
    160.                 }
    161.                 else if (Keyboard.GetKeyName(keyCode) == "Pause")
    162.                 {
    163.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyPause;
    164.                 }
    165.                 else if (Keyboard.GetKeyName(keyCode) == "Escape")
    166.                 {
    167.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyEscape;
    168.                 }
    169.                 else if (Keyboard.GetKeyName(keyCode) == "Space")
    170.                 {
    171.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeySpace;
    172.                 }
    173.                 else if (Keyboard.GetKeyName(keyCode) == "Up Arrow")
    174.                 {
    175.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyUpArrow;
    176.                 }
    177.                 else if (Keyboard.GetKeyName(keyCode) == "Down Arrow")
    178.                 {
    179.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyDownArrow;
    180.                 }
    181.                 else if (Keyboard.GetKeyName(keyCode) == "Right Arrow")
    182.                 {
    183.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyRightArrow;
    184.                 }
    185.                 else if (Keyboard.GetKeyName(keyCode) == "Left Arrow")
    186.                 {
    187.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyLeftArrow;
    188.                 }
    189.                 else if (Keyboard.GetKeyName(keyCode) == "A")
    190.                 {
    191.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyA;
    192.                 }
    193.                 else if (Keyboard.GetKeyName(keyCode) == "B")
    194.                 {
    195.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyB;
    196.                 }
    197.                 else if (Keyboard.GetKeyName(keyCode) == "C")
    198.                 {
    199.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyC;
    200.                 }
    201.                 else if (Keyboard.GetKeyName(keyCode) == "D")
    202.                 {
    203.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyD;
    204.                 }
    205.                 else if (Keyboard.GetKeyName(keyCode) == "E")
    206.                 {
    207.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyE;
    208.                 }
    209.                 else if (Keyboard.GetKeyName(keyCode) == "F")
    210.                 {
    211.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyF;
    212.                 }
    213.                 else if (Keyboard.GetKeyName(keyCode) == "G")
    214.                 {
    215.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyG;
    216.                 }
    217.                 else if (Keyboard.GetKeyName(keyCode) == "H")
    218.                 {
    219.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyH;
    220.                 }
    221.                 else if (Keyboard.GetKeyName(keyCode) == "I")
    222.                 {
    223.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyI;
    224.                 }
    225.                 else if (Keyboard.GetKeyName(keyCode) == "J")
    226.                 {
    227.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyJ;
    228.                 }
    229.                 else if (Keyboard.GetKeyName(keyCode) == "K")
    230.                 {
    231.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyK;
    232.                 }
    233.                 else if (Keyboard.GetKeyName(keyCode) == "L")
    234.                 {
    235.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyL;
    236.                 }
    237.                 else if (Keyboard.GetKeyName(keyCode) == "M")
    238.                 {
    239.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyM;
    240.                 }
    241.                 else if (Keyboard.GetKeyName(keyCode) == "N")
    242.                 {
    243.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyN;
    244.                 }
    245.                 else if (Keyboard.GetKeyName(keyCode) == "O")
    246.                 {
    247.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyO;
    248.                 }
    249.                 else if (Keyboard.GetKeyName(keyCode) == "P")
    250.                 {
    251.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyP;
    252.                 }
    253.                 else if (Keyboard.GetKeyName(keyCode) == "Q")
    254.                 {
    255.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyQ;
    256.                 }
    257.                 else if (Keyboard.GetKeyName(keyCode) == "R")
    258.                 {
    259.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyR;
    260.                 }
    261.                 else if (Keyboard.GetKeyName(keyCode) == "S")
    262.                 {
    263.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyS;
    264.                 }
    265.                 else if (Keyboard.GetKeyName(keyCode) == "T")
    266.                 {
    267.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyT;
    268.                 }
    269.                 else if (Keyboard.GetKeyName(keyCode) == "U")
    270.                 {
    271.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyU;
    272.                 }
    273.                 else if (Keyboard.GetKeyName(keyCode) == "V")
    274.                 {
    275.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyV;
    276.                 }
    277.                 else if (Keyboard.GetKeyName(keyCode) == "W")
    278.                 {
    279.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyW;
    280.                 }
    281.                 else if (Keyboard.GetKeyName(keyCode) == "X")
    282.                 {
    283.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyX;
    284.                 }
    285.                 else if (Keyboard.GetKeyName(keyCode) == "Y")
    286.                 {
    287.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyY;
    288.                 }
    289.                 else if (Keyboard.GetKeyName(keyCode) == "Z")
    290.                 {
    291.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyZ;
    292.                 }
    293.                 else if (Keyboard.GetKeyName(keyCode) == "RightShift")
    294.                 {
    295.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyRightShift;
    296.                 }
    297.                 else if (Keyboard.GetKeyName(keyCode) == "Right Shift")
    298.                 {
    299.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyRightShift;
    300.                 }
    301.                 else if (Keyboard.GetKeyName(keyCode) == "LeftShift")
    302.                 {
    303.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyLeftShift;
    304.                 }
    305.                 else if (Keyboard.GetKeyName(keyCode) == "Left Shift")
    306.                 {
    307.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyLeftShift;
    308.                 }
    309.                 else if (Keyboard.GetKeyName(keyCode) == "Right Control")
    310.                 {
    311.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyRightControl;
    312.                 }
    313.                 else if (Keyboard.GetKeyName(keyCode) == "Left Control")
    314.                 {
    315.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyLeftControl;
    316.                 }
    317.                 else if (Keyboard.GetKeyName(keyCode) == "Right Alt")
    318.                 {
    319.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyRightAlt;
    320.                 }
    321.                 else if (Keyboard.GetKeyName(keyCode) == "Left Alt")
    322.                 {
    323.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyLeftAlt;
    324.                 }
    325.                 else if (Keyboard.GetKeyName(keyCode) == "Menu")
    326.                 {
    327.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyMenu;
    328.                 }
    329.                 else if (Keyboard.GetKeyName(keyCode) == "ESC")
    330.                 {
    331.                     keyNameString = I2.Loc.ScriptLocalization.INPUTKEYS.KeyESC;
    332.                 }
    333.                 else
    334.                 {
    335.                     keyNameString = Keyboard.GetKeyName(keyCode);
    336.                 }
    337.                 return keyNameString;
    338.                 //return Keyboard.GetKeyName(keyCode);
    339.             }
    340.         }
     
  7. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,500
    For those wondering, this file is part of the optional Control Mapper install and is for localizing names displayed by Control Mapper, not generally. How to use this system is described here:
    https://guavaman.com/projects/rewired/docs/ControlMapper.html#language
     
    Last edited: Dec 14, 2021
  8. HofiOne

    HofiOne

    Joined:
    Apr 19, 2021
    Posts:
    66
    first time i searched for this topic it led to me into this long thread and only on that single page of it where the search landed i saw 2 other requests, i did not go through all the 156 pages, i just assumed that it could be a common request if i immediately saw 2 similar on one page out of 156

    also it was not totally clear if it's enough only to disable the controllers or not (i guess that part of the conversation i've read is nowadays a bit outdated)

    anyway, thanks for this example, it will do the trick perfectly!
     
  9. idibil

    idibil

    Joined:
    Oct 10, 2015
    Posts:
    24
    Thanks for the clarification, guavaman.
    From localization keycodes on other script you can use something as:

    Code (CSharp):
    1.                         if (Rewiredplayer.controllers.maps.GetFirstElementMapWithAction(ControllerType.Keyboard, "Forward", skipDisabledMaps) != null)
    2.                             tempKey = Rewiredplayer.controllers.maps.GetFirstElementMapWithAction(ControllerType.Keyboard, "Forward", skipDisabledMaps).elementIdentifierName;
    3.  
    4.  
    5.             tempKeyString = GetKeyCodeName(tempKey);
    6.  
    Code (CSharp):
    1.     private string GetKeyCodeName(string TempKeyKeyCode)
    2.     {
    3.         if (TempKeyKeyCode.ToString() == "Mouse Vertical")
    4.         {
    5.             TempKeyStringText = I2.Loc.ScriptLocalization.INPUTKEYS.KeyMouseVertical;
    6.         }
    7.         else if (TempKeyKeyCode.ToString() == "A")
    8.         {
    9.             TempKeyStringText = I2.Loc.ScriptLocalization.INPUTKEYS.KeyA;
    10.         }
    11.         else if (TempKeyKeyCode.ToString() == "B")
    12.         {
    13.             TempKeyStringText = I2.Loc.ScriptLocalization.INPUTKEYS.KeyB;
    14.         }
    15. ....
    16.  
    17.  
     
  10. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,739
    Hi there

    I'm having an issue with the keyboard settings for Mac vs Window.
    I need on mac that the LeftCommand key works as my fire button. That's fine. I add it.
    But then, when I go to windows, it seems that the "alt gr" key, gets detected as a LeftCommand. So when I press the Alt Gr, it begins firing and that key is actually used for the keyboard to type things like the @ in many languages. (you must alt gr+2 key).

    So the question is, how can we disable the LeftCommand setting but only on Windows? that key doesn't exist on window and it should consider Alt Gr to be it.

    I've tried to do this when on Windows, but it didn't work
    IEnumerable<ControllerMap> maps = player.controllers.maps.GetMapsInCategory(ControllerType.Keyboard, 0, 0);
    foreach(ControllerMap m in maps)
    {
    m.DeleteElementMap(33);
    }

    33 is my Element ids for the LeftCommand fire on the keyboard.

    Still, I can't get it to work. I don't even know if that's the right way since it seems so convoluted.
     
    Last edited: Dec 15, 2021
  11. Innovine

    Innovine

    Joined:
    Aug 6, 2017
    Posts:
    522
    How do i hide this: Screenshot 2021-12-15 214234.png
    without hiding other symbols?
     
  12. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,500
    Use different Layouts for Windows and Mac:
    https://guavaman.com/projects/rewired/docs/Layouts.html
    https://guavaman.com/projects/rewired/docs/LayoutManager.html

    The behavior of what keys are returned when pressed on Windows using Rewired's native keyboard handling is identical to the keys returned by UnityEngine.Input. On MacOS, the actual source of input is UnityEngine.Input for keyboards.
     
  13. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,500
    I can't even tell what that picture even is. It's a large empty brown background with "Rewired Input Manager" highlighted.
     
  14. Innovine

    Innovine

    Joined:
    Aug 6, 2017
    Posts:
    522
    It's a scene with rewired in it. This yellow thing is some kind of label. Its drawn at the transform position of the gameObject with rewired on it. It disappears when i toggle off this button:
    Screenshot 2021-12-15 215815.png
    However, then all my other things disappear too. I have individually toggled off everything in the dropdown list under that icon, and this rewired label remains.
    If I disable the gameObject, it disappears. If i disable the Input Manager monobehavior, it will still be there. I can click on it in the scene view, and then the rewired game object will be selected.
    Hope that helps in identifying what it is.
     
    Last edited: Dec 15, 2021
  15. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,739
    Ok, so I created 2 layouts. The default one without Mac keys. And another one that I called "Mac" with the mac keys.
    Now how do I switch among them when it's running on mac or pc?

    From what I can see, both are executed right now. And the layoutmanager rules and that doesn't seem to help me from the example.

    I tried to find both layouts, controller.layoutId returns only one id, i don't find how I can enable or disable depending on the platform.

    Then I tried using this:
    // Disable all Rule Sets
    foreach (var ruleSet in player.controllers.maps.layoutManager.ruleSets)
    {
    Debug.LogError("disabled rules:" + ruleSet.Count);
    foreach (ControllerMapLayoutManager.Rule r in ruleSet)
    {
    Debug.LogError("rule:" + r.layoutName);
    }
    ruleSet.enabled = false;
    }
    player.controllers.maps.layoutManager.Apply();


    I assigned both rulesset to the Player.
    and I get this printed out for each iteration.

    disabled rules:1
    rule:Default

    disabled rules:1
    rule:Mac

    Seems ok. It's printing both layouts, the Default one I use for windows and the Mac layout for the mac keys.

    But my expections were that no layout should be active now, since the rules I set to enabled=false, but I still get both layouts working, windows and mac at the same time.
     
    Last edited: Dec 15, 2021
  16. HofiOne

    HofiOne

    Joined:
    Apr 19, 2021
    Posts:
    66
    Hi,

    I'm trying to use the Apple TV Remote, set up the Apple TV Remote (2015) Joystick Map that works nicely except one case.

    I assigned the element called "Menu" to my Cancel action and though it works (mostly) but at the same time it triggers a Home button event too, so the app goes background after my Cancel action triggered (it is bound the the back navigation on my UI)

    I'd like to have the Menu button work like in any other default tvOS application, pressing it should go just back one level and only pressing the Home button should exit from the app (putting it background)

    How can I fix this?
     
  17. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,500
    I didn't write that. Unity did. There is zero code whatsoever in Rewired related to labels and I did not set up any labels on any Rewired objects.

    https://answers.unity.com/questions/805785/label-in-scene-window.html

     
  18. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,500
    Special Apple TV functionality is not handled by Rewired. Rewired does not implement any sort of native libraries on iOS or tvOS as stated here, therefore it cannot change anything in the Apple API:
    https://guavaman.com/projects/rewired/docs/Overview.html#tested-platforms

    Unity provides the API wrappers to modify system behavior:
    https://docs.unity3d.com/Manual/tvos-supporting-input-devices.html

    Quote:
    You can control the Apple TV Remote operational modes via a dedicated API as follows: * UnityEngine.tvOS.Remote.allowExitToHome * UnityEngine.tvOS.Remote.allowRemoteRotation * UnityEngine.tvOS.Remote.reportAbsoluteDpadValues * UnityEngine.tvOS.Remote.touchesEnabled

    Note: When UnityEngine.tvOS.Remote.allowExitToHome is false, the Menu button maps to joystick button 0. This causes a conflict with the default Input window, because it also uses joystick button 0 to map the Submit virtual button. This results in the Menu button triggering actions on UI elements. To fix this issue, remove or modify the Submit virtual button bindings in the Input window (menu: Edit > Project Settings, then select the Input category).
     
  19. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,739
    I think i'm going to give up. All I want to is to disable the Command Left mapping when is not a Mac. Or reverse, don't have them and then add them from script on mac.

    I thought that would be easy couple of lines of script... so far I had to
    1) Create a new layout without the keys.
    2) Create set of rules. One for windows and one for mac.
    3) Add them to the layout manager.
    4) Add those to the player.
    5) Write script to disable the rules.

    Results: It doesn't work. I still get the keys detected on Windows.

    Is this so hard????
     
    Last edited: Dec 15, 2021
  20. HofiOne

    HofiOne

    Joined:
    Apr 19, 2021
    Posts:
    66
    This would be the key i guess, thank you so much!
     
    Last edited: Dec 16, 2021
  21. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,500
    I told you how to manage controller maps that differ based on platform in the most robust way possible. If you don't like that and you just want to disable the binding yourself, you can do it that way, but it may result in issues/artifacts under some circumstances such as if the user has rebound keys, depending on when you call this. If you load default controller maps, you'll have to run this function again also. There are probably other edge cases as well.

    You are passing the wrong value to the ControllerMap.DeleteElementMap function. You are passing the controller element id to a function that takes an Action Element Map id, which is a unique identifier for that Action Element Map. A controller element id will not work and explains why it didn't do anything.

    If you are going to do it this way, you must search through the Action Element Maps to find the Action Element Maps that bind to the key you're looking for and delete them. There is no one-line search and delete function that looks for a specific key binding. Controller Maps are nothing more than a container for Lists<ActionElementMap> categorized into Button and Axis Lists. You can search through them however you want. There are tons of exposed functions for searching and iterating the contents of these lists in the Controller Map class. This is just one possible way to find the Action Element Maps in question and delete them.

    Code (csharp):
    1. List<ActionElementMap> matches = new List<ActionElementMap>();
    2. foreach (ControllerMap m in player.controllers.maps.GetMapsInCategory(ControllerType.Keyboard, 0, 0)) {
    3.     m.GetButtonMapMatches(
    4.         aem => aem.keyboardKeyCode == KeyboardKeyCode.LeftCommand && aem.modifierKeyFlags == ModifierKeyFlags.None,
    5.         matches
    6.     );
    7.     foreach (var aem in matches) {
    8.         m.DeleteElementMap(aem.id);
    9.     }
    10. }
    The better way to do it is how I told you using the Layout Manager. If this were a Joystick, you'd have to be worrying about the user connecting a new Joystick and that joystick loading the Controller Map at that time and your method of just deleting the binding would fail unless you did that same check every time a joystick was connected. The Layout Manager method is designed specifically to keep the specified Layout enabled for the controllers in question at all times including when a new controller is connected. Defining Layouts for specific platforms is one of the many uses of it that it was specifically designed to handle. One common use case is swapping A and B on Nintendo platforms.

    You're misunderstanding how Rule Sets work. A Rule Set doesn't do anything but perform the specified set of actions if it is enabled and applied (or some other trigger causes an automatic apply such as connecting a controller.) A disabled rule set does nothing because it is not evaluated once disabled.

    Disabling a Rule Set does not disable or unload Controller Maps in that Layout from the Player. You simply disabled the rule so it doesn't perform the action anymore when Apply is called. Whatever the action you set up in the Rule will not be executed. Disabling a Rule Set does not mean to do the inverse of the Rule you defined. It simply means, do not execute this rule anymore.

    Two Keyboard Map Layouts:
    Default
    Mac

    Rule Set 0:
    Tag: WindowsKeyboardLayout
    Rule 0:
    Controller Selector: Controller Type
    Controller Type: Keyboard
    Categories: Default
    Layout: Default

    The above rule ensures the Keyboard Map in Category Default, Layout Default is loaded in the Player. This will unload any other Keyboard Maps in Category Default.

    Rule Set 1:
    Tag: MacKeyboardLayout
    Rule 0:
    Controller Selector: Controller Type
    Controller Type: Keyboard
    Categories: Default
    Layout: Mac

    The above rule ensures the Keyboard Map in Category Default, Layout Mac is loaded in the Player. This will unload any other Keyboard Maps in Category Default.

    If both Rule Sets are disabled, no change will be made to the Controller Maps in the Player because both Rule Sets are disabled and will not be evaluated.

    If one Rule Set is enabled, it will execute and load the Controller Map in the specified Layout and unload any other Controller Maps that share the same Category.

    If both Rule Sets are enabled, both will execute in sequence, so the 2nd will end up overriding the 1st because the action it performs negates the action the 1st performed.

    Layout Manager does not manage platforms. You write code that enables/disables the Rule Sets based on whatever criteria you choose, like when a specific platform is detected.

    Code (csharp):
    1. #if (!UNITY_EDITOR && UNITY_STANDALONE_OSX) || UNITY_EDITOR_OSX
    2.  
    3.     // Enable Mac Layout in Layout Manager
    4.     player.controllers.maps.layoutManager.ruleSets.Find(item => item.tag == "WindowsKeyboardLayout").enabled = false;
    5.     player.controllers.maps.layoutManager.ruleSets.Find(item => item.tag == "MacKeyboardLayout").enabled = true;
    6.     player.controllers.maps.layoutManager.Apply();
    7.  
    8. #endif
    In addition, Layout Manager must be enabled in the Player to have any effect.

    LayoutManager.PNG
     
    Last edited: Dec 17, 2021
  22. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,739
    Ok so I think I found a bug. Not sure whether it's unity or your code.

    On windows editor 2021.1.27.
    "Left Control" key, which I use to "fire" is setup. All good.
    But it seems that "Alt Gr" also calls "Left Control". Which is very weird. I mean, i have nothing setup for Alt Gr, and anything as setup for Left Control, gets called when I press Alt Gr too. This is horrible becase Alt Gr is used on different languages to type special characters.

    I found this post from 7 years ago with this same problem:
    Why right alt (alt gr) acts like left ctrl?! - Unity Answers

    I could use that, but then it would change all my rewired code to begin calling Unity Input directly. Is there something you can do about it?

    Thanks
     
  23. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    395
    Alt Gr is usually ALT+CTRL, so you might need to check if ALT is held down when you consume your CTRL event.
     
    guavaman likes this.
  24. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,500
    The issue has to be caused by either the keyboard or by Windows. Rewired on Windows with the default settings does not use Unity for keyboard input.

    Rewired receives key events directly from Windows Raw Input. Those key events are reporting that "Left Control" is pressed when "Alt Gr" is pressed on your keyboard. I can't selectively silence key events being sent by Windows to fix some kind of probably intentional behavior of the keyboard / layout that is being used. And it's very unlikely I can even detect the fact that the Left Control key event didn't come from the Left Control key. I have done something like this in the past based on observation. Obviously the hack isn't working in your case. Looking at my code, I have seen this kind of issue before and put in hacks to silence the Control key being triggered by other keys on Danish keyboards because of a very similar scenario:

    Code (csharp):
    1.  
    2. case Keys.ControlKey: {
    3.  
    4.     // Special handling for Danish keyboard error
    5.     // Right Alt sends Right Control key events
    6.     Keys key = (Keys)NativeMethods.MapVirtualKeyW((uint)eventData.makeCode, NativeConsts.MAPVK_VSC_TO_VK_EX);
    7.     if(key != Keys.LControlKey && key != Keys.RControlKey) {
    8.     // Control event came from some non-Control key. Discard.
    9.         return;
    10.     }
    11.  
    12.     eventData.key = (eventData.scanCodeFlags & ScanCodeFlags.E0) != 0 ? Keys.RControlKey : Keys.LControlKey;
    13.     }
    14.     break;
    The Keys value that is being switched here is coming directly from the Raw Input keyboard key event. The only way a Left Control key could be getting detected by Rewired is if Raw Input is telling it Left Control was pressed.

    On my US keyboard, pressing the "Right Alt" key also produces an "Alt Gr" key event. This is true for both Rewired and Unity input. Pressing "Left Control" + "Left Alt" also produces an "Alt Gr" key event in Unity input but not in Rewired input. I have to assume that they are either manually simulating that "Alt Gr" event, or the fact that they are using the WM_KEY API instead of Raw Input in the legacy input system is altering the result.

    You can easily see what Unity input is reporting from it's WM_KEY-based system by disabling Native Keyboard Handling in the Rewired settings for Windows.

    I am very, very leery of attempting to "fix" oddities of how Windows reports key events in various different keyboard layouts because any patch job would be based purely on observation and looking for patterns and would be very prone to breaking something else entirely in this or some other keyboard layout. It's also often times impossible to do, such as when Windows decides not to send up events for keys which did have down events because the user starts holding some other modifier key down that changes something. That happens. It's easy to reproduce stuck keys with certain key combinations. There are tons of issues with modifier keys and the number pad that exist and cannot be fixed because of how Windows and/or the keyboard hardware chooses to report these key events.

    Operating system support of keyboard input was not designed for gaming, it was designed for typing. Most people expect keyboard keys to act exactly like buttons on a controller where a key is a key is a key and every key press can be detected and handled independently. This is not the case. There's a whole complex mapping system underneath keyboard input handled by the operating system that can and does change what the application sees when keys are pressed. This is necessary for the handling of various modifier key combination behaviors.

    https://docs.microsoft.com/en-us/windows/win32/inputdev/about-keyboard-input

     
    Last edited: Dec 18, 2021
  25. Shafournee

    Shafournee

    Joined:
    Dec 18, 2021
    Posts:
    2
    Hi, sorry if this has been asked before, I looked around but didn't find anything on this.

    Is there a way for mouse movement to set the last active controller to the mouse? It doesn't seem like there's any option to enable this behavior, and I don't think I can set the LastActiveController directly.
     
  26. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,500
    It already does that automatically.

    If you are using the Player version of LastActiveController, it will only apply if the Mouse is assigned to the Player and if a Mouse Map is loaded in the Player, enabled, and maps a button or axis to an Action. Player LastActiveController is based on Actions as the documentation states:

    https://guavaman.com/projects/rewired/docs/HowTos.html#last-used-controller
     
  27. Shafournee

    Shafournee

    Joined:
    Dec 18, 2021
    Posts:
    2
    It looks like this fixed it. Notably, I had left and right mouse buttons mapped but the mouse only registered when left or right clicking. Now that I've mapped an action to "Mouse Horizontal" it shows up as the LastActiveController on mouse move. Thank you!
     
  28. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,500
    Rewired 1.1.41.2 is available on the Unity Asset Store:
    1.1.41.2:

    Bug Fixes:
    - Unity 2021.2+, Windows Standalone, Raw Input, Direct Input w/ Native Mouse/Keyboard Handling: Fixed bug in processing Raw Input messages on 32-bit builds running on 64-bit Windows resulting in Unity logging "Invalid raw input data size" messages when using certain controllers.
    - Reworked Rewired Editor handling of prefabs in versions of Unity that use the new prefab workflow due to new errors caused by recent updates to Unity resulting in data not being saved when modifying data in a prefab using the Rewired Editor.
    - Rewired Input Manager "Don't Destroy on Load" setting is set properly when Rewired Initializer is a child of a GameObject and instantiates the Rewired Input Manager as a child of that parent GameObject.
    - Fixed Global Options Window not displaying any information.
     
    tntfoz and Zante like this.
  29. indie6

    indie6

    Joined:
    Dec 15, 2012
    Posts:
    100
  30. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,500
    This has been asked several times recently. Here are links to the discussions:

    https://forum.unity.com/threads/rewired-advanced-input-for-unity.270693/page-153#post-7586833
    https://forum.unity.com/threads/rewired-advanced-input-for-unity.270693/page-153#post-7592173
    https://forum.unity.com/threads/rewired-advanced-input-for-unity.270693/page-153#post-7592476

    https://forum.unity.com/threads/rewired-advanced-input-for-unity.270693/page-154#post-7601026
    https://forum.unity.com/threads/rewired-advanced-input-for-unity.270693/page-154#post-7601989

    Rewired does not explicitly support the newest remote because, apparently from what I can gather from these comments, Unity does not support all the features of it. Rewired is 100% dependent on UnityEngine.Input for all input on iOS and tvOS.
     
    indie6 likes this.
  31. Meceka

    Meceka

    Joined:
    Dec 23, 2013
    Posts:
    420
    Hello, two different players reported having input spam after updating to windows 11. They get all the inputs spammed every frame and game and ofc UI behaves weirdly.

    The rewired version of the released version is around 6 months old. Could that be the reason for the issue? Were the older versions not directly supporting input in windows 11?

    I didn't yet narrow the issue down to rewired though, just wanted to consult you before I investigate further. Thank you and happy new year :)

    Edit: One helpful player helped me investigate the issue. I sent him an up-to-date version of the game with an updated rewired but it didn't fix the issue.
    Then we figured out input spam was caused by this device. When device is unplugged it no longer spams the input and game is playable.
    "PXN V3II PC Racing Wheel, 180 Degree Universal USB Car Racing Game Steering Wheel with Pedal"

    Even if that's an unsupported device. I believe it's a bug to get input spam like that. It makes the game unplayable.

    Edit 2: Second player also contacted and said when he unplugs his device game works well.
    His device: "Rampage V900"
     
    Last edited: Jan 4, 2022
  32. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,500
    There is no specific support for any specific version of Windows in Rewired's Windows Standalone code. Rewired uses standard Microsoft API's for input, depending on your choice of Primary and Secondary input sources for the platform.

    Raw Input
    Direct Input
    XInput
    SDL2
    Unity

    Function calls are identical on all versions of Windows. All calls to the Windows API are based on Windows Vista or earlier for maximum compatibility. XInput is separate from Windows and Rewired attempts to use the latest version available it finds on the system to use for XInput-compatible devices. No code should have to be changed for Windows 11 compatibility as all of these APIs are backward compatible.

    Have you attempted to use the Direct Input source instead of Raw Input? Past show-stopping problems that were present using Raw Input were not present using Direct Input.

    The term "input spam" is quite vague. You say "They get all the inputs spammed every frame". Are you saying all possible buttons are reported as pressed and all possible axes are non-zero? Are you referring to buttons and axes on only the specific device or are you saying all Rewired Actions are returning non-zero values? Or could this be more simply a matter of noisy axes causing values to be sent because they're greater than the default dead zone value of 0.1 for unknown controllers?

    IF this is actually a problem at the device level and it actually only happens on Windows 11, it seems like these specific devices are at fault. I would need a device to understand if bad information it is being sent through Raw Input to be able to identify some kind of pattern to filter it out. (Doing things like that to "fix" a bug at a lower level is a very questionable practice, IMO.) If this device is sending non-zero values for all its element at the same time, nothing like this has ever been reported before, and it is likely this is some new bug in the Raw Input API due to some change they made elsewhere in the device and driver stack.

    Device-level problems that happen immediately after a major OS update like this have always in previous cases been caused by new bugs in the OS or device drivers. New bugs introduced at this level need to be fixed by Microsoft and/or the device driver developer. There's no correct way to "fix" bugs caused at this level (OS / driver) at a higher level in software (Rewired). Any attempt to do so would be prone to breaking and causing other problems. (Rewired's code is littered with workarounds to attempt to avoid problems with certain devices which are caused at a lower level already because of a history of bugs being introduced in Windows and customers and end users look to me to solve these problems.) Based on past experience, I would guess that Microsoft doesn't test Raw Input at all when rolling out new Windows updates, having struggled with years of problems after Windows 10 was introduced including system crashes with various devices triggered by simply opening the device using Raw Input. This lead to months of development of workarounds found simply by trial and error including an entirely new input code path using direct HID device access to avoid opening certain blacklisted devices (Microsoft Xbox One controller) at all with Raw Input because of their new bugs in core functionality of their own input API when using their own devices. Going to this extreme to find workarounds by trial and error to "fix" Microsoft APIs that worked for years and only break after some major OS update is a losing battle as they broke the functionality no less than 3 additional times with subsequent updates that fixed one thing but then caused even more bugs. This is not something I would attempt again. If the problem is in the Raw Input API or the device driver, the problem needs to be fixed by Microsoft or in the device driver.
     
    Last edited: Jan 7, 2022
    Meceka likes this.
  33. Meceka

    Meceka

    Joined:
    Dec 23, 2013
    Posts:
    420
    Thanks for the very detailed response.

    One of the players uploaded the issue on Youtube, and I sent the youtube link to second player and he confirmed it's the same issue.

    Second player sent me the logs and there isn't anything unusual. Second player also stated its very hard to navigate on the main menu as it sometimes uses back button(ESC) by itself.
    From the video I can't see the wheels rotating, so I believe it's just the buttons. And I get most button calls simply with player.GetButtonDown

    The second player also found a workaround by himself. After launching the game, he unplugs and plugs back the device and this somehow fixes the issue.

    He also says he doesn't have the issue with a racing game "RaceRoom Racing Experience" I don't know if it also uses Raw Input.

    And I attached my windows settings to this post.
    upload_2022-1-7_14-54-14.png

    We are using RawInput with Use XInput in the project. I can send the user an updated version with a different "Primary Input Source" to see if it's caused by raw input.
    Which one would you recommend? Should I try Direct Input? The game is on Steam.
     
  34. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,739
    If it doesn't happen with other games, this is a Unity bug. Report it to Unity, Rewired all it does is read the data from whatever unity gives.
     
  35. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,548
    (1) After upgrading to Windows 11 did the users install/reinstall the device drivers for their specific racing wheels?
     
  36. Meceka

    Meceka

    Joined:
    Dec 23, 2013
    Posts:
    420
    That's quite possible. But unity will ask me a repro to report it. I don't have a Windows 11 device yet so I can't reproduce it myself.
     
  37. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,739
    If you have any windows 10 device, windows 11 is a free update and you can roll back. I did a few times for testing without issues.
     
  38. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,500
    Actually, this is not true. Rewired implements native input on many platforms using a variety of optional input APIs. Windows Standalone using Raw Input + Native Mouse Handling + Native Keyboard Handling + XInput does not read a single bit of input information from Unity. The reason I wrote Rewired in the first place was because of Unity's input system's bugs which could only be fixed by getting input directly from the native APIs instead of Unity.

    Using other games for comparison is rarely helpful. You have no idea what input API's those games chose to use to get input, none of which work the same way. There are quite a few available on Windows 10. Off the top of my head:

    Raw Input
    Direct Input
    XInput
    Direct HID message
    Windows.Gaming.Input
    Windows GameCore API
    Device-specific SDKs (Logitech, Thrustmaster, etc.)

    Also, Raw Input and Direct HID are very implementation specific, with the developer responsible for writing the majority of code that interprets the HID information.
     
    Last edited: Jan 8, 2022
  39. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,500
    Based on what you've said, I see no way this could be anything but a new driver and/or OS bug, or possibly Steam. Raw Input sends messages every time an element on a device changes. This message contains the Up/Down state of every button that changed value. If all buttons are getting stuck on, that means Windows is telling Rewired that all buttons are in the ON state and never telling it they are in an OFF state. There's no way Rewired can correct this. It can only know information about the device that the input API in use is telling it. If the input API in use is telling it all buttons are pressed, then for all intents and purposes, all buttons are pressed.

    If you are using GetButtonDown, that would mean the buttons are going on and off rapidly.

    The only other viable API to use is Direct Input. Direct Input requires the Direct X runtime be installed:
    https://guavaman.com/projects/rewired/docs/Deployment.html
     
    Last edited: Jan 8, 2022
  40. BackToPass

    BackToPass

    Joined:
    Oct 14, 2020
    Posts:
    6
    Hi there, i have problem when run with PS5 controller. Is that Rewired supported PS5 right now?
     
  41. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,500
    Yes, the PS5 controller is supported and works on Windows when using Raw
    Input or Direct Input as the Primary Input Source.

    The list of supported controllers is here:
    https://guavaman.com/projects/rewired/docs/SupportedControllers.html

    Sony DualSense is the PS5 controller.

    Any problems with a controller should be investigated using the Troubleshooting documentation on this topic:

    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#controller-doesnt-work
    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#joystick-problems
    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#debug-information
    https://guavaman.com/projects/rewir...l#debug-information-diagnosing-input-problems

    Follow the checklists to determine where the problem lies.
     
    BackToPass likes this.
  42. BackToPass

    BackToPass

    Joined:
    Oct 14, 2020
    Posts:
    6
    Thank for reply soon.
    In setting i see like image below, so how i can setting for PS5 (Sony DualSense) cause i don't see PS5 but PS4 PS3 already have.
    upload_2022-1-11_15-14-21.png
     
  43. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,500
    You are looking at build target settings, not controller settings. PS4 there refers to building on the PS4 platform. Rewired does not support the PS5 platform yet.

    Your question was about the PS5 controller, therefore I assume you're talking about using the PS5 controller in Windows. The Dual Sense controller works like every other supported controller in Rewired. You create Joystick Maps for the controller or for the Gamepad Template and it should work. If you are having problems, use the links I posted above and discover the exact nature and reason for the problem.
     
  44. crdmrn

    crdmrn

    Joined:
    Dec 24, 2013
    Posts:
    152
    Hi!
    I'm trying to extend ControlMapper, but I can't seemt o understand when the "InputFieldInfo" components get updated.
    I noticed that when restoring the default map they don't until they get disabled and reenabled... am I doing something wrong?

    _targetRwPlayer.controllers.maps.LoadDefaultMaps(ControllerType.Joystick);

    This is the line I'm using to reset to the default map.
     
  45. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,500
    You have to call the Redraw function.
     
    BackToPass likes this.
  46. BackToPass

    BackToPass

    Joined:
    Oct 14, 2020
    Posts:
    6
    Thank you, i fixed it.
    ;)
     
  47. crdmrn

    crdmrn

    Joined:
    Dec 24, 2013
    Posts:
    152
    there seem not to be a redraw function => Controlmapper.Redraw();
    There's only a Reset one, but that destroys and recreates everything.
    Also, what about the scrollrect? I seem not to be able to set the vertical position at start neither by setting it directly on the component or on the scrollbar, or on both... is there something else setting it?

    EDIT: found the Redraw function but it's private... I'm trying not to modify ControlMapper classes and extending them instead, but I cant seem to make my partial class work :S
     
  48. ScottySR

    ScottySR

    Joined:
    Sep 29, 2018
    Posts:
    46
    I found a bug (probably?) in Rewired.

    Here is how to do it:
    1. Start game with a controller plugged in
    2. Disconnect a the controller
    3. Plug in a different controller
    4. Press a button on that controller
    Result?
    Controller ctrl = player.controllers.GetController(type, 0);
    returns
    null
    even though the code checks the correct player and does in fact have have a controller. I have verified that through the debug overlay as well as a breakpoint with Visual Studio and inspecting variables, etc.

    The code where the bug happens is executed numerous times during regular gameplay, but this is the only time this bug happens. Could there be another reason why Rewired fails to get the controller regardless of the player having one?

    Rewired version: 1.1.41.3.U2019
     
  49. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,548
    For completeness.
    (A) What type of controller is plugged in originally?
    (B) What is the second controller that is plugged in?
    (C) What version of Windows are you using?
    (D) What input method (e.g. Raw, DirectInput) are you using?
     
  50. ScottySR

    ScottySR

    Joined:
    Sep 29, 2018
    Posts:
    46
    On PC:
    -The original controller was a 3rd party XBox One controller
    -Second controller was a Switch Pro controller
    -I'm using Windows 10
    -Most likely XInput

    This is not PC exclusive. I originally noticed this on Switch, but used PC to debug it.