Search Unity

Rewired - Advanced Input for Unity

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

  1. crazymonkay

    crazymonkay

    Joined:
    Apr 1, 2013
    Posts:
    101
    Hey there, I was wondering If I could get some advice on the best way to go about making "compound" glyphs for inputs like the left and right joysticks.

    Basically rather than displaying 2 separate glyphs for actions mapped to the X and Y axes, for simplicity I would like to display a single glyph to cover both. My inputs are rebindable separately for the X and Y axes, so I can't hard-code anything just in case someone wants weird bindings.

    I've been looking at the docs and it seems like the CompoundElement class may be useful? I'm just not sure if its possible to find the "parent" compound element given just an X or Y element.

    Thanks in advance!
     
  2. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    I haven't thought about this before, but CompoundElement would work with limitations.

    A Joystick may have any number of Axis2D's. Whether or not this is a "stick" is undefined. It's simply 2 axes bound together for the purpose of calculating a radial dead zone. The Axis2D class exposes the 2 component axes. The Axis exposes the Element Identifier.

    https://guavaman.com/projects/rewir.../html/P_Rewired_ControllerWithAxes_Axes2D.htm

    Unknown Controllers do not have any Axis2D's.

    The only way you can be certain as to what kind of stick it is (if that matters) would be to use the Controller Template system to determine what Template is being used, then determine the Template element type, associate that with the axes, etc. The GamepadTemplateUI example would be the best way to learn how to do this.
     
  3. crazymonkay

    crazymonkay

    Joined:
    Apr 1, 2013
    Posts:
    101
    That's exactly what I was looking for! I can loop through the Axis2D's to find the one that contains the x and y axes corresponding to my element maps, and then use the Axis2D's element identifier to get the appropriate glyph.
     
  4. fairchild670

    fairchild670

    Joined:
    Dec 3, 2012
    Posts:
    55
    Hello there!

    I've run into what I thought was a relatively simple issue, but it has turned out to be quite difficult and I haven't had much luck searching through older forum posts and through the documentation/API.

    Basically I'm trying to display icons on the HUD according to the current active layout (we have two layouts, one for right handed players and another for left). I've been able to figure out how to enable/disable the layouts however updating the icons on the HUD according to which one is active has been tricky. I can get the icons showing up for the right hand players (Default) but not for left handed. Is there a way to get which key is currently mapped to a RewiredAction based on the currently active ControllerMap?

    Attached are the images of the left and right handed keyboard layouts for the same Controller, to get an idea of how it's set up. Code wise here are the chunks of what I've got so far, which essentially works for the Default layout:

    Code (JavaScript):
    1. var controller : Controller = replayer.controllers.GetLastActiveController();
    2.  
    3. if (!controller) {
    4.     controller = replayer.controllers.GetController(ControllerType.Keyboard, 0);
    5. }
    6.  
    7. .......
    8.  
    9. for (var aeme : ActionElementMap in replayer.controllers.maps.ElementMapsWithAction(controller, rewiredAction, true)) {
    10.     return GetInputSprite(aeme.elementIdentifierName); // works for Default, not left handed layout
    11. }
    12.  
    13. .....
    14.  
    15. private static function GetInputSprite(elementIdentifierName : String) : String {
    16.  
    17.     var sprite : String;
    18.  
    19.     if (InputHandler.GetControllerType()==ControllerType.Keyboard) {
    20.  
    21.         switch (elementIdentifierName) {
    22.             // keyboard and mouse
    23.             case "A":
    24.                 sprite = "Keyboard_White_A";
    25.                 break;
    26.             case "B":
    27.                 sprite = "Keyboard_White_B";
    28.                 break;
    29.             case "C":
    30.                 sprite = "Keyboard_White_C";
    31.                 break;
    32.  
    33.         //// there is a sprite for each key
    34.     }
    35. }
    Any help would be greatly appreciated!
     

    Attached Files:

  5. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    That's exactly what this code is doing:

    Code (csharp):
    1. for (var aeme : ActionElementMap in replayer.controllers.maps.ElementMapsWithAction(controller, rewiredAction, true)) {
    2.     return GetInputSprite(aeme.elementIdentifierName); // works for Default, not left handed layout
    3. }
    It works for any Layout.

    This function iterates all the Controller Maps in the Player for that Controller, searches for bindings to the Action in question, and returns all the results. You are calling the function with skipDisabledMaps set to True. If the Controller Map is disable, it will be skipped and will not return any results.

    Look at what exactly is loaded and enabled to find your problem:
    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#debug-information

    It's likely the Controller Map you think is enabled isn't enabled and/or loaded.

    I strongly suggest you use Layout Manager for handling switching between layouts.
     
  6. GenericJoe

    GenericJoe

    Joined:
    Apr 27, 2012
    Posts:
    19
    Rewired is fantastic, but the only thing I was disappointed with was the fact that Control Mapper does not use Textmesh Pro, meaning working with non-standard fonts is difficult. I will have to tweak the control mapper manually or write my own, which will take a long time considering I was hoping to have this functionality "out of the box".
    I understand the Control Mapper is an extra, but given how TM Pro comes standard and bundled with Unity these days, it would have meant I would have minimal customization to do resulting in an awesome product. Considering the price of Rewired I think it's fair to point this out.
     
  7. fairchild670

    fairchild670

    Joined:
    Dec 3, 2012
    Posts:
    55
    Thanks!! Looking at the Debug made me realize I was accidentally using the Mouse controller when I meant to be using the Keyboard. Got it working, really appreciate the help!
     
  8. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    Thanks for your opinion.

    Rewired's price is absurdly low for all it gives you. Nothing has ever existed before like it with so many features, working on so many platforms, across so many devices. I have spent over 5 years developing, expanding, and supporting it (support has been the majority of the work which I in no way expected when I started this). I have done this largely out of passion because I want to offer the best possible input experience I can. I have sacrificed an enormous amount of income (multiple times what I make) I would have been making had I been working in a software developer job where I live instead of doing this and selling this boutique software at the price I sell it at, spending all my time doing support. Rewired is and has always been ridiculously under priced for the amount of time and work I put into it. Each copy translates into $31.50 for me, then I get a free support question that eats up 5 hours of my time, and frequently longer. This happens on a very, very regular basis. It has a reputation as being "expensive" because we live in a world where everything is "free", especially digital stuff, funded by giant corporations that spend vast amounts of money to create something, give it away for nothing to attract as big an audience as possible, and then come up with creative ways to squeeze money/value out of them. Rewired isn't anything like that. You buy Rewired once, you can use it forever in as many games as you want. The price went up one time 2 years after release and has been the same price for the last 3 years. I also haven't done like many other assets and released a "v2" update of the software and charged an upgrade fee. Someone who bought Rewired for $20 ($14 in the pocket.) on sale when it was first released 5 years ago can still get access to the latest versions of Rewired that run on platforms that didn't even exist 5 years ago like Nintendo Switch and Google Stadia. Fixes and new features are constantly being added for free. Every new feature added adds to the amount of support I have to provide, especially if that feature "touches" any other ancillary system because that ends up spilling over into support for that other system and red-herring issues involving those other systems where the user thinks Rewired is at fault, I have to spend time investigating, etc. Unity UI is a prime example. And every single new feature added ends up resulting in continual requests for expansion, modification, or improvement to those new systems, as nothing ever meets the needs/wants of everyone and many don't want to take the time to make the modifications themselves.

    Control Mapper was developed long before Text Mesh Pro was free. It was added to Rewired as an extra for users who could not or would not take the time and effort to implement a control remapping system with the API provided. A drop-in remapping UI is frankly, far beyond what an input system library is responsible for providing out-of-the-box. Rewired still supports Unity 4.3.0 to this day, and Control Mapper must be able to run in all versions all the way back to 4.6.0 when Unity released the new UI. Control Mapper cannot be changed to work with Text Mesh Pro out of the box. It has to be completely replaced by a new Control Mapper made for Text Mesh Pro that works with whatever the earliest version of Unity Text Mesh Pro works with.
     
    Last edited: Nov 11, 2019
    GenericJoe, SugoiDev and flashframe like this.
  9. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    Rewired 1.1.29.2 is now available on the Unity Asset Store.

    Please see Updating Rewired before updating.

    Release Notes:

    1.1.29.2:

    Changes:
    - Improved detection of rapid button taps at lower frame rates.

    Bug Fixes:
    - Rewired Editor saves prefab before exporting constants so changes made before editor recompiles are not lost. (Unity 2018.3+)
    - Windows Standalone, XInput, Direct Input: Fixed issue causing fast button taps to be missed at high input thread frequency and low frame rates (increased buffer size).
     
  10. GenericJoe

    GenericJoe

    Joined:
    Apr 27, 2012
    Posts:
    19
    Hey, thank you for the eloquent response and for taking the time to help me understand how these things work. You are absolutely right - I retract my disappointment, and wish you the best of luck!
     
    flashframe likes this.
  11. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    I understand you are disappointed and you have every right to be. I recognize that. The only thing I was trying to point out was that Rewired's price is much lower than it rightfully should be and therefore shouldn't factor into this issue.

    I will be making a Text Mesh Pro version of Control Mapper and have to come up with some way of distributing it without breaking everyone's projects who have already made customizations to Control Mapper. That's probably not going to be possible and I'm going to have to end up having 2 control mapper install packs -- Control Mapper and Control Mapper (TMP) and give the user the choice which to install. I must maintain two Control Mappers concurrently from now on as well.
     
  12. GenericJoe

    GenericJoe

    Joined:
    Apr 27, 2012
    Posts:
    19
    No worries, I genuinely do agree with your points most of which I hadn't considered. To be completely honest, because Unity's Input system is so bad, and Rewired so good, I expected you to be a wealthy entrepreneur, with a team of devs who did most of the work for you :D

    Just for context when I made my comment (which was really just a feature request I guess) the bundled Control Mapper was something that actually sealed it for me when I was shopping around. It's actually great, and as an indie dev it has already saved me weeks of development time.
    I know what you mean about needing to maintain multiple versions - that would be far from ideal, and I don't know if it would be worth the effort!?
     
  13. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    Thanks for the kind words. That certainly would have been nice.

    Eventually, I will have to drop support for very old versions of Unity. Making new builds to publish just takes hours and hours these days because of all the versions with all the testing that has to be done. But until then, there's no choice but to maintain multiple version of things when something has to be updated for a new feature of Unity.
     
    Last edited: Nov 13, 2019
  14. Glowing_Slab

    Glowing_Slab

    Joined:
    Jun 19, 2015
    Posts:
    30
    Hi, I was wondering if anyone had already written a nice solution that they would be willing to share for how to simulate the 'Center 1' and 'Center 3' buttons on the PS4 DualShock controller via the touchpad and and touchpad button? As these are the 'Share' and 'Options' buttons on a PS4 I'd need to instead divide the Touchpad button to recreate 'Start' and 'Select' from the PS3 controller. From looking at the 'DualShock4SpecialFeatures' example in the Rewired Asset I'm guessing a way to do it is to get the touchpad input position and the center button press together?
     
  15. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    After converting everything to Text Mesh Pro in Unity 5.7.0 using the last version they offered on the Unity Asset Store, adding all the code required for the editor to offer and support 2 versions of Control Mapper, I find out that Text Mesh Pro prior to the move to the Package Manager in 2018.1 and the Package Manager version are not compatible. I am just not going to support and maintain 3 versions of Control Mapper, one for standard UI, one for Text Mesh Pro 5.7.0 - 2017.x, and one for 2018.1+. Looks like I'm going to have to make this 2018+ only. What a mess.
     
    SugoiDev likes this.
  16. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    That's the only way you could do it. If you want it to contribute value to an Action, use a Custom Controller:
    https://guavaman.com/projects/rewired/docs/CustomControllers.html
     
    Glowing_Slab likes this.
  17. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    @GenericJoe Here is the Text Mesh Pro version. It can only be used in Unity 2018.1+ with Text Mesh Pro installed from the Package Manager and the Text Mesh Pro Essentials pack installed.

    Extract the contents of the zip into the Assets/Rewired/Extras/ folder replacing any files within.

    Warning: If you have an existing Control Mapper setup, you will not be able to easily migrate to a different version of Control Mapper because your copy will not automatically inherit all the changes required to work. The Text Mesh Pro version uses different text components than the Unity UI version, and all the object references to text components will be lost when switching between versions. The best way to switch from Standard to the Text Mesh Pro version is to rebuild your setup using the Text Mesh Pro version.

    Edit: The file has been removed. It has come to my attention that many changes have been made to Text Mesh pro, including breaking changes, including major changes in the 2.x branch on Unity 2018.3+ that include major changes such as a new font engine, stylesheets support, and more. Due to the constantly changing nature of this asset, to prevent myself from having to support 4-5 versions of Control Mapper for various versions of Unity and Text Mesh Pro, I have removed the file and will only be supporting the latest released version of Text Mesh Pro at the time of release.
     
    Last edited: Nov 14, 2019
    GenericJoe and SugoiDev like this.
  18. Glowing_Slab

    Glowing_Slab

    Joined:
    Jun 19, 2015
    Posts:
    30
  19. Joshdbb

    Joshdbb

    Joined:
    Oct 28, 2014
    Posts:
    13
    Hey

    I am having issues with the screensaver showing while my controller based game is playing on OSX.

    It seems that the OS isn't aware of the controller input and so shows the screensaver due to inactivity.

    I was wondering if this issue was something to do with Rewired?

    Has anyone else experienced this?
     
  20. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    Rewired just consumes input values from I/O Kit and UnityEngine.Input. Unity is also getting input at the same time Rewired is. Just because you installed Rewired doesn't mean Unity was disabled.

    According to all the information I can find, an application can call UpdateSystemActivity (deperecated in 10.8) or IOPMAssertionDeclareUserActivity (10.7+) to prevent the screensaver from activating. Rewired does not do this and obviously neither does Unity.
    https://stackoverflow.com/questions...ammatically-prevent-a-mac-from-going-to-sleep
    https://developer.apple.com/documen...opmassertiondeclareuseractivity?language=objc

    There is also this. I have no idea if it works on OSX:
    https://docs.unity3d.com/ScriptReference/Screen-sleepTimeout.html

    This is the first I've ever heard of an application having explicitly tell the OS not to turn off the screen when some kind of input is received. My question is, if this is something the application is expected to do, why doesn't Unity do it? It makes little sense for this to be the responsibility of a plugin and not the game engine itself. Regardless, it seems like I'm going to have to add this because Unity isn't doing it.

    Plenty of other people having the same issues:
    https://github.com/360Controller/360Controller/issues/250
    https://forum.parallels.com/threads/how-do-i-turn-off-osx-screensaver-when-playing-games.96416/
    https://answers.unity.com/questions/1023185/need-help-preventing-the-screensaver-on-a-mac.html
     
    Last edited: Nov 14, 2019
  21. Threepwood

    Threepwood

    Joined:
    Jul 23, 2009
    Posts:
    87
    Quick question on the Switch Pro Controller.

    I set up a base Gamepad Template and the Xbox Elite, PS4 and some random Logitech Gamepad all work great. The Switch Pro Controller is recognized on my MacPro via bluetooh and works fine in some other games. It doesn't seem to work in Unity/Rewired.

    Any tips in setting it up? This is ultimately just to work on a windows/mac PC and not the Switch itself.
     
  22. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    Follow this guide:
    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#controller-doesnt-work
     
  23. slowpokimus

    slowpokimus

    Joined:
    Jun 12, 2017
    Posts:
    5
    I'm having an issue where controllers work perfectly in editor but appear to not work in build. I ran through the troubleshooting and found that all the debug information in build appears to match what's in editor; the controller is enabled and assigned, and any inputs I make are displayed as expected in the debug, but the player character isn't responding to the detected controller inputs, so I'm not sure where the issue lies.

    http://puu.sh/EEGel/e52b2ae3c2.jpg
    This screenshot was taken in build. The red cube is assigned to keyboard and works in editor and build. The purple sphere is assigned to controller 1 and works in editor but not in build. In the screenshot you can see that Player1 (purple sphere) recognizes its controller, and it says I'm pushing left stick X to the right, but the purple sphere doesn't move (whereas in editor it does). I've tried using an Xbox One controller and PS4 controller with identical results.

    I looked at the "something works in editor but not in standalone build" section of troubleshooting, but the solutions there don't seem to apply. If I'm not mistaken, #1 is for if you're saving data/using controller mapper (I'm not), and #2 doesn't seem relevant because my Rewired Input Manager was made using the "in scene" option and so isn't a prefab, and I only have one scene.

    I'm sure I'm making some dumb mistake, but I'm not sure how to troubleshoot from here.
     
  24. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    You are viewing the Controller elements in that screenshot. Did you then go on to view the Action values being returned by the Player? Controller elements lie below the Action system and fuel the resulting Action values. Your scripts consume Actions, not Controller values. The Controller Map system goes between the Controller elements and the Action values. If your Controller Maps are not loaded or wrong, you will get no input. The checklist in the debug information documentation takes you through all these steps to identify the problem:
    https://guavaman.com/projects/rewir...l#debug-information-diagnosing-input-problems
     
  25. slowpokimus

    slowpokimus

    Joined:
    Jun 12, 2017
    Posts:
    5
    Yeah, the Action values are being returned as well: https://puu.sh/EF6Eu/575efe179c.jpg
    I've run through every item on that checklist and they're all reporting what they should be.
    The game objects the players control are prefabs placed in the scene with their playerId manually set in the inspector. In Awake() they assign player = ReInput.players.GetPlayer(playerId).

    Out of curiosity, I tried setting Player1 (purple sphere) to have keyboard controls, and setting Playerkb (red square) to have joystick controls. The joystick worked for Playerkb as intended, and when using keyboard controls in build Player1 still returned action values in debug but didn't respond to controls in game. So it's not an issue with the type of controller, it's just something with the inputs not being sent to where they should be... or something? I at least know their playerIds are correct because those are the numbers shown on their faces (with +1 for readability). I also tried logging the player.ToString() of each game object and they each reported Rewired.Player.

    I reverted the controls to normal (Playerkb using kb, Player1 through 3 using joystick) and told Rewired to auto exclude Player1 from being assigned a joystick. It skipped over him and gave blue sphere the joystick, as expected. Same results: I can control blue sphere in editor, but not in build.

    So it seems a more accurate way to describe the problem is every Player beyond the first can't be controlled in build despite their controllers reporting accurately in the debug.
     
  26. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    If the Action values displayed are correct for the correct Player in Debug Information, the problem in your scripts/serialized data. If Rewired is returning Action values for Player 1 when you interact with the controllers that are assigned to Player 1, but the object you think is Player 1 is moving, then your code to get the Player for that object is wrong. The Action values you see in the Debug Information are the only Action values that exist for that Player. Any script that consumes Action values from that Player can only possibly get those exact same values you're seeing in Debug Information.

    Log the Player Id values for each object in the build. I suggest you do this in Update and not Awake in case some code is changing this id after start.
     
  27. slowpokimus

    slowpokimus

    Joined:
    Jun 12, 2017
    Posts:
    5
    Here's the log for the playerId values: https://imgur.com/hmjYTVG
    It's being logged in Update, and showing what is expected. I'm also having each game object print its playerId on its face, and they are showing what is expected in editor and in build.

    I'd like to stress that everything works perfectly in editor; I can control as many characters as I have controllers. It's only once I test the game in a build that every player game object after the first doesn't respond to input anymore (despite the debug info in the build saying it's got the right player id and is returning actions, etc). I don't have any idea how to troubleshoot that. I feel bad for taking up your time with this, but I'm at a loss!
     
  28. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    Post your entire script for the controllers. It's the only way I will be able to find something possibly being done wrong.

    I really can't tell you anything about this working in the editor and not the build. As you state, Rewired IS returning the correct Action values for each Player in the Debug Information in the build. That means Rewired is doing everything correctly. Every Player is assigned a controller and every Player has Controller Maps that apply, therefore final Action values are correct. Whatever is happening here is outside Rewired, so whether it happens differently in the editor or the build doesn't help me since I don't have all the information about what you're doing that could be affecting this. Building the wrong scene, having some editor-only code, loading something from PlayerPrefs... There could be many, many causes. The only thing that matters is that the right Player Id is being used when the script calls ReInput.players.GetPlayer(). If that Player Id is correct, and as you state, the Action values for that Player are reporting correctly in the Debug Info, Rewired is giving you the correct data. Beyond that, something else in your code after you get the input values and actually apply them would be causing the issue. The easiest way for me to see what's happening would actually be to have your project. If you send it to me in a PM (dropbox link or something) and tell me the version of Unity you're using, I will look at it.

    Also, the screen shot you sent with the debug log was taken in the editor. It's only useful if you do this logging in the build to see what's actually happening in the build where you're having the problems.
     
    Last edited: Nov 16, 2019
  29. slowpokimus

    slowpokimus

    Joined:
    Jun 12, 2017
    Posts:
    5
    Last edited: Nov 16, 2019
  30. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    Thanks. Setting up my own Rewired Input Manager and objects to reference your script, everything works identically in a build vs the editor. Please send me the entire project in a private message (because Rewired isn't free). Please zip the whole project folder so I have the entire thing.
     
    Last edited: Nov 17, 2019
  31. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    Thanks for sending the project. I was able to look through it and figure out what your problem is.

    This isn't a problem with Rewired or even input at all. The problem is all instances of your CharacterControl scripts except the first one that instantiates are throwing Null Reference Exceptions in Awake. Open the build log file and you will see this or do a Development build and you will see 3 Null Reference exceptions logged in red at the bottom. The Null Reference Exceptions in Awake cause Unity to ignore these MonoBehaviours from then on and their Update methods are never called, hence your objects don't respond to input.

    The Null Reference Exceptions are happening in ColorChange.cs, line 46:
    Code (csharp):
    1. gameManager.AddUsedColor(colors[myColor]);
    This is called from Awake in CharacterControl.cs, line 57:
    Code (csharp):
    1. SwitchTo(allObjects[Random.Range(0, allObjects.Count - 1)]);//switch to a random object when the game starts
    The gameManager field is null by the time gameManager.AddUsedColor is called. Your code also logs the value "GM" because of this line in ColorChange.cs, line 44:
    Code (csharp):
    1. if(!gameManager) { Debug.Log("GM"); }
    Now why would this happen in a build and not in the editor? Pure luck in the order of execution of Awake on the MonoBehaviours. The underlying cause of this is Unity's order of execution of the special methods like Awake.

    Awake is called on all MonoBehaviours in the scene in succession. There is no guarantee of the order Awake will be called on different GameObjects, and there is no guarantee the order Awake will be called even on multiple MonoBehaviours on the same object.

    Your CharacterControl.cs is calling GetComponent<ColorChange>.PaintObject() in Awake. ColorChange.PaintObject is using the gameManager field which is set in ColorChange.Awake(). If CharacterControl.Awake is called by Unity before ColorChange.Awake is called by Unity, your gameManager field is still null at the time of the call and you get the Null Reference Exception you are seeing in the build.

    You cannot rely on Awake to have already been called in other MonoBehaviours in the Awake method of a MonoBehaviour.

    These may be of some use to you:
    https://learn.unity.com/tutorial/awake-and-start
    https://forum.unity.com/threads/be-careful-about-run-order-of-awake-functions.513892/#post-3365000
    https://docs.unity3d.com/Manual/ExecutionOrder.html
     
    Last edited: Nov 17, 2019
  32. slowpokimus

    slowpokimus

    Joined:
    Jun 12, 2017
    Posts:
    5
    I knew I had done something dumb! Thank you so much!
     
  33. maxxa05

    maxxa05

    Joined:
    Nov 17, 2012
    Posts:
    105
    I'm using Rewired with ECS and I tried using Rewired.Player.GetButton/Axis/Whatever in a job, and so far, it seems to work! But I wanted to make sure, is Rewired supposed to be thread safe? Also, is there another way you know to get the actions that is more ECS friendly?
     
  34. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    No, Rewired is not thread safe at all. There is no way to use Rewired safely from a thread other than the main thread in Update or Fixed Update. Rewired is a frame-based input system just like UnityEngine.Input and is built around Unity's MonoBehaviour callbacks.
     
  35. Karearea

    Karearea

    Joined:
    Sep 3, 2012
    Posts:
    322
    You should get the input values from the main thread in OnUpdate, and pass the values in when you schedule the job (much like they show with getting deltaTime in a lot of the demo scripts).
     
    guavaman likes this.
  36. Cris_2013

    Cris_2013

    Joined:
    Nov 25, 2017
    Posts:
    16
    Hi, I would like to ask about using Rewired on multiple platforms.
    I'm developing a single project which I can build to multiple platforms. I am encapsulating the Rewired Input Manager in an asset bundle and instantiating it in real time. On Windows I have no issues, however when I setup the editor (running on Windows 10) to OSX and I lunch press play, I get this warning:
    "Rewired: The current build target is set to OSX. Controller capabilities in the Unity editor may not accurately reflect those in a OSX build."
    Everything works well though (so far), but I would like to ask a few questions regarding this:

    - Is it correct to have a single Rewired Input Manager prefab per platform? Or should I have a single one for all platforms?
    - Is there any particular way to setup Rewired for a particular platform?
    - How do I fix the warning mentioned above?

    Many thanks in advance.
     
  37. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    It's very unusual to set up different Rewired Input Managers for different platforms. If you really need different input configurations for different platforms, use Layouts. You don't want to have to be keeping a Actions, Players, Controller Maps, etc. in sync among different platforms. That could also lead to a mess trying to use exported constants and have the same code run on all platforms should one Rewired Input Manager get out of sync with the constants somehow (delete an Action, make a new one and the id's don't match across Input Managers, etc).

    You cannot "fix" the warning. It is simply there to tell you not to expect controller input on the build target platform to work like it does in the editor platform. Different input libraries, different OS controller support, different results.
     
    Last edited: Nov 20, 2019
  38. Cris_2013

    Cris_2013

    Joined:
    Nov 25, 2017
    Posts:
    16
    Many thanks for your quick reply and explanation. I'll give layouts a go :)
     
  39. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    413
  40. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    413
    One question
    in Unity 2019.2.12f1
    i use Rewired 1.1.29.2

    in a common setup
    with Rewired Initializer in manin and subscene.


    This error is often thrown e.g after scene startup and after builds.
    Unbenannt.JPG

    But the editor build and scene works great.
     
  41. maxxa05

    maxxa05

    Joined:
    Nov 17, 2012
    Posts:
    105
    Ok, I see. Did you have a plan to adapt Rewired to ECS? If not, I guess I'll just check the input from a system on the main thread for now.
     
  42. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,459
    From that page it says the following.
    SimSteering2 FFB System (52) - Standard

    "... PC connection is through USB and is detected by Windows as a generic gaming device so no drivers or plugins are required. Compatible with directX allowing excellent compatibility with current and future simulation software. Will work with any game that offers force feedback ... "

    = = = = =

    I would expect the main reason for your interest is in the force feedback portion of this controller especially considering the price of the controller.

    For the basic controller point of view you would need to create a Rewired controller definition. From the Rewired documentation.

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

    Rewired ONLY supports gamepad vibration as mentioned in the Rewired docs.

    https://guavaman.com/projects/rewired/docs/FAQ.html#force-feedback

    You will need to look into alternatives to handling DirectX force feedback yourself. Alternatives for handling force feedback you can look at this thread as an example ...

    https://forum.unity.com/threads/force-feedback-for-windows.78268/
     
    guavaman and keeponshading like this.
  43. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    Report this to Unity. This is their error. I cannot fix it. Unity is responsible for handling all assembly management.
     
    keeponshading likes this.
  44. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    The price is prohibitively expensive.

    If this controller appears as a normal HID device, it can easily be supported via runtime mapping by the user as an Unknown Controller.

    I do not add obscure controllers like this to Rewired's controller definitions because it bloats the system, slowing down builds in the editor for everyone for a controller that few if any users will ever use.
     
    Last edited: Nov 20, 2019
  45. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    No, there are no plans to completely restructure and rebuild the entire system as a data-oriented system built on an experimental/preview API that is in constant flux or to be thread-safe so you can get input from jobs. Rewired's frame-based structure and required support of Unity's Update loop (for Unity UI) makes that impossible.
     
    Last edited: Nov 20, 2019
  46. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    Rewired 1.1.29.3 is available on the Unity Asset Store.

    See Updating Rewired before updating.

    Release Notes:

    1.1.29.3:

    Changes:
    - Added new version of Control Mapper that uses Text Mesh Pro (Unity 2018.1+).
    - Windows Standalone, Raw Input / Direct Input + Native Mouse Handling: Input values are now cleared when any mouse is disconnected to prevent buttons from getting stuck on because Windows does not send button up events when a device is disconnected.
    - Windows Standalone, Raw Input / Direct Input + Native Keyboard Handling: Input values are now cleared when any keyboard is disconnected to prevent buttons from getting stuck on because Windows does not send button up events when a device is disconnected.
    - OSX, Native: Added system sleep prevention to prevent display from powering off or entering screen saver mode when using joysticks.

    Bug Fixes:
    - Fixed Start button mapping for Oculus Touch Left controller due to documentation bug in Unity documentation listing the wrong button index.
     
    Bartolomeus755 likes this.
  47. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    413
    Thanks for the info and clarification about the Force Feedback.
    It s not a comon controller but the best i found to get an realistic driving behaviour and the needed nm for steering feedback. We use modified versions of this

    Point of interest was the Force Feedback.
    Because we want to use our simulation with multi user and common input device on other platforms i integrated Rewired.
    The CXC Rigs are only the main use now.
     
    Last edited: Nov 20, 2019
  48. GenericJoe

    GenericJoe

    Joined:
    Apr 27, 2012
    Posts:
    19
    Wow!! Thank you guavaman, I really wasn't expecting that, certainly not so quick!

    The forum didn't notify me of your previous reply/my name mention, but I happened to see the new release notes by chance today and I nearly fell off my chair :D

    It sounds like it was a painful experience, but I do hope many more people also appreciate this and even increase your sales. The fact that you can plug in a full Control Mapper UI, that comes with all the benefits TMP provides is a huge bonus - it means you can easily configure it for any font or language with all the usual fancy text bells and whistles. Fantastic!

    You deserve asset support person of the year award.
     
    guavaman likes this.
  49. NobleRobot

    NobleRobot

    Joined:
    Jan 14, 2016
    Posts:
    33
    Hear! hear!

    More than that, with the "free updates forever" model of the Unity Asset Store, the amount I paid for Rewired two years ago is a distant memory, yet the asset gets better and better all the time. I have no idea how I would have manged to so quickly support every Joy-Con configuration for the Switch version of my latest game without it (by the way, the game comes out next week!!! widgetsatchel.com).

    Have you considered offering any potential "new" version of Control Mapper as a separate paid asset in the Unity Asset Store, rather than including it for free in Rewired? I personally don't use it, but I recognize how valuable it is, and if I ever decided to incorporate it into a project, I would have absolutely no objections to paying for it separately.

    --

    Anyway, here's another support request that guavaman isn't getting paid for...

    I received a Stadia controller today and am adding support for it in my game (this is not for the Stadia platform itself, but for when the controller is used as a standard PC controller), and I noticed that the element ids for the "Options" (three dots) and "Menu" (three lines) buttons are swapped. At first, I thought maybe I had it backwards, but I double-checked on Google's site just to be sure, and Stadia's Menu button is indeed the same as the Xbox One Menu button.

    This has to be the most easily undersood configuration mistake in the history of buttons. Anyway, I was able to adjust the StadiaController and DualAnalog template assets myself (I mean, I could have made it easy on myself and just adjusted my Joystick Maps, but I'm a stickler). Just an FYI for future updates.
     
  50. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    Thanks for the kind words. I'm glad you've been happy with Rewired! And thanks for sharing about your game. I hope the launch goes well!

    No, I haven't. I don't think that would work very well, requiring Rewired as a dependency, and the fact that Rewired already comes with Control Mapper, I doubt it would get anywhere close enough sales to make it worth the effort.

    You are correct. Interestingly, the template mapping negated the transposed mapping on the controller definition.