Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. We are looking for your feedback about Templates! Tell us about your experiences by taking our survey.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Rewired - Advanced Input for Unity

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

  1. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,511
    I have heard of no other reports of this. In the entire development of Rewired I have never had a single instance or report of a complete system-wide input failure. Rewired Windows has been stable for a very long time.

    Can you confirm definitively that it only locks the system when Rewired is running? Please test in a new project with Rewired but without any other plugins. You can use one of the example scenes. Then test again without Rewired.

    This does not sound like something that could possibly be caused by Rewired. This sounds like a hardware problem or Windows problem. There's nothing Rewired can possibly do that would prevent input from working outside Rewired and Unity. Also, Rewired has no native keyboard input components at all, so if keyboard input stops working on your system outside of Unity, I can absolutely guarantee you Rewired isn't the cause.

    If you are saying that input in your game ceases, that's one thing, but input failure system-wide that requires a hard reset is entirely different. If there is a failure of input in-game, there would be a log entry and Windows would still function normally.

    Again, zero reports like this. This is going to require log files and stack traces. I need as much information as possible. At this point, I don't have anything with which to diagnose the problem.

    Please contact me on my website so we can handle this through email. http://guavaman.com/rewired/#support
     
    Last edited: Mar 11, 2016
  2. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,511
    @DeadShawn

    I think your description of having to hard-reset the computer threw my analysis of the problem off. I did find a bug which I just introduced in 1.0.0.81 in the XInput manager. It seems that Rewired will throw an exception when an XInput controller is disconnected. This exception will cause input in your game to cease functioning, but it will not cause any kind of system-wide input failure. You do not have to reboot your PC. You only have to quit and restart the game. (Alt Tab if you're full screen and you want to get back to Windows.) The error is logged in the Unity log file.

    This is a pretty serious issue and I will release an update immediately. Thanks for catching this!

    As for your beta tester who reported the game crashing to Windows, that could not be caused by this same issue.
     
    Last edited: Mar 11, 2016
  3. VoidFish

    VoidFish

    Joined:
    Nov 27, 2012
    Posts:
    30
    I've done a bit more investigating.

    When I disable the Rewired Input Manager prefab in my main menu I have no problems, when it is enabled I do. When a controller is disconnected I get the exception. Then my input hangs on a system level. Keyboard input is in no way effected but the mouse begins to studder, doesn't register clicks, and my speakers output beeps when I click the mouse. No problems with the keyboard at all, music continues to play and everything. Also, while this is happening dwm.exe (Windows Desktop Manager) maxes out one of the cores on my computer. If I try to close it via task manager my entire system halts and I must hard reset. I should have described this process earlier, thank you for working with me on this.

    It only happens when the controller disconnects, not connects.

    I'm guessing my system problems are cased by this exception (it was a 1 to 1 correlation) and its a driver level windows issue.
     

    Attached Files:

  4. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,511
    Thanks for the explanation.

    There's nothing driver-level going on here with Rewired. It's simply calling out to XInput.dll, failing to get a result because the device has been disconnected, and throwing an exception. I really can't see how it could remotely be causing any of those other symptoms besides the exception. The exception is caught and handled and simply logged, so the exception wouldn't be interfering with anything else. There's no deeper level to XInput access than that. In fact, calling to the XInput device when it's not connect is not an error either as that's the standard way of telling if a device is connected. XInput has no relation to mouse or mouse pointer either. Rewired has no code to even manipulate the mouse pointer position even on the Raw Input side.
     
  5. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,490
  6. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,511
    Do you mean me personally on my PC? It shows:
    Xbox Peripherals -> Xbox Controller

    And in the details it shows:

    C:\WINDOWs\system32\DRIVERS\dc1-controller.sys
    C:\WINDOWs\system32\DRIVERS\devauthe.sys
    C:\WINDOWs\system32\DRIVERS\xboxgip.sys
     
  7. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,511
    @DeadShawn

    I've been able to reproduce this using the Xbox One controller. Previously I was testing with an Xbox 360 controller and a clone. With the XBone, it indeed does very much like you describe, essentially making the mouse completely unusable and requiring a system restart. There is definitely something happening within Windows to cause this. It happens at times upon plugin as well and the controller won't respond. Then Unity locks and eventually the mouse pointer will start moving around at a super low frame rate. (It feels like the USB bus is being clogged with too much data or something.)

    I'm going to do a bunch of testing to see if I can rule out Rewired as the cause. It seems to me that it may be related to simply polling XInput at the time the controller is removed. The Xbox One controller was tested many times in Windows 10 before, so something has changed since then. It's possible a Windows update may have changed something. I'll know shortly.

    Incidentally, this is unrelated to the exception. That's fixed and its still happening.
     
  8. VoidFish

    VoidFish

    Joined:
    Nov 27, 2012
    Posts:
    30
    @guavaman
    I'm glad that you were able to reproduce it. I was beginning to think I might have a hardware problem with my computer or something. I've attached the screenshot of my gamepad as windows names it. Not sure if that'll be helpful.

    Thank you so much for helping with this. Besides this problem I've found Rewired to be basically perfect.
     

    Attached Files:

  9. _met44

    _met44

    Joined:
    Jun 1, 2013
    Posts:
    591
    Hey guys, has someone successfully used rewired while having a VR headset (occulus or vive) plugged in ? (not saying it doesn't work, we're just tracking down issues here and since rewired hooks with hardware at low level we wanted to rule it out if possible)
     
  10. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    Never had an issue with Rift DK1 or DK2.
     
    _met44 likes this.
  11. _met44

    _met44

    Joined:
    Jun 1, 2013
    Posts:
    591
    Awsome thanks a lot !
     
  12. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,511
    I spent all of today working on this and it boils down to this:
    There appears to be a major bug in the Xbox One Controller driver on Windows 10.

    I have isolated the problem to one of the most basic Windows Raw Input functions which is not optional. After calling this, once the device is removed, Windows Desktop Manager goes into an infinite loop, and the system grinds to a halt. There is no error in Rewired causing this. To do detailed testing and attempt (so far completely unsuccessfully) to find a workaround, I have created a super basic Windows Form Application with nothing but a few Raw Input calls so as to eliminate Unity and Mono entirely from the equation. The exact same behavior occurs when the Xbox One controller is removed.

    At this point, there's only one possible way to prevent this:
    Do not allow handling any XInput devices through Raw Input and only use XInput. This is a terrible option because one of the most important features about using Raw Input vs XInput is the removal of the 4 device limit (even at the loss of the vibration, separate triggers, and universal XI device identification).

    I am continuing to try everything I can think of to somehow workaround this, but it's not looking good.
     
  13. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    11,098
    Me either. We're happily using Rewired with UFPS in a VR game. In fact, I just posted a download link for feedback in the Game Design forum. It's in this post.
     
    _met44 and guavaman like this.
  14. VoidFish

    VoidFish

    Joined:
    Nov 27, 2012
    Posts:
    30
    It sounds like we should report this to Microsoft then. Perhaps on technet?

    Incidentally I didn't have this problem before I was using rewired, I was using xinput.
     
  15. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,511
    They're completely different systems. Xbox One controller crashes the system when you use Raw Input messaging. It has no effect on XInput. XInput only supports Xbox-compatible gamepads, nothing else.

    Yes, I'll do that.
     
    Last edited: Mar 12, 2016
  16. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,511
    @DeadShawn

    Just for confirmation I tested a C++ Raw Input tester project I got off of Code Project just to make sure C# interop wasn't an issue and it produced the exact same crash behavior.

    So there's nothing I can do to prevent this if you want to support XInput devices without XInput. BUT, I did just think of a likely acceptable compromise. I will disable Raw Input support for XInput gamepads, but only if XInput is enabled. It won't crash then. (It's also possible some other non-XInput gamepads would stop working but I'll have to test all my controllers again and see.) EDIT: It does break support for quite a number of gamepads... Nevermind.

    But if your game requires that you disable XInput so you can have more than 4 controllers, Raw Input will crash if you are using Windows 10 + Xbox One gamepad and unplug it. It's an MS driver problem with no workaround. In that situation, there is no choice but to use Direct Input instead, which has quite a number of other drawbacks vs Raw Input. That last option is to wait for MS to fix their driver.

    Incidentally, I'm pretty sure this was caused by a recent Windows Update because I have been using Windows 10 since I added support for the Xbox One gamepad including the Windows 10+ definition and this never happened before.
     
    Last edited: Mar 12, 2016
  17. ObsidianSpire

    ObsidianSpire

    Joined:
    Sep 13, 2013
    Posts:
    20
    Hey, I noticed the Steam controller doesn't send joystick connected/disconnected events while testing control mapping. It will stay in Rewired's controller list after I turn it off and stay assigned.

    What can I do to notify the player if they are using a Steam controller and it disconnects?
     
  18. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,511
    Shouldn't happen. It's just an XInput device. All my tests have shown Steam Controller sends connect and disconnect events fine. Are you sure you're not getting an exception? Does control still work after it's disconnected and reconnected? There's a bug in 1.0.0.81 that causes an exception sometimes when an XInput controller is disconnected as mentioned here. I'm going to release an update today to fix that. (I really dislike how long it takes to get updates approved in the asset store...)

    Also, how do you mean while remapping? You mean while using the Steam remapping system or something inside Unity?
     
    Last edited: Mar 12, 2016
  19. ObsidianSpire

    ObsidianSpire

    Joined:
    Sep 13, 2013
    Posts:
    20


    It eventually gave an exception after disconnecting 3-4 times, but I don't see a connect/disconnect event at all for the Steam controller. I turned it on and off over and over until the exception occurred. Could it be ignoring the disconnect because I'm using the wireless adapter with the Steam controller?

    The controller works after reconnecting, which is good, but if the batteries die or other events occur I need to indicate that to the player. I was in the control mapper while disconnecting and reconnecting a couple controllers. I wanted to see what sort of UI I needed to make for controller issues.
     
  20. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,511
    Thanks for the explanations.

    If the Steam Controller isn't sending device connect/disconnect message through Windows, Rewired won't know it's disconnected. That sounds like exactly what's happening. In Windows, Rewired uses standard Windows device events to determine when a controller changed. If those messages aren't being generated by Steam, Rewired can't know to disconnect it. That would be Steam's issue. The only possible workaround would be constant polling to detect when an XInput device disappears which is far from ideal because it introduces a very significant lag every time you poll XInput devices that aren't attached.

    I will have to do testing and find out what Steam is doing. As far as I remember this was not an issue. It may be something they did in a recent update causing this. (They do keep breaking things -- this is not the first time.) If the controller appears when turning it on after you launch your game, it _is_ sending device events -- at least the connect event.
     
  21. ObsidianSpire

    ObsidianSpire

    Joined:
    Sep 13, 2013
    Posts:
    20
    I just tried it by plugging in directly to the controller with a micro-USB cable and it sends the events like normal. My guess was right - it isn't sending any Windows events while using the wireless adapter. That's really annoying. Steam controller support is too finicky right now; I'm not going to worry too much about it.

    I'll probably let people know about the potential problems with a text box. Thanks for the quick response.
     
    Last edited: Mar 12, 2016
  22. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,511
    You know, this will actually be "fixed" in 1.0.0.82 automatically. I think the reason why it was never an issue before was that I was checking the connected status of all _connected_ XInput devices every frame before. In 1.0.0.81 I made some small optimization and changed a few things and didn't check every frame. That's where the exception came in on disconnect. Now that I put the check back, even though the device event isn't sent by Steam, on the first frame it updates the XInput controller, it's going to check if it's connected and will see that it's not connected anymore and disconnect it. This won't cause any performance loss because it only costs a lot of CPU time if the device isn't connected when you check for it. This was an accidental workaround for Steam's issue.
     
    Last edited: Mar 12, 2016
  23. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,511
    Rewired 1.0.0.82 is now available for download by registered users on the website. If you'd like to register, contact me here. Asset Store will get the update when approved (3-10 days).

    Please be sure to read the docs on updating first.

    This update was scheduled to have Windows UWP support, but I had to push it out due to the XInput fix. The next update should have UWP support.

    Some may find the new Action list exporter useful.

    RewiredExportActions.jpg

    It allows you to export all Actions from a Rewired Input Manager to a cs file containing a static class and integer constants. You can use them in the Rewired API in place of a string or integer like this:

    Code (csharp):
    1. player.GetAxis(RewiredActions.Fire);
    Of course, you're free to rename the class anything you like. One thing to note: Rewired is not a static input system like most with one global static configuration. Each Rewired Input Manager can have different inputs defined, so if you need to use more than one for some reason, you'll need to export both Action lists and give them separate class names.

    As a bonus, I've included a property drawer and attribute that will allow you to use these Actions in the inspector.

    Code (csharp):
    1. public class MyClass : MonoBehaviour {
    2.  
    3.     // This will display a categorized popup field of all the Actions in the RewiredActions class.
    4.     [Rewired.ActonIdProperty(typeof(RewiredActions))]
    5.     public int rewiredAction;
    6.  
    7. }
    RewiredPropertyDrawer.jpg


    Release Notes:
    1.0.0.82:

    Changes:
    - Windows Raw Input: Improved Bluetooth device detection when paired during gameplay.
    - Windows Raw Input: Reduced Bluetooth device detection overhead.
    - Rewired Input Manager: Added Action list exporter.
    - Added Action id property drawer and attribute.
    - Changed platform library loading system to include only necessary libraries to reduce project build size on Unity 5.0+ builds. (Unity 4.x still uses Resources system.)

    API Changes:
    - Added ActionIdPropertyAttribute
    - Added Dev.ActionIdFieldInfoAttribute

    Bug Fixes:
    - Windows XInput: Fixed newly introduced bug where exception could be thrown when an XInput controller was disconnected.
    - Windows Raw Input: Fixed extremely rare exception thrown when Bluetooth device is not identified properly when paired during gameplay, disconnected, then re-connected.

    New Controller Definitions:
    - Thrustmaster Dual Analog 3
     
    Last edited: Mar 13, 2016
  24. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,511
    @DeadShawn I've reported the problem to Microsoft on TechNet and on the Xbox site. I will post back here if I get a reply. I was unable to find any kind of workaround in the end. If Xbox One controller support on Windows 10 is critical for you at this time, the only thing I can suggest is to change the input source on Windows Standalone to Direct Input (and leave XInput checked).

    Note: Raw Input carries significant advantages over Direct Input such as better Bluetooth controller support, support for more elements on certain controllers, better controller recognition and therefore support for more auto-recognized controllers, optional Enhanced Device support such as DS4 vibration, gyro, optional Steam workarounds, etc. Raw Input also does not require any extra libraries to be installed by the user while Direct Input may.
     
    Last edited: Mar 13, 2016
  25. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,490
    These articles appear to be related to this particular problem.

    Bad Windows 10 Xbox One controller driver forces Microsoft’s hand
    http://www.infoworld.com/article/30...ox-one-controller-forces-microsofts-hand.html

    That infoworld article also had a link to this URL (which talks about going back to a previous xbox one driver for Windows 10)

    http://forum.halomaps.org/index.cfm?page=topic&topicID=49128
     
    Last edited: Mar 13, 2016
  26. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,511
    Very interesting. They don't mention a crash, but it's very likely that update was indeed the culprit as this issue was brand new and did not occur the last time I tested the Xbox One controller. There have been so many issues like this caused by new bugs in Windows, OSX, Unity, Steam, Visual Studio, etc. that have taken up so much of my time (days and sometimes weeks) tracking them down I sure wish I was getting paid by them as a debug engineer... :(
     
  27. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,490
    If anyone is going to GDC 2016 this week that is the best place to ask Microsoft about this particular XBOX One controller driver problem.
     
  28. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,490
    This is 1.0.0.82 update looks great. I am looking forward to be able export the Rewired Actions.
     
  29. noanoa

    noanoa

    Joined:
    Apr 17, 2014
    Posts:
    225
    Can you set button dead zone for when pressing a button and releasing a button separately? Like when rotating a character or view with right analog stick, it should stop rotating as soon as the player releases the stick.
     
  30. pjburnhill

    pjburnhill

    Joined:
    Mar 2, 2016
    Posts:
    27
    You could just stop the rotation as soon as no more input is coming from the stick? And yes, each stick has a definable deadzone, if I remember correctly.
     
  31. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,511
    No you can't. The Input Behavior Button Dead Zone defines the lower threshold of when to consider an axis movement a button press or not. It also applies when released however, so when the axis value falls below Button Dead Zone, the "button" is considered off again. Releasing a stick would center the axis very quickly, so the button value would reach off very quickly as well.

    However, I would question why you are using GetButton for an action like rotation anyway. GetAxis sounds far more appropriate for that kind of Action. It gives you a precise instantaneous value of the analog stick and allows the user to adjust rotational speed based on the stick position. GetButton would be just be an on/off state and not very accurate for this purpose. In addition, if the rotation action is bound to true buttons or keys, digital axis simulation smoothing can be applied to smooth out the axis value. In both situations regardless of whether the action is being controlled by a real axis or button, GetAxis is more appropriate.
     
    Last edited: Mar 14, 2016
  32. SteveB

    SteveB

    Joined:
    Jan 17, 2009
    Posts:
    1,448
    Either this hasn't been asked or I'm unable to find an answer...

    ...but is it possible to visually edit the uGUI ControlMapper? I understand I can change the theme, but I'd like to adjust the layout and such, to make it more my own. I've tried to 'unhide' the Canvas but I don't see the entire screen. Canvas Scaler Ext seems to be what scales the UI at runtime, but I'm apparently unable to edit it in the editor.

    Any guidance is much appreciated

    Cheers

    -Steven
     
  33. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,511
    No it isn't. The dynamic script-generated nature of Control Mapper makes this impossible. The best you can do is press Play, look at the structure, and then rearrange things as much as possible after stopping the player, press Play again and see what happened.

    There are certain things you just cannot change the layout on because they're generated by scripting such as the columns of input fields. Other things can be moved such as the various sections at the top. But be aware that some changes will cause problems. One thing everyone seems to want to do is to move the Done button to the bottom. I advise against this because the auto-scroll system put in place for the input field grid will make it so you have to scroll through every Action entry before it will jump down to the Done button.

    Control Mapper is not just simple Unity GUI layout. It has a lot of scripted areas, a whole different auto-navigation system, it handles nested elements inside scroll areas, and is designed to be responsive and change aspect ratios based on the current screen aspect ratio. There's a lot of potential to break the layout, so you have to know exactly what you're doing to edit the layout apart from the the theme template.
     
    Last edited: Mar 15, 2016
  34. SteveB

    SteveB

    Joined:
    Jan 17, 2009
    Posts:
    1,448
    Well two things then...

    ...if someone wanted to dive into the automation part where is that best investigated?

    ...shouldn't there be a way (within your implementation) to do basic customization such as adding background to particular 'sub-sections', or perhaps center alignment so it's not all shoved to the left? Otherwise, other than some basic re-theme-ing everyone's uGUI control mapper looks identical. I understand the power of your tool, but perhaps there should be some documentation on how to roll-your-own uGUI so we don't have to rely just on yours.

    I appreciate the quick response guava thank you :D

    -Steven
     
  35. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,511
    In the source code. Rewired/Extras/ControlMapper/Scripts

    Alignments, padding, spacing, etc. can be changed with the standard options in Unity's UI system for the various UI game objects. Other developers have done it.

    I don't have the capability to implement every possible kind of customization one would want to do in the theme inspector. It already provides the capacity to change colors, fonts, and even button graphics and type. You can change backgrounds and even could even do animated buttons with what options I have provided in the theme. The theme was meant to provide basic customization of the styles on all elements because they're dynamically generated. Basic functional customization is done through the Control Mapper inspector. Anything beyond that is out of the scope of the tool and up to you to implement if you choose to and requires a very good knowledge of Unity UI. There is nothing you can't do if you know Unity UI well and change the scripts. You have complete source code.

    The purpose of Control Mapper was to provide a complete UI remapping tool for those that want something quick and don't want to or don't have the programming knowledge to write their own. It tries to provide as many options as possible to allow you to customize it both from a functionality standpoint and a styling standpoint, but I can't reasonably be expected to take all the functionality of Unity UI and make it one-click-easy to change the layout in every way one might want to customize it. Unity UI is enormous and very complicated. The point of the system is not to be an abstraction tool for Unity UI to allow you to create customized dynamic layouts. If I were to create something like that, I would sell it as a separate product because it would be a huge undertaking.

    Documentation:
    http://guavaman.com/projects/rewired/docs/HowTos.html#controller-mapping-screen

    Rewired comes with a complete example with source code in the Rewired/Examples/ControlRemapping1 folder as well as the complete source code to Control Mapper in Rewired/Extras/ControlMapper/Scripts.

    It is stated in the docs that controller remapping is a very complex topic, therefore step-by-step tutorials will not be provided. Souce code showing how to use the API to achieve any remapping task is provided for those with programming skills that want to delve into this topic.
     
    Last edited: Mar 15, 2016
  36. SteveB

    SteveB

    Joined:
    Jan 17, 2009
    Posts:
    1,448
    Perfect!

    ...and just to be clear (so I don't appear irrational or unwilling to do the heavy-lifting), I just wanted direction to where I can indeed delve into this myself. Prior to this I was under the impression it would require a lot of dismantling to do basic changes, so what you've provided in the post above is all I wanted to know!

    Thanks again man

    -Steven
     
  37. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,511
    Unless you are going to completely revamp the entire layout, the vast majority of the heavy lifting has already been done for you. You just have to know Unity UI and you can rearrange it pretty much however you want with the exception of the input grid. If you want to change that (beyond styling), you'll have to edit source code. And be aware that the layout, especially concerning the input grid scroll area, is prone to breaking depending on what you do.

    The basic groupings that pre-exist in the scene can all be rearranged at will:
    • WindowButtonGroup
    • PlayersGroup
    • ControllerGroup
    • SettingAndMapCategoriesGroup
    • InputGridGroup

    You can press Play and change the order of these in the hierarchy and see them switch places in real-time. Committing changes requires you do it again outside Play mode though.

    The objects inside these groups are dynamically generated based on settings in the Control Mapper inspector. In addition, visibility of these groups may also be affected by Control Mapper inspector options. You could manually set backgrounds on these groups in by adding Image components to them.

    Any dynamically generated elements are loaded from the prefabs:
    Rewired/Extras/ControlMapper/Prefabs/Parts

    Some things you could customize by modifying the prefabs, while some options would be overridden by the theme when it loads.

    As for centering the window:
    ControlMapper -> Canvas -> MainPageGroup

    Set equal paddings on Left, Top, Right, and Bottom and the window will be centered.

    The ControlMapper->Canvas: Canvas Scaler Fitter component governs responsive break points. It can be disabled if you don't need that functionality.

    If you need to modify any source prefab components, it's best to work with copies of everything so you can still update Rewired and not lose your changes. If you copy all the prefabs, you will need to re-assign the copies as the sources for the dynamically generated objects in the ControlMapper inspector -> Advanced Settings -> Internal Data -> Prefabs section.

    If you want to customize the popup windows, they are also in the prefabs folder. Same rules apply. Copy them, then re-assign the copies as the prefab sources.
     
    Last edited: Mar 15, 2016
  38. SteveB

    SteveB

    Joined:
    Jan 17, 2009
    Posts:
    1,448
    Oh wow now THIS is exactly what I was looking for!

    I was already keen on editing the individual prefabs, which leads to me to what you've mentioned before:

    ...this is where I was confused originally. How do I make the changes again outside of Play mode when I don't see the UI layout in Edit mode to make the adjust adjustments?
     
  39. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,511
    You would have to write down your changes or take a picture and re-do the changes after exiting Play mode. That's exactly how I worked when building it. Script-generated UI's in Unity UI aren't easy to work with.

    Obviously, any changes you make to dynamically generated elements like buttons can't be done that way and would have to be done in the theme and/or prefabs.
     
  40. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,511
  41. SteveB

    SteveB

    Joined:
    Jan 17, 2009
    Posts:
    1,448
    I've been playing around and have been able to do quite a bit, you're absolutely right. It was entirely simple and yea honestly what more would anyone really need to do when you can quite easily change all of the basics, the alignments and even positions of the various sub-elements.

    I was even able to change the Canvas Render Mode to World Space (requiring that during Play Mode, I had to switch from World to Screen Overlay to World Space again to see the values that are automatically entered in the Canvas - Rect Transform)...very nice!

    Again thank you for your patience and time Guavaman

    -Steven
     
    guavaman likes this.
  42. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,490
    Great news! The asset store had a very quick turn around this time.
     
  43. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,511
    It was super quick! I just submitted it Saturday night and they approved it on Tuesday. :eek:
     
  44. Badin

    Badin

    Joined:
    Jul 21, 2015
    Posts:
    14
    Is it possible to detect exaclty which controller the player is using and change the HUD according to the controller the player is playing?

    Like change the message from "press X to attack" (with a XBOX controller) to "press SPACE to attack" (with keyboard) to "press SQUARE to attack (with PS3/4 controller). It would be like a dream coming true to me.
     
  45. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    I posted how I do it a year ago in this thread. Take it with a grain of salt, since every game is going to have slightly different requirements, but it could be a starting point at least:

    http://forum.unity3d.com/threads/rewired-advanced-input-for-unity.270693/page-6#post-1918549
     
    Badin and guavaman like this.
  46. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,511
    @Badin


    There are three steps involved in displaying on-screen glyphs for controller elements:
    1. Create the controller element glyph graphics.
    2. Create a lookup table of controller element glyphs.
    3. Display the glyph on-screen.

    Step 1:
    Obviously this is up to you to decide how your glyphs will look and in what data format they will be in.

    Step 2:
    You will need to create a lookup table that associates particular Element Identifiers from particular controllers to the glyphs. This could be in any format you choose -- a database lookup, serialized data in a MonoBehaviour, etc.

    This would look something like this in concept:

    name = Xbox 360 Controller
    guid = d74a350e-fe8b-4e9e-bbcd-efff16d34115
    elementidentifierid = 0
    sprite = 360_LeftStick_Horiz
    elementidentifierid = 1
    sprite = 360_LeftStick_Vert
    elementidentifierid = 6
    sprite = 360_ButtonA

    Step 3:
    Display the glyph on screen. This is up to you however you choose to do so depending on your data format and needs.

    You can retrieve the glpyh based on the Joystick's GUID and the current Element Identifier Id mapped to a particular Action.

    Here are the basic steps:
    1. Get the last used controller from the Player using Player.controllers.GetLastActiveController.
    2. Determine the type of the controller using the Controller.type property.
    3. If a Joystick, identify this Joystick as a recognized type using the Joystick.hardwareTypeGuid property. (The type GUID for each recognized controller can be found in the HardwareJoystickMap definition for each controller on the Settings page.)
    4. Check if any element on this controller is mapped to the Action in question using one of the following methods:
      • Player.controllers.maps.GetFirstElementMapWithAction
      • Player.controllers.maps.GetFirstButtonMapWithAction
      • Player.controllers.maps.GetFirstAxisMapWithAction
      • Player.controllers.maps.ElementMapsWithAction
      • Player.controllers.maps.ButtonMapsWithAction
      • Player.controllers.maps.AxisMapsWithAction
    5. If the element is mapped, use this information to look up the glyph from your lookup table using the ActionElementMap.elementIdentifierId property and the Joystick.hardwareTypeGuid property.
    6. Optional: Further information about the mapping can be found in the ActionElementMap such as the Axis Range, Axis Contribution, type, or other useful information should you need more specific glyphs for a finer level of detail.

    The same concepts would work for Keyboard, Mouse, and even Custom Controllers.

    An example of how one might store the glyph table data:
    Code (csharp):
    1. // ControllerGlpyhs.cs
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. namespace Rewired.Demos {
    6.     using Rewired.Data.Mapping;
    7.  
    8.     // This is a basic example showing one way of storing glyph data for Joysticks
    9.     public class ControllerGlyphs : MonoBehaviour {
    10.  
    11.         [SerializeField]
    12.         private ControllerEntry[] controllers;
    13.  
    14.         private static ControllerGlyphs Instance;
    15.  
    16.         void Awake() {
    17.             Instance = this; // set up a singleton
    18.         }
    19.  
    20.         public static Sprite GetGlyph(System.Guid joystickGuid, int elementIdentifierId, AxisRange axisRange) {
    21.             if(Instance == null) return null;
    22.             if(Instance.controllers == null) return null;
    23.  
    24.             // Try to find the glyph
    25.             for(int i = 0; i < Instance.controllers.Length; i++) {
    26.                 if(Instance.controllers[i] == null) continue;
    27.                 if(Instance.controllers[i].joystick == null) continue; // no joystick assigned
    28.                 if(Instance.controllers[i].joystick.Guid != joystickGuid) continue; // guid does not match
    29.                 return Instance.controllers[i].GetGlyph(elementIdentifierId, axisRange);
    30.             }
    31.  
    32.             return null;
    33.         }
    34.  
    35.         [System.Serializable]
    36.         private class ControllerEntry {
    37.             public string name;
    38.             public HardwareJoystickMap joystick;
    39.             public GlyphEntry[] glyphs;
    40.  
    41.             public Sprite GetGlyph(int elementIdentifierId, AxisRange axisRange) {
    42.                 if(glyphs == null) return null;
    43.                 for(int i = 0; i < glyphs.Length; i++) {
    44.                     if(glyphs[i] == null) continue;
    45.                     if(glyphs[i].elementIdentifierId != elementIdentifierId) continue;
    46.                     return glyphs[i].GetGlyph(axisRange);
    47.                 }
    48.                 return null;
    49.             }
    50.         }
    51.  
    52.         [System.Serializable]
    53.         private class GlyphEntry {
    54.             public int elementIdentifierId;
    55.             public Sprite glyph;
    56.             public Sprite glyphPos;
    57.             public Sprite glyphNeg;
    58.  
    59.             public Sprite GetGlyph(AxisRange axisRange) {
    60.                 switch(axisRange) {
    61.                     case AxisRange.Full: return glyph;
    62.                     case AxisRange.Positive: return glyphPos != null ? glyphPos : glyph;
    63.                     case AxisRange.Negative: return glyphNeg != null ? glyphNeg : glyph;
    64.                 }
    65.                 return null;
    66.             }
    67.         }
    68.     }
    69. }
     
    Last edited: Mar 16, 2016
    GibTreaty and Badin like this.
  47. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,490
    Cool. I always was wondering what Game you were working on with Rewired. Thanks for posting.
     
  48. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,490
    The Rewired Action Exporter is extremely useful feature. It really a good way to keep track of all of your actions easily. Another great time saver. Keep up the good work.
     
    guavaman likes this.
  49. TryHarder

    TryHarder

    Joined:
    Jan 1, 2013
    Posts:
    121
    Hi,

    Has anyone used Rewired with UFPS Mobile ?

    If so how have you fouund the way to swap between Mobile input and Joystick ?

    I'm guessing I need to change the keyboard and Mouse maps, but I can't seem to stop the Keyboard and Mouse working, if I disable the maps then no mobile input works at all. Hmmm I think I need to go for a walk and come back to it, if I disable the Rewired Input Manager gameobject and re run the mobile works fine, so hmmm there must be a way to leave it running but use the mobule input.

    Any help gratefully recieved !

    Thank you..
     
  50. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,511
    That's because when you launch the project without Rewired UFPS Input Helper enabled, vp_Input.cs creates a singleton and all input is handled by UFPS and UnityEngine.Input. Then when you enable the Rewired Input Manager, it overrides that singleton UFPS created and now all input comes from Rewired. UFPS's input vp_Input.cs will no longer receive any input calls. Disabling the Rewired Input Manager will not revert the singleton control to UFPS because the variable has been overwritten.

    RewiredUFPSInputHelper.cs line 50:
    Code (csharp):
    1. m_Instance = this;  // Set up singleton
    That m_Instance is a static field and exists in the vp_Input class.

    I do not know how UFPS Mobile Addon handles input. Rewired's UFPS input helper script was not written to take into account UFPS Mobile Addon. It's almost certain you will have to change source code to get it to work.

    I would be surprised if touch control worked with Rewired enabled, but it sounds like it does to some extent. The way you describe it, it sounds like it's emulating the keyboard and mouse through touch controls? Is it somehow sending keyboard and mouse events through UnityEngine.Input? Because that's the only way possible that changing Rewired's maps could possibly affect it. This would be very unusual.
     
unityunity