Search Unity

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,632
    Crazy. If your game is such that 20+ controllers per-player are a possibility you'd probably need to adjust the display to show everything smaller to have room for that. But it is possible.

    Very cool! Thanks for posting that.
     
  2. _met44

    _met44

    Joined:
    Jun 1, 2013
    Posts:
    633
    I Guavaman, dunno if you remember we talked about a super weird error between Steamworks & Rewired a few weeks ago. Wanted to let you know that I haven't seen the error again since I made sure to start Steamworks after Rewired as you suggested so thanks a lot !!!

    Hey I haven't tried myself but someone in the team tried Unity's latest patch release (the one from today) and said it caused Rewired to error out like hell, do you any plans on supporting it soon ? (sorry if I missed the information but I'm not aware of your policy regarding patch releases)
     
  3. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,632
    Glad to hear it.

    Very descriptive. I'm going to guess OSX editor because looking at the release notes they made changes.

    Well it just came out today.... I'll look into it.
     
  4. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,632
    EDIT: If you're using a 5.1.2 patch release, remove the #if #else block from the code and just use "var mouseData = GetMousePointerEventData(kMouseLeftId);"

    Unity made an undocumented breaking change to UnityEngine.EventSystems.PointerInputModule.GetMousePointerEventData(). It now requires int id to be passed.

    As best I can tell, you should pass -1 there for left mouse button.

    Change line 303, RewiredStandaloneInputModule.cs to:
    Code (csharp):
    1. var mouseData = GetMousePointerEventData(kMouseLeftId);
    As far as I know there is no possible way to add a preprocessor if for a patch release because they don't add any new defines for them. I cannot make this work on both older and newer versions until 5.1.3 is out. I'm assuming the same change was made to 4.6.7p1.

    This is the beautiful code that will be in the next release to catch this change for 5.1.3+ and 4.6.8+ when they're out.

    Code (csharp):
    1.           // Breaking change to UnityEngine.EventSystems.PointerInputModule.GetMousePointerEventData() in Unity 5.1.2p1. This code cannot compile in the patch release because no defines exist for patch releases
    2. #if (!UNITY_5 && (UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_5 || UNITY_4_6_0 || UNITY_4_6_1 || UNITY_4_6_2 || UNITY_4_6_3 || UNITY_4_6_4 || UNITY_4_6_5 || UNITY_4_6_6 || UNITY_4_6_7)) || (UNITY_5 && (UNITY_5_0 || UNITY_5_1_0 || UNITY_5_1_1 || UNITY_5_1_2))
    3.             var mouseData = GetMousePointerEventData();
    4. #else
    5.             var mouseData = GetMousePointerEventData(kMouseLeftId);
    6. #endif
    EDIT: Nope. The change was not made to 4.6.7p1. I have no idea if this will filter down to 4.6.8 at this point. This is the problem with trying to support patch releases.
     
    Last edited: Aug 6, 2015
    _met44 likes this.
  5. _met44

    _met44

    Joined:
    Jun 1, 2013
    Posts:
    633
    Ha sorry for lack of proper description, i would have provided more information if i had more !

    Anyways thanks for checking it out and wow so quickly, my day starts earlier than most of the team but i'll them know we can update now, again thanks a lot ! (ps: was on PC)
     
  6. radimoto

    radimoto

    Joined:
    Aug 23, 2012
    Posts:
    257
    Hi guavaman, I just updated to 5.1.2p2 and found it broken due to GetMousePointerEventData. Your post above fixes the issue. Thanks
     
  7. bkw

    bkw

    Joined:
    Sep 20, 2013
    Posts:
    49
    Hey, just saw that XboxOne support was added. I'm giving it a shot, but it seems to be crashing on launch. This is on a new project, with one scene that has only the Main Camera, a Directional Light, and the Input Manager added. Any idea what might be wrong? This is on Unity 5.0.2. Is there a minimum version required for the XboxOne related stuff?

    Still kind of new at this stuff, so I don't know where I should be looking for logs or dumps. Standard debug output doesn't log any errors in particular when it crashes.
     
  8. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,632
    Did you follow the directions here: http://guavaman.com/projects/rewired/docs/SpecialPlatformSupport.html#xbox-one ?
     
  9. bkw

    bkw

    Joined:
    Sep 20, 2013
    Posts:
    49
    Ah, didn't know there was special platform support for it. Giving it a go now. Maybe add a link to that page on the installation page as well?
     
  10. bkw

    bkw

    Joined:
    Sep 20, 2013
    Posts:
    49
    Hmm... no dice. Same thing happens. Do you think Unity/XDK version matters?
     
    Last edited: Jul 24, 2015
  11. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,632
    Have you tried a build without Rewired?

    Version would only matter if they changed the method signatures in Gamepad.dll.
     
  12. bkw

    bkw

    Joined:
    Sep 20, 2013
    Posts:
    49
    Yup. If I remove the input manager from the scene, it runs fine. Which version do you dev/test on? I'm currently on April 2015.
     
  13. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,632
    Please contact me my PM or by the support form on my website: http://guavaman.com/rewired#support
     
  14. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,632
    Rewired 1.0.0.62 has been released on the website for registered users. (Contact me if you want to register to get early access to updates.) Unity Asset Store should get the update in 3-10 days.

    Note: The patch for GetMousePointerEventData will not fix the issue for the 5.1.2 patch releases. It will only begin working after 5.1.3 is released. 5.1.2 patch releases will require manual modification of the file to compile.

    1.0.0.62:

    Changes:
    - Patched RewiredStandaloneInputModule for undocumented change Unity made to PointerInputModule.GetMousePointerEventData in Unity 5.1.2p1

    Bug Fixes:
    - Fixed initialization issue on Xbox One platform.
     
    _met44 likes this.
  15. Karearea

    Karearea

    Joined:
    Sep 3, 2012
    Posts:
    386
    Hi Guavaman,

    Just wanted to say a massive thanks for the new remapper- really user friendly and beautifully implemented. I've gone through and tried remapping a whole bunch of old joysticks at runtime just as players can, so I no longer need any 'unknown' maps. Very cool.
     
    guavaman likes this.
  16. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,632
    You're welcome! Glad to hear it's working out so well for you! :)
     
  17. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    I was thinking about this issue too.

    Making a change to use three or four columns instead of two were used for assigned controllers that could help too.

    If you are really desperate for space you could have each assigned controller used only the amount of space to display the name of the controller. Then you could have more controllers using that method but they would not really be in true column format. The controller names can be reduced without much effort and still be readable using an alternative display fieldname. Using my previous screen as an example the CH FighterStick would become CH FS. CH Pro Throttle would become CH PRO THR. Thrustmaster T.Flight Hotas.X would become TM T.Flight Hotas.X. This could save a large amount screen real estate without too much work. Then having 30 controllers should work without having to reduce the screen size too much if at all. Might not be the most readable display.

    Thanks for creating the control mapper.
     
  18. _met44

    _met44

    Joined:
    Jun 1, 2013
    Posts:
    633
    @longroadhwy have you considered using a dropdown with gamepad/button pairs (or 2 dropdown together, one for gamepad the other for the button).

    This way you could map 300 actions with 50 gamepads all in a single column ^^.
     
    guavaman likes this.
  19. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,632
    A dropdown was one of the first ideas for this interface to support more than the original 1 gamepad per player that I had intended. But I would have had to create a reliable drop down UI control that works intelligently with joysticks which as it turns out is no easy feat with Unity's new UI (regarding next control navigation). Even the scroll boxes presented unique challenges. (A lot of the necessary UI code to deal with these things is private.)

    Because 50 joysticks per player is such an extreme edge case, I chose to do it the way I did. My intention was never to create the be-all-end-all of UI screens for every single purpose under the sun, but it sort of got pushed in that direction which is one reason why it took so long to get out. I think the way it currently is is fine for the vast majority of use cases. Those with more extreme needs are probably going to need to write their own UI screen anyway, so why complicate everything for the 99.999% that don't need that.
     
  20. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,632
    Rewired 1.0.0.63 has been released on the website for registered users. (Contact me if you want to register to get early access to updates.) Unity Asset Store update will be delayed until 1.0.0.62 is approved.

    @FlaxSycle
    This update includes support for Sony DS3 and DS4 on Linux when pre-configured by Unity 5. Thus far, these are the only controllers I've tested that have different mappings than before.

    Additionally, the Logitech F310 seems to work in X mode in 5.1.2 again and is detected as an Xbox 360 controller. D mode still does not work at all.

    1.0.0.63:

    Changes:
    - Added support for Unity pre-configured joysticks on Linux platform.
    - Added Linux pre-configured controller definitions for:
    - Sony Dual Shock 3
    - Sony Dual Shock 4
    - Unity Pre-Configured Gamepad (any other pre-configured gamepad)
    - Added Guide button to Microsoft Xbox 360 Controller definition.
    - Added Guide button mapping to Dual Analog Gamepad Template for Microsoft Xbox 360 Controller.
     
    Last edited: Jul 25, 2015
  21. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    Control Mapper in its current form works great! I guess that makes me in the 99.9999999% category. :)

    On a related note I did see there is support for a UI Dropdown control in the future Unity 5.2 release based on road map (http://unity3d.com/unity/roadmap). That could be helpful for those who want to roll their own custom Unity UI screens.
     
  22. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,632
    :cool:

    Somehow I doubt that will help much for joysticks. Unity's UI selection system simply isn't designed to handle layers of controls or controls hidden by scroll rects in any way. While it will probably work for the mouse, without a sweeping overhaul of the auto-selection system adding some kind of selection layering/grouping concept, joystick navigation in complex UI controls will be a royal pain. And the way Control Mapper is able to allow you to select deactivated controls is also not part of the UI system -- that required hacking. The Unity selector skips over disabled controls making for very unpredictable and frustrating navigation, plus there's no state for selected-and-disabled in Selectable.
     
  23. guavaman

    guavaman

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

    I will now upload 1.0.0.63. It should be available in 3-10 days.

    1.0.0.62:

    Changes:
    - Patched RewiredStandaloneInputModule for undocumented change Unity made to PointerInputModule.GetMousePointerEventData in Unity 5.1.2p1

    Bug Fixes:
    - Fixed initialization issue on Xbox One platform.
     
  24. magonicolas

    magonicolas

    Joined:
    Dec 4, 2013
    Posts:
    30
    Hello, is it possible to use other phone (For Example an Android) as a Control for other android?

    Bests!
     
  25. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,632
    Control one phone with another phone? No. Rewired does not do this. There are specialized assets on the Asset Store than can make a phone into a game controller using Wifi.
     
  26. guavaman

    guavaman

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

    1.0.0.63:

    Changes:
    - Added support for Unity pre-configured joysticks on Linux platform.
    - Added Linux pre-configured controller definitions for:
    - Sony Dual Shock 3
    - Sony Dual Shock 4
    - Unity Preconfigured Gamepad (any other pre-configured gamepad)
    - Added Guide button to Microsoft Xbox 360 Controller definition.
    - Added Guide button mapping to Dual Analog Gamepad Template for Microsoft Xbox 360 Controller.
     
  27. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,632
    Rewired 1.0.0.64 has been released on the website for registered users. (Contact me if you want to register to get early access to updates.)

    1.0.0.64:

    Changes:
    - Exceptions that occur in user event handler code are handled more gracefully.

    Bug Fixes:
    - Control Mapper now unsubscribes from input events when destroyed.
    - Fixed hot-plugging issue in 64-bit builds on Windows.
     
  28. Tak

    Tak

    Joined:
    Mar 8, 2010
    Posts:
    1,001
    Surely you must have filed dozens of reports for these critical bugs, in addition to complaining in an echo chamber...
     
  29. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,632
    I have over the last 6 years for Windows and OSX. After some point, I quit bothering. Wrote my own system to replace it. Never did any Linux dev before Rewired so I didn't know about those bugs, but by then I had already given up on Unity ever fixing or even acknowledging any of the Input bugs so I didn't report any Linux issues. (Though I did write about them in an Input thread in which a Unity staff member had posted.) I'm looking into replacing Unity input for Linux (hopefully) soon as well.

    This isn't complaining. It's explaining to my customers why Linux support is flaky at best, unusable at worst.
     
    Last edited: Jul 31, 2015
  30. WillemKokke

    WillemKokke

    Joined:
    Sep 6, 2014
    Posts:
    31
    I have a question about the statement "Unity's Standalone Input Module is not compatible with the Touch Input Module." and "Since the Standalone Input Module is required for joystick input, you should disable the Touch Input Module entirely" (http://guavaman.com/projects/rewired/docs/Integration.html)

    Does that mean you can't use rewired to add joystick support to an android title that uses the unity gui system for it's UI?

    Would making a RewiredTouchInputModule based on the open source official TouchInputModule and the joystick support in RewiredStandalone be a potential solution? (There is too much existing UI in the project and I refuse to do joystick support without using the excellent Rewired)

    I can't find anything else on this Unity bug, so if anybody has a link with more info on it I'd be grateful.
     
  31. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,632
    No it doesn't. The StandaloneInputModule also includes treating touches as a mouse. Touch will still control the UI that way.

    :D

    If using the StandaloneInputModule's mouse support doesn't work for your existing touch UI, then the only solution would be to dig through the source of StandaloneInputModule and TouchInputModule and determine why they conflict. Essentially, debugging Unity's code. A RewiredTouchInputModule wouldn't be a solution because Rewired doesn't need to interact with touch controls in the UI in any way. A modified TouchInputModule would just be a bug fix for Unity's module and would work with or without Rewired in the mix.

    This isn't a limitation of Rewired or the modified RewiredInputModule. The conflict is between Unity's StandaloneInputModule and their TouchInputModule. Using a system other than Rewired wouldn't change this unless they're using a totally different system to activate Unity's UI.

    Perhaps disabling mouse input on mobile devices in the StandaloneInputModule would be all that's required. I'll do some testing.

    I can't find the exact post where I found the solution to this issue when I was testing on Android and iOS, but here are a couple:

    http://forum.unity3d.com/threads/st...ouch-input-module-behavior-difference.265309/
    http://forum.unity3d.com/threads/in...nity-4-6-eventsystem-on-surface-pro-3.291046/
     
    Last edited: Aug 2, 2015
  32. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,632
    @WillemKokke

    I added filtering of mouse input to the RewiredStandaloneInputModule. There are two new bool options: allowMouseInput and allowMouseInputIfTouchSupported. Disabling the 2nd will prevent the StandaloneInputModule from processing mouse input if the device is touch enabled. You should be able to enable the TouchInputModule now alongside Standalone. Tests on Android show no issues. I haven't tested iOS yet.
     

    Attached Files:

    Last edited: Aug 2, 2015
  33. igdu

    igdu

    Joined:
    Jul 24, 2015
    Posts:
    1
    Hello! Help me, please!

    The joystick does not work under Windows 8.1.
    Unity player - it's OK.
    What is the problem?

    Снимок.PNG
    Снимок1.PNG
    Снимок2.PNG
    Снимок3.PNG

    Снимок4.PNG
     
  34. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,632
    I am assuming by "Windows 8.1" you mean "Windows Store 8.1". I can only deduce this because the References pic shows ".NET for Windows Store Apps".

    WSA builds do not support any devices except XInput compatible devices. This "FrSky Taranis Joystick" is not an XInput compatible device. It will work fine in a Windows Standalone build, but Rewired implements XInput for WSA platform as the only native input source. The same is true for Unity. Unity supposedly added support for regular HID devices in Unity 5 but the feature does not work still as of Unity 5.1.2. Rewired does not implement a Windows 8.1 WSA HID native library to fix this, only XInput.
     
    Last edited: Aug 3, 2015
  35. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,632
    Rewired 1.0.0.64 is live on the Unity Asset Store!

    1.0.0.64:

    Changes:
    - Exceptions that occur in user event handler code are handled more gracefully.

    Bug Fixes:
    - Control Mapper now unsubscribes from input events when destroyed.
    - Fixed hot-plugging issue in 64-bit builds on Windows.
     
  36. WillemKokke

    WillemKokke

    Joined:
    Sep 6, 2014
    Posts:
    31
    guavaman likes this.
  37. schmosef

    schmosef

    Joined:
    Mar 6, 2012
    Posts:
    852
    The last few updates have not been working for me.

    With today's update, after importing the asset to an empty project and running the installer, I get a lot of console errors right away.

    Rewired errors after import.png

    In prior versions I didn't have any issues. I'm using Unity 5.1.2p2.

    Am I missing a step?
     
  38. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,632
    schmosef likes this.
  39. schmosef

    schmosef

    Joined:
    Mar 6, 2012
    Posts:
    852
    I see, thanks. This fixed the issue I was having.
     
    Last edited: Aug 5, 2015
  40. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,632
    Great! Glad it helped!
     
  41. CaptainMurphy

    CaptainMurphy

    Joined:
    Jul 15, 2014
    Posts:
    746
    I have read back through the past 4+ pages and haven't seen the answer to this, so sorry if this has been answered before. I have a UI that I am trying to get the rewired to work with and it is not, so I am assuming there is something I am missing from the UI canvas. I added the ControlMapper to the scene and it works fine, but once the ControlMapper is closed I lose the ability to use the UIHorizontal/UIVertical and the buttons. I also was able to get two overlaid canvases to work while ControlMapper was open but again, not after. Something I need to set in the UI canvases? I imagine it is something REALLY simple in the demos that I am not seeing.
     
  42. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,632
    Control of the Unity UI is handled by the RewiredStandaloneInputModule which is a component on the EventSystem or RewiredEventSystem game object in the scene. You must have this EventSystem enabled, you must have the relevant UI control Actions defined in the Rewired Input Manager, and you must have these Actions assigned to some joystick or keyboard maps that are currently active and assigned to the Player(s) set to control the UI in the RewiredStandaloneInputModule or you will get no control of the UI. If you have multiple event systems in your scene with multiple StandaloneInputModules, you'll also have problems.

    Setup instructions for the RewiredStandaloneInput can be found here.
     
  43. CaptainMurphy

    CaptainMurphy

    Joined:
    Jul 15, 2014
    Posts:
    746
    The event system components are in place, the actions are there. It is working correctly and I have control of the ControlMapper but no other UI. Once the mapper is closed it loses control of the UI's. A new scene with just a single UI doesn't seem to have control either.
     
  44. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,632
    Post your scene file so I can look at it. Control Mapper does not (and cannot) modify the EventSystem that runs the UI.

    But are these actions assigned to any Joystick Maps for whatever joysticks are attached or Keyboard maps and assigned to Players?
     
  45. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,632
    Wait a minute... I think I know what you may be talking about. Have you "selected" any UI object to be the currently selected object in your other UI? Unity's Selectable system does not automatically select something for you. You cannot navigate the UI by keyboard or joystick without having something selected.

    EventSystem.current.SetSelectedGameObject(someSelectableControl);

    ControlMapper also has an event you can use to tell when it's been closed after which you can set your UI selection:

    Code (csharp):
    1. public event System.Action ScreenClosedEvent;
    See these links for Unity UI help:
    Unity Manual - Event System
    Unity Manual - Standalone Input Module
    Unity UI Tutorials
     
    Last edited: Aug 5, 2015
  46. CaptainMurphy

    CaptainMurphy

    Joined:
    Jul 15, 2014
    Posts:
    746
    Ok, so for future reference to anyone else that gets confused by that EventSystem....

    I had it selecting, but it was going to a lower level object, i.e. the panel, and not to a directly interactable object. I added in a field to go to the first field on the panel and now it is working.... duh....
    Thanks for the help, sorry that it was something simple.
     
  47. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,260
    Not sure this has been covered but I'm getting the following errors when I import Rewired v1.0.0.64 in to Unity v5.1.2p2

     
  48. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,260
    I just changed

    Code (CSharp):
    1. #if !UNITY_5 || (UNITY_5 && (UNITY_5_0 || UNITY_5_1_0 || UNITY_5_1_1 || UNITY_5_1_2))
    to

    Code (CSharp):
    1. #if !UNITY_5 || (UNITY_5 && (UNITY_5_0 || UNITY_5_1_0 || UNITY_5_1_1 || UNITY_5_1_2p2))
    And the errors above went away. I think new defines are automatically added.
     
  49. schmosef

    schmosef

    Joined:
    Mar 6, 2012
    Posts:
    852
  50. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,632
    @schmosef @derkoi

    That solution and the explanation is linked here: http://forum.unity3d.com/threads/rewired-advanced-input-for-unity.270693/page-20#post-2216921

    The UNITY_5_1_2p2 define does not exist. You can check in the build settings page in Visual Studio of the project. By changing UNITY_5_1_2 to UNITY_5_1_2p2 you effectively removed the 5.1.2 define and made it use the code in the else block, hence it worked. However, if I were to release that, everyone with 5.1.2 (non-patched) would also go to the else block and it would fail.

    These are the conditional compilation symbols from Unity 5.1.2p1:

    You can see there is no UNITY_5_1_2p1 in there.

    This change would be incorrect anyway even if that symbol did exist because the patch releases and every release after them should be running in the else block, not this block. This if block is trying to target versions 5.1.2 and below.
     
    Last edited: Aug 6, 2015