Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    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:
    4,350
    https://guavaman.com/projects/rewir.../M_Rewired_ControllerMap_DeleteElementMap.htm
    https://guavaman.com/projects/rewir...ControllerMap_DeleteElementMapsWithAction.htm

    No. All map information in Rewired is organized by Controller Map, not binding. If you want to do something like that, you have to manage it completely. Load the default controller map instance, make your comparisons, replace the binding you want, and validate for new conflicts because you have no idea what other bindings have been changed by the user.

    There is no known issue with UserDataStore_PlayerPrefs. Probably most Rewired users use it because it's part of Control Mapper and I've never had any complaints, nor I have I ever seen any problems in my own testing of it over the years.

    How are you using it? It does not automatically save data for you when you change bindings. You have to explicitly tell it when to load and save. See the documentation of User Data Store: https://guavaman.com/projects/rewired/docs/UserDataStore.html

    Usage

    Just add a component derived from UserDataStore (such as UserDataStore_PlayerPrefs) to your Rewired Input Manager Game Object. When the Rewired Input Manager initializes, it will automatically initialize the UserDataStore component and make a reference to it accessible via the ReInput.UserDataStore property.

     
  2. the_mr_matt

    the_mr_matt

    Joined:
    Jul 21, 2015
    Posts:
    105
    Understood. Thanks.

    Moved ReInput.userDataStore.Save() from input mapped event to input stopped event - saving works now.
     
  3. Erveon

    Erveon

    Joined:
    Sep 15, 2019
    Posts:
    4
    I've noticed that mouse movement has a fairly big impact on performance. Is this a known issue? I unbound it from everything to make sure it wasn't my code and the issue persists. The profiler shows the big spike coming directly from Rewired_Windows.dll.
     
  4. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,350
    No, there is no known issue with mouse input performance. This is by far the most likely explanation:
    https://guavaman.com/projects/rewir...#windows-editor-keyboard-keys-stuck-raw-input

    That roundabout interaction of Unity and Raw Input messages could cause potentially unlimited lag depending on how much is going on in the editor scripting side of the Unity editor.
     
  5. Grumpy-Dot

    Grumpy-Dot

    Joined:
    Feb 29, 2016
    Posts:
    66
    castor76 likes this.
  6. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    1,839
    I am sure official Rewired 2020.1 version will be released soon, it is just question of when. I too wonder about this.

    Having said that, I am already using it on 2020.2 alpha and it seems to work so far. Just need that stupid IL2CPP VS 2019 bug to be fixed by microsoft..
     
  7. Roman-Ilyin

    Roman-Ilyin

    Joined:
    Oct 9, 2013
    Posts:
    17
    Hello.

    I've try to implement Full Controller Support
    Unity 2019.4.6f1+Rewired 1.1.35.3.U2019

    Code (CSharp):
    1.  
    2. _player.controllers.AddLastActiveControllerChangedDelegate(OnLastActiveControllerChange);
    3.  
    4. private void OnLastActiveControllerChange(Player player, Controller controller)
    5.     {
    6.         UpdateLastActiveInputType();
    7.     }
    8.  
    9.     private void UpdateLastActiveInputType(ControllerStatusChangedEventArgs args = null)
    10.     {
    11.         Controller activeController = _player.controllers.GetLastActiveController();
    12.         if (activeController != null)
    13.         {
    14.             switch (activeController.type)
    15.             {
    16.                 case ControllerType.Keyboard:
    17.                     JoystickMode = JoystickMode.KeyboardAndMouse;
    18.                     break;
    19.                 case ControllerType.Joystick:
    20.                     if (activeController.hardwareIdentifier == "WindowsXInputGamepadGamepad" || activeController.hardwareIdentifier == "WindowsFallbackController(XEOXGamepad)")
    21.                         JoystickMode = JoystickMode.XBox;
    22.                     else if (activeController.hardwareIdentifier.Contains("Steam")) // ?
    23.                             JoystickMode = JoystickMode.Steam;
    24.                         else
    25.                             JoystickMode = JoystickMode.PS;
    26.                     break;
    27.                 case ControllerType.Mouse:
    28.                     JoystickMode = JoystickMode.KeyboardAndMouse;
    29.                     break;
    30.                 case ControllerType.Custom:
    31.                     JoystickMode = JoystickMode.KeyboardAndMouse;
    32.                     break;
    33.             }
    34.         }
    35.         else
    36.         {
    37.             JoystickMode = JoystickMode.KeyboardAndMouse;
    38.         }
    39.         UpdateJoystickHints();
    40.     }
    41.  
    this code correctly switches JoystickMode when using gamepad and keyboard, but does not respond to mouse movement and mouse buttons clicks. only responds to the mouse scroll wheel. could you please explain why AddLastActiveControllerChangedDelegate is not called on mouse movement?
     
  8. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,350
    It is not out yet. There are blocking issues caused by Unity and their move of the UI system to the package manager. I do not know when/if these issues will be resolved. I have not heard back from Unity.
     
    SVC-Games and Grumpy-Dot like this.
  9. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,350
    It does respond to mouse movements. You must have the mouse assigned to the Player and a Mouse Map enabled that binds those elements for it to become the last active controller if using the Player event.

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

    "The Player.controllers.GetLastActiveController method will get the last active controller used by that Player. Be aware that only mapped elements determine whether a Controller just became active. For example, if you're testing to see if the mouse is the last active controller, if nothing is mapped to the left mouse button and it is clicked, it will not be considered the last active controller in the Player."
     
    Roman-Ilyin likes this.
  10. airvrstudio

    airvrstudio

    Joined:
    Nov 24, 2018
    Posts:
    7
    Unity 2019.1/.2/.3/.4 + Latest Rewired + il2cpp (.net 4.0) + VS2019 == Crash when app is launched

    Steps to reproduce on my system: Create new Unity 3D project (Unity 2019.4.6f1), set build type to il2cpp and .net4.0 in ProjectSettings=>Player, import and install latest Rewired package (versions at least back to April also crash), add a new Rewired InputManager to the scene, open Build Settings, set output to Windows x64, build, launch the built app.

    Observed: Unity crash dialog, then app closes

    This began happening after I installed Visual Studio 2019 and tools for Hololens2 development on my Windows10 system. Others on our team who have not upgraded to VS2019 seem to be able to make Windows 64bit builds which work fine. How can we help debug this?
     
  11. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,350
    This is a very well known issue and is at the top of the front page of the documentation in the notice area.

    https://guavaman.com/projects/rewired/docs/KnownIssues.html#windows-standalone-il2cpp-vs2019-hang
     
  12. KHagen95

    KHagen95

    Joined:
    Oct 15, 2019
    Posts:
    10
    Hey @guavaman !

    Im trying to figure out how the whole layout manager + rule system works but I cant get it to work somehow.
    Here is what I want to do:

    I want to test some different control schemes and for that I'd like to swap the current layout upon pressing one of the F1-FX keys.

    Here is what I did:
    For each of them, I configured a Joystick Layout in the respective tab. In the joystick map for the generic controller, I set up all controls for each layout. After that I configured rules for it, in the Layout Manager Rules, they look like this:

    Unity_Vc0oV2Nqum.png

    Now I tried following the documentation for it, as specified at the bottom of this page.

    I hit a road block doing so, because the
    ControllerMapLayoutManager.RuleSet.Rule
    doesn't seem to have the enabled property that is being used in the documentation. Instead that property is only available for the
    ControllerMapEnabler.RuleSet.Rule
    .

    I guess I could use the ControllerMapEnabler instead in a very similar way but from what I understood, it is best practice to use the LayoutManager for that. Another way I could solve this might be to just have many different rulesets in the LayoutManager and each ruleset only contains one rule which in return specifies the joysticks layout.

    What would be the best/correct way to go about this?
     

    Attached Files:

  13. gaterooze

    gaterooze

    Joined:
    Jul 17, 2019
    Posts:
    10
    I'm seeing something similar, causing the mouse input to freeze for a second now and then - was not happening prior to using Rewind, and nothing else has changed. I'm still on Unity 2018.3.f02.
     
  14. airvrstudio

    airvrstudio

    Joined:
    Nov 24, 2018
    Posts:
    7
  15. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,350
    The documentation is wrong. Neither ControllerMapLayoutManager.RuleSet.Rule nor ControllerMapEnabler.RuleSet.Rule have enabled properties. The ControllerMapEnabler.RuleSet.Rule.enable property is not the enabled property mentioned in the documentation. The enable property exists to set the final enable state on the Controller Map (is it enabled or disabled), it does not flow control evaluation of the rule. This feature was probably removed after writing the documentation because of issues or the lack of necessity. I don't remember.

    Rules are designed to be processed as a sequence within a rule set. Rule Sets can be processed in sequence, or Rule Sets can be disabled to prevent processing.
     
    KHagen95 likes this.
  16. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,350
    Nothing has changed in Rewired's mouse system in years. Sudden reports that affect things at a very low level are evidence of a change at a level lower than Rewired's code. That likely means a Windows update breaking something in the API, a driver change, or something in Unity interfering with core Windows API functions. All 3 have happened before.

    I cannot reproduce any problem, so issues like this that require extensive, trial-and-error debugging at the very lowest system API level are impossible to solve without the ability to reproduce it. Problems like this are also always, in my experience, impossible to actually fix because the problem is below Rewired's code. The only possible resolutions in the past have been workarounds to do things in a different way, avoid calling the offending functions, or similar if even at all possible.

    The most recent example of this is Raw Input errors caused by a change Unity made in 2019.3.8 that introduced lag to all Raw Input events sent by the system. Windows Updates frequently do break core Windows API functions. Nearly every single major Windows update brings with it new bugs that affect Rewired in some unexpected way that require a great deal of time to identify, debug, and work around.

    1. What build version of Windows are you using?
    2. Is this in the editor, build, or both?
    3. What model mouse are you using?
    4. Is the mouse connected via USB or Bluetooth?
     
    Last edited: Aug 5, 2020
  17. the_mr_matt

    the_mr_matt

    Joined:
    Jul 21, 2015
    Posts:
    105
    Hello!

    I'm having great difficulty with the event system. Both Unity EventSystem.current and Rewired Event System.current are returning null. I've posted questions here and here with no helpful responses.

    Some more details:
    • To clarify, it is not EventSystem.current.gameObject that is null, it is EventSystem.current itself
    • I have tried combinations of the Unity EventSystem and Rewired Event System, and the Unity/Rewired Standalone Input Module, all have the same issue
    • I'm using the latest Rewired version and Unity 2019.3.15f1
     
  18. gaterooze

    gaterooze

    Joined:
    Jul 17, 2019
    Posts:
    10
    As it turns out, I think it was coincidental with my use of Rewired - I believe it's actually my mouse failing! Apologies for the false alarm.
     
  19. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,350
    Both of your examples show you testing for the EventSystem.current value in OnEnable. If this test object is being instantiated in the scene at the same time as the EventSystem, you cannot be guaranteed the EventSystem is ready by the time you make that call because you don't have control over the order of execution.

    EventSystem.current is never set to any value until the OnEnable function is called in the EventSystem. See the source code:

    https://bitbucket.org/Unity-Technologies/ui/src/2019.1/UnityEngine.UI/EventSystem/EventSystem.cs
     
  20. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,350
    Thanks for letting me know.
     
  21. the_mr_matt

    the_mr_matt

    Joined:
    Jul 21, 2015
    Posts:
    105
    Interesting. I wasn't aware of that.

    However, I have found that the issue happens even after the initial OnEnable(). It's repeatable every time I disable/enable the object with that test script on it.
     
  22. KHagen95

    KHagen95

    Joined:
    Oct 15, 2019
    Posts:
    10
    Thanks for the answer. I got it working now.

    Two things remaining:

    1) What is the purpose of rules then/how exactly do they work? Does one rule prevent others? Will all rules in a given ruleset be processed? So for example if I have a Left-Hand profile, and the user switches to it, will all input devices be switched to that layout if I set the rules for it?

    2) I'm not quite happy with the code yet, because it relies on strings. LayoutID is currently not in use, it was used with the two commented lines before. However with that variation I can't receive the rulesets assigned to a certain player, hence the changes are not applied. Is there a similar ID-based approach for Player.LayoutManager ?

    Code (CSharp):
    1.  
    2.         private void CheckForControllerLayoutSwitch()
    3.         {
    4.             if (UnityEngine.Input.GetKeyDown(KeyCode.F1))
    5.                 ChangeControllerLayout(LayoutManagerRuleSet.JoystickDefault, nameof(LayoutManagerRuleSet.JoystickDefault));
    6.             if (UnityEngine.Input.GetKeyDown(KeyCode.F2))
    7.                 ChangeControllerLayout(LayoutManagerRuleSet.JoystickDefaultTopBotRowSwapped, nameof(LayoutManagerRuleSet.JoystickDefaultTopBotRowSwapped));
    8.             if (UnityEngine.Input.GetKeyDown(KeyCode.F3))
    9.                 ChangeControllerLayout(LayoutManagerRuleSet.JoystickMorphShoulderButtons, nameof(LayoutManagerRuleSet.JoystickMorphShoulderButtons));
    10.             if (UnityEngine.Input.GetKeyDown(KeyCode.F4))
    11.                 ChangeControllerLayout(LayoutManagerRuleSet.JoystickThreeMorphSlots, nameof(LayoutManagerRuleSet.JoystickThreeMorphSlots));
    12.         }
    13.  
    14.         private void ChangeControllerLayout(int layoutID, string tag)
    15.         {
    16.             // Find all LayoutManager RuleSets
    17.             List<ControllerMapLayoutManager.RuleSet> ruleSets = _player.controllers.maps.layoutManager.ruleSets;
    18.             // disable all RuleSets
    19.             foreach (ControllerMapLayoutManager.RuleSet ruleSet in ruleSets)
    20.             {
    21.                 ruleSet.enabled = ruleSet.tag.Equals(tag);
    22.             }
    23.  
    24.             // ControllerMapLayoutManager.RuleSet controllerMapLayoutManagerRuleSetInstance = ReInput.mapping.GetControllerMapLayoutManagerRuleSetInstance(layoutID);
    25.             // controllerMapLayoutManagerRuleSetInstance.enabled = true;
    26.  
    27.             // Need to apply the changes back to the layout manager
    28.             _player.controllers.maps.layoutManager.Apply();
    29.         }
     
  23. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,350
    Then the only things I can think of:
    1. You don't have an enabled EventSystem in the scene.
    2. Some script has set EventSystem.current to null.
    3. Some kind of new Unity bug in EventSystem that I'm not aware of.
     
  24. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,350
    This should be clear by the diagram at the top of the documentation page:





    I have no idea what you are trying to do here. This code doesn't achieve anything.

    You are creating a new instance of your Rule Set that you defined in the Rewired Input Manager and then setting it enabled. This rule set is not stored so it does not exist in your Layout Manager is as simply discarded when the function exists.

    Further, trying to use the LayoutId in the GetControllerMapLayoutManagerRuleSetInstance function is incorrect and will not work. Look at the API documentation:
    https://guavaman.com/projects/rewir...ControllerMapLayoutManagerRuleSetInstance.htm

    The id you are required to pass is the id of the Rule Set as shown in the Rewired Editor, not the layout id. This tells it which Rule Set to instantiate.

    There is nothing at all wrong with using tags to find your Rule Sets you want to enable/disable. That's exactly how the system was designed to work. You are not going to be calling this every frame, so doing a check on a string is not going to cause you any performance penalties.

    If you don't want to find the Rule Set in the Player instace of the LayoutManager Rule Set list by tag, then you have to search and find the Rule Set you want manually. LayoutManager.ruleSets is nothing more than a C# generic List, and therefore you have every single List tool available to you to search it for the data you are looking for including extensions and Linq. There are no convenience functions in LayoutManager to allow you to search the list for various criteria.

    It's up to you to choose how you want to use the Rule Sets. This is covered in the documentation:
    • One way of working with Rule Sets is to split up your Rules into many single-purpose Rule Sets, assign all the Rule Sets to your Player, starting them disabled, and selectively enable combinations of groups of Rule Sets to achieve different modes.
    • Another way of working with Rule Sets is to stack many Rules into a Rule Set defining an entire mode in one Rule Set and just enable or swap out the Rule Set.
    If you choose to use method 1, you would create your Rule Sets and assign them to the Player in the editor, disable them, then enable/disable them as needed in a script using the Tag to determine which to enable.

    If you choose to use method 2, you would create a bunch of different sets that contain a complete description of what needs to be enabled/disabled and load only the one Rule Set you want into the Layout Manager.

    If you want to add/remove them instead of enabling/disabling them, the code how to do that is also shown in the docs:

    Code (csharp):
    1. // Load an instance of the Rule Set
    2. var ruleSet = ReInput.mapping.GetControllerMapLayoutManagerRuleSetInstance(ruleSetId);
    3.  
    4. // Add the Rule Set to the Player's Layout Manager
    5. player.controllers.maps.layoutManager.ruleSets.Add(ruleSet);
    6.  
    7. // Apply the changes to the Player's Controller Maps
    8. player.controllers.maps.layoutManager.Apply();
    In your code above you have omitted the necessary line to add the Rule Set to the Layout Manager.
     
    Last edited: Aug 6, 2020
  25. brinca

    brinca

    Joined:
    Mar 29, 2015
    Posts:
    22
    There seems to be a bug with input event delegates in which removing a delegate during the execution of said delegate seems to stop the propagation of the event, so other delegates for the same event don't get called.

    If we delay the delegate removal to be outside of the delegate execution (e.g. using a coroutine), then it works as expected.

    Perhaps this happens because the collection holding the delegates is getting modified while being traversed, so one option would be to delay the delegate removal until all delegates have been executed.
     
  26. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,350
    Modifying event listeners inside the event handler callback is not going to work. This is akin to modifying a list while iterating in a foreach loop, which throws an exception, because you are trying to modify the list during iteration. You might remove an item, add an item, or even clear the entire list depending on what method you choose to call.

    The only way I can make it work to do what you want to do is to copy the event list every time before iterating the copy.
     
  27. Colin_MacLeod

    Colin_MacLeod

    Joined:
    Feb 11, 2014
    Posts:
    168
    Hi @guavaman,

    I'm trying to set up Rewired to work with Opsive Third Person Controller using a wired Xbox-One controller - on macOS Catalina.

    I installed the 360Controller 1.0.0-alpha.6 driver from GitHub. When I look in the Mac preferences, I see the controller is recognized and its axes behave as expected.

    In Unity Editor with Rewired, the controller works to control player direction with the left stick but the look controls are wrong. Specifically:

    Down on the right stick rotates the camera view to the right
    Up on the right stick rotates camera to the left
    Left shoulder trigger controls camera movement up/down.

    I'm sorry if I missed this somewhere in the setup - just can't seem to find this info googling. Is there something obvious I need to setup?
     
  28. the_mr_matt

    the_mr_matt

    Joined:
    Jul 21, 2015
    Posts:
    105
    In the process of creating a controller binding display. I know how to find what element is mapped to a given action. How can I go the other way around? E.g. Get the action mapped specifically to R Stick X specifically for the XBox controller.

     
  29. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,350
    This is nothing more than a search. There are dozens of convenience functions to allow you to search for whatever you want. You also have complete access to all the Controller Maps and their Action Element Maps (bindings) and can search for whatever you want in those mappings.

    See this:
    https://guavaman.com/projects/rewired/docs/HowTos.html#display-glyph-for-action

    If you want to search for a specific controller element, you must know what element identifier id you're looking for. The CSV file contains all the element identifier ids for all recognized controllers.
     
  30. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,350
    If there is some kind of new problem with the driver, they made a breaking change and it is not supported.

    The way you are describing a resulting action happening when you press a controller element leads me to believe you have not debugged this using Debug Information:
    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#debug-information

    Looking at the final Action value is too high level to really know what's happening. You have to see what's happening at every level of input from the controller level all the way up to the Player Action to understand what's happening. If there is a controller mapping problem, it may not have anything to do with the controller or the driver. Use Debug Information and the checklist provided to discover the source of the problem.
     
  31. the_mr_matt

    the_mr_matt

    Joined:
    Jul 21, 2015
    Posts:
    105
    Thanks. GetFirstElementMapWithElementTarget looks promising but I don't understand the usage of ControllerElementTarget. It has a controller property but is readonly and the constructors don't allow me to specify a controller.

    I'm going to do a manual search through every category and every actionElementMap but if you have any other (more efficient) suggestions I would be very grateful.
     
  32. Colin_MacLeod

    Colin_MacLeod

    Joined:
    Feb 11, 2014
    Posts:
    168
    Hey thanks for the pointer.

    The axes do appear to be reacting correctly in Players → Controllers → Joysticks, so I have a mapping issue. Not sure at this point why that should be but this should let me get to the bottom of it.
     
  33. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,350
    It isn't possible to make anything more efficient. Those convenience functions you use to find various information have to do the exact same thing under the hood. It's only a matter of do you want to call the convenience function to search the bindings for you or do it yourself.

    ControllerElementTarget.controller is readonly because it is read from the Controller element you provide in ControllerElementTarget.element. The same goes for elementIdentifierId. Using this structure requires you have the actual Controller object and pass it the element (button/axis) you're interested in. This structure is mostly used when working with Controller Templates.

    Another convenience function in Controller Map:
    https://guavaman.com/projects/rewir...red_ControllerMap_GetFirstElementMapMatch.htm
     
  34. ben06feb

    ben06feb

    Joined:
    Oct 2, 2012
    Posts:
    34
    Thanks for the update. I would like to have scripting reference of list of keys in the controllers (keyboard, mouse, connected joystick) at run time.
     
  35. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,350
    Get the information from the Controllers.

    Code (csharp):
    1. foreach(var joystick in ReInput.controllers.Joysticks) {
    2.     foreach(var element in joystick.Elements) {
    3.         Debug.Log(element.name);
    4.     }
    5. }
    6.  
    7. foreach(var element in ReInput.controllers.Mouse.Elements) {
    8.     Debug.Log(element.name);
    9. }
    10.  
    11. foreach(var element in ReInput.controllers.Keyboard.Elements) {
    12.     Debug.Log(element.name);
    13. }
    https://guavaman.com/projects/rewired/docs/HowTos.html#get-controller
     
  36. xelanoimis

    xelanoimis

    Joined:
    Oct 29, 2013
    Posts:
    36
    Just a question / feature suggestion:
    Any chance to support the Steam Remote Play Together feature? Like to know per device if it's owned by a remote player. If I'm not mistaken, Steamworks api offers this support through GetRemotePlaySessionID( InputHandle_t inputHandle );

    When playing remote, Steam creates "remote" devices for the connected players. These gamepad devices are listed as they are connected to the current PC, but apparently Steamworks api knows they're remote and you can access the user name of the corresponding player. It would be nice to display these names above their avatars or so.

    Now, I'm not sure if it's possible to do a correspondence between that InputHandle that Steam works with and some index of the device listed by Rewired. I haven't looked into it, but I thought to ask, maybe it's an easy to add feature.
     
  37. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,350
    It's not easy. Rewired has no native Steam API integration. Doing so, as I have attempted to do this before, is a big job fraught with many very significant problems and usability issues which I won't go into.

    Rewired has no access to any kind of input handle because that would be provided by the Steam API.
     
  38. qpuilie

    qpuilie

    Joined:
    Jan 14, 2020
    Posts:
    48
    Hi @guavaman,

    Is there some kind of custom update loop in Rewired. I do not want Rewried to update input data in unity's Update/FixedUpdate methods. I want to call some methods of Rewired(eg: CustomUpdate()) to update input data. So that I can controll when to update input data.
    Hope to provide a special edition related file with this function in the forum, if possible.;)

    Thanks,
    Zhang
     
    Last edited: Aug 12, 2020
  39. GoldFireStudios

    GoldFireStudios

    Joined:
    Nov 21, 2018
    Posts:
    61
    Any tips on getting mouse look in a first person controller to feel good with Rewired? Using the default settings, the cursor continues to move across the screen for half a second after the physical mouse stops moving, which makes it rather difficult to click on objects.
     
  40. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,350
    No. You can only update in Update, Fixed Update, or OnGUI.
     
  41. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,350
    You are experiencing this Unity bug:
    https://guavaman.com/projects/rewir...#windows-editor-keyboard-keys-stuck-raw-input

    This cannot be fixed by me because Unity caused the issue so they have to fix it.
     
  42. GoldFireStudios

    GoldFireStudios

    Joined:
    Nov 21, 2018
    Posts:
    61
    Hmm, that says it is an issue with Windows and I'm on a Mac. Also, I'm on 2020.1.1. The issue feels more like a slow lerp of the movement rather than the input being stuck. The input starts to slow down immediately after stopping the physical input, but it just takes too long to stop and drifts past the target.
     
  43. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,350
    Rewired is definitely not doing that. On Mac, Rewired reads the mouse input directly from UnityEngine.Input.GetAxis. There is no transformation or filtering of that value whatsoever.

    The only thing in Rewired that can possibly affect mouse axis values is your Input Behavior settings for the mouse:
    https://guavaman.com/projects/rewired/docs/RewiredEditor.html#InputBehaviors

    What you describe does not sound like the behavior of any of these settings.

    I suggest you watch the values of the mouse using UnityEngine.Input.GetAxis in real time. You can also watch the Mouse axes directly in the inspector:
    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#debug-information
     
  44. rpgw

    rpgw

    Joined:
    Jul 3, 2012
    Posts:
    45
    I'm trying to implement touch screen joysticks for my first person game. When I test the touch controls in Unity using mouse input they work exactly as expected. However when I test them on iOS they only respond to the first tap and the sticks don't move when I continue to hold down and try to move them around. Anyone got any sugggestions for where I should look to fix this?
    Touch buttons work just fine, suggesting that the taps are getting through.
     
    Last edited: Aug 13, 2020
  45. NathanJeeves

    NathanJeeves

    Joined:
    Jul 6, 2015
    Posts:
    13
    Forgive me if im blatantly ignoring something from the documentation here, is there any way to detect which buttons you are pressing on a controller like you would in antimicro or vjoy?
     
  46. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,350
    I don't know what you're asking.

    If you are talking about remapping controls:
    https://guavaman.com/projects/rewired/docs/HowTos.html#controller-mapping-screen

    If you're are talking about showing what button is being pressed:
    https://guavaman.com/projects/rewired/docs/HowTos.html#display-glyph-for-active-elements
     
  47. GoldFireStudios

    GoldFireStudios

    Joined:
    Nov 21, 2018
    Posts:
    61
    Thanks, that debug view is really handy! That helped me track down the issue to being the damping on the cinemachine camera.
     
  48. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,350
    There are almost countless reasons why this could happen because of the sheer number of systems involved. 9/10 times all touch control problems are caused by raycasting issues caused by your layering in the canvas.

    I can only make blind guesses.

    Disable Input.simulateMouseWithTouches.

    Build Rewired's Touch Controls examples and see if they work correctly. They should. If they do, you know it's something in your setup. How to find out what is a matter of debugging.
     
  49. rpgw

    rpgw

    Joined:
    Jul 3, 2012
    Posts:
    45
    Thanks Guavaman. I did some quick test builds and this seems like the correct area to investigate. Cheers.

    edit - Update. Turns out it wasn't raycasting related. Installing the Unity Device Simulator package allowed me to quickly test all the options on the joysticks as the problem was replicated in the simulator. The 'Activate on swipe in' bool needed to be on. Yet the joysticks worked ok with this off in other contexts. :shrug:
     
    Last edited: Aug 14, 2020
  50. InvincibleCat

    InvincibleCat

    Joined:
    Dec 23, 2014
    Posts:
    73
    Hi there! Any ETA on when Rewired will be compatible with Unity 2020 ? I am getting this warning: Please install Rewired for Unity 2020
    So far it doesn't seem to cause to much trouble though.

    Thanks!
     
    LucidDreamsStudio likes this.
unityunity