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,605
    Hi,

    I can't tell you if there is an obvious problem because I don't have enough information about how you've set things up.

    First, you will have to verify things are working with Rewired alone. I can't help you with Otii's Motion Controller as I don't have any experience with that.

    Please try one of the example scenes such as EightPlayers and see if the controller works. If it does, then you've either done something wrong in the basic setup, so restart at the Quick Start, or there may be an issue or setup required with Otii's integration (choose a source Player?).

    If nothing works in the EightPlayer demo, create a new scene, add the Rewired/DevTools/JoystickElementIdentifier to the scene and create an empty Rewired Input Manager. Press Play and see if anything joysticks show up in the left column.

    If you have multiple joysticks attached to the system, remove all but the DS4 because this could be the problem.
     
    Last edited: Feb 19, 2016
  2. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    No. If it's a true joystick axis, Digital Axis Smoothing will not be applied. It is only applied to keyboard keys and buttons to simulate an axis so you have some acceleration and deceleration. Applying a time-based smoothing to a joystick axis leads to a very laggy feeling and unresponsive input experience. Of course, you can always process it outside Rewired if you really want that.
     
  3. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    I received this response today on the Win10 Universal IL2CPP bug:

    No mention is made of what version the update will be in. I'm guessing it will be in the next patch.
     
    miannello likes this.
  4. AVOlight

    AVOlight

    Joined:
    Apr 15, 2014
    Posts:
    427
    me too, usually its the 2nd or 3rd patch when it comes to a newly verified bug
     
    guavaman likes this.
  5. tapticc

    tapticc

    Joined:
    Jan 16, 2014
    Posts:
    379
    Hi, if I set up the actions, players etc with the Trial version and then upgrade to the new version, will I need to redo all of the setup again please? :)
     
  6. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    No. You will not lose any data. Always follow the Updating Rewired instructions when upgrading to avoid Unity-related issues.
     
  7. tapticc

    tapticc

    Joined:
    Jan 16, 2014
    Posts:
    379
    Perfect thanks :)
     
  8. tapticc

    tapticc

    Joined:
    Jan 16, 2014
    Posts:
    379
    Just trying to implement this on a copy project, one which uses the Third Person Controller asset https://www.assetstore.unity3d.com/en/#!/content/27438

    This asset is great but has its own input manager, and simply replacing Input.GetButton and Input.GetAxis isn't enough to play nicely. Just wondered if you have had any dealings with this asset or if there could be any integration advice please?
     
  9. tapticc

    tapticc

    Joined:
    Jan 16, 2014
    Posts:
    379
    Should an Xbox One controller be picked up as either Xbox One Controller or Xbox Controller One (Win 10+) in the trial version? I mapped both of these joysticks but no input was received. When I mapped the actions to the generic [T] Dual Analog Gamepad, input was received. I am using Windows 10 for info with the controller plugged into USB.
     
  10. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    Opsive created an integration for Rewired already. It's on his website.
     
  11. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    You're using XInput.

    See this topic from the Known Issues documentation page:
    Windows: All XInput devices use the Xbox 360 Controller map when "Use XInput" is enabled

    -------------

    As explained in the previous topic, when Use XInput is enabled, there is no way to differentiate one XInput device from another by name or product/vendor id. Therefore, all XInput devices will use the Xbox 360 Controller map on Windows when Use XInput is enabled. This will match all XInput devices, generic or not, and will provide full coverage of all XInput devices. You cannot map these devices based on the individual device type such as Xbox One or Logitech F310 when using XInput because the device cannot be identified as as specific device type but rather simply as an XInput gamepad. All XInput gamepads will use Xbox 360 Controller profile when Use XInput is enabled.

    If you disable Use XInput, you will get device-specific identification and recognition, but you will also have the drawbacks explained in the previous topic.

    There is rarely ever a need to map these controllers individually by using the specific device-type maps. Just create your Joystick Map using the Dual Analog Gamepad Template and it will cover all gamepads listed here regardless of whether or not you have Use XInput enabled.
     
    Last edited: Feb 20, 2016
  12. tapticc

    tapticc

    Joined:
    Jan 16, 2014
    Posts:
    379
    Thanks, I was going to use the Xbox One setup as the names were obvious but happy to use the generic names, didnt take too long to find out which button was which :)

    In the Rewired stuff when I did the find /replace on Input.GetButton and axis, the rewired code didnt work so there was more to it than that. I do have the code working though now
     
  13. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    That information is in the documentation:
    http://guavaman.com/projects/rewired/docs/ControllerMaps.html#dual-analog-gamepad-template

    In addition, mapping the Dual Analog Gamepad Template will automatically create usable maps for all the gamepads listed here. There is little reason to ever map a gamepad by specific type. The only reason would be to use a special element not covered by the template such as the Touchpad button on the DS4.

    The documentation describes how to transition from UnityEngine.Input to Rewired input:
    http://guavaman.com/projects/rewired/docs/HowTos.html#converting-scripts

    Obviously, you cannot just find and replace script references if you haven't also set up Actions, Controller Maps, Players, and made map assignments to Players in the Rewired input manager.

    Documentation - All topics in the first two main sections are required reading.
    Quick Start - Covers the most basic basics of getting something simple running.

    I haven't looked at Opsive's Third-Person Controller integration so I'm not familiar with how he set that up.
     
    Last edited: Feb 20, 2016
    tapticc likes this.
  14. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    Each second or two, ReWired produces a performance spike, which is very noticeable during gameplay:
    This is not a result of running from Editor. Actual builds still have noticeable spikes.
    What could be the reason? Can something be done about this?
     
  15. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    First, you didn't say what build target your are referring to. But I already know what this is, assuming Windows Standalone build and Raw Input. It's a lag caused by an attempt to handle problem Bluetooth controller connect/disconnect detection better and because Windows does not send connect/disconnect events for certain Bluetooth devices. This attempted fix was added in 1.0.0.77. Windows doesn't do its job properly leading to a lot of problems when powering off and on some popular BT devices, so I tried to work around the issue, which did make everything work as expected, but the result was a 1.5ms lag (when you're not using Deep Profiler which exaggerates everything) every 1 second as this Windows API routine is run. I have already found a workaround for the performance hit (literally an hour ago) but it will not be available until 1.0.0.82.
     
    Last edited: Feb 20, 2016
    tapticc likes this.
  16. tapticc

    tapticc

    Joined:
    Jan 16, 2014
    Posts:
    379
    Just upgraded to the paid version, thanks for your support.

    Is this message anything to worry about, and can it be suppressed?

    Rewired: The version of XInput (Xinput1_4.dll) detected on your system does not support the detection of non-gamepad XInput devices. Input will still function, but all features may not be available. See the documentation for required dependencies
     
    Last edited: Feb 22, 2016
  17. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    What version of Windows are you running?

    From the documentation:

    http://guavaman.com/projects/rewired/docs/Deployment.html


    Windows Standalone

    OPTIONAL: If using XInput or Direct Input, the DirectX End-user Runtimes (June 2010) from Microsoft should be installed for optimal support. You should include this runtime in your game installer. This is not necessary if only using Raw Input or Unity input.

    If XInput is enabled, Rewired can use any of these versions of XInput if they are installed on the system:

    XInput_1_4.dll
    XInput_1_3.dll
    XInput_1_2.dll
    XInput_1_1.dll
    XInput_9_1_0.dll

    The preferred version is XInput_1_3.dll, which is included in the DirectX Runtimes above. This version of XInput allows the device to return an accurate device type such as Gamepad, Guitar, Wheel, etc. If using any version other than XInput_1_3.dll, input will still function as expected, but any non-gamepad XInput devices will be treated as a Gamepad.

    Windows Vista, Windows 7, and Windows 8 all come with a version of XInput pre-installed.
     
  18. tapticc

    tapticc

    Joined:
    Jan 16, 2014
    Posts:
    379
    I'm using Windows 10 and this is within the editor rather than a build. How typical as well I wait days to see if a sale is coming, as soon as I buy the asset the sale hits and includes Rewired argh!
     
  19. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    Thanks! :)

    Windows 8+ comes with XInput 1.4. XInput 1.4 removed many functions available in XInput 1.3 such as support for the Xbox 360 chat pad, support to control the audio port, detection of device type, and many other features. However, Rewired doesn't use any of these features, so the message really doesn't mean anything. The message only shows up in the log file upon initialization with all of Unity's other message and doesn't affect anything. There's no way to suppress it, but I might as well remove it since I never ended up adding support for those extra features.
     
  20. tapticc

    tapticc

    Joined:
    Jan 16, 2014
    Posts:
    379
    Thanks for letting me know :)
     
  21. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    Sales never happen more than once a year and I'm not even made aware when it will be on sale until days before it happens (Unity chooses what will be on sale from a list of signups.). PM'd.
     
    tapticc likes this.
  22. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    ...
     
    Last edited: Mar 4, 2016
  23. michelm

    michelm

    Joined:
    Jul 2, 2012
    Posts:
    15
    I just picked this up in the sale, and it looks brilliant, but there's one thing missing I hope you'll consider adding in the future: Modifier keys for mouse actions.

    Example: I want to rotate the camera with a Mouse Horizontal Element only when the right mouse button or CTRL or another modifier key is pressed. Correct me if I'm wrong, but it seems the only way to do this is to set up a right mouse button action, then in the script check for that before checking for the Camera Rotate action? It'd be nice to be able to set these modifiers in the editor Mouse Map UI like I can for the Keyboard Map. Another use-case would be the movement axis of the mouse behaving differently with middle mouse button "modifier" held down. These are pretty common input behaviours, especially for camera controls, so worth including I think. Thanks!
     
  24. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    Thanks for the suggestion.

    At the present time, the mouse and keyboard are treated as entirely separate devices (partly due to the initial intention to support multiple mice and keyboards, which does not exist at present). There is no system of "button combos" or "compound actions" in place, which is especially complicated when you are talking about a generic system that can handle this across devices which must be able to include blocking activations for Actions mapped to the individual elements in a combo when one or more of the modifiers are held down. (Suffice it to say, the per-Player, input source-agnostic, pooled Action mapping system makes it vastly more complicated than with a simple static binding as with most input systems.) At this point, the solution you already mentioned is the best way to handle it - use an Action as the modifier and check for if(player.GetButton("ModifierAction") && player.GetButtonDown("PrimaryAction")) // do something;

    This is already on the (gigantic) to do list.
     
    Last edited: Feb 22, 2016
  25. michelm

    michelm

    Joined:
    Jul 2, 2012
    Posts:
    15
    Ah, thanks for the explanation. I just integrated it into my project (still in early stages), replacing InControl, and feel like I dodged a bullet. Almost everything I was piling into the "worry about the massive headaches this will cause later" category is supported out of the box in Rewired.
     
    Steve-Tack and guavaman like this.
  26. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    That is great news. I am always interested in success stories from those who converted from InControl and other input systems to Rewired.
     
  27. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    This is just in time for GDC 2016 too.

    Rewired native input on Linux is just simple amazing. I have been working with Racing Game Starter Kit v1.08 by @Intense_Gamer94 and Rewired v1.0.0.79. Building with Unity 5.3.1 for Windows standalone and Linux standalone. And it works perfectly. I am using Ubunutu Mate (64-bit) v16.0.4 alpha 2 release for my Linux testing.

    Using gamepads (XBOX-360 and XBOX-One), Flight controllers (CH FighterStick, and CH Pro Pedals) and of course keyboard input. It is so cool to only have to map to Rewired Actions and everything just works.

    It really nice to have such powerful input system on Linux where I do not have to worry about it anymore. I honestly cannot tell the difference between Linux and Windows standalone when it comes to input handling. It is just wonderful to see it work without any effort.

    Just for an experiment I plan on adding CH Eclipse yoke (flight controller) and see how much excitement that adds to the racing game.

    Thanks for all of the hard work you have put into Rewired's native input handling.
     
    Last edited: Feb 24, 2016
    Karearea, Ian094 and guavaman like this.
  28. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    @longroadhwy Thanks! I always love hearing what people are doing with Rewired! The point of it always was to make something that "just works." :)
     
  29. cj31387

    cj31387

    Joined:
    May 23, 2012
    Posts:
    143
    Does rewired support Steam Controllers analog joystick, and Steam Controller in general?
     
  30. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    Information on Steam Controller:
    http://guavaman.com/projects/rewired/docs/SupportedControllers.html#SteamController
    http://guavaman.com/projects/rewired/docs/Troubleshooting.html#steam-controller

    Steam Controller

    All Platforms
    Native Steam Controller support is not available at this time. Direct support of the controller's special features is not currently available. The Steam Controller can only be supported through Steam's automatic emulation of a standard controller (type varies by platform.)

    Windows
    The Steam Controller automatically emulates an XInput gampad (XBox 360) on Windows and is supported as an XInput gamepad only at the present time.

    Linux
    The Steam Controller can only be detected through the use of the SDL2 input library. If your game needs Steam Controller support, you must change the Linux Standalone Primary Input Source to SDL2.

    IMPORTANT NOTE
    The Steam Controller is not a standard HID device and cannot be seen by the OS without Steam being initialized for your process through the Steam API with Steam running in the background. It is not possible to use the Steam Controller without Steam. Rewired does not initialize Steam for you -- you will have to do so using the Steam API or a C# Steam library such as Steamworks.net.
     
    Last edited: Feb 24, 2016
  31. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    Rewired 1.0.0.81 is now live on the Unity Asset Store!

    1.0.0.81:

    New Controller Definitions:
    - 8Bitdo Zero (Wireless)
    - 8Bitdo SNES30 / SFC30 (Wireless, Joy Mode)
    - 8Bitdo SNES30 / SFC30 (Wireless, Mode 1)
    - Zhidong N (XInput mode)
    - Zhidong N (Direct Input mode)
    - Zhidong N (Android mode)
    - Zhidong V+ (XInput mode)
    - Zhidong V+ (Direct Input mode)
    - Satechi ST-UBGC Bluetooth Wireless Universal Gamepad

    Modified Controller Definitions:
    - Sony Dual Shock 2 (My-Power CO.) - Removed GUID from matching criteria due to potential mismatching issues.
     
    600 likes this.
  32. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    Here's an updated image of the controllers Rewired explicitly supports out of the box.

    RewiredSupportedControllers001e.jpg

    Keep in mind, it supports far more than this because it can support just about any HID joystick through savable runtime user mapping even if not explicitly recognized.
     
    docsavage likes this.
  33. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    The most awesome picture of controllers that any developer can ever see. The best part is I can map them all. :D

    That is absolutely crazy (true madness) to have all of those controllers supported out of the box with Rewired. It is even more amazing that every usb element of each controller is explicitly named and can be mapped individually. Wow!

    Rewired is definitely the most comprehensive input system on any platform. Definitely raises the bar for Unity and more importantly the industry.
     
    guavaman likes this.
  34. ObsidianSpire

    ObsidianSpire

    Joined:
    Sep 13, 2013
    Posts:
    48
    I've read those pages and I think I've addressed all of the potential issues. What should I do when the Steam controller is only partially recognized? The game is detecting when I press the triggers, but it doesn't react when I use the joystick or the d-pad. I removed all the other controllers attached and it's still not doing anything.
     
  35. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    The only way possible I can imagine this is happening is if you haven't set the Steam Controller configuration to Gamepad in Steam. If it's set to keyboard/mouse or hybrid mode, it will not send all the XInput data for all elements and instead send keyboard key data and mouse axis data.

    Rewired does not set anything in Steam with regards to the controller. It can only read it as an XInput controller based on how you've set things up in Steam. I would refer to Steam's developer documentation on the Steam Controller.
     
  36. ObsidianSpire

    ObsidianSpire

    Joined:
    Sep 13, 2013
    Posts:
    48
    You were right. I thought I had set it to gamepad, but it went back to emulating a keyboard/mouse.
     
  37. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    I just pulled down 1.0.0.81 from the asset store, and it seems that the Extras folder is missing? I wiped my existing Rewired folder before importing, so it seems that I'm missing the prefab for the control mapper UI now (and whatever else was in there).
     
  38. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    I just pulled down 1.0.0.81 (into a new project) and everything appears to be present.

    Assets\Rewired\Extras\ControlMapper\Prefabs
     
  39. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    @longroadhwy Just figured it out. I had to allow (or rerun) the setup. I guess I figured since I already had "installed" Rewired before, I didn't need to accept that. It apparently generates that folder on the fly during that process. Looks good now. :)
     
  40. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    Yep. Rewired supports Unity down to 4.3 which doesn't have any of the UI classes. Everything has to be unpacked by the editor script or else Unity users < 4.6 would get compile errors.

    Had you not deleted the Rewired folder first, it would have automatically updated the Control Mapper files and wouldn't have asked you to reinstall because the ScriptableObject that stores the Rewired version information would still have existed in the folder so Rewired would know that it was being upgraded.
     
    Last edited: Feb 27, 2016
  41. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    Looking forward to your new custom Control Mapper screen shots.
     
  42. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    @guavaman Ah, clever. Didn't realize the setup process was that fancy. :)
     
  43. Stevepunk

    Stevepunk

    Joined:
    Oct 20, 2013
    Posts:
    205
    If people are playing online, can I assign them to player 1, player 2 etc. ?
    Is there an "online controller" that I can assign that takes the actions from another specific player and applies them to the other characters that inhabit the host's game?
     
  44. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    Rewired does not have any kind of network components. It does not manage input from multiple clients. It only manages input on a single machine. If you want to send input to another client or from a client to a server, you would have to manage that outside of Rewired.
     
  45. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    You should talk to @CaptainMurphy who making the Tides of War game. He is using Rewired and his game also uses the network.

    http://forum.unity3d.com/threads/ti...arque-naval-combat-in-the-age-of-sail.342341/
     
    Last edited: Feb 28, 2016
  46. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    Most network games do not require that the input be piped to the server for processing. If it does, it should be a simple matter of piping the results of the Actions to the server instead of all the input. The bulk of Rewired's code wouldn't make sense run on a server because it's almost all to do with managing local devices, device to Player associations, and element mappings. All of that is strictly client-side responsibility. The only part that makes much sense to have processed by the server would be actually processing the result of input (moving the player, etc.).
     
  47. llJIMBOBll

    llJIMBOBll

    Joined:
    Aug 23, 2014
    Posts:
    578
    Hi, I'm just wondering, can this be used just to allow players to change inputs to what keys they want. ?
    Would I need to change any code, like any input code?

    Thanx Jimbob
     
  48. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    The Control Mapper GUI allows you to change inputs. See this link for details.

    http://guavaman.com/projects/rewired/docs/ControlMapper.html
     
  49. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    Rewired is not UnityEngine.Input, so yes, you do have to change your code to get input from Rewired instead of Unity.

    The Rewired documentation contains answers to just about every question you could have:
    http://guavaman.com/projects/rewired/docs/

    See this link for how to migrate simple scripts from UnityEngine.Input to Rewired:
    http://guavaman.com/projects/rewired/docs/HowTos.html#converting-scripts

    Information on control remapping:
    http://guavaman.com/projects/rewired/docs/ControlMapper.html
    http://guavaman.com/projects/rewired/docs/HowTos.html#controller-mapping-screen (for advanced programmers only)
     
  50. blindmen

    blindmen

    Joined:
    Sep 10, 2015
    Posts:
    34
    Hi there,

    I've a bluetooth Moga Pro connected to Win 8. Game work perfectly fine with XBox One and Moga Pro on Win 8.

    However I'm not able to make it work on Android (Samsung S6 Edge -> Android 5.1.1 -> Moga Pivot installed and paired in Mode B).

    In game ReInput.controllers.Joysticks[0].name returns correct name on both platforms however left/right joysticks / DPad and L2/R2 does not work on Android. Most of the buttons works as expected.

    in game I use as follows
    InputManagerRewired Start () {
    p = ReInput.players.GetPlayer(0);
    j = p.controllers.Joysticks[0];
    }
    input = GameObject.Find("My Rewired Input Manager").GetComponent<InputManagerRewired>();

    if (input.p.GetAxis("Horizontal") > 0.7f) {
    ...}

    In joystick maps I've mapped [T] Dual Analog Gamepad,

    Am I missing something?

    Many thanks