Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Rewired - Advanced Input for Unity

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

  1. spacefrog

    spacefrog

    Joined:
    Jun 14, 2009
    Posts:
    734
    Many thanks for that thorough explanation
    For the time being i simply filed the issue under "curiosity on my aging W7 installation" - or maybe its indeed some corner case hardware problem on the specific controller that prevents the mini USB plug to draw enough power or something ... might retest the controller in wireless mode if i find time and curiosity again

    As W7 is past its official support anyways, i hope once the game is officially released it doesnt affect us too much
     
  2. topofsteel

    topofsteel

    Joined:
    Dec 2, 2011
    Posts:
    999
    Is there a way to check if there is any input at all coming from a player? I can use player.IsCurrentInputSource but I still have to check for each action. Thanks.
     
  3. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    There is no convenience function to determine if any Action has a non-zero value in Player. You iterating the Actions and checking each would be the same thing a convenience function would do.

    There are other options that do not tell you exactly that but may be good enough:

    Check AnyButton:
    https://guavaman.com/projects/rewired/docs/api-reference/html/M_Rewired_Player_GetAnyButton.htm
    https://guavaman.com/projects/rewired/docs/api-reference/html/M_Rewired_Player_GetAnyButtonDown.htm
    https://guavaman.com/projects/rewired/docs/api-reference/html/M_Rewired_Player_GetAnyButtonUp.htm
    https://guavaman.com/projects/rewir...tml/M_Rewired_Player_GetAnyNegativeButton.htm
    https://guavaman.com/projects/rewir...M_Rewired_Player_GetAnyNegativeButtonDown.htm
    https://guavaman.com/projects/rewir...l/M_Rewired_Player_GetAnyNegativeButtonUp.htm

    Receive an event when any Action axis value is non zero:
    https://guavaman.com/projects/rewir.../M_Rewired_Player_AddInputEventDelegate_1.htm

    Use InputActionEventType.AxisActive. Note that this is no faster than you iterating the Actions yourself and checking player.GetAxis.
     
    Delforce likes this.
  4. eighto

    eighto

    Joined:
    Apr 27, 2013
    Posts:
    32
    Hello, I was happy to see this last update because that raw input change sounded like it would fix this problem I've had. But it did not.

    It's not a big deal because it only happens in unity editor, not in builds. And only to my wireless 8bitdo snes controller and my snes controller with usb to pc adapter, not my 360 controller.

    I have raw input enabled, xinput disabled. Windows 10.

    Steps:
    1. launch steam
    2. enter playmode, all controllers are working.
    3. exit playmode, and enter playmode again, those 2 controllers are gone, can't assign them/detect input.
     
  5. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    This is the second report like this in the last couple of weeks. This is not a Rewired problem. This is clearly a new Steam/Unity editor problem. It has never happened before now and suddenly it's happening.

    Based on my conversation with the other user, this is my best guess as to what is happening:

    1. The first time you launch Rewired, Rewired initializes before Steam. Rewired is able to get all the information it needs from the Windows API without interference from Steam.

    2. Steam initializes, hooking the Windows libraries and/or the Wndproc of the application. From now on, Steam decides what you can and can't see and what all those Windows API calls return.

    3. You press Stop and Start again. Now Steam has already hooked everything and it changes what Rewired sees. Something is wrong with what they're returning.

    The other user had ridiculous problems like a DS4 alternately being detected as a DS4 and an XInput controller or just not appearing at all.

    This is a Steam problem and I cannot fix it.

    If you want the behavior to be consistent, you are going to have to initialize Steam before Rewired so Rewired is never able to see anything but what Steam wants it to see.
     
  6. eighto

    eighto

    Joined:
    Apr 27, 2013
    Posts:
    32
    Ah, right, ok thanks.
     
  7. eighto

    eighto

    Joined:
    Apr 27, 2013
    Posts:
    32
    Also btw this started happening to me earlier this year, maybe Jan or Feb.
     
  8. MallNinjaMax

    MallNinjaMax

    Joined:
    Apr 17, 2017
    Posts:
    25
    Unity 2019.4.8

    I deleted the asset files from the AppData download location and removed it from my project and did a fresh download and reinstall. I have never downloaded or installed Rewired in any other major version of Unity, only jumped a minor version (2019.4.3 > 2019.4.8). I don't have, and have never installed, Unity 2020. It has no reason to install the 2020 version.
     
  9. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Then report this to Unity. This would mean the Asset Store is serving you the Unity 2020 file in Unity 2019. This would be an error on their end. I don't have control over what assets are served by the Asset Store. All I do is upload the asset for each version of the Unity Editor and they serve the files to you based on the version of Unity you're using when you download it.

    I just tested a new project in 2019.4.10f1 downloading Rewired from the Asset Store and it correctly installed the U2019 version.
     
    Last edited: Sep 23, 2020
  10. ben06feb

    ben06feb

    Joined:
    Oct 2, 2012
    Posts:
    42
    Hi, How can I setup same joystick controller for multiple players without assigning every time when switching player. It used to show warning pop up - particular controller assigned to another player do you want to remove and reassign to this player?
     

    Attached Files:

  11. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    I can't understand what you're asking.

    What does "setup same joystick controller for multiple players" mean? Are you talking about having to re-create the same custom input bindings on the controller when you re-assign it to another Player?

    If you're talking about something else regarding joystick assignment, nothing affects that except the Max Joysticks Per Player setting in the Rewired Input Manager -> Settings -> Joystick Auto-Assignment. If you have this set to 1, it's not going to let you assign multiple joysticks to the same Player.
     
    Last edited: Sep 23, 2020
  12. ben06feb

    ben06feb

    Joined:
    Oct 2, 2012
    Posts:
    42
    It's not about max joystick for players or re assigning control map of one player to another. Scenario is I have 2 players with my Rewired input manager, I have assigned joystick which is connected (Extreme 3d pro) to player one using assign controller option,
    1) is there any way to get it connected automatically to the player without assign it manually?
    2) with the example scene if I assigned to a player and when i switch to next player, I have to assign it manually again, at that time this particular warning comes as remove from already assigned player and assign to this player. Is there any way to assign joystick to all players connected without re-assign every time?
     
  13. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Let me get this straight -- you want the same joystick assigned to all Players? If you want this, you can't use Control Mapper. Control Mapper only allows a controller to be assigned to a single Player at a time, except for the keyboard.

    When you change the controller assignment in Control Mapper from Player 1 to Player 2, it unassigns it from Player 1.

    Rewired has no limitations on how many Players can be assigned the same Joystick. Control Mapper does. Control Mapper is designed for the most common scenarios. It's very uncommon for a joystick to be shared among multiple players.
     
  14. ben06feb

    ben06feb

    Joined:
    Oct 2, 2012
    Posts:
    42
    Okay, got it. Thanks for the details.
    One more thing, what is the code to assign newly selected key element to a action (need to assign both modifier key + other key element) - for keyboard, mouse and joystick. Also what is the code for clear the key element details assigned to a action.
     
  15. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Control remapping is an advanced topic and is documented by 4 examples. See the documentation for an overview and links to the examples:
    https://guavaman.com/projects/rewired/docs/HowTos.html#controller-mapping-screen
     
  16. pskortelshuette

    pskortelshuette

    Joined:
    Sep 24, 2020
    Posts:
    1
    Hi,

    is there a way to go for using multiple layouts for one controller type?

    My use-case is following: I want to use two joysticks, one for left hand and one for right hand, with different actions assigned to the X/Y axis. I thought about creating a Layout for each hand and loading maps with the according layout for each joystick.

    Since the same Joystick Map is loaded for both Joysticks, loading a dfferent layout affects the maps of both controllers. You stated in the docs, that it is not possible to use multiple layouts at one controller map at the same time. What would be the best way to assign a different layout to each Joystick (maybe without using multiple players)?

    The only workaround I can imagine is using a second player, when a second joystick is attached, which would mean big changes in our input system. So I wonder if there are other possibilities.

    Thanks!
     
  17. Skegon

    Skegon

    Joined:
    Feb 21, 2013
    Posts:
    26
    Hi. :) I'm having a hard time understanding how to manage maps and layouts, even after reading the documentation.
    I'm using the default RewiredStandaloneInputSystem with UI actions set up in both keyboard and joystick maps, which works super.
    I am then enabling/disabling maps based on the players choice of controller. (Player chooses their preferred input method)
    The thing I'm not sure how to solve is, how to keep UI actions for keyboard and full actions for joystick. So the player can interact with menus even after choosing joystick.
    My thought was to always keep both keyboard and joystick maps enabled, but have a "disabled" layout on each map that removes all actions but the UI ones, and then simply change the layouts based on which one is active, but I can't seem to figure out how. I have tried:
    ReInput.players.GetPlayer(controllerIndex).controllers.maps.LoadMap(ControllerType.Keyboard,controllerIndex, 0, usesKeyboard ? 0 : 1);
    where layoutId 0 is enabled and 1 is UI only, but this doesn't change the layoutId for some reason.
     
  18. eighto

    eighto

    Joined:
    Apr 27, 2013
    Posts:
    32
    Hey letting you know I found a fix from this post: https://stackoverflow.com/questions...hange-problem-with-steam-devices-not-detected

    I just needed to disable "generic gamepad configuration" in steam controller settings.
     
  19. ben06feb

    ben06feb

    Joined:
    Oct 2, 2012
    Posts:
    42
    There is no script reference in it, just a documentation about example scene screenshot.
     
  20. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Look in the /Assets/Rewired/Examples folder of your project.
     
  21. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
  22. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    There is nothing stopping you from having 30 different Layouts loaded for a particular Map Category loaded.

    If you are talking about having Rewired automatically load different Controller Maps in different Layouts for 2 different identical controllers assigned to a single Player, then no, it will not do that for you. There is no system to say: Load controller map X for Xbox controller # 1 and load controller map Y for Xbox controller #2. You will have to take over the job of loading the appropriate Controller Maps for each Joystick in the Player when joysticks are assigned. You can also use Layout Manager for the task.

    Using two separate Players is also another way to handle it with its own set of issues.
     
  23. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    1. You do not load controller maps to enable and disable them. You enable them or disable them using the methods outlined in the documentation:
    https://guavaman.com/projects/rewired/docs/HowTos.html#enabling-disabling-controller-maps

    2. To enable/disable controller maps, they must first be loaded in the Player. You normally do this by setting up the Controller Maps to be loaded in the Player by default on the Players page of the Rewired Input Manager. See Controller Maps.

    3. Use constants for Action, Map Category, and Layout Ids. It's far too common for people to assume an id is an index, which it is not, and get incorrect results.

    4. Use separate Map Categories for UI and game controls as outlined in the RewiredStandaloneInputManager documentation. There's no reason to use Layouts for this.

    5. Use Debug Information to see exactly is loaded and enabled in your Player.
     
  24. olivier_henley

    olivier_henley

    Joined:
    Aug 14, 2012
    Posts:
    7
    Control UFE2 Player 2 using Rewired touch controller

    Hi,

    Note: Rewired Player0 is UFE2 Player1, Rewired Player1 is UFE2 Player2

    In the game object hierarchy -> Rewired UFE2 Input Manager -> Rewired Touch Control Canvas -> Touch Controller, in the inspector if I choose Custom Controller Options -> Assign to Player: Player1 (Player2 for UFE2), the control is still on Player0 (Player1 for UFE2) during a game.

    The only way I found to control UFE2 Player2, is to move the Player1 to a higher priority than Player0 inside the Rewired Editor.

    a) Someone knows what I am doing wrong setting up the TouchController script (close code from Rewired) and/or what is wrong for the Rewired UFE2 Input Manager (open script from UFE2)?
    b) If no solution for a), someone knows how I can manipulate the player's order inside the Rewired Editor -> Players at runtime.

    Thanks

     
  25. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    You cannot change the Player the controller belongs to at runtime after the Touch Controller has been created using the inspector or any function in the Touch Controller component. The options in the inspector only apply when the Touch Controller is first initialized (enabled). It creates the Custom Controller and assigns it to the Player at that time if you have those options enabled. It will not re-assign the Custom Controller to another Player when you change the value in the inspector or through a script that manipulates these values on the Component. You would see what is happening at the Rewired object level if you used Debug Information to view what controllers are assigned to what Players.

    If you are trying to switch what controller owns the Touch Controller at runtime, you would have to either manually unassign and reassign the Custom Controller to the Players through scripting in the Player class or create two separate Touch Controller hierarchies, one for each Player, and show only the one you want at a time.

    You cannot change the ordering of the Players at runtime. This wouldn't do what you think it would anyway. Players and Actions and many other objects in Rewired are static and defined at edit time and cannot be created or deleted at runtime.
     
  26. topofsteel

    topofsteel

    Joined:
    Dec 2, 2011
    Posts:
    999
    It's not clear how to override the default Horizontal and Vertical inputs. Previously I was writing my own controller, but I'm trying to implement Rewired using an existing car controller. Should I modify the car controller scripts using 'player.GetAxis(...)' ? Or can I override the horizontal and vertical inputs through Rewired? It seems like I'm missing something obvious. Thank you.
     
  27. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Start with the basics. First understand the Rewired system:
    https://guavaman.com/projects/rewired/docs/

    There's plenty of documentation to make this clear, like this:
    https://guavaman.com/projects/rewired/docs/HowTos.html#converting-scripts
     
  28. Roman-Ilyin

    Roman-Ilyin

    Joined:
    Oct 9, 2013
    Posts:
    29
    Hello.
    I want to add actions for camera rotation and zoom.
    I have already made them (cross buttons of the gamepad / Q, E, W, S keyboard keys).
    Now I want to change the controls on the controller so that the camera controls work when the lower trigger is pressed.
    LT + crossdown, LT + crossup, etc.
    But I don't plan adding two keyboard buttons (Ctrl+W, etc) for this action.
    What is the correct way to do this type of control?
     
  29. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    https://guavaman.com/projects/rewired/docs/HowTos.html#button-combos

    If you do not want the keyboard keys to react to the combination of buttons, then you'll have to make different Actions for them.

    Arbitrary multi-element Action bindings are not supported in Rewired's Controller Map system.
     
  30. Beargarr

    Beargarr

    Joined:
    Jun 5, 2020
    Posts:
    1
    Hello @guavaman I'm currently experiencing an issue where when an action is bound to the key right control, it also gets triggered by right alt. So far this is the only key where something like this is happening. I have made sure to check multiple times if I had everything set up correctly and it seems to be that way.
    Is this a known issue?
     
  31. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    No it is not a known issue and I cannot reproduce it on Windows. What platform?

    Look at your Controller Maps at runtime. You cannot trust what's in the Rewired Input Manager because you may be loading saved bindings:
    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#debug-information
     
  32. Grumpy-Dot

    Grumpy-Dot

    Joined:
    Feb 29, 2016
    Posts:
    93
    @guavaman Got this error when updating to 2020.1.7f1:
    Error: Could not load signature of Rewired.Editor.ComponentControls.TouchInteractableEditor:GenerateInteractableAnimatorContoller due to: Could not load file or assembly 'UnityEngine.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
    The build works fine however.
     
  33. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    This has been happening for a very long time and is a well-known, Unity issue that I cannot fix:
    https://guavaman.com/projects/rewired/docs/KnownIssues.html#assembly-errors-2019-2

    A notice about this was pinned in giant bold letters to the top of the main documentation page for a very long time, but I removed it because a much more important, actual issue (VS 2019 IL2CPP) came up so I replaced it.
     
    Grumpy-Dot likes this.
  34. NikoBay

    NikoBay

    Joined:
    Aug 15, 2018
    Posts:
    39
    hi, is there any notes for mobile performance?

    On iPhone build, InputManager_Base.Update() often cost 4~5ms, sometimes it's lower. For input that's not always happening, this is costly to me.
    Controller map is simple with 4 input of axes, disabled keyboard, disabled FixedUpdate, OnGUI... (basically followed the performance advice on website).

    Is this normal? What should I do to improve its performance? If it could stay lower than 2ms, that would be great.

    Thanks in advance.
     
  35. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    https://guavaman.com/projects/rewired/docs/HowTos.html#optimization

    I do not test performance on different mobile devices to tell you what performance should be. I only do performance testing on my development Windows PC.
     
  36. Derakon

    Derakon

    Joined:
    Jul 3, 2019
    Posts:
    20
    I am trying to use Rewired's rule sets to switch control schemes depending on what scene I'm in. In the combat scene, I want the left mouse button (LMB) to fire; in the designer scene, I want it to select. I created three rule sets: one for basic controls, one for the designer, and one for combat. Each simply enables the relevant input category.

    The combat scene works fine; where I'm having trouble is the designer scene, which doesn't appear to believe that any action is connected to LMB at all. I wrote this simple test function in my input wrapper, to log all inputs that are mapped to the "select" action:
    Code (CSharp):
    1.     public static void DebugCheck() {
    2.         Init();
    3.         var results = new List<ActionElementMap>();
    4.         var elems = player.controllers.maps.GetElementMapsWithAction(Inputs.SELECT, true, results);
    5.         foreach (var elem in results) {
    6.             Debug.Log($"Action {Inputs.SELECT} has elem {elem} in map {elem.controllerMap} isMouse? {elem.controllerMap is MouseMap} isKey? {elem.controllerMap is KeyboardMap} isGamepad? {elem.controllerMap is JoystickMap}");
    7.         }
    8.     }
    It gives me three results: one for the A button on my gamepad, and two identical entries for the Enter key:
    Code (csharp):
    1.  
    2. Action Id = 17
    3. Action Descriptive Name = Select
    4. Element Type = Button
    5. Element Identifier Id = 6
    6. Element Identifier Name = A
    7. Element Index = 0
    8. Axis Range = Full
    9. Invert = False
    10. Axis Contribution = Positive
    11. Keyboard Key Code = None
    12. Has Modifiers = False
    13. Modifier Key 1 = None
    14. modifier Key 2 = None
    15. modifier Key 3 = None
    16. modifier Key Flags = None
    17. in map Rewired.JoystickMap isMouse? False isKey? False isGamepad? True
    Code (csharp):
    1.  
    2. = True
    3. Controller Map Id = 0
    4. Action Id = 17
    5. Action Descriptive Name = Select
    6. Element Type = Button
    7. Element Identifier Id = 58
    8. Element Identifier Name = Return
    9. Element Index = 58
    10. Axis Range = Full
    11. Invert = False
    12. Axis Contribution = Positive
    13. Keyboard Key Code = Return
    14. Has Modifiers = False
    15. Modifier Key 1 = None
    16. modifier Key 2 = None
    17. modifier Key 3 = None
    18. modifier Key Flags = None
    19.  in map Rewired.KeyboardMap isMouse? False isKey? True isGamepad? False
    Code (csharp):
    1.  
    2.  
    3. Action Descriptive Name = Select
    4. Element Type = Button
    5. Element Identifier Id = 58
    6. Element Identifier Name = Return
    7. Element Index = 58
    8. Axis Range = Full
    9. Invert = False
    10. Axis Contribution = Positive
    11. Keyboard Key Code = Return
    12. Has Modifiers = False
    13. Modifier Key 1 = None
    14. modifier Key 2 = None
    15. modifier Key 3 = None
    16. modifier Key Flags = None
    17.  in map Rewired.KeyboardMap isMouse? False isKey? True isGamepad? False
    Note that there is no entry for the mouse button at all. I assume that the duplicate Return key action maps are because both my default and designer keyboard maps have an entry for the Return key

    Here is my mouse input map:

    The "Select" action is part of the "Default" action category, but a) as I understand it rule sets apply to map categories, not action categories. And anyway the "Default" category is enabled.

    Here is my rule sets:




    I am confident that the first two rule sets are enabled and the third is disabled; for the sake of completeness this is the code I'm using to toggle rule sets:

    Code (csharp):
    1.  
    2.     private static HashSet<string> ruleTags = new HashSet<string>();
    3.     public static void SetRuleForScene(string sceneName) {
    4.         Init();
    5.         ruleTags.Clear();
    6.         ruleTags.Add(DEFAULT_RULESET);
    7.         // Set the active rulesets based on the scene.
    8.         switch (sceneName) {
    9.             case "combat":
    10.                 ruleTags.Add(COMBAT_RULESET);
    11.                 break;
    12.             case "designer":
    13.                 ruleTags.Add(DESIGNER_RULESET);
    14.                 break;
    15.         }
    16.         Debug.Log($"Set rules for scene `{sceneName}`; ruleset tags are {string.Join(",", ruleTags)}");
    17.         foreach (var rules in player.controllers.maps.mapEnabler.ruleSets) {
    18.             rules.enabled = ruleTags.Contains(rules.tag);
    19.             Debug.Log($"Rules {rules}/{rules.tag} enabled? {rules.enabled}");
    20.         }
    21.         player.controllers.maps.mapEnabler.Apply();
    22.         // Force reloading the player and valid actions.
    23.         player = null;
    24.         Init();
    25.     }
    Its logging confirms that the rule set tagged with "Combat" is disabled and the other two are enabled.

    Why doesn't my game think that LMB is mapped to the Select action? Thank you for your time!

    EDIT: I have enumerated all of the actions used by any MouseMap, and the Select action is not listed, despite what the Rewired Editor claims.
     

    Attached Files:

    Last edited: Oct 7, 2020
  37. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    @Derakon

    Are you aware of Debug Information? You could be visualizing everything happening at runtime without making your own logging functions.

    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#debug-information

    I do not see anything in any of your logs that shows any Mouse Maps at all. This leads me to believe you did not assign this Mouse Map to the Player. You do not show the Player page of the Rewired Input Manager that shows what Mouse Maps are designated to be loaded in your Player on start.

    If the Mouse Map is listed to be loaded in the Player but the binding is missing, then this is my best guess:
    https://guavaman.com/projects/rewired/docs/UserDataStore.html#saved-xml-not-synced
     
  38. Derakon

    Derakon

    Joined:
    Jul 3, 2019
    Posts:
    20
    I did not know about Debug Information; that's helpful, thank you. Here's it showing that I have loaded the mouse map but it only has axis maps, not button maps:



    And indeed, the scroll wheel works, but neither left or right mouse button work.

    Though, on that note -- this also says that the "Combat" map is enabled. It should not be, as I disabled the ruleset that controls it.



    Am I misunderstanding rulesets, or misreading the debug information?

    Regarding saved XML not being synced -- I am still using the default PlayerPrefs storage system, as I don't use PlayerPrefs for anything else so it seemed harmless to use it for controls only. I have tried deleting the stored PlayerPrefs but this does not change any behavior. Is there some other step I should take to rectify a sync failure?

    EDIT: I happened to be perusing the Rewired Editor and was accidentally not editing the prefab, and I noticed that there were no buttons mapped for the mouse in this instance of the prefab! I deleted the instance and recreated it from the prefab and now it works. How in blazes could that have happened and what do I need to do to make sure it doesn't happen again?
     
    Last edited: Oct 7, 2020
  39. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    There's a warning that shows in the inspector and in the Rewired Input Manager when you try to edit a prefab instance and not the parent. Once you change something and cause the instance to go out of sync with the parent, changes to the parent will be overridden by the instance and you'll get different results. This is standard prefab override stuff and has to be managed by using the tools provided by Unity for synchronizing prefabs like Revert and Apply.

    If I were to do all this over again, I would not even use the prefab system and store all the data in a Scriptable Object. It's too late for that now. The prefab system has been a huge pain to deal with, especially after the change to the "new prefab workflow" which still has some issues.

    Use Rewired Instancer to instantiate the prefab into the scene instead of having it live in the scene and you won't run into this issue again because there will be no Rewired Input Manager instance in the scene hierarchy to accidentally click on.

    I don't see anything in your Controller Map Enabler Rule Sets that tells it to ever disable any Controller Maps. Just because your Rule Set says to enable "Combat", it's not automatically going to disable everything else. You have to explicitly make it do that.
     
    Last edited: Oct 7, 2020
  40. tcz8

    tcz8

    Joined:
    Aug 20, 2015
    Posts:
    504
    Was dropping by to ask something but I just figured it out, so I will take the opportunity to tell you all how much I LOVE REWIRED!

    It' has fixed so many problems for us, and this asset has one of the most supporting developer I have ever seen.

    Thank you SUPER... err, I mean GUAVAMAN! :D
     
    Delforce and guavaman like this.
  41. Derakon

    Derakon

    Joined:
    Jul 3, 2019
    Posts:
    20
    Great, thank you for the explanation and the solution!

    Alright, that makes sense. I need to explicitly disable maps (by making a rule with "Enabled" unchecked) or else they'll remain enabled.

    I want to echo what tcz8 said -- this asset has been a huge help to me, and I really appreciate that it's so well-supported. Thank you!
     
    guavaman likes this.
  42. Spabbage

    Spabbage

    Joined:
    Feb 15, 2015
    Posts:
    37
    Hey. Hopefully this is just a misunderstanding of fundamentals on my part.

    I have "ActionX" in "CategoryY" and GetButtonDown("ActionX") is true for this frame.

    If I call SetMapsEnabled(false, "CategoryY"); what should GetButtonDown("ActionX") now be if called straight after the map disable? In my tests it's still true but to me it feels like this should be false because the category is no longer enabled. Is it by design that GetButtonDown will always return the same value for the entire frame?

    Are there any Rewired workaround for this or shall I do it in my own code?

    Thanks!
     
  43. ObsidianSpire

    ObsidianSpire

    Joined:
    Sep 13, 2013
    Posts:
    48
    Hi, do you have any instructions for integrating Rewired with TopDown Engine? I'm trying to follow this blog when translated to English but I can't get the input to be recognized immediately after modifying the CorgiEngine integration like they seem to suggest should be happening. https://blog.gigacreation.jp/entry/2020/07/05/143213

    I tried adding "using namespace Rewired.Integration.CorgiEngine;" to the top of a script that calls for input to use the RewiredCorgiEngineInputManager script but it won't even find that namespace for some reason, so I'm a little lost.
     
  44. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Action values are evaluated when Rewired updates at the beginning of the frame and are constant for the entire duration of that frame. Disabling a Controller Map and checking it on that same frame will not clear the current Action value. The Action value will be updated on the next frame and become false at that time.
     
  45. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Sorry, no I don't. There is no official supported integration for Top Down Engine. If you want to make one, you are free to do so, but requires a thorough understanding of both Rewired and Top Down Engine. I am not going to be making or supporting any future integrations for other assets because they take too much time and effort supporting and maintaining them as the assets change and as people have problems.
     
  46. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    There has been a sudden influx of reports of Xbox Controllers no longer working in Windows. (This issue also affects DualShock 4, Nintendo Switch Pro Controller, and potentially all controllers.) This is not a Rewired issue, it is a Steam issue. The reports almost always also state that disabling native input and using Unity input as the source of input makes the problem go away. This is not a solution, and the fact it works is merely an artifact of the fact Unity input does not play well with Steam's input override system because Steam can't reliably hide these devices from Unity due to differences in how their system works.
    1. What controllers appear to Rewired are entirely determined by what Steam allows Rewired to see. Steam hooks the Windows input APIs to change what controllers are visible to the application. This is done so they can support their Steam Controller Configuration, Steam Remote Play, controlling remapping, and other Steam controller emulation features. Steam is blocking Rewired from seeing these controllers.
    2. Steam has 4 separate settings that determine how controllers are managed: The Steamworks developer backend settings for controller "configuration" for the application, the default developer-defined Steam Controller profile used by your application, the user client controller "configuration" settings, and the user Steam controller profile setting. These settings determine both what controllers Steam is allowed to “configure” and how those controllers appear to the application. (A "Steam-configured” controller is a controller that Steam has taken control over and has hidden the actual device from the application. It then creates a virtual device so the application can see only that virtual controller. This is how it handles things like button remapping and Steam Remote Play.)
    3. All Steam-configured controllers now appear as Steam Controllers to the application and work based on the Steam Controller settings in Steam (developer defaults and/or end-user).
    4. By default, with no Steam Controller profile to determine how a Steam Controller or a Steam-configured virtual controllers should behave, it defaults to behaving as a Keyboard + Mouse, and therefore Steam hides the devices from the application.
    5. Set the Steam Controller profile to Gamepad to make these Steam Controllers appear as gamepads and your controllers will appear again to Rewired. Alternately, if "configuration" of the controller is disabled in the developer backend settings or the user's client controller configuration, the controllers will appear to Rewired without modification from Steam and Rewired will be able to get input directly from the system.
    This is a Steam configuration issue and to make it work requires Steam’s settings for these controllers be configured correctly. Refer to the Steamworks documentation to understand how to configure controllers for your application.

    See important documentation on Steam and Rewired before attempting to use Rewired with Steam.
     
    Last edited: Oct 15, 2020
  47. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Notice:
    Unity 2019.4.x downloads the incorrect branch of Rewired from the Unity Package manager.


    Even up to the latest 2019.4.12f1, the Unity 2019 package manager downloads the Unity 2020 version of Rewired. Rewired 2020 was built to Unity 2020's libraries and is not compatible with Unity 2019. This is a new Unity Package Manager bug and I cannot fix it. I have reported it to Unity, but have received no response on the issue.

    If you are using Unity 2019.4, you cannot download Rewired from the Unity Asset Store because it will give you the wrong version. The only way to get the correct version is to contact me with your email address so I can give you direct access to download it from my website.
     
    Grumpy-Dot likes this.
  48. FriedelDev

    FriedelDev

    Joined:
    Sep 18, 2020
    Posts:
    2
    Hey, I've got reports of players experiencing a very severe lagspike and after further investigation I found what the cause of the issue is.
    1.Has to be a bluetooth/wireless controller (only seen it with Xbox One Wireless controllers and most likely only Xbox controllers as I suspect it is actually XINPUT acting out)
    2.Controller has to be suddenly disconnected(to test this I literally removed one of the batteries to simulate this)
    3.you have to set/change the vibration-value. I do that specifically with the Joystick.SetVibration-functionality.
    This will cause a severe lagspike and it will happen before we hear back from ControllerDisconnected or even ControllerPreDisconnected. For now I worked around this issue mostly by only changing the vibration when an actual change is detected and not setting it every frame but as I said it's a workaround and it's not a perfect one either.

    Let me know if you would know of a better workaround or even a fix for this. If you need any more details let me know since I'm able to replicate this pretty easily. Also if I remove the SetVibration-functionality the disconnect works as it should although the ControllerDisconnect-event might not be immediatly as well.
     
  49. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    I have been down these kinds of rabbit holes, especially with Xbox One Controllers, way too many times already to know that symptoms like this are always, without a doubt, caused by low-level Windows API functionality behaving improperly under a perfect storm of circumstances. It never turns out good. I spend days tracing down only to discover in the end some core function in the Windows HID API, Bluetooth, XInput, or something else causes the stall, cannot be worked around, and only happens with specific versions of Windows because of some driver Update Microsoft made to the Xbox One controller. You juggle and come up with crazy roundabout workarounds to dodge some issue in one driver, then it all blows up in the next driver or firmware update or new XInput controller they come out with. This has happened too many times to count. I just spent the last several hours down this rabbit hole yet again.

    I can reproduce it, but only under the following scenario:
    • 2 or more Xbox One controllers are attached.
    • At least one of these is a Bluetooth controller and connected via Bluetooth.
    • Vibrations are being sent continuously to the Bluetooth controller.
    • The battery is removed from the Bluetooth controller.
    • XInput still reports this device present for 2 or more seconds
    • The other controller has to be actively producing some input (may just be axis noise in some cases.)
    • Unity stalls and stutters until the device is fully disconnected.
    Non-instantaneous reporting of disconnections is because the underlying system (XInput) is not reporting the disconnection instantly.

    After a bunch of deep debugging of Rewired's XInput system, I am concluding that during this period where the Bluetooth device has been disconnected but has not been reported as disconnected:
    • Calls to XInput functions do not return with errors.
    • Calls to set vibration to XInput on the disconnected device apparently stall out the entire XInput system regardless of which thread is making the calls?
    • Calls to read input from XInput take an excessive amount of time, even on a separate thread, because of the calls to set vibration on the other thread?
    Upon further investigation, after doing a bunch of deep debugging on Rewired's XInput system, ultimately commenting out most of Rewired code so that it is not even ever calling any XInput functions except set vibration, I still was able to still see the massive lag happening on the main thread when moving the 2nd joystick during this lag out period. Then it dawned on me... Unity also uses XInput. Looking at the profiler, Rewired's InputManager_Base update doesn't show any spikes. Then I see "UpdateSceneManagerAndInput" reporting ~250 ms every frame during this period. This is a Unity function.

    So here's my conclusion:
    • Unity is calling functions in XInput on the main thread that are lagging out due XInput going into some kind of spasm because you are calling set vibration on a wireless Bluetooth controller that has been disconnected but XInput has not reported it disconnected yet and is not throwing errors when functions are being called on that device.
    • Even my most elaborate workarounds can't fix it because I can't disable Unity's input system. Rewired's multi-threaded system is already hiding this XInput API stall from you and is not stalling out the main thread when it happens, but Unity's input system is.
    • Only Microsoft can fix it. Unity could jump through hoops and implement workarounds like I keep doing, but they can't fix the underlying cause.
    I've dealt with these kinds of behavior before and they are the entire reason Rewired moved to a multi-threaded input/output system for XInput. The original Xbox 360 Controller never had a single hiccup. You could easily do everything from the main thread, including vibration and input with 4 devices, wired or wireless, without having to throttle the rate of vibrations you sent. It just worked perfectly, all the time. Ever since the Xbox One controller came out, XInput (and more so Raw Input) has become extremely brittle, finicky, full of incremental bugs with different versions of the driver, and requires all kinds of exotic workarounds to get things to work as one would expect they would. There's a ton going on under the hood to try to make it so the user can use XInput as it used to work before the days of Xbox One, but new edge cases keep getting exposed because their system is buggy and keeps changing. Xbox One controllers problems have easily consumed many hundreds of hours of my time over the different drivers, especially since Windows 10.

    Yet another thing to add to Known Issues. Otherwise I'll forget having done this and do it all again the next time someone reports again in a few months.
     
    Last edited: Oct 16, 2020
    ratking likes this.
  50. FriedelDev

    FriedelDev

    Joined:
    Sep 18, 2020
    Posts:
    2
    @guavaman really appreciate the thorough response. I'm sad to hear there is no fix, but I can appreciate the work you put in to getting the Rewired the most stable as possible. Keep on the good work as you are the best input solution out there! I do still have a possible question though, would it be possible to get some HID disconnect from Windows. If we can base it on that response we might be able to detect a disconnect sooner and make sure Unity doesn't lag out. Have you looked into that avenue yet?