Search Unity

Rewired - Advanced Input for Unity

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

  1. kevinsyang17

    kevinsyang17

    Joined:
    Apr 3, 2018
    Posts:
    37
    Hi I'm using rewired and my world space canvas has an input field that used to work. Now, it can only be selected but when I type on keyboard nothing types into the input field.
     
    lyingturkey likes this.
  2. InvincibleCat

    InvincibleCat

    Joined:
    Dec 23, 2014
    Posts:
    83
    Thanks for the reply. What is weird though is that it only does that on the Steam Deck.
    On Windows (with the Steam SDK) I get the correct guids so I can tell which controller is connected but not on the Steam Deck (always returns the Xbox 360 guid not matter what controller is connected).
    Is that normal?
     
  3. jngo102

    jngo102

    Joined:
    Nov 8, 2019
    Posts:
    1
    Hello guavaman,

    Thank you for continuing to provide support to users all these years.

    I was hoping to mod an existing Unity game (Have a Nice Death) that uses Rewired 1.1.43.0U2020 for its input system. My plan was to add local multiplayer.

    Is there a way to add new players and controllers to ReInput at runtime using some heavy amounts of reflection? And is there any documentation or examples for using Rewired with multiple players? From what I've seen, adding players the proper way is only through the project opened in the Unity editor, which I obviously do not have access to.

    On a side note, the game uses Unity 2021.3.13f while using Rewired 1.143.0U2020, which is apparently not recommended from your post here: https://forum.unity.com/threads/rewired-advanced-input-for-unity.270693/page-174#post-8837461 What consequences could this have? I could relay this to the developers if its something game-breaking.

    Thank you for your time.
     
    lyingturkey likes this.
  4. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    That can't be the case if both are running Windows builds and both have the same input API settings. There is no way a Windows Standalone build or a Windows Unity Editor can tell different Steam-controlled controllers apart if Use XInput is enabled.

    The only ways that the input API would be able to expose information specific enough for Rewired to differentiate the controllers would be:
    1. Use XInput is disabled and Steam is not configuring that controller. Rewired would be able to see the true Raw Input / Direct Input information about the controller in that case.
    2. Use XInput is disabled, you have initialized Rewired before Steam, had a controller connected at the time, and are seeing outdated controller information from the real Raw Input / Direct Input API instead of the Steam-modified information. Unplugging and replugging the controller will result in the outdated information being lost and Steam-configured information being used from then on.

    It is possible if Steam changed something that if Use XInput is disabled, it may show different information for Xbox 360 and Xbox One controllers. I don't know. This is Steam implementation and I don't have a stream of continuous knowledge of all the updates they're constantly making to Steam. Regardless, this would require Use XInput to be disabled which means no vibration support and no independent trigger axes, among other limitations.

    Steam Deck can be configured to run Windows builds or Linux builds. Steam Deck runs Steam OS which is Linux-based. If you make a Windows build, you are running your game under Proton, a Steam-maintained fork of Wine, which is essentially a Windows API emulator. Proton is a work in progress. If you are running your game as a Linux build, it will by definition behave differently than a Windows build because it's using entirely different input APIs to get input. Xbox Controllers do not behave the same on Linux and Windows and there is no XInput on Linux. Specific distro and drivers heavily influence how these controllers behave on Linux.

    My most current information on Steam on Linux is that it exposes all Steam-configured devices as "Steam Controller", and Rewired detects that and creates a Steam Controller, not an an Xbox Controller. Of course, as always with Steam, things may have changed since I last tested these things.
     
  5. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    Rewired does not handle typing input and has no impact on Unity's input field controls. Only under extremely rare circumstances can Rewired's use of Raw Input interfere with Unity's use of Raw Input. This is only under specific versions of Rewired and specific versions of Unity, and was caused by Unity's breaking changes to their input system in Unity 2021.2.0.

    If you are using a version of Unity 2021.2.0 or greater, you must be using Rewired 1.1.41.0+ (1.1.44.0+ recommended) or there will be problems with Unity and or Rewired input in Windows. You also must be using the correct branch of Rewired for the version of Unity you are using. Every major release of Unity requires a matching branch of Rewired. Unity 2021 requires Rewired 2021, Unity 2022 requires Rewired 2022, etc. Inexplicable problems can result in using the wrong branch of Rewired for the major version of Unity you are using. See this:
    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#wrong-rewired-version-installed

    1. What version of Unity are you using?
    2. What version of Rewired are you using, including the major branch designation?
    3. What is your Unity Player -> Active Input Handling setting?
     
    Last edited: Mar 27, 2023
  6. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    No. This is impossible. Rewired's configuration is designed to be static after initialization. The entire runtime system is instantiated on Awake from the data configured in the Rewired Input Manager. The assumption that things like the Players, Actions, etc., are known before instantiation time and never change throughout the lifetime of the Rewired Input Manager session is baked into the system. Using reflection to somehow force another Player into the system would result in exceptions being thrown all over the place. There's no way to add a Player at runtime.

    The only way you could do what you want to do is to replace the Rewired Input Manager serialized data with your own.

    See the forum post I just wrote right above this one. Unity made breaking changes in 2021.2.0 to their input systems to solve massive slowdown from 8 khz mice. This broke Rewired. Unity had to expose a new API for Rewired to be able to grab Raw Input events from Raw Input and then forward them to Unity. This API does not exist in Unity 2020 or Rewired 2020.

    Edit: Actually, the results would be worse than I described before. Since Unity 2021.3.13 is programmed to use the Raw Input buffered methods, the result will be broken keyboard and mouse input in Rewired. Rewired 2020 does not use the buffered read method, therefore will read one input event at a time and forward these to Unity in sequence using the old method of forwarding. If more than one mouse or keyboard input event is received during a frame, Rewired will only be able to process one of them, as Unity will gobble all the remaining events up out of the windows message queue when it calls the buffered read method. This results in missed input events, which cause all sorts of problems such as slow or intermittent mouse movement and stuck on/off buttons. This will always cause problems when the mouse is being moved while pressing a button as that will always result in more than one event per frame.
     
    Last edited: Mar 27, 2023
    lyingturkey and jngo102 like this.
  7. kevinsyang17

    kevinsyang17

    Joined:
    Apr 3, 2018
    Posts:
    37
     
  8. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    My previous message covered the only known way possible Rewired could have any impact whatsoever on an input field. There is no other way I know of that it could have any affect on it.

    The Event System and Input Module are working as evidenced by the fact that you can click on the Input Field and it takes focus. That would not happen if the Input Module were not working correctly. The hover, mouse in, mouse out, click, submit, etc. events are the only events the Input Field gets from the Input Module. The actual text input is not handled through the Event System at all and is not dependent on the Rewired Standalone Input Module.

    The source code to the Input Field control is in the Packages folder of your project. Looking through that, I see the keyboard input is obtained from compositionString property which is defined as:

    Code (csharp):
    1.  
    2. private string compositionString
    3. {
    4.     get { return input != null ? input.compositionString : Input.compositionString; }
    5. }
    The "input" property is defined as:

    Code (csharp):
    1. private BaseInput input
    2. {
    3.     get
    4.     {
    5.         if (EventSystem.current && EventSystem.current.currentInputModule)
    6.             return EventSystem.current.currentInputModule.input;
    7.         return null;
    8.     }
    9. }
    This gets the source of input from the current Input Module on the Event System. The base class of the Rewired tandaloneInputModule is Unity's BaseInputModule, and this input property is not set or overridden by the RewiredStandaloneInputModule. Therefore, this value will be coming directly from UnityEngine.Input.compositionString. Even if the Input Module is disabled or missing, it will still get its value from UnityEngine.Input.compositionString because of how they fall back to getting the value from there when "input" is null. So in no case does this value come from Rewired or the Rewired Standalone Input Module. Therefore, if simply merely using Rewired is causing the Input Field to not take text input, I can only surmise that the actual keyboard input from Windows is not making it to UnityEngine.Input. The only way possible I know of for that to happen is what I stated before -- using incompatible branches of Rewired and Unity or using an outdated version of Rewired in a new version of Unity post 2021.2.0f1.

    Based on the information I have, that's all I can tell you. If you want me to investigate further, I need to know more information.
    1. What version of Unity are you using?
    2. What version of Rewired are you using, including the major branch designation?
    3. What is your Unity Player -> Active Input Handling setting?
    4. Are you using a Unity Input Field or a Text Mesh Pro Input Field?
     
    Last edited: Mar 28, 2023
  9. kevinsyang17

    kevinsyang17

    Joined:
    Apr 3, 2018
    Posts:
    37
    Yes so as said in previous post, my unity version is 2020.3.46f1. Rewired is Version 1.1.44. , Active input handling is Old Input Manager. Using Unity Input Field, not TMP
     
  10. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    I didn't see it because your message was posted with broken quote tags:

    Capture.PNG

    >> Rewired is Version 1.1.44

    Please verify the full Rewired version including the major Unity branch designation.

    Window -> Rewired -> Help -> About

    The format is 1.1.44.0.U2020 or similar.
     
  11. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    I installed Unity 2020.3.46f1 and did extensive testing. I cannot reproduce any problem with Unity UI Input Field. The only way I've figured out to make the input field not accept any keyboard input to disable either the Input Module or the Event System component. This happens with both the Rewired Standalone Input Module and the Unity Standalone Input Module. Nothing else I tried was able to stop keyboard input from being processed by the Input Field.

    Do you have multiple Event Systems in your scene?

    I haven't seen anything so far in any of the information you've provided or in my testing to lead me to believe that Rewired is the cause of the Input Field text input not working. I suggest you replace the Rewired Standalone Input Module with the Unity Input Module and test it again. You can also disable the Rewired Input Manager Game Object to ensure Rewired is not running at all.
     
    Last edited: Mar 28, 2023
  12. kevinsyang17

    kevinsyang17

    Joined:
    Apr 3, 2018
    Posts:
    37
    I figured out the cause of the problem. Basically, since I'm using a custom cursor can can work with controller on world space canvas, it's a custom script that extends the PointerInputModule class, and to prevent conflict RewiredStandaloneInputManager is disabled. Can you please take a quick look at my code if I can do something to support the UI input? Thanks!

    Here is the code: https://pastie.io/rtzuzg.cs
     
  13. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    I'm sorry, but helping you write an extension to Unity's Pointer Input Module is well outside the scope of the support I provide, and doesn't even involve Rewired. I've spent a significant amount of time on this issue already, which turned out to not be caused by Rewired.

    Unity UI's source code is in your project. You can look at the Input Field source code to understand how keyboard input is processed by the Input Field and what it needs from the Input Module to do so.
     
  14. marchall_box

    marchall_box

    Joined:
    Mar 28, 2013
    Posts:
    139
    Hello,

    What is the best way to pause the input?
    I dont want to "Disable" or "Enable" but rather just pause accepting/processing input so Enable/Disable states stay as is.

    So if the certain map are enabled it will stay as enabled and if I "pause the game", whether its enabled or disable, the state just stay as is but does not "process input".

    Thank you,
     
  15. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    You should flow control processing of input in your game code, not by disabling the input system while your code continues to read input.

    A similar question asked recently in the same vein:
    https://forum.unity.com/threads/rewired-advanced-input-for-unity.270693/page-174#post-8876889
     
  16. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Hi,
    We just upgraded our project from 2020.3 to 2021.3.22 -- and are getting this error below -- which I know means that we have the 2020 version of Rewired installed. So I deleted Rewired from the project, deleted the Rewired package from the cache, and redownloaded and reinstalled it -- but we still get this error. Did that process twice just to be sure. The Rewired>Help>About window says we have Rewired 1.1.44.0.U2021....so any idea what's going on?

    Assets\Rewired\Internal\Scripts\Misc\ExternalTools.cs(419,13): error CS0234: The type or namespace name 'Windows' does not exist in the namespace 'Rewired.Internal' (are you missing an assembly reference?)
     
  17. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    797
    Code (CSharp):
    1. // Enable the Rule Set with the tag "UI"
    2. player.controllers.maps.mapEnabler.ruleSets.Find(item => item.tag == "UI").enabled = true;
    Is it possible to enable/disable a MapEnablerRuleSet using its ID instead of Tag? I can't work out how to do it, sorry!
     
  18. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    Rewired.Internal.Windows is defined in Assets\Rewired\Internal\Scripts\Platforms\Windows\Functions\Functions.cs. This folder contains an ASMDEF file which compiles this script to an assembly and makes it available to scripts compiled to Assembly-csharp.dll. The reason this has to be done like this using an ASMDEF is that when Unity exposed this new function that Rewired needs due to breaking changes in Unity 2021.2.0f1, they exposed an unsafe function that uses unsafe pointers. A script cannot call unsafe code unless the entire project is set to allow compiling of unsafe code. It was unreasonable to require every user to enable compiling unsafe code just for Rewired because of this function. The only way around this was to create an ASMDEF file which could compile a safe wrapper function to a DLL for use by scripts in the project.

    The error means the assembly in which Unity is compiling Assets\Rewired\Internal\Scripts\Misc\ExternalTools.cs does not have a reference to the assembly containing the required function. The only I know of that this can happen is through the use of your own ASMDEF files in your project, causing Assets\Rewired\Internal\Scripts\Misc\ExternalTools.cs to be compiled in some assembly other than Assembly-csharp.dll that does not have a reference to the assembly compiled from Assets\Rewired\Internal\Scripts\Platforms\Windows\Functions\Functions.asmdef.

    If you use ASMDEF files in your project, you have to carefully manage every aspect:
    https://guavaman.com/projects/rewired/docs/HowTos.html#asmdef-files
     
  19. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    The Id cannot be used to select a Rule Set or Rule in a Player at runtime. Rule Sets can be defined entirely in code and can also be duplicated at runtime, in which case they would not have an id that would correspond to the other Rule Set definitions that exist in the Rewired Input Manager.

    The Id constant which can be exported for rule sets exists only for the purpose of instantiating that Rule Set (loading it from the Rewired Input Manager) into a Player. That is not a common thing to do since most of the time you will assign these Rule Sets to your Player in the Rewired Editor and they will be loaded for you when the application starts. Once the application starts, Rule Sets are instantiated for each Player, after which point they have no connection anymore to the parent Rule Set definition from which they came.

    You have to use the Tag to select a rule set at runtime as shown in the Map Enabler documentation:

    Code (csharp):
    1. // Enable the Rule Set with the tag "UI"
    2. player.controllers.maps.mapEnabler.ruleSets.Find(item => item.tag == "UI").enabled = true;
     
    Last edited: Apr 5, 2023
    flashframe likes this.
  20. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    797
    Ok, thanks for clarifying. I was just switching to using the generated IDs for Actions, and thought it'd be nice to do the same for rule sets, to avoid strings throughout my code. So I'll use constant strings instead
     
  21. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Thx! That solved it.
     
  22. iLoveGamesDeveloper

    iLoveGamesDeveloper

    Joined:
    Aug 8, 2019
    Posts:
    14
    Hello!
    I have been getting a null object in the Controller controller in some occasions when getting the event from Player.controllers.AddLastActiveControllerChangedDelegate(Player, Controller). Is this expected?

    This is not usual, but I have been trying different controls swapping so it might be why I started seeing it. The main things that might be out of the ordinary is thatt I'm accessing the game UI which is stopping Time.deltaTime. The main steps for our project for this to happen are:
    • I start the game with the controller connected (if I connect it while the game is on, it doesn't happen)
    • I don't use move or use the mouse or keyboard
    • I only use the gamepad
    • I open the UI menu
    • I disconnect the controller
    • The exception happens when is calling LastActiveControllerChanged
    There might be other ways of triggering the error but this has been the one I've found consistent so far.
    This is a picture of the breakpoint:

    upload_2023-4-7_16-30-12.png

    This is the error:
    Code (CSharp):
    1.  
    2. Trying to get controller name exception: System.NullReferenceException: Object reference not set to an instance of an object
    3.   at Nomad.GoneAway.GameInputManager.DefineAnalyticsWhenControllerChanged (Rewired.Player player, Rewired.Controller controller) [0x00053] in C:\Users\ProjectManager\Documents\Unity\GoneAway\Assets\Scripts\Input\GameInputManager.cs:45
    4. UnityEngine.Debug:LogError (object)
    5. Nomad.GoneAway.GameInputManager:DefineAnalyticsWhenControllerChanged (Rewired.Player,Rewired.Controller) (at Assets/Scripts/Input/GameInputManager.cs:49)
    6. OzuwuQspMvDmFgaYlkFgVUjXOREyA`1<Rewired.PlayerActiveControllerChangedDelegate>:WkEIHNWRAChbzjbcJQHkWrAwQxsd (OzuwuQspMvDmFgaYlkFgVUjXOREyA`1/vTwgdOCpSZMFKOjluHWlifFQVnbHA<Rewired.PlayerActiveControllerChangedDelegate>,int,Rewired.Controller)
    7. OzuwuQspMvDmFgaYlkFgVUjXOREyA`1<Rewired.PlayerActiveControllerChangedDelegate>:lzQtftFgrdhWxlSTZNBDDLGbQNu (int,Rewired.Controller,int)
    8. OzuwuQspMvDmFgaYlkFgVUjXOREyA`1<Rewired.PlayerActiveControllerChangedDelegate>:uzSzkOiWrHdHOPzoeKyrCQovkTvT (int,Rewired.Controller)
    9. ZdahRlzMRHmytynTlBGzlbkkdrOo`1<Rewired.PlayerActiveControllerChangedDelegate>:pwvRIiZFyXcgvjXLwkzpOgUWBiEL (int,Rewired.Controller,Rewired.Controller,Rewired.Controller)
    10. sQUhNuelsgdElREOuzBUnZbPDjkc:ZfZDpSDjmUjdkljSuTJYJHAjjIkkA ()
    11. sQUhNuelsgdElREOuzBUnZbPDjkc:sOLNzBCCbZmFXkMugfndpShqgrUP (Rewired.UpdateLoopType)
    12. Rewired.ReInput:sOLNzBCCbZmFXkMugfndpShqgrUP (Rewired.UpdateLoopType)
    13. Rewired.InputManager_Base:DoUpdate (Rewired.UpdateLoopType,Rewired.Config.UpdateLoopSetting)
    14. Rewired.InputManager_Base:Update ()
    15.  
    Thanks in advance!
     
  23. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    Yes. This is not guaranteed to return a non-null controller object. The last active controller can be null. It will always be null before any controller is used. It will also be null if the last active controller is no longer present (you unplug it). Check whether the last active controller is null before using it or use the GetLastActiveControllerType instead.
     
    iLoveGamesDeveloper likes this.
  24. iLoveGamesDeveloper

    iLoveGamesDeveloper

    Joined:
    Aug 8, 2019
    Posts:
    14
    I'll use OnControllerPreDisconnect to store the name and use if if the name is null then. Thanks for your help!
     
  25. ThomasMoonKang

    ThomasMoonKang

    Joined:
    Aug 19, 2013
    Posts:
    7
    Holding Shift and R is not getting recognized (both are returning as false for GetButton())
    Shift and E work for example.
    Is there any way around this?
     
  26. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    Rewired isn't stopping two keys from working when pressed simultaneously. If they're not working, then it's either your keyboard map causing it or key jamming:
    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#key-jamming

    It is highly doubtful that a two key combination involving the Shift key would be unsupported by your keyboard. This would only be the case if other keys are also being pressed.

    Otherwise, your keyboard map has to be at fault. View exactly what is mapped live at runtime in all your keyboard maps using Debug Information:
    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#debug-information
     
  27. ThomasMoonKang

    ThomasMoonKang

    Joined:
    Aug 19, 2013
    Posts:
    7
    Thanks yeah, it was another keyboard map with a binding for Shift+R that nullifies the Shift binding and R binding if both are pressed.
     
  28. uurha

    uurha

    Joined:
    Nov 15, 2020
    Posts:
    21
    Hi, does bug with Steam Deck fully fixed?
     
  29. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    I would ask Valve this question. It was never a bug in Rewired. As far as I am aware, it is fixed.
     
    uurha likes this.
  30. Peeling

    Peeling

    Joined:
    Nov 10, 2013
    Posts:
    443
    Hi! For months now we've been experiencing a strange cross-platform lockup on our Steam and Switch builds that we haven't been able to pin down. I'll explain why I'm bringing it up here in a moment.

    If we pause the game (Time.timeScale=0) for a significant period, say 20 minutes, and then attempt to resume, the game locks up for a minute or so, not refreshing the screen and not responding to input. After a couple of minutes, it unfreezes and everything continues as normal. The same occurs on Switch if the device is put to sleep and woken up.

    The length of the lockup is proportional to the amount of time spent paused, very much as though something in the game is attempting to catch up on real time elapsed. It can occur in any scene in the game, including front-end scenes with no game logic.

    We only use Time.unscaledTime in one place in the game, and not in a way that could cause a block. We use Time.frameCount a lot, but only as random seeds.

    The reason I'm coming here is that we discovered today if we unplug the (wired) controller and plug it back in again while the game is locked up, it immediately returns to life. This doesn't mean the issue is in Rewired but it does seem controller-related., so I wondered if you had any experience of this. Maybe we're misusing it in some fashion - that's happened before :)

    So far we've been unable to repro the problem in the editor, only in builds.

    Thanks!
     
  31. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    Rewired only uses Time.unscaledTime and its own internal 64-bit time that uses System.Stopwatch. Changing Time.timeScale won't affect Rewired. Rewired only monitors Time.timeScale so it can clear input events. Changing the time scale would not cause Rewired to freeze or any of its code to stop running.

    There is only one known issue that would result in something bad to occur with time passage, and it would only affect Windows Standalone build and editor Pause in Windows with specific settings and controllers.

    1. Unity Player with Run in Background set to False.
    2. Dual Shock 4 or Dual Sense controller connected with Enhanced Device Support Enabled.
    3. Send application out of focus for a long time.

    Input events from the gyro / accelerometer will build up in memory, causing the memory footprint of the application to grow.

    This would not lead to a freeze, nor a freeze that would be resolved by disconnecting a controller.

    There's very little in common with the Nintendo Switch platform and Windows Standalone. I can't discuss Switch issues on this forum, but there is nothing I can think of that could cause what you're describing, and definitely nothing in the common Rewired_Core.dll code that is shared among all platforms.
     
  32. nickfourtimes

    nickfourtimes

    Joined:
    Oct 13, 2010
    Posts:
    219
    I've got a little issue on macOS. I've got Settings → OSX → Input Source set to "GameController" (note that I also get this behaviour if Input Source is set to "Native" and I enable "Use Game Controller Framework"). I'm using the SteelSeries Nimbus+ controller, and I have a mapping for the "Center 2" button called "Pause" (i.e., hitting the Menu button on the Nimbus+ should fire the "Pause" action).

    However, if I run the game, there's no response from hitting the Menu button. Note that I can look in the Rewired Input Manager's inspector, and under Controller Maps/Joysticks/Nimbus+/Category (Enabled)/Button Maps, I do not see the Menu button listed as a possible input provider. If I return the Input Source to "Native," I do see "Center 2" listed under Button Maps.

    I've also tried in the Rewired sample PressStartToJoin, and I get the same results: using the Game Center Framework, I do not see "Center 2/Menu" in the list of Button Maps; but switching to Native Input Source, I do see it present. We sort of need the Game Center Framework (I'm using it to support Apple's button remapping API), so I'm wondering if the behaviour I'm seeing is a bug, or if I'm missing something else...
     
  33. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    This is because the Gamepad Template mapping was made for the Apple MFi gamepad was made many, many years ago and remains unchanged to be compatible with old MFi devices. Apple has changed the buttons of MFi "extended gamepad" devices since then.

    The Gamepad Template defines Center 2 as Pause. The problem is, Pause does not exist on the Nimbus+. Instead, it has Menu, Home, and Options buttons with no Pause button. Therefore, nothing is mappable for any of the center buttons using the Gamepad Template. The easiest solution is to map your controller using the Apple MFi controller definition. If you want to support both old and new gamepads, you're going to have to bind your Pause Action to both Pause and Menu. If I wanted to make the Gamepad Template support both old and new devices, I would have to make it bind Center 2 to two buttons as well. I don't know if there are MFi controllers that exist with both Pause and Menu buttons, but if there are, this will cause a double mapping to be created for a single Action which may cause problems in some binding UI designs in games where they do not account for more than one binding per Action.

    All MFi gamepads when used through Game Controller Framework are considered the same device type -- Apple Game Controller Extended Gamepad. Apple did not choose to create a new identifier when they decided to change the definition of what an Extended Gamepad was.
     
    nickfourtimes likes this.
  34. nickfourtimes

    nickfourtimes

    Joined:
    Oct 13, 2010
    Posts:
    219
    Got it, I'll see about that workaround – thanks for the detailed explanation!
     
  35. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    I will update the Gamepad Template as well.
     
    nickfourtimes likes this.
  36. ObsidianSpire

    ObsidianSpire

    Joined:
    Sep 13, 2013
    Posts:
    48
    Hi, is it possible to display more columns in the input field for controllers based on the number of mappings set up in Rewired? For example, take a ground pound that by default uses down on d-pad and down on the left stick, but almost all other actions only have one mapping. So the ideal display would be one column for everything other than the actions that have multiple mappings previously set up.
     
  37. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    If you're referring to Control Mapper, no. You set the number of columns you want when you set up Control Mapper. All Control Mapper options are displayed in the inspector:
    https://guavaman.com/projects/rewired/docs/ControlMapper.html#inspector-options

    Obviously, you can do whatever you want when you create your own UI from the ground up.
     
  38. nickfourtimes

    nickfourtimes

    Joined:
    Oct 13, 2010
    Posts:
    219
    Oh and just to confirm: I don't strictly see "Apple MFi" in the list of joysticks under Joystick Maps; do you mean the "iOS MFi Gamepad"? I've set up a mapping for the latter, though my SteelSeries Nimbus+ still gets assigned the Gamepad Template mapping. (Or do I have to create a mapping for the Nimbus+ specifically, which I know does show up in the list of joysticks)
     
  39. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    iOS MFi Gamepad. The editor-facing name will be changed in the next version. MFi as well as Game Controller Framework were once iOS-only.

    If you are using the Game Controller Framework, the iOS MFi Gamepad applies to all Game Controller Framework Extended Gamepads unless a controller definition explicitly exists for this input source that takes priority. The only controllers that have their own Game Controller Framework definitions are Xbox One controller, Dual Shock 4, Dual Sense, and Nintendo Switch Pro Controller. Everything else uses iOS MFi Gamepad definition if it is supported by the Game Controller Framework and is an Extended Gamepad.

    Whenever you change something in the Rewired Input Manager and nothing happens, it usually means you're loading saved XML data that is overriding your changes. This is logged as warnings in the editor.

    https://guavaman.com/projects/rewired/docs/UserDataStore.html#saved-xml-not-synced

    If the controller is not being detected as a Game Controller Framework compatible device, it will be treated as a HID device, assuming you're using the Native input source with Game Controller Framework support and not the Game Controller Framework input source exclusively. This would be visible in Debug Information looking at the Controller's data. The name of the underlying api is visible in the joystick identifier string. If it says "GCController" or GameControllerFramework, then it is being handled by GCController. If just says OSX, then it's not.
     
    Last edited: May 3, 2023
    nickfourtimes likes this.
  40. mm1982

    mm1982

    Joined:
    Apr 28, 2015
    Posts:
    35
    Hi,
    was wondering if someone could point me in the right direction for debugging this issue I'm having after upgrading. I went from Unity 2020.3 to Unity 2022.2 (Linux) and Rewired 1.1.41.5 to latest 1.1.44.0

    The issue is with the mouse look axis. Instead of smooth movement, it appears as if it basically doesn't move until some threshold and then snaps to the next point. My joysticks still work fine, this affects the mouse only. I did a clean re-install of Rewired, and did not change any of my Unity input settings nor Rewired input manager settings. I'm using the Mouse Axis mode, and "Input Manager (Old)" for my Active Input Handling in project settings.

    Using the debug info and logging what the ReInput player GetAxis/GetAxisRaw methods return for the mouse axis, it looks like I get back 0 most frames, interleaved with values ranging between ~10-50 for a couple frames in a row, before returning 0s again

    Thanks for the help
     
  41. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    On Linux, Rewired simply consumes UnityEngine.Input.GetAxis with "Mouse X", "Mouse Y", and "Mouse Scroll Wheel" values to get the input for the mouse. It does not implement native input for Mouse input on Linux.

    Player.GetAxisRaw is not the lowest level you can test in Rewired. Debug Information -> Controllers -> Mouse -> Axes is. Player.GetAxisRaw is still going through the Player-Action system and is affected by your Controller Maps and Input Behaviors.

    If the Controller Axis vales are bad too, the most likely source of the problem would be UnityEngine.Input. You can easily verify this easily by logging UnityEngine.Input.GetAxis for the mouse axes every frame.
     
  42. mm1982

    mm1982

    Joined:
    Apr 28, 2015
    Posts:
    35
    thanks for the reply, yeah, I've verified that, it is the same values from Unity Input. So, sorry you can disregard my post... I'll have to find my solution elsewhere. Rewired still requires the legacy Unity input system to work correct?
     
  43. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    Yes. You can see exactly what platforms and device types use or can use native solutions and which depend on Unity here. I will not be replacing it with dependency on the new input system unless I am absolutely forced to. That would likely be a several months long process because of all the platforms, and it would require me to re-map all devices for every platform regardless of whether or not a native solution also exists because of the ability to choose your input sources on every platform. There would be no functional benefit, apart from sidestepping Unity legacy input system bugs like the new one you discovered, but there would also likely be many new problems and bugs to deal with in the new input system. The better solution would be for me to make native input solutions for every single platform and every device type across the board, but I simply don't have the time to do that. Native libraries are also a heavy maintenance burden, as SDKs constantly change, and many platforms that have app stores also have progressive minimum SDK build requirements that require you constantly be updating your binaries (while also maintaining support for older SDK's for existing games that get updates.)
     
    Last edited: May 5, 2023
  44. mm1982

    mm1982

    Joined:
    Apr 28, 2015
    Posts:
    35
    thanks, no I wasn't asking for a switch, just verifying.
    For what it's worth, it appeared to be an editor only issue (I also tried the 2023 alpha/beta editors), I ran a build and the mouse look seemed ok in the build.
    Regardless I ended up downgrading back down to Unity 2020 for now
     
  45. Diogof

    Diogof

    Joined:
    Oct 4, 2016
    Posts:
    5
    Hello good morning. I have a problem. My Rewired Input Manager reads joystick inputs but doesn't link them to actions. I'm using 2 xbox 360 joysticks. It's probably a rookie mistake but I'm having a hard time solving it haha.
     

    Attached Files:

  46. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    Controller Maps are responsible for binding controller elements to Actions in a Player:

    https://guavaman.com/projects/rewired/docs/ControllerMaps.html

    Whenever you are trying to debug why something isn't working in Rewired, use the Debug Information checklist:
    https://guavaman.com/projects/rewir...l#debug-information-diagnosing-input-problems
     
  47. qazwsx2498

    qazwsx2498

    Joined:
    Oct 17, 2022
    Posts:
    13
    IDragHandler.OnDrag is not working on the game UI of mobile devices, whether this is due to a setting of rewired
     
  48. qazwsx2498

    qazwsx2498

    Joined:
    Oct 17, 2022
    Posts:
    13
    Both OnPointerDown and UP fired when I clicked on the UI, only OnDrag didn't take effect
     
  49. Cellenseres

    Cellenseres

    Joined:
    Mar 30, 2015
    Posts:
    67
    Hello everyone,

    I'm currently working with Rewired in a project that was initially set up by a former colleague. They implemented a system for the player to rebind their buttons, and this feature is functioning properly. However, we're experiencing difficulties when trying to integrate new actions into the system.

    The existing setup uses ReInput.userDataStore.Save() and ReInput.userDataStore.Load() to manage changes to the user input settings. The issue arises when we attempt to add new actions; these new actions don't appear in the ControllerMap obtained via player.controllers.maps.GetMap(...). The only workaround we've found to ensure the new actions appear is to call player.controllers.maps.LoadDefaultMaps(ControllerType....), but this unfortunately resets the player's custom input bindings, which we want to avoid at all costs.

    I've attempted to solve this problem by creating and adding missing button maps to the ControllerMap. However, this approach hasn't yielded the expected results, and the added actions are mysteriously absent after calling AddMap. Here's the relevant code:

    Code (CSharp):
    1. [ContextMenu("Check Controllers")]
    2.     public async void CheckControllerMaps()
    3.     {
    4.         foreach (Controller controller in player.controllers.Joysticks)
    5.         {
    6.  
    7.             var MissingMaps = GetMissingButtonMaps();
    8.             Debug.Log("Elements: " + MissingMaps.Count);
    9.  
    10.             foreach (var missingMap in MissingMaps)
    11.             {
    12.                 var controllerMapToModify = player.controllers.maps.GetMap(missingMap.ButtonMapId);
    13.                 controllerMapToModify.CreateElementMap(missingMap.MissingActionElementMap.actionId,
    14.                     missingMap.MissingActionElementMap.axisContribution, missingMap.MissingActionElementMap.keyCode,
    15.                     missingMap.MissingActionElementMap.modifierKey1, missingMap.MissingActionElementMap.modifierKey2,
    16.                     missingMap.MissingActionElementMap.modifierKey3, out ActionElementMap element);
    17.            
    18.                 player.controllers.maps.AddMap(controller, controllerMapToModify);
    19.             }
    20.         }
    21.     }
    22.  
    23.  
    24. public List<MissingElement> GetMissingButtonMaps()
    25.     {
    26.         const int DefaultMapLayoutId = 0;
    27.         var player = ReInput.players.GetPlayer(0);
    28.         List<MissingElement> missingElements = new List<MissingElement>();
    29.  
    30.         foreach (Controller controller in player.controllers.Joysticks)
    31.         {
    32.             var rewiredDefaultMaps = ReInput.mapping.MapCategories;
    33.             var rewiredUserMaps = player.controllers.maps.GetAllMaps().ToList().FindAll(x => x.controllerType == ControllerType.Joystick);
    34.  
    35.             foreach (var mapCategory in rewiredDefaultMaps)
    36.             {
    37.                 var defaultMap = ReInput.mapping.GetJoystickMapInstance(controller.identifier, mapCategory.id, DefaultMapLayoutId);
    38.                 var userMap = rewiredUserMaps.Find(x => x.categoryId == defaultMap.categoryId);
    39.                 if (defaultMap == null || userMap == null)
    40.                 {
    41.                     continue;
    42.                 }
    43.  
    44.                 // Get all ButtonMaps in the defaultMap and check if they exist in userMap
    45.                 foreach (var buttonMap in defaultMap.ButtonMaps)
    46.                 {
    47.                     // If a ButtonMap with the same actionId does not exist in the userMap, add it to the missingElements list
    48.                     if (!userMap.ButtonMaps.Any(bm => bm.actionId == buttonMap.actionId))
    49.                     {
    50.                         missingElements.Add(new MissingElement { MissingActionElementMap = buttonMap, ButtonMapId = userMap.id });
    51.                     }
    52.                 }
    53.             }
    54.         }
    55.  
    56.         return missingElements;
    57.     }
    This code attempts to find missing button maps and add them to the player's ControllerMap. However, after invoking AddMap, the newly added ActionElementMap seems to disappear from controllerMapToModify and won't appear in the newly added ControllerMap as well.

    I'm wondering if there's a more efficient way to integrate the missing ActionElementMap into the existing ButtonMap. Any insights or guidance on this issue would be greatly appreciated. Thanks in advance for your time and help!
     
    Last edited: May 16, 2023
  50. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    1. You are attempting to create a keyboard key binding in a Joystick Map. This will not work and explains why your Action Element Map is disappearing.

    2. You are attempting to add the same Controller Map that already exists in the Player back into that Player. This will not do anything.

    3. Your code does not handle the problem of your merging creating new binding conflicts.

    4. There is no especially efficient way to handle managing saved user data. There are many possible issues you will run into in doing this and many different ways merging might need to be handled based on individual needs. There is no built-in functionality designed to make management of this task easier. It will always be a manual process of making comparisons and merging.

    ---------

    https://guavaman.com/projects/rewired/docs/UserDataStore.html

    "IMPORTANT: Saved XML data is not updated when you make changes to the Rewired Input Manager

    UserDataStore does not manage changes between the Rewired Input Manager and data that is already saved to XML. If you make changes to the Rewired Input Manager settings such as adding new controls to a Joystick Map, these new changes will not be preserved when loading saved XML data. The only automated solutions would be to either clear the save data by clearing Player Prefs so that the Rewired Input Manager defaults are used instead or load the default maps in the Player for the any controllers that changed and save those to XML overwriting the existing saved mappings.

    Management of saved user data is up to the developer. If you have special needs beyond the basic use cases, you should extend and replace the UserDataStore_PlayerPrefs component with a new UserDataStore component that meets your specific needs."

    ---------

    There is already code in UserDataStore_PlayerPrefs to handle very simple new Action binding merging with saved user data. This is a very rudimentary implmentation, subject to the limitations of Player Prefs. I suggest you look at the UserDataStore_PlayerPrefs source code. A more sophisticated management of saved user bindings should be handled by re-implementing UserDataStore, saving the data to a more flexible system than PlayerPrefs, and then writing all the code to manage changes to this data before ever loading this data back into Rewired Controller Maps or Players.