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. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,607
    This is a sure indicator of the source of the problem. You are using UserDataStore_PlayerPrefs. You have the option enabled to save controller assignments. This is causing the controller to be assigned back to the previous owner when the data is loaded.

    The workaround is unnecessary. Disable this option in the inspector.
     
    Last edited: Aug 29, 2020
  2. InertialDrift

    InertialDrift

    Joined:
    Jan 3, 2018
    Posts:
    12
    Yeah I'm aware user data store is causing the problem, but disabling that option seemed to cause the saved custom mappings not to be loaded which is obviously the whole reason I'm using the user data store (I only tested this once because I already had an acceptable fix so I could be mistaken about how this works). Perhaps I'm supposed to trigger the loading manually in that case? Regardless, the controller isn't being assigned back to its previous owner, it's just being unassigned from System after I explicitly assign it there. After the data store runs neither System or Player 1 have the controller assigned so it just gets lost unless I go back and reacquire it through the controller list.

    In this circumstance I would have expected that either user data store would have left the controller assigned to System because it had already been directly assigned, or that it would have successfully assigned it to the player it previously belonged to, Player1, but just totally unassigning it from everyone seemed odd. It's also worth noting that this always happens for the first disconnect and reconnect after hitting play, but repeating the process worked fine and the controller stayed assigned to System so the results aren't even consistent.

    I had a bunch of other strange behaviour while debugging this at different points but this was the stuff I could reproduce reliably in a simple test scene.

    But yeah, again, I don't need this changed, I'm fine with having it wait a frame, I just wanted to let you know because I wasn't sure if this was all expected behaviour or not and figured it might save you some debugging time if someone else ran into it in the future.
     
  3. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,607
    Are you disabling the right option? I do not mean to disable the entire component. Disable the option "Load Joystick Assignments" and probably mouse and keyboard also. Disabling this option will not prevent saved Controller Maps from being loaded. This option only affects assignment of the controller to Players.

    If you have the UserDataStore_PlayerPrefs inspector option Load Data on Start enabled and Load Joystick Assignments enabled, the Joystick assignment will be loaded on start before you script executes. This will load whatever the last saved assignment was. It will also save assignments at this time if there are any Joysticks connected, so this will save an empty assignment list for each Player since you have Joystick Auto Assignment disabled.

    Last saved assignment does not mean the last assignment you made. Data is not saved when you make an assignment. Saving and loading are explicit processes that only happen at certain points. Saving of assignments only happens on start (if Load Data on Start is enabled), when all the data is saved manually, or when a Joystick is connected or disconnected.

    Controller assignment save data is not a history of controllers that were assigned previously to the Player. It is only a single snapshot of the controllers assigned to that Player at the time it is taken. So saving controller assignments cannot substitute for the Joystick Auto Assignment system to make sure the last Player that owned a controller gets that controller when it is attached again. Further, the assignment snapshot is saved after a controller is disconnected, so if you unplug the last Joystick from the Player, it saves an empty snapshot of controllers. The purpose of "Load Joystick Assignments" is to essentially save the state of assignments when you quit the application so you can resume from the same state the next time you start provided the same Joysticks are still present.

    Another thing is also happening here which explains the inconsistency you're seeing:
    OnControllerConnected

    Code (csharp):
    1. // Load joystick assignments once on connect, but deferred until the end of the frame so all joysticks can connect first.
    2. // This is to get around the issue on some platforms like OSX, Xbox One, and iOS where joysticks are not
    3. // available immediately and may not be available for several seconds after the Rewired Input manager or
    4. // Unity starts. Also allows the user to start the game with no joysticks connected and on the first
    5. // joystick connected, load the assignments for a better user experience on phones/tablets.
    6. // No further joystick assignments will be made on connect.
    7. if (loadDataOnStart && loadJoystickAssignments && !wasJoystickEverDetected) {
    8.     this.StartCoroutine(LoadJoystickAssignmentsDeferred());
    9. }
    This is called the first time you plug in a controller regardless of when that occurs. The loading of assignments happens at the end of the frame using a coroutine. This is what is overwriting your script's assignment of the Joystick to the System Player the first time you actively plug in a controller at runtime. This should probably not run if it has already detected joysticks present on Awake, but that's how it works at present. If this is what you want, add this to line 346: wasJoystickEverDetected = true;

    Based on what I think you are trying to achieve, you should simply disable Load Joystick Assignments. It can't be used reassign a previously connected Joystick to the same Player that previously owned it during a session.
     
    Last edited: Aug 29, 2020
  4. InertialDrift

    InertialDrift

    Joined:
    Jan 3, 2018
    Posts:
    12
    So I just double checked there, and if I untick Load Joystick Assignments, Load Mouse Assignments and Load Keyboard assignments then it doesn't load saved controller remappings. If I tick them again then the remapped controls are successfully loaded. Load Data On Start was always ticked. I'm testing that in my full game rather than a simple reproduction case so there may well be something more complex going on in my code that is causing it but I don't interact directly with the user store other than to save the assignments when closing the menu which is clearly working.

    It totally makes sense given what you've said that I should have those off as saving player joystick assignments is not something I want at all, and disabling just that would have solved the issue for me, but when I tested it and loading controller mappings stopped working I assumed that "Load Joystick Assignments" must mean button assignments rather than player assignments so that explains the confusion. I'll try and investigate the Load Assignment thing further if I have some time to work out if that is caused by something I'm doing or if I can reproduce it in the simplest case.
     
  5. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,607
    Saving controller assignments was added much later than the rest of the system due to repeated requests that controller assignments be saved. None of the code that saves Controller Maps is affected by disabling those options.

    What is happening to you is more complicated, and again happens because you have Auto Assign Joysticks disabled.

    This information is important:
    https://guavaman.com/projects/rewired/docs/ControllerMaps.html#joystick-maps

    How Joystick Maps are Loaded
    Joystick Maps for a particular Joystick do not exist in the Player unless that Joystick is currently connected and assigned to that Player. By default, Rewired auto-assigns Joysticks to each Player as controllers are detected. The Joystick Maps are loaded at assignment time based on the settings defined in the Rewired Input Manager - Player page for that particular Player.

    -----

    This is the sequence of events happening in your project.

    1. Application starts with controllers connected but not assigned to any Players.
    2. UserDataStore_PlayerPrefs runs Awake and loads saved user data.
    3. Because no Joysticks are assigned to any Players, no joystick map data is loaded in those Players.
    4. Your script runs and assigns Joysticks to each Player.
    5. The Player loads the default Controller Maps for the Joystick at the time it is assigned.

    UserDataStore_PlayerPrefs does not monitor Players for when a controller is assigned to them and load saved user data. If you are managing your own Joystick assignment, you also have to manage when the data is saved and loaded.

    IUserDataStore has various functions to load and save data depending on what you need to load or save.

    This does not happen with Joystick Auto Assignment because each Joystick will be assigned to a Player the moment it is connected or at start and UserDataStore_PlayerPrefs will therefore be able to load saved user data for that device assigned to the Player.

    As a side note, if you use LayoutManager for map management, it has the option to load controller maps from saved user data and that does trigger on controller assignment.
     
    Last edited: Aug 30, 2020
  6. amynox

    amynox

    Joined:
    Oct 23, 2016
    Posts:
    177
    Hi,

    is it normal that rewired generate GC on every frame ? (Unity 2020.1.3f1)



    Ps: replacing RaycastAll with RaycastNonAlloc may resolve the issue ?
     
    Last edited: Aug 30, 2020
  7. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,607
    The call to EventSystem.RaycastAll comes from Unity's own PointerInputModule source code which is the basis of the RewiredPointerInputModule.

    There is no EventSystem.RaycastAllNoAlloc function. The EventSystem class is Unity's class and in their UI package. I cannot modify the source of their EventSystem without copying it and maintaining my own branch of EventSystem, requiring users replace the EventSystem component with my own, and always keep the source code of it in sync with whatever changes they make to the Event System over time. That's not something I'm not willing to do to work around this GC penalty generated by Unity UI's core system.

    To answer your question, yes, it is normal for the PointerInputModule to generate garbage every frame because that is how Unity designed it. This is an issue in Unity, so I would report it to them.
     
    amynox likes this.
  8. InertialDrift

    InertialDrift

    Joined:
    Jan 3, 2018
    Posts:
    12
    Ok, that makes a lot of sense. I just need to load the data for a player any time I assign them a controller then. I guess I was lulled into a false sense of security about the amount of automation happening because things just worked without me doing anything, but there's actually a little bit of stuff that I should be doing myself given that I've taken over responsibility for controller assignment.

    Presumably a similar thing will happen at the moment if I were to move a controller from Player 1 to Player 2, where Player 2 wouldn't get their custom mappings loaded for that controller. If that is the case it might be worth sticking a line in the docs to warn that maps need to be loaded if controllers are manually reassigned. I think if I'd had that in mind from the start I'd have had a better understanding of what was actually going wrong. It totally makes sense when you understand that mappings can only be loaded for attached joysticks, but from the outside that wasn't really on my radar and I basically just assumed that if any of the data was loaded then all of the data was loaded.

    I feel like that explains all the behaviour I was seeing now though so hopefully that's the last I'll be bothering you! Thanks for taking the time
     
  9. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,607
    I'm glad this explains your problem.

    It is always a problem for me when people ask that I document negatives -- when something doesn't happen or doesn't work the way they think it might. That requires that I anticipate any possible misunderstanding one might have about this system. This is really not feasible because there are virtually unlimited ways one could misunderstand every part of the system (because these kinds of misunderstandings happen across the entire system in a multitude of different ways on a very regular basis).

    What exactly UserDataStore_PlayerPrefs does do is documented:

    UserDataStore_PlayerPrefs

    This is a user data storage component that uses Unity's PlayerPrefs class for storing data. Whenever a controller is attached, if any data has been saved before for that controller, it will be loaded from PlayerPrefs. If the user has customized his control mappings, these will be loaded on a per-player, per-controller basis. Controller calibration settings and customized Input Behavior settings will also be loaded. Data will be saved manually when Save() is called or automatically when a controller is disconnected from the system.

    If "Load Data on Start" is checked in the inspector, all controller data will be loaded at the beginning of the session.
    This is useful if you want the player's last settings to be loaded automatically for any controllers already attached to the system at runtime.

    ---

    This documents the 3 types of automatic load/saving UserDataStore_PlayerPrefs does. Nothing beyond these 3 triggers is implied.

    Even if Joystick Auto-Assignment is enabled, assigning a Joystick to another Player will not cause UserDataStore_PlayerPrefs to load saved Controller Maps for that Player (however Control Mapper will because it explicitly makes a call to UserDataStore to load this data when a controller assignment is changed through the UI). That might be something I should consider changing, but at the present time, that is not the case. There might be some issues doing that though since the user may have modified controller maps already during the session for a Player without saving them to XML/JSON, and therefore triggering a load on assignment would overwrite these values. I would also have to implement auto-saving on de-assignment of controllers, which again, may be undesirable for a variety of reasons. These kinds of individual use-cases are the reason most of the system is left un-automated beyond the most common scenario of using Joystick Auto-Assignment and loading the saved maps on start and when the controller is first connected. UserDataStore_PlayerPrefs was always meant to be a minimum viable product primarily used by Control Mapper. More complex requirements are to be implemented by the developer by extending the UserDataStore class.

    The important concept that Joystick maps do not exist in a Player until that Joystick is assigned to the Player is documented on the Controller Maps page:

    How Joystick Maps are Loaded
    Joystick Maps for a particular Joystick do not exist in the Player unless that Joystick is currently connected and assigned to that Player. By default, Rewired auto-assigns Joysticks to each Player as controllers are detected. The Joystick Maps are loaded at assignment time based on the settings defined in the Rewired Input Manager - Player page for that particular Player.

    ----

    I understand there could be confusion between "loading a Controller Map" (from the Rewired Editor default configuration) and UserDataStore_PlayerPrefs loading saved Controller Maps from saved data. However, the core concept that a Joystick Map cannot exist in a Player for a Joystick that is not assigned to that Player applies here and is the reason the saved Controller Maps are not loaded in the Player if the controller is not assigned to that Player at the time UserDataStore_PlayerPrefs loads data.
     
    Last edited: Aug 30, 2020
  10. InertialDrift

    InertialDrift

    Joined:
    Jan 3, 2018
    Posts:
    12
    Yeah I totally understand this is complicated. I had read the bits you highlighted, and for what it's worth I think the line that's tricky is "If "Load Data on Start" is checked in the inspector, all controller data will be loaded at the beginning of the session". If you don't understand how this works, "All controller data" sounds like data for all controllers, connected or not connected, assigned or unassigned, but it's actually "all controllers currently assigned to a player", so yeah, it wasn't obvious to me that I needed to load stuff manually if that wasn't set.

    Incidentally I think it's fine that stuff is left unautomated, in fact I think the thing that tripped me up here was actually the amount of stuff that was already automated and so I didn't even realise what aspects actually needed manual intervention. So yeah, that was my only suggestion, that it being slightly more obvious at what point you need to do stuff manually might have been helpful. Obviously though, you're welcome to take that suggestion or ignore it, I don't mind, I understand it now anyway.
     
  11. the_mr_matt

    the_mr_matt

    Joined:
    Jul 21, 2015
    Posts:
    124
    Having trouble loading default bindings for new actions. I created an action and assigned values to the gamepad template. Obviously these mapping won't be present in the game save at first. However they are not being loaded in. I'm using a the UserDataStore_PlayerPrefs and I found a method called AddDefaultMappingsForNewActions. Any ideas why it might not be assigning?
     
  12. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,607
    That function is part of UserDataStore_PlayerPrefs and attempts to merge bindings for new Actions into old save data. This is a very basic hack to allow you to add an Action and a default binding to existing save data. It can only work under very limited circumstances. It cannot substitute for proper management of saved data.

    There are many scenarios where this won't work. If the new binding conflicts with anything on the Controller Map, it is skipped. This check happens only once. The next time you save data for that Controller, the known Action id list is updated and it will no longer perform this check the next time you load. This list of known Action ids is not saved per-controller map. It is saved per-Player, per-Controller. If you save any Controller Map, the id list will be updated for all Controller Maps for that device + Player and another Controller Map later loaded for that device + Player will not longer have the new binding.

    This function was a simplistic hack designed for the most-common-use-cases because of user requests. I really should never have added it because it adds the expectation that it will do more than it does.
     
  13. the_mr_matt

    the_mr_matt

    Joined:
    Jul 21, 2015
    Posts:
    124
    Any ideas for a workaround? Easiest solution is to just clear the user saved data and load the whole default mappings but I'd like to preserve the players data if possible.
     
  14. bladerunner69008

    bladerunner69008

    Joined:
    May 2, 2019
    Posts:
    25
    Before buying the gem, I would like to be sure it will do what I expect:

    I would like to ignore all joystick inputs and just get mouse/keyboard inputs.
    Will Rewired help ?

    Working on Unity 2019.4
     
  15. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,607
    What I implemented in UserDataStore_PlayerPrefs was already workaround. I do not know why your specific case is failing, so I can't tell you what to do to make it work if that's even possible. You'd have to debug it to know exactly why it's not able to add the binding. But I won't be trying to enhance this system to make it more robust for merging new bindings after the fact into saved user data and to handle more use cases. Management of user data after it is saved is up to the developer to implement. UserDataStore_PlayerPrefs is just a starting point, primarily written to work with Control Mapper and fulfill the most common use cases. If you need more sophisticated behavior, you need to replace it with your own system extending UserDataStore as the documentation states. Eliminating PlayerPrefs from the equation and using your own data storage system gives you far more flexibility in what you want to do because you have the ability to catalog and search saved data, modify it, clear information separate from clearing all PlayerPrefs, etc, etc.
     
    Last edited: Sep 1, 2020
  16. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,607
    Download the fully functional trial. You have the entire system at your disposal to evaluate in any way you want. Nobody should ever buy Rewired before using the trial.

    No input is processed unless you set it up to be processed by the Player. This is implicit in the design of the Controller Map system. Read the documentation and learn how the system works.
     
    Last edited: Sep 1, 2020
  17. bladerunner69008

    bladerunner69008

    Joined:
    May 2, 2019
    Posts:
    25
    I am playing with it and it seems to work !

    Is the migration to the paying version quite seamless or everything should be started all over again ?
     
    Last edited: Sep 1, 2020
  18. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,607
    There are zero differences. Only the DLLs are different. No data is changed regardless of the version you use.
     
  19. DziDAI

    DziDAI

    Joined:
    Dec 6, 2012
    Posts:
    68
    Hello @guavaman

    Does it have any possibilities to tune length of gesture in touchpad (without scripting) I mean value returned for GetAxis method for touch distance?

    Second question regarding delay with touchpad and buttons over them. I use touchpad for camera rotating.
    I have two buttons over touchpad (fire and jump, I can fire while I move and rotate camera), and when I clicked on any button (under touchpad), I guess this click go down through them and reaches touchpad immediately

    BUT, right now I see another behaviour, when I clicked on any button over touchpad, touchpad not worked immediately (I clicked o button and try to swipe) touchpad starts work when highlighted animation on button finished. How disable this timeout for touchpad?
     
  20. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,607
    No. You get the value you specify in the inspector based on the type of data you specified to be returned. Beyond that, it does not provide any way to transform or process this data. You do that in your script if that's what you want to do with the data.

    There is no timeout. You are not understanding what's happening.

    It's not possible for the Touch Pad to detect touches through a Button. The Touch Controls use Unity UI and its raycast system like all UI elements use. Raycast hits ONE target -- only the highest enabled control in the Canvas hierarchy.

    The reason you are able to continue using your Touch Pad when you move your finger over a Button after first touching the pad first is you have enabled "Stay Active on Swipe Out" on the Touch Pad. The initial touch was detected on the Touch Pad because you pressed on an area that wasn't covered up by a button so the raycast hit the Touch Pad, then you moved your finger over a Button. The Touch Pad still has that touch "captured" and so it still uses your finger position even though it's no longer over the touch pad and continues to send data. The Button will activate only if you have "Activate on Swipe In" enabled.

    If, however, your first touch is over the Button, the the Touch Pad will not see that until your finger moves out of the rectangle of the button UI Image so the raycast can hit the Touch Pad. This is the "delay" you're seeing. The Touch Pad cannot know you are pressing anything because it is covered up by the button and the touch never reaches it. If "Activate on Swipe In" is enabled on the Touch Pad, when your finger moves outside the Button rect, the Touch Pad will capture and begin sending back data.

    There's no way to make the Touch Pad activate when you press the Button on top of it. The only way I can think of doing this is to disable the button Image component raycastTarget once it is touched and re-enable it when it is deactivated. The button would also have to have "Activate on Swipe In" enabled for this to work. Touch Button Manage Raycasting also may need to be disabled.
     
    Last edited: Sep 2, 2020
  21. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Quick question @guavaman
    Is possible to get the actual category name (not the categoryId!) of an Map Category or Action Category via scripting?
    I want to create some custom Inspectors where the designer can select a potential category from a dropdown.
     
  22. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,607
    Scripting cannot be used at edit time to get any information from Rewired because Rewired is a static class that is populated with the current enabled Rewired Input Manager when the GameObject awakens when you hit Play.

    This is all that is available for that purpose:
    https://guavaman.com/projects/rewired/docs/HowTos.html#actionid-property-drawer

    Otherwise, you'd have to have an inspector link to the Rewired Input Manager and used undocumented editor functions to get the data you want from the linked Rewired Input Manager.
     
    BTStone likes this.
  23. socialtrens

    socialtrens

    Joined:
    Oct 23, 2017
    Posts:
    64
    I can confirm that Fall Guys (the currently popular but cute battle royale) is using Rewired for their input system! In fact I know Rewired after inspect Fall Guys source code. Why you not add them into your portfolio?
     
  24. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,607
    Thanks for the information! In order to show games on my list of games made with Rewired, I have to get permission from the developer/publisher.
     
  25. ge01f

    ge01f

    Joined:
    Nov 28, 2014
    Posts:
    121
    @guavaman Any update on framerate independent input? I saw there are some threads where the new input system seems to make this possible.

    Im doing some Street Fighter type controls, and it is easy to drop inputs if they are done quickly, and fast input handling is preferred for that type of control.

    Any news on this?
     
  26. ratking

    ratking

    Joined:
    Feb 24, 2010
    Posts:
    349
  27. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,607
    No there are no plans to do this. See the FAQ. It's far too fraught with problems to do with the frame-based structure of Unity and Rewired and has limitations based on each individual platform, input API, and even device type.
    https://guavaman.com/projects/rewired/docs/FAQ.html#framerate-independent-input
     
  28. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,607
    ratking likes this.
  29. Ziron999

    Ziron999

    Joined:
    Jan 22, 2014
    Posts:
    282
    I have a custom tcpclient server and integrated myself with thread handling. Will this be possible with it? Does it use input OUTSIDE of the main update thread in unity for a huge performance boost? Does it not use "string" based key searching? Horrible on performance as well..

    These are the 3 key things I am looking for.

    Also, ya OnGUI SUCKS!
     
    Last edited: Sep 10, 2020
  30. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,607
    No. Rewired only works in Update, FixedUpdate, and OnGUI. See the FAQ:
    https://guavaman.com/projects/rewired/docs/FAQ.html#framerate-independent-input

    Rewired uses strings for nothing unless you choose to do so. There is always an integer constant way to do everything.
     
  31. vsertich

    vsertich

    Joined:
    Aug 11, 2017
    Posts:
    2
    Hello. We recently upgraded to Unity 2020.1.4f1. We updated Rewired to the latest too.
    When we run the game and try to access the control set up it crashes and gives this error.
    _____
    Rewired Control Mapper: All references must be assigned in the inspector!
    UnityEngine.Debug:LogError(Object)
    Rewired.UI.ControlMapper.ControlMapper:Initialize() (at Assets/Rewired/Extras/ControlMapper/Scripts/ControlMapper.cs:795)
    Rewired.UI.ControlMapper.ControlMapper:Open(Boolean) (at Assets/Rewired/Extras/ControlMapper/Scripts/ControlMapper.cs:3101)
    Rewired.UI.ControlMapper.ControlMapper:Open() (at Assets/Rewired/Extras/ControlMapper/Scripts/ControlMapper.cs:3098)
    MainMenuManager:OnControlSetupClicked() (at Assets/_Scripts/Managers/MainMenuManager.cs:322)
    UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
    Rewired.Integration.UnityUI.RewiredStandaloneInputModule:SendSubmitEventToSelectedObject() (at Assets/Rewired/Integration/UnityUI/RewiredStandaloneInputModule.cs:830)
    Rewired.Integration.UnityUI.RewiredStandaloneInputModule:process() (at Assets/Rewired/Integration/UnityUI/RewiredStandaloneInputModule.cs:685)
    UnityEngine.EventSystems.EventSystem:Update() (at C:/Program Files/Unity/Hub/Editor/2020.1.4f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:376)
    ______

    Here's a link to an image of the console: https://imgur.com/OwffUye

    I can't figure out what is missing. It seems like everything is assigned.
    Is there a common thing that needs to be re-assigned when you update?
     
  32. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,607
    No. This is the result of Unity serialization corruption. It happens all the time and has been happening for years when updating projects.

    https://guavaman.com/projects/rewir...ialized-data-corruption-after-upgrading-unity

    The newer versions of this corruption always happen to Control Mapper. There is no reason for this, but it happens anyway. It's been happening to Control Mapper since their new prefab system introduced in 2018 or 2019 at some point. Unity's got some kind of problem reading these GameObjects and I don't know why.

    There is nothing I can do about it when Unity corrupts GameObject serialized data. The references to all the prefabs used by Control Mapper are broken in the inspector and no longer point to the objects they originally pointed to before you upgraded. You either have to manually fix the references (but there may be more problems across all the different objects in the hierarchy), delete and rebuild the Control Mapper, or restore backups of the GameObjects.
     
  33. vsertich

    vsertich

    Joined:
    Aug 11, 2017
    Posts:
    2
    Thank you for the response. It's a bummer, but I'm relieved to know what it is now.
     
  34. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,607
    If the Control Mapper prefab is corrupted, deleting the Control Mapper folder and reinstalling Control Mapper from the menu might fix it.
     
  35. spacefrog

    spacefrog

    Joined:
    Jun 14, 2009
    Posts:
    734
    Are there any known W7 - XboxOne Controller reconnect issues for the following situation ?
    * Windows 7
    * XBox One Controller
    * Unity 2019 or 2020 , Rewired 1.35.3 or 1.36
    * Xinput enabled ( + Raw Input, but that doesnt seem to matter )

    As soon i enter playmode in editor or run the build, unplugging and replugging the Xbox One Controller enters an infinite connected/disconnected loop ( without further user action - all happens by itself) . I have the impression the Xbox One controller takes too long to warm up ( and finished its reconnect vibration ) and Rewired interprets that as disconnected controller
    I do NOT have this problem when i dual boot into W10 ( same hardware , same situation, same project ). Or with any other controller i tested ( Xbox 360 , PS4 Dualshock )
    I wanted to add that this problem appears as soon as a vanilla ( non-prefab) Rewired InputManager + assigned ControllerDatafiles sits in the scene, so i have the suspicion its not a config issue on my side, but something in the Rewired core for windows ...

    Only thing that helps is DISABLING XInput, which is apparently not recommended on Windows ...

    any clue ?
     
    Last edited: Sep 12, 2020
  36. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,607
    Sounds like a hardware problem to me. There is nothing in Rewired's code that would do this. The only way it would be detecting multiple connects and disconnects is if XInput is telling it there is no controller, then there is a controller, then there is no controller. This issue is below Rewired at the hardware/driver/system level.

    XInput should not be reporting a connected device until the vibration happens.
     
  37. Unlimited_Energy

    Unlimited_Energy

    Joined:
    Jul 10, 2014
    Posts:
    469
    Just updated to Unity 2019.4.10 and the Launch Rewired Editor button on teh Input Manager script is not launching the editor anymore now. No Errors in the compiler.
     
    Last edited: Sep 12, 2020
  38. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,607
    Last edited: Sep 12, 2020
  39. Plesioth

    Plesioth

    Joined:
    Jun 10, 2015
    Posts:
    6
    How do you equate specific controller indices with "button top 1, button top 2, etc" via code? I'm trying to make heads or tails of how I'm supposed to show proper button prompts but it's quite an uphill battle here. I spent 3 days, wake to sleep, figuring out remapping via code, which was a huge pain, but it's all working now. I love this tool but it truly could use some better documentation than reading 10k lines of code... Keep up the good work!

    EDIT: I just had an idea to use the descriptive name of the button as a key to a dictionary. Is this intended?
     
    Last edited: Sep 13, 2020
  40. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,607
    No. Never use descriptive strings as keys. They are prone to change or not be the same on all platforms.

    There's documentation on how to display glyphs for controller elements:
    https://guavaman.com/projects/rewired/docs/HowTos.html#display-glyph-for-action

    There is no such association of index X always equals a certain button on all controllers. Every single controller has a completely unique layout and completely unique id list. Each controller has to be handled separately.

    If you are trying to generalize for all supported gamepads, then you would base it off of the Gamepad Template, but that will only work with the explicitly supported gamepads that implement the Gamepad Template. For all other controllers, they have to be supported independently or fall back to a catch-all.

    Re: Rewired should have better documentation...

    I have been told many, many times that there is no product on the Unity asset store with more complete documentation than Rewired. The documentation is the equivalent of over 600 book pages of text, and that does not include the API reference and XML documentation. The documentation alone took several months to write. There is a point at which enough is enough and I cannot afford to spend even more time writing documentation, tutorials, and examples.

    And remapping is and always has been considered an advanced topic for hardcore programmers only. It says as much in the documentation. That's why I include the complete, drop-in Control Mapper system. If you don't want to or can't figure out how to all the programming tasks required for the job by going through the 4 example projects provided, you can just drop it in and use it.
     
    Last edited: Sep 13, 2020
  41. Plesioth

    Plesioth

    Joined:
    Jun 10, 2015
    Posts:
    6
    I'll check it out. Skimming it, I did find a missing link between A and B that I was searching for, so this should be fine.

    Also don't take the documentation thing personally, my guy. It wasn't intended as an attack, just voicing frustration at how much of an uphill battle this is being. I know how frustrating writing documentation is, so I don't really blame you for just being done with it. I really appreciate all the work you've put into this.
     
  42. spacefrog

    spacefrog

    Joined:
    Jun 14, 2009
    Posts:
    734
    Vibration starts for a short moment on reconnect - but then a Disconnect happens ( again: only when Rewired Input Manager is active - without it in the scene , Unity Editor handles disconnect reconnect flawlessly )

    Regarding potential hardware issue:
    Tested on a completely different machine - still happens when running the build on W7 ( W10 didnt ever show the problem )
    changed USB cables and USB ports, happens on all of them
    Another Xbox one controller ( the one from my Devkit ) doesnt show this problem though, so im not quite sure ...
     
  43. Erveon

    Erveon

    Joined:
    Sep 15, 2019
    Posts:
    13
    How can we display positive & negative axis bindings within the control mapper on a case-by-case basis? For some actions we'd like them to be available to bind and others we don't.
     
  44. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,607
    Rewired can't disconnect a controller from the system. It has no capacity to do so. If the controller is being disconnected from the computer when Rewired is running and not when it isn't, then the only possible explanation is a Windows-level bug (and there have been scores with these controllers over the years.) Why might Unity not behave the same way? Because Unity does not use Raw Input for joysticks. Unity uses XInput for Xbox controllers and reads input reports directly from the HID devices. They never register joysticks for Raw Input events. This an entirely different code path. There were at least 4 different cases of Raw Input system-level crashes with Xbox devices over different versions of Windows 10 as they kept introducing new bugs into the driver. Unity was never affected because they never registered this device for Raw Input events and Rewired did. Apparently Microsoft doesn't test Raw Input.

    This sounds like yet another classic Windows Xbox driver bug that just so happens to be triggered by the specific Windows APIs Rewired uses. There are so many attempted workarounds for problems like this in the code already for the various generations of Windows 10 driver bugs. At some point, the layer on top cannot compensate for the bugs beneath it. A workaround that fixes one particular bug in one particular driver version then cascades into revealing a new bug with a previous driver version...
     
    spacefrog likes this.
  45. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,607
    If the Action is a Button type Action it will not show +/- binding fields.
     
  46. KarlKarl2000

    KarlKarl2000

    Joined:
    Jan 25, 2016
    Posts:
    606
    Hi @guavaman

    I'm not sure if this is a Rewired issue or something else. I see something about Rewired_Core23.cpp.
    Do you have some suggestions? I installed the latest rewired from the package manager.

    I'm using Unity 2020.1.4f1

    Thank you!


    Code (CSharp):
    1.  
    2. Building GameAssembly.dll with MsvcDesktopToolChain
    3.     Msvc Install Version: 15.0
    4.     Msvc Install SDK Directory: C:\Program Files (x86)\Windows Kits\10
    5.     Msvc Linker Path: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\bin\HostX64\x64\link.exe
    6.     Msvc Compiler Path: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\bin\HostX64\x64\cl.exe
    7.  
    8.     Output directory: C:\ProjectY\Temp\StagingArea\Data\Native
    9.     Cache directory: C:\ProjectY\Library\il2cpp_cache
    10. il2cpp.exe didn't catch exception: Unity.IL2CPP.Building.BuilderFailedException: Rewired_Core23.cpp
    11. C:\ProjectY\Temp\StagingArea\Data\il2cppOutput\Rewired_Core23.cpp(30329) : fatal error C1001: Internal compiler error.
    12. (compiler file 'd:\agent\_work\7\s\src\vctools\Compiler\Utc\src\p2\main.c', line 195)
    13. To work around this problem, try simplifying or changing the program near the locations listed above.
    14. If possible please provide a repro here: https://developercommunity.visualstudio.com
    15. Please choose the Technical Support command on the Visual C++
    16. Help menu, or open the Technical Support help file for more information
    17.  cl!RaiseException()+0x69
    18.  cl!RaiseException()+0x69
    19.  cl!CloseTypeServerPDB()+0x22e6b
    20.  cl!CloseTypeServerPDB()+0xcd30a
    21.  
    22. Invocation was: Executable: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\bin\HostX64\x64\cl.exe"
    23. Arguments: "C:\ProjectY\Temp\StagingArea\Data\il2cppOutput\Rewired_Core23.cpp" /nologo /c /bigobj /W3 /Z7 /EHs /GR- /Gy /utf-8 /wd4102 /wd4800 /wd4056 /wd4190 /wd4723 /wd4467 /wd4503 /wd4996 /wd4200 /wd4834 /Ox /Oi /Oy- /GS- /Gw /GF /Zo /Yupch-cpp.hpp /Fp"C:\ProjectY\Library\il2cpp_cache\72EF9B0B204B11B4F295428CCEAD1EC6.pch" /MT /DNET_4_0 /DUNITY_AOT /DIL2CPP_MONO_DEBUGGER_DISABLED /DGC_NOT_DLL /DRUNTIME_IL2CPP /DBASELIB_INLINE_NAMESPACE=il2cpp_baselib /D_WIN32 /DWIN32 /DWIN32_THREADS /D_WINDOWS /DWINDOWS /D_UNICODE /DUNICODE /D_CRT_SECURE_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS /D_WINSOCK_DEPRECATED_NO_WARNINGS /DNOMINMAX /D_NDEBUG /DNDEBUG /DWINDOWS_SDK_BUILD_VERSION=19041 /DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP /I"C:\Program Files\Unity\Hub\Editor\2020.1.4f1\Editor\Data\il2cpp\libil2cpp" /I"C:\Program Files\Unity\Hub\Editor\2020.1.4f1\Editor\Data\il2cpp\libil2cpp" /I"C:\Program Files\Unity\Hub\Editor\2020.1.4f1\Editor\Data\il2cpp\external\bdwgc\include" /I"C:\Program Files\Unity\Hub\Editor\2020.1.4f1\Editor\Data\il2cpp\external\xxHash" /I"C:\Program Files\Unity\Hub\Editor\2020.1.4f1\Editor\Data\il2cpp\external\baselib\Include" /I"C:\Program Files\Unity\Hub\Editor\2020.1.4f1\Editor\Data\il2cpp\external\baselib\Platforms\Windows\Include" /I"C:\Program Files\Unity\Hub\Editor\2020.1.4f1\Editor\Data\il2cpp\libil2cpp\pch" /I"C:\ProjectY\Temp\StagingArea\Data\il2cppOutput" /I"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\winrt" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt" /Fo"C:\ProjectY\Library\il2cpp_cache\B2F7742428966665D56E066A727674C1.obj" /Fd"C:\ProjectY\Library\il2cpp_cache\B2F7742428966665D56E066A727674C1.pdb"
    24. EnvArg key: PATH value: C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64;C:\Program Files (x86)\Windows Kits\10\bin\x64;C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x86;C:\Program Files (x86)\Windows Kits\10\bin\x86;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\bin\HostX64\x64
    25.  
    26.   at Unity.IL2CPP.Building.CppProgramBuilder.BuildAllCppFiles(IEnumerable`1 sourceFilesToCompile, IBuildStatisticsCollector statisticsCollector)
    27.   at Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics)
    28.   at il2cpp.Compilation.CompilationDriver.Run(RuntimePlatform platform, BuildingOptions buildingOptions)
    29.   at il2cpp.Program.DoRun(String[] args, RuntimePlatform platform, BuildingOptions buildingOptions)
    30.   at il2cpp.Program.Run(String[] args, Boolean setInvariantCulture)
    31.   at il2cpp.Program.Main(String[] args)
    32. stderr:
    33. Unhandled exception. Unity.IL2CPP.Building.BuilderFailedException: Rewired_Core23.cpp
    34. C:\ProjectY\Temp\StagingArea\Data\il2cppOutput\Rewired_Core23.cpp(30329) : fatal error C1001: Internal compiler error.
    35. (compiler file 'd:\agent\_work\7\s\src\vctools\Compiler\Utc\src\p2\main.c', line 195)
    36. To work around this problem, try simplifying or changing the program near the locations listed above.
    37. If possible please provide a repro here: https://developercommunity.visualstudio.com
    38. Please choose the Technical Support command on the Visual C++
    39. Help menu, or open the Technical Support help file for more information
    40.  cl!RaiseException()+0x69
    41.  cl!RaiseException()+0x69
    42.  cl!CloseTypeServerPDB()+0x22e6b
    43.  cl!CloseTypeServerPDB()+0xcd30a
    44.  
    45. Invocation was: Executable: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\bin\HostX64\x64\cl.exe"
    46. Arguments: "C:\ProjectY\Temp\StagingArea\Data\il2cppOutput\Rewired_Core23.cpp" /nologo /c /bigobj /W3 /Z7 /EHs /GR- /Gy /utf-8 /wd4102 /wd4800 /wd4056 /wd4190 /wd4723 /wd4467 /wd4503 /wd4996 /wd4200 /wd4834 /Ox /Oi /Oy- /GS- /Gw /GF /Zo /Yupch-cpp.hpp /Fp"C:\ProjectY\Library\il2cpp_cache\72EF9B0B204B11B4F295428CCEAD1EC6.pch" /MT /DNET_4_0 /DUNITY_AOT /DIL2CPP_MONO_DEBUGGER_DISABLED /DGC_NOT_DLL /DRUNTIME_IL2CPP /DBASELIB_INLINE_NAMESPACE=il2cpp_baselib /D_WIN32 /DWIN32 /DWIN32_THREADS /D_WINDOWS /DWINDOWS /D_UNICODE /DUNICODE /D_CRT_SECURE_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS /D_WINSOCK_DEPRECATED_NO_WARNINGS /DNOMINMAX /D_NDEBUG /DNDEBUG /DWINDOWS_SDK_BUILD_VERSION=19041 /DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP /I"C:\Program Files\Unity\Hub\Editor\2020.1.4f1\Editor\Data\il2cpp\libil2cpp" /I"C:\Program Files\Unity\Hub\Editor\2020.1.4f1\Editor\Data\il2cpp\libil2cpp" /I"C:\Program Files\Unity\Hub\Editor\2020.1.4f1\Editor\Data\il2cpp\external\bdwgc\include" /I"C:\Program Files\Unity\Hub\Editor\2020.1.4f1\Editor\Data\il2cpp\external\xxHash" /I"C:\Program Files\Unity\Hub\Editor\2020.1.4f1\Editor\Data\il2cpp\external\baselib\Include" /I"C:\Program Files\Unity\Hub\Editor\2020.1.4f1\Editor\Data\il2cpp\external\baselib\Platforms\Windows\Include" /I"C:\Program Files\Unity\Hub\Editor\2020.1.4f1\Editor\Data\il2cpp\libil2cpp\pch" /I"C:\ProjectY\Temp\StagingArea\Data\il2cppOutput" /I"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\winrt" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt" /Fo"C:\ProjectY\Library\il2cpp_cache\B2F7742428966665D56E066A727674C1.obj" /Fd"C:\ProjectY\Library\il2cpp_cache\B2F7742428966665D56E066A727674C1.pdb"
    47. EnvArg key: PATH value: C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64;C:\Program Files (x86)\Windows Kits\10\bin\x64;C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x86;C:\Program Files (x86)\Windows Kits\10\bin\x86;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\bin\HostX64\x64
    48.  
    49.   at Unity.IL2CPP.Building.CppProgramBuilder.BuildAllCppFiles(IEnumerable`1 sourceFilesToCompile, IBuildStatisticsCollector statisticsCollector)
    50.   at Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics)
    51.   at il2cpp.Compilation.CompilationDriver.Run(RuntimePlatform platform, BuildingOptions buildingOptions)
    52.   at il2cpp.Program.DoRun(String[] args, RuntimePlatform platform, BuildingOptions buildingOptions)
    53.   at il2cpp.Program.Run(String[] args, Boolean setInvariantCulture)
    54.   at il2cpp.Program.Main(String[] args)
    55.  
     
  47. Erveon

    Erveon

    Joined:
    Sep 15, 2019
    Posts:
    13
    Thanks for the reply. We'd want it to be an axis, still.

    We have one input type on an axis that we want people to be able to rebind.
    We have another input type on an axis that we do not want people to be able to rebind. (Hide in the controls UI)

    The reason for this is that we need different mechanics for controller and don’t want those mechanics to be bound to buttons but disabling positive and negative for everything loses the functionality of rebinding for things we want.

    Is this possible at all or will we have to resort to changing one of them to two buttons (which we'd rather not do)
     
  48. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,607
    Control Mapper does not support that feature.

    To branch behavior based on device type, you use this:
    https://guavaman.com/projects/rewired/docs/HowTos.html#get-contributing-input-sources
     
  49. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,607
    https://guavaman.com/projects/rewired/docs/KnownIssues.html#windows-standalone-il2cpp-vs2019-hang
     
  50. KarlKarl2000

    KarlKarl2000

    Joined:
    Jan 25, 2016
    Posts:
    606