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,609
    Exactly.

    http://guavaman.com/projects/rewired/docs/RewiredEditor.html#ActionCategories

    Action Categories can be used to organize your Actions. Action Categories can also be used in a user control mapping UI to display categorized lists of Actions to the user.
     
  2. _eternal

    _eternal

    Joined:
    Nov 25, 2014
    Posts:
    303
    Thank you! I can't speak for other issues yet, but this fix is working now for both keyboard and joystick.
     
    guavaman likes this.
  3. IceBeamGames

    IceBeamGames

    Joined:
    Feb 9, 2014
    Posts:
    170
    Hey @guavaman,

    I am having trouble getting the steam controller working. I have followed the steam best practises, and have set the input manager to use "RawInput" with the "use Xnput" set as true, and "Disable Native Input" is not checked.

    When running in the unity editor, the controller appears as a mouse and keyboard (although this might actually be expected behaviour? I am not 100% sure). And when I run the development build through the steam app, the controller is completely disabled.

    Is there a key step I have missed in the documentation?
     
  4. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    See the Troubleshooting section on the Steam Controller:
    http://guavaman.com/projects/rewired/docs/Troubleshooting.html#steam-controller

    #1 Editor problem: The mode of the Steam Controller is completely dependent on your settings in Steam: http://guavaman.com/projects/rewire...ml#steam-controller-appears-as-mouse-keyboard
    This is an issue in Steam and not something that I can really provide support on even though I have this information in my documentation because of the number of people asking. See the Steamworks documentation for how to set this up.

    #2 Build problem: Probably the same as #1, but if not, check all the usual suspects first:
    http://guavaman.com/projects/rewired/docs/Troubleshooting.html#joystick-problems
    http://guavaman.com/projects/rewired/docs/Troubleshooting.html#debug-information

    Debug Information is always the best way to solve almost every problem. You will be able to see whether it's a Joystick not appearing or non-functional issue, joystick assignment to Player issue, Controller Map issue, etc.

    There is quite literally nothing Rewired has to do to support the Steam Controller beyond picking it up as an XInput device if using XInput. This is extremely uncomplicated and cannot be broken unless XInput support is broken completely.
     
    IceBeamGames likes this.
  5. cascadiagames

    cascadiagames

    Joined:
    Dec 21, 2015
    Posts:
    3
    Hey all,

    So far I'm loving Rewired. But I have a mystery problem. When I used "Gamepad Template" as my joystick, everything mapped well for most controllers / platforms. But for some reason, on Apple TV tvOS, the "B" and "Center" buttons didn't map properly -- they both just minimize the game and take me back to the OS's dashboard.

    To try to remedy this, I also mapped "iOS MFi Gamepad". It maps perfectly on iOS. I also mapped two extra buttons to ensure this was the map being used on tvOS -- and it is. But still the B / Center buttons minimize the game, rather than do the actions they're mapped to.

    Any thoughts?
     
  6. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    This has nothing to do with mapping. These are actions being controlled by the OS. Rewired does not communicate directly with the OS in any way on iOS or tvOS and runs on top of Unity's input system. Look here:
    https://docs.unity3d.com/Manual/tvOS.html

    The Menu button has special behavior on this device; a long press invokes the tvOS task switcher. This behavior cannot be overridden. Short taps can be processed two ways:
    • a) Returning to the tvOS system home screen (if UnityEngine.Apple.TV.Remote.allowExitToHome is true)
    • b) Letting your app respond to taps (mapped to button “Pause” / joystick button 0), when UnityEngine.Apple.TV.Remote.allowExitToHome is false. This the default behavior.
    • Your app should switch between a) and b) based on the current state of your game. If the user is interacting with the top menu, enable behavior a); if they are interacting in real time with the game you should enable behaviour b) and invoke in the in-game pause menu when this button is pressed.
    ---

    Even if Rewired did someday implement native code on iOS, Unity's system would be running in the background regardless.
     
    Last edited: Jul 28, 2018
  7. QFSW

    QFSW

    Joined:
    Mar 24, 2015
    Posts:
    2,906
    Hi @guavaman , is it possible to localise action names, categories etc? I have the control remapper localised but they remain the same since I don't see any way to do it
     
  8. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    No. There is no localization system in Rewired. One of a million things on the to-do list.

    You would also have to localize controller names, controller element names, partial element names, etc. You would have to do this the same way you do glyphs:
    http://guavaman.com/projects/rewired/docs/HowTos.html#display-glyph-for-action
    http://guavaman.com/projects/rewired/docs/HowTos.html#identifying-recognized-controllers
     
  9. Raidenwins

    Raidenwins

    Joined:
    Dec 18, 2012
    Posts:
    132
    Hey @guavaman,

    I am experiencing the following problem with Rewired. I have an animated character and a Punch animation. The behavior I want is when the button for punching is pressed the Punch animation to be played once and that's it.

    If the button in question is pressed once it works as expected. However, if the button is pressed and held the character starts performing the Punch animation over and over in a loop and that pretty much breaks the game from that point on.

    The code I have for accomplishing this is the following:

    Code (CSharp):
    1. public class MyClass : MonoBehaviour
    2. {
    3.     private static float lastTechniqueTime;
    4.  
    5.     private int playerId;
    6.     private float animationLength;
    7.     private Animator animator;
    8.  
    9.     void Start()
    10.     {
    11.         playerId = 1;
    12.         animationLength = 2.0f;
    13.         lastTechniqueTime = Time.realtimeSinceStartup;
    14.         animator = GetComponent<Animator> ();
    15.     }
    16.  
    17.     void Update()
    18.     {
    19.         float timeElapsed = Time.realtimeSinceStartup - lastTechniqueTime;
    20.  
    21.         if (PunchDown() && timeElapsed > animationLength)
    22.         {
    23.             lastTechniqueTime = Time.realtimeSinceStartup;
    24.  
    25.             animator.SetBool ("Punch", true);
    26.         }
    27.  
    28.         if (PunchReleased())
    29.         {
    30.             animator.SetBool ("Punch", false);
    31.         }
    32.     }
    33.  
    34.     private bool PunchDown()
    35.     {
    36.         if (!ReInput.isReady) return false;
    37.  
    38.         return ReInput.players.GetPlayer(playerId).GetButtonDown("punchAction");
    39.     }
    40.  
    41.     private bool PunchReleased()
    42.     {
    43.         if (!ReInput.isReady) return false;
    44.  
    45.         return ReInput.players.GetPlayer(playerId).GetButtonUp("punchAction");
    46.     }
    47. }
    In my PunchDown method I've tried using GetButton instead of GetButtonDown, but the result is the same. I've also tried to put the logic in the Update method in an If-Else clause, like so:

    Code (CSharp):
    1.     if (PunchDown() && timeElapsed > animationLength)
    2.     {
    3.         lastTechniqueTime = Time.realtimeSinceStartup;
    4.  
    5.         animator.SetBool ("Punch", true);
    6.     }
    7.     else if (PunchReleased())
    8.     {
    9.         animator.SetBool ("Punch", false);
    10.     }
    Again, I got the same result as above.

    What is the problem here?
     
    Last edited: Aug 1, 2018
  10. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    The problem you're having is not with Rewired. It's a problem with your logic in your use of the Animator variable. Rewired is giving you the correct data. Try replacing the Rewired GetButtonDown call with Input.GetKeyDown(KeyCode.P) and you'll get the same result.

    You've set the value of Punch in the animator to True for as long as the button is held. So your animator is going to keep seeing that bool as set to True and will keep punching until the button is released and the Punch value is set to false.

    Look at the example in the Animator documentation:
    Code (csharp):
    1. //Click the mouse or tap the screen to change the animation
    2. if (Input.GetMouseButtonDown(0))
    3.     m_Jump = true;
    4.  
    5. //Otherwise the GameObject cannot jump.
    6. else m_Jump = false;
    The value is instantly set to false if GetButtonDown is not true. The Animator has already received the True value for one frame and started the animation. It doesn't need that value set anymore.

    If you have problems like this, a super quick debug log showing that the value coming back from Rewired's player.GetButtonDown is correct would show you that the problem isn't in Rewired.
     
  11. Raidenwins

    Raidenwins

    Joined:
    Dec 18, 2012
    Posts:
    132
    My apologies, I didn't fully explain what the problem was. What I meant to say was that if I press the button for punching, hold it, and then release, the animation still keeps on playing over and over again. Essentially, even though I release the button, the Punch value is never set to false.

    So, in short:

    Press Button --> Release: things work fine

    Press Button --> Hold --> Release: punch animation stuck in loop
     
  12. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Do this:

    Code (csharp):
    1. private bool PunchDown()
    2. {
    3.     if (!ReInput.isReady) return false;
    4.     bool value = ReInput.players.GetPlayer(playerId).GetButtonDown("punchAction");
    5.     Debug.Log("Punch pressed");
    6.     return value;
    7. }
    8.  
    9. private bool PunchReleased()
    10. {
    11.     if (!ReInput.isReady) return false;
    12.     bool value = ReInput.players.GetPlayer(playerId).GetButtonUp("punchAction");
    13.     Debug.Log("Punch released");
    14.     return value;
    15. }
    Tell me what you see in the log.
     
  13. Raidenwins

    Raidenwins

    Joined:
    Dec 18, 2012
    Posts:
    132
    Because these two methods are inside of the Update method and are being called on every frame, the log is basically this repeated over and over again:

    However, if I do this instead:

    Code (CSharp):
    1. void Update()
    2.     {
    3.         float timeElapsed = Time.realtimeSinceStartup - lastTechniqueTime;
    4.         if (PunchDown() && timeElapsed > animationLength)
    5.         {
    6.             Debug.Log("Punch pressed");
    7.          
    8.             lastTechniqueTime = Time.realtimeSinceStartup;
    9.             animator.SetBool ("Punch", true);
    10.         }
    11.         if (PunchReleased())
    12.         {
    13.             Debug.Log("Punch released");
    14.  
    15.             animator.SetBool ("Punch", false);
    16.         }
    17.     }
    and I press the button for Punch and release it, the log looks like so:

    and if I press the button, hold, and then release, the log is:

     
  14. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Sorry, I messed up in the code. It should have been:

    Code (csharp):
    1. private bool PunchDown()
    2. {
    3.     if (!ReInput.isReady) return false;
    4.     bool value = ReInput.players.GetPlayer(playerId).GetButtonDown("punchAction");
    5.     if(value) Debug.Log("Punch pressed");
    6.     return value;
    7. }
    8.  
    9. private bool PunchReleased()
    10. {
    11.     if (!ReInput.isReady) return false;
    12.     bool value = ReInput.players.GetPlayer(playerId).GetButtonUp("punchAction");
    13.     if(value) Debug.Log("Punch released");
    14.     return value;
    15. }
    Based on your code, GetButtonUp is never returning true. This should not be possible. There are only a couple of scenarios I know of where you could ever not receive a GetButtonUp event:
    1. The underlying Controller is disabled somewhere else in code between the time you call GetButtonDown and GetButtonUp.
    2. The Controller Map or Action Element Map is removed or disabled somewhere else in code between the time you call GetButtonDown and GetButtonUp.
    3. Rewired is being disabled somewhere else in code between the time you call GetButtonDown and GetButtonUp.

    What are you using for testing? Joystick, keyboard, mouse? Which controller if joystick?
    What version of Rewired are you using?

    Are you using a non-zero Button Down Buffer on your Input Behavior?

    Replace the code with this and test just to make sure:

    Code (csharp):
    1. private bool PunchDown()
    2. {
    3.     bool value = ReInput.players.GetPlayer(playerId).GetButtonDown("punchAction");
    4.     if(value) Debug.Log("Punch pressed");
    5.     return value;
    6. }
    7.  
    8. private bool PunchReleased()
    9. {
    10.     bool value = ReInput.players.GetPlayer(playerId).GetButtonUp("punchAction");
    11.     if(value) Debug.Log("Punch released");
    12.     return value;
    13. }
    If Rewired is being disabled, you will get a null reference exception.
     
    Last edited: Aug 2, 2018
  15. Raidenwins

    Raidenwins

    Joined:
    Dec 18, 2012
    Posts:
    132
    Well that's interesting. I used your code above and if I do press button then release, I get this in the log:

    And if I do press, hold, release, the log is:

    So GetButtonUp returns True, but for some reason it doesn't go in the IF clause that checks if it's True. That's puzzling.

    I tested with a keyboard and an XBox One controller and I got the same result both times. My Rewired version is 1.1.7.8.U5. And I do not get a null reference exception, so Rewired must not be disabled.

    And I don't know if I am using a non-zero Button Down Buffer. How do I do that?
     
  16. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    You're getting two punch releases and only one press? The only way this would be possible would be if you were calling this in FixedUpdate and Rewired is not set to update in FixedUpdate. But your code says Update.

    Can you post your whole chunk of code again, the current version you're testing with?

    If you don't know what the setting is, you've left it at the default value of 0 and it's not an issue.

    Can you add this to the top of the Update function before any of your code executes and see what it says?

    Code (csharp):
    1. if(ReInput.players.GetPlayer(playerId).GetButtonDown("punchAction")) Debug.Log("Punch Down: " + Time.frameCount);
    2. if(ReInput.players.GetPlayer(playerId).GetButtonUp("punchAction")) Debug.Log("Punch Up: " + Time.frameCount);
     
  17. Raidenwins

    Raidenwins

    Joined:
    Dec 18, 2012
    Posts:
    132
    Just to test me theory I also added logs where the Punch animation is started and stopped, i.e. this:

    Code (CSharp):
    1. void Update()
    2.     {
    3.         float timeElapsed = Time.realtimeSinceStartup - lastTechniqueTime;
    4.         if (PunchDown() && timeElapsed > animationLength)
    5.         {
    6.             Debug.Log("Start Punch animation");
    7.        
    8.             lastTechniqueTime = Time.realtimeSinceStartup;
    9.             animator.SetBool ("Punch", true);
    10.         }
    11.         if (PunchReleased())
    12.         {
    13.             Debug.Log("Stop Punch animation");
    14.             animator.SetBool ("Punch", false);
    15.         }
    16.     }
    The press-release log is:

    while the press-hold-release log is:

     
  18. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    That's seriously odd. I feel like some code is missing here because that should not be possible. Nothing can stop it from doing the Debug.Log after if(PunchReleased()) if it went ahead and logged the Debug.Log inside the PunchReleased method. There's not even a chance for an exception there.

    In addition, it should be impossible based on the code I see to show two "Punch Released" in the logs before showing "Stop Punch Animation". Every single "Punch Released" should be followed up by a "Stop Punch Animation."

    Can you post the whole script in its entirety?
     
  19. Raidenwins

    Raidenwins

    Joined:
    Dec 18, 2012
    Posts:
    132
    Yup, and definitely using an Update, i.e. not FixedUpdate.

    I think I may have figured it out, but first here is my whole code:

    Code (CSharp):
    1. public class MyClass : MonoBehaviour
    2. {
    3.     [B]private static int fightingState = Animator.StringToHash ("Base Layer.fighting_state");[/B]
    4.     private static float lastTechniqueTime;
    5.     private int playerId;
    6.     private float animationLength;
    7.     private Animator animator;
    8.     [B]private AnimatorStateInfo currentAnimatorState;[/B]
    9.  
    10.     void Start()
    11.     {
    12.         playerId = 1;
    13.         animationLength = 2.0f;
    14.         lastTechniqueTime = Time.realtimeSinceStartup;
    15.         animator = GetComponent<Animator> ();
    16.     }
    17.     void Update()
    18.     {
    19.         [B]currentAnimatorState = animator.GetCurrentAnimatorStateInfo (0);[/B]
    20.         float timeElapsed = Time.realtimeSinceStartup - lastTechniqueTime;
    21.  
    22.         [B]if (currentAnimatorState.nameHash == fightingState)
    23.         {[/B]
    24.             if (PunchDown() && timeElapsed > animationLength)
    25.             {
    26.                 lastTechniqueTime = Time.realtimeSinceStartup;
    27.                 animator.SetBool ("Punch", true);
    28.             }
    29.             if (PunchReleased())
    30.             {
    31.                 animator.SetBool ("Punch", false);
    32.             }
    33.         [B]}[/B]
    34.     }
    35.     private bool PunchDown()
    36.     {
    37.         if (!ReInput.isReady) return false;
    38.         return ReInput.players.GetPlayer(playerId).GetButtonDown("punchAction");
    39.     }
    40.     private bool PunchReleased()
    41.     {
    42.         if (!ReInput.isReady) return false;
    43.         return ReInput.players.GetPlayer(playerId).GetButtonUp("punchAction");
    44.     }
    45. }
    The code I had omitted before, thinking it wasn't relevant, is in bold. Well, upon thinking about some more it turns out that IF clause in bold may have been the problem, because it only allows program flow to go through if the character is in Fight animation, but if he is in the process of punching he is in a Punch animation and probably that's why when holding the button the Punch animation is not set to False. If I modify the IF clause to look like this:

    Code (CSharp):
    1. if (currentAnimatorState.nameHash == fightingState || currentAnimatorState.nameHash == punchingState)
    things work fine even if I hold the button before releasing.
     
  20. Raidenwins

    Raidenwins

    Joined:
    Dec 18, 2012
    Posts:
    132
    See my code above. You are right, I had omitted some code because I didn't think it was relevant. I was wrong though. So with the change I mentioned above it now works fine, although I still get "Punch released" twice for every "Punch pressed".
     
  21. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    @Raidenwins Thanks for posting it and clearing it up. That makes sense, except for the double "Punch Released". Do you happen to have two copies of this MonoBehavior being used at the same time? That's the only thing I can think of that could cause that. Rewired should not send GetButtonUp two frames in a row. The code I posted above would shed some light on this:

    Code (csharp):
    1. if(ReInput.players.GetPlayer(playerId).GetButtonDown("punchAction")) Debug.Log("Punch Down: " + Time.frameCount);
    2. if(ReInput.players.GetPlayer(playerId).GetButtonUp("punchAction")) Debug.Log("Punch Up: " + Time.frameCount);
    Placed directly after void Update() {, you would be able to see exactly how many times ButtonDown and ButtonUp are returned without any of the complication of other if statements. You would also see the frame count printed on it so you would know whether it's on the same frame or another frame that the two "Punch Released" is happening. If it shows the same frameCount, you could add the gameObject.name property to the log lines to log which GameObject the Component is on.
     
  22. Raidenwins

    Raidenwins

    Joined:
    Dec 18, 2012
    Posts:
    132
    Not a problem. Thank you and you were right about this not being a Rewired issue. I'll experiment with the code above.
     
  23. cascadiagames

    cascadiagames

    Joined:
    Dec 21, 2015
    Posts:
    3
    Thanks RE: Apple TV. That worked!
     
  24. auroxi

    auroxi

    Joined:
    Dec 31, 2012
    Posts:
    85
    Hi,

    I'm trying to add support for controllers in my game. All of the button maps are fine, as are movement of my character. The only thing I need to tackle is moving the "mouse" position with the right stick (say, on an Xbox 360 controller). Does anyone have a small c# code example that would achieve this well? I use the mouse to aim with PC controls so I'm just trying to replicate that with the right stick.

    Thanks.
     
  25. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    If you're talking about moving a mouse pointer, you cannot move the hardware pointer using anything but the mouse in Rewired. Rewired does allow control the hardware pointer on any platform. You would have to create a software pointer using a sprite, Unit UI Image, 3D object, etc. and move its position with the Player.

    If you're talking about just normal camera look code and the code expects pixel delta values like a mouse returns, process your input into simulated pixel deltas:

    Code (csharp):
    1. float lookSpeed = 1f;
    2. float absToRelMult = 400f; // this provides a base speed for sticks converted to pixel deltas
    3. // If you want this to scale to screen resolution, do something like
    4. // absToRelMult *= Screen.currentResolution.width / 1920f;
    5.  
    6. Vector2 lookDelta = player.GetAxis2D("LookHorizontal", "LookVertical");
    7. if(player.GetAxisCoordinateMode("LookHorizontal") == AxisCoordinateMode.Absolute) lookDelta.x *= Time.unscaledDeltaTime * absToRelMult;
    8. if(player.GetAxisCoordinateMode("LookVertical") == AxisCoordinateMode.Absolute) lookDelta.y *= Time.unscaledDeltaTime * absToRelMult;
    9. lookDelta *= lookSpeed;
     
    auroxi likes this.
  26. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Rewired 1.1.19.0 is now available for registered users. If you'd like to get early access to updates, contact me here.

    Please see Updating Rewired before updating.

    New Feature:
    Player Mouse makes it easy to create one or more software pointers controllable by keyboard, mouse, or joystick. The Rewired Standalone Input Module now supports software pointers so multiple Players can interact with the UI using any controller. See the documentation for additional important information including limitations.

    examples_playermouseunityui.png

    Release Notes:

    1.1.19.0:

    Changes:
    - Input Behaviors can now be exported to constants.
    - Added Player Controllers.
    - Rewired Standalone Input Module:
    + Modified Repeat Delay behavior to work better with joystick input.
    + Added support for interacting with the UI using one or more Player Mouse.
    + Added PlayerPointerEventData events to send UI pointer events with Player information.
    + Added custom inspector.
    - Added Player Mouse Sprite example.
    - Added Player Mouse Unity UI example.
    - Added DualShock 4 Special Features example.
    - Added Cinemachine integration.
    - Removed Ultimate Survival integration.
    - Unity UI integration is now part of the base package for Unity 5+. The auto installer has been removed.
    - Reverted to previous behavior where mouse input is always ignored when the Unity editor window is out of focus regardless of "Ignore Input when App out of Focus" setting.
    - UserDataStore_PlayerPrefs now saves and loads separate Controller Map data for multiple identical controllers assigned to the same Player.

    API Changes:
    - Added ReInput.MappingHelper.GetControllerTemplateMapInstance method.
    - Added ControllerTemplateActionElementMap.id property.
    - Added ReInput.InitializedEvent event.
    - Added PlayerController class.
    - Added PlayerController.Element class.
    - Added PlayerController.Axis class.
    - Added PlayerController.Button class.
    - Added PlayerController.MouseWheel class.
    - Added PlayerController.Element.Definition class.
    - Added PlayerController.Axis.Definition class.
    - Added PlayerController.Button.Definition class.
    - Added PlayerController.MouseWheel.Definition class.
    - Added PlayerMouse class.
    - Added Components.PlayerController class.
    - Added Components.PlayerMouse class.
    - Added UI.IMouseInputSource interface.
    - Added UI.ITouchInputSource interface.
    - Added Integration.UnityUI.RewiredPointerInputModule class.
    - Added Integration.UnityUI.PlayerPointerEventData class.
    - Added Integration.UnityUI.PointerEventType enum.
    - Added many new properties and methods to Integration.UnityUI.RewiredStandaloneInputModule.
    - Added ComponentControls.TouchPad.touchPosition property.
    - Added ComponentControls.TouchPad.touchStartPosition property.
    - Added ControllerExtensions.IDualShock4Extension interface.
    - Added ControllerExtensions.IDualShock4Extension interface to ControllerExtensions.DualShock4Extension.
    - Added ControllerExtensions.IDualShock4Extension interface to Platforms.PS4.PS4GamepadExtension.
    - Added ControllerExtensions.DualShock4Extension.touchCount property.

    Bug Fixes:
    - Setting Mouse.enabled = true every frame no longer causes mouse input to stop working.
    - Rewired Standalone Input Module: Fixed Repeat Delay bug in Unity StandaloneInputModule source causing Repeat Delay to be ignored after pressing two orthogonal direction keys quickly in succession.
    - Input Behavior id is now displayed in the Rewired Editor.
    - Fixed transposed On Press Down and On Press Up events in Touch Pad touch control.
    - Inserting a new Action in a non-Default Action Category is no longer set to the Default Action Category.
     
    Last edited: Aug 3, 2018
  27. Filhanteraren

    Filhanteraren

    Joined:
    May 14, 2014
    Posts:
    47
    Hi, First of all I want to say thanks for a fantastic product and support.

    I am using Rewired on Playstation4 and I have some issues that have accured and wanted to see if there is something to fix them

    1. Can you disable the touchpad input on the DS4 controller. Right now if you touch it gives input to the Right stick. I have aiming on that axis and I cant seem to find a way to disable the touchpad.

    2. I have a bug in the game that sometimes rarely when starting a level the Fire input seems to get stuck in a pressed state. Even after restarting the level the error exists. Why I suspect that Rewired is the culprit here is because it only happens on PS4 and Rewired is the only object marked as DontdestroyOnload so if there was something else it should get resolved upon restarting level.

    Thanks.
     
  28. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    No, I can't. But I doubt it's giving input through the right stick. It's almost certainly returning input as a mouse. Try disabling this:

    https://docs.unity3d.com/ScriptReference/Input-simulateMouseWithTouches.html

    If that doesn't work, do this:

    Code (csharp):
    1. #if UNITY_PS4
    2. ReInput.controllers.Mouse.enabled = false;
    3. #endif
    That can't be Rewired and I have heard of the issue before. Rewired polls all button states every single frame. There's no possibility it could retain the value. If the button value is getting stuck, it would have to be Input.GetKey getting stuck. Rewired uses Input.GetKey plus Unity's special PS4 input class for input on the PS4 platform. Drop the Rewired/DevTools/UnityJoystickElementIdentifier in your project and it will display on screen the values from UnityEngine.Input for each joystick. If that sticks, file a bug report with Unity.
     
  29. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    Several nice things in this Rewired update @Steve-Tack . The Player Controllers addition will be very useful.
     
    guavaman likes this.
  30. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
  31. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
  32. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
  33. s8cusyqr

    s8cusyqr

    Joined:
    Jul 9, 2018
    Posts:
    7
    I want to change input if mode is handheld, how can I check what map is used for a player (if he uses jaycon or handehld mode) like this:
    if(Reinput.Player(0).handheldmode)
     
  34. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
  35. TareqProjects

    TareqProjects

    Joined:
    Jun 27, 2016
    Posts:
    55
    Hello,

    I've downloaded the trial and have been following the documentation. So far I've managed to get something working with one joystick (I'm using the Thrustmaster t.160000M). I'm wondering if it's possible to assign the one player two joysticks, a left joystick and a right joystick?

    What I've tried is separating actions for the left and right joystick into two categories, and then added another joystick input under the Player. Within the same tab, I've set Joystick map 0 to use the actions for the right category, and joystick map 1 to use the left category actions. The code hasn't changed (it's the same one that's written in the documentation). I was wondering if there was an extra step that I have to do to be able to use 2 joysticks for one player

    Many thanks

    edit: I actually managed to connect the two joysticks and output a debug message. The problem is that moving the right joystick also does the actions for the left joystick. Am I suppose to set the actions for one joystick using the Thrustmaster preset and then set the left joystick action under a custom profile?
     
    Last edited: Aug 9, 2018
  36. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    There is no way to assign different default Controller Maps in the Rewired editor to two identical Joysticks in the same Player. The only way you'd be able to do this is to load the controller maps yourself through a script or to use two separate Players to hold the two joysticks.
     
  37. HeyItsLollie

    HeyItsLollie

    Joined:
    May 16, 2015
    Posts:
    68
    Hi @guavaman,

    I'm having trouble figuring out how to set up a D-Pad as a Hat. There doesn't appear to be any way to configure Hats via the Rewired Editor (I was hoping for something like: add a Hat action, enter the 4 or 8 buttons/axis that make up the Hat), and haven't been able to find documentation or answers for how to set it up via C# - besides the references to the Controller.Hat class in the Rewired API.
     
  38. TareqProjects

    TareqProjects

    Joined:
    Jun 27, 2016
    Posts:
    55
    Would I still need to run the editor script if I decide to map controls through code?
     
    Last edited: Aug 10, 2018
  39. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    What type of controller is this? Is this new controller that does not have a controller definition? If you want to get into the details of setting a up controller definition. See this page of the documentation.

    https://guavaman.com/projects/rewired/docs/HowTos.html#new-controller-definitions

    HATs are generally just treated as buttons basically. You just map your actions accordingly. You can look at this example that uses a HAT rather than a D-PAD. But the same idea applies.

    https://forum.unity.com/threads/can...ship-or-aircraft-cockpit.455223/#post-2957041
     
  40. HeyItsLollie

    HeyItsLollie

    Joined:
    May 16, 2015
    Posts:
    68
    Currently using a PS4 controller. I'll eventually be working with controllers that don't have definitions (old PS1 controllers via USB adapter), but I'm working with common controllers as well. (Switch Pro, 360, Xbox One)

    The main reason I'd like to be able to treat a D-Pad as a Hat is so that I can cleanly define actions for diagonals. I want to be able to test specifically for something like "Hat Up-Right", rather than having to test for the combination of "D-Pad Up" AND "D-Pad Right" in my code. (as far as I can tell, Rewired can't assign button-combinations to a single action)
     
  41. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    514
    Hi there, I'm experiencing an issue with the Rewired Standalone Input Module's inspector editor since updating to 1.1.19.0. When I try and view the editor inspector for the component I'm getting the stack trace below. I tried recreating the game object and components fresh to make sure there was nothing else going wrong but as soon as the Rewired Standalone Input Module component is added I start getting the error. Let me know if you need any more info, cheers.

    Code (CSharp):
    1. Rewired: Exception drawing properties:
    2. System.NullReferenceException: Object reference not set to an instance of an object
    3.   at Rewired.Editor.Libraries.Rotorz.ReorderableList.ReorderableListControl.PrepareState (Int32 controlID, IReorderableListAdaptor adaptor) [0x00000] in <filename unknown>:0
    4.   at Rewired.Editor.Libraries.Rotorz.ReorderableList.ReorderableListControl.Draw (Int32 controlID, IReorderableListAdaptor adaptor, Rewired.Editor.Libraries.Rotorz.ReorderableList.DrawEmpty drawEmpty) [0x00000] in <filename unknown>:0
    5.   at Rewired.Editor.Libraries.Rotorz.ReorderableList.ReorderableListControl.DrawControlFromState (IReorderableListAdaptor adaptor, Rewired.Editor.Libraries.Rotorz.ReorderableList.DrawEmpty drawEmpty, ReorderableListFlags flags) [0x00000] in <filename unknown>:0
    6.   at Rewired.Editor.Libraries.Rotorz.ReorderableList.ReorderableListGUI.‫‪‍‌‏‏‬‭‌‍‎‭‫
‫‎‫‮‫‪
‌‍‮ (IReorderableListAdaptor , Rewired.Editor.Libraries.Rotorz.ReorderableList.DrawEmpty , ReorderableListFlags ) [0x00000] in <filename unknown>:0
    7.   at Rewired.Editor.Libraries.Rotorz.ReorderableList.ReorderableListGUI.NyZZmEjPZIWstcVISPgGBpmesLi (UnityEditor.SerializedProperty , Single , Rewired.Editor.Libraries.Rotorz.ReorderableList.DrawEmpty , ReorderableListFlags ) [0x00000] in <filename unknown>:0
    8.   at Rewired.Editor.Libraries.Rotorz.ReorderableList.ReorderableListGUI.ListField (UnityEditor.SerializedProperty arrayProperty) [0x00000] in <filename unknown>:0
    9.   at Rewired.Editor.RewiredStandaloneInputModuleInspector_Internal.‭‬‍‍‌‮‮‎‬‍‎‫‫‎‭‭‮‌‍‬‭‏

‎‬
‌
‮ (UnityEditor.SerializedProperty ) [0x00000] in <filename unknown>:0
    10.   at Rewired.Editor.RewiredStandaloneInputModuleInspector_Internal.DrawProperties () [0x00000] in <filename unknown>:0
    11.   at Rewired.Editor.RewiredStandaloneInputModuleInspector_Internal.OnInspectorGUI () [0x00000] in <filename unknown>:0
    ------- Rewired System Info -------
    Unity version: 2018.2.2f1
    Rewired version: 1.1.19.0.U2018
    Platform: OSX
    Editor Platform: OSX
    Using Unity input: False
     
    Last edited: Aug 10, 2018
  42. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    514
    ohh and one more clue is that the last thing rendered on the inspector is the Player Mice heading line.
     
  43. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    No, there is no way to treat a D-Pad as an 8-way hat (8 buttons). Rewired only supports 8-button hats on flight sticks.

    Rewired only binds Actions to Axes and Buttons. There is no other Action binding type in Rewired. There are no multi-element bindings either: http://guavaman.com/projects/rewired/docs/HowTos.html#button-combos
     
    Last edited: Aug 10, 2018
  44. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    The only thing that could cause this is a bug in Unity in the OSX editor.

    Player Mice is a new field added in 1.1.19.0. Unity is supposed to serialize that with a default value, not a null, which it does on the Windows editor. Change your inspector window to a Debug window by right clicking the tab that says "Inspector" and choosing Debug. Go find the Player Mice field and set it to be of size 1, then back to 0, then switch the inspector back.

    There's nothing I can do to prevent this. The field is already properly initialized in the declaration:

    Code (csharp):
    1. private List<Rewired.Components.PlayerMouse> playerMice = new List<Rewired.Components.PlayerMouse>();
    Edit: Well that doesn't work. I am able to reproduce it on Windows also under certain upgrade situations. There is no explanation for this. There is no null object possible in the code that's complaining. I may have to rip out Rotorz Reorderable List.
     
    Last edited: Aug 10, 2018
  45. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    @jason_yak The problem is completely different than I thought. It's Unity 2018.2. Unity went and made a breaking change to a property from a public property to an internal property which Rotorz Reorderable List relies on. You can even see it in the new Rotorz source code:

    https://bitbucket.org/rotorz/reorderable-list-editor-field-for-unity/src/master/Editor/Internal/
    Adjust reflection on `GUIClip.visibleRect` due to change in access specifier in the Unity API.

    Silent breaking API change in minor Unity version update...
     
  46. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    514
    Right, thanks for looking into this. I'll keep an eye out for a Rewired update. I'm guessing that because it's just an editor inspector failing that it won't really cause any runtime issues, cheers!
     
  47. Sofiel

    Sofiel

    Joined:
    Aug 6, 2017
    Posts:
    60
    @guavaman I'm very interested in Rewired, and I'll accuire it some time next week. I do have a question (wont change my mind on the purchase) How many players does it support in mobile multiplayer?

    Thanks for your time
     
  48. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    It will prevent you from assigning anything to the Player Mice fields. If you want to, you'll have to do it in the Debug inspector mode. I've updated it already but the Asset Store hasn't published it yet.
     
  49. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    There is no limit to the number of players it supports. But you have to understand rewired is a LOCAL input manager. It does absolutely nothing with regards to networking.
     
  50. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Rewired 1.1.19.1 is available on the Unity Asset Store.

    Se Updating Rewired before updating.

    1.1.19.1:

    Bug Fixes:
    - Editor DLL: Updated Rotorz Reorderable List due to breaking changes made in Unity 2018.2 API.
    - Windows Standalone, Raw Input + Native Keyboard Handling: Keyboard no longer returns key values the frame after being enabled if any keys were pressed when the Keyboard was disabled.
    - Windows Standalone, Raw Input + Native Mouse Handling: Mouse no longer returns button values the frame after being enabled if any buttons were pressed when the Mouse was disabled.