Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Rewired - Advanced Input for Unity

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

  1. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    Glad to hear you're happy with Rewired so far!
     
  2. ModLunar

    ModLunar

    Joined:
    Oct 16, 2016
    Posts:
    374
    @guavaman Yeah definitely! Also, I happened to come into a problem, though it's probably because my controller is pretty cheap haha. I was gonna email you about this, but perhaps others may benefit from this. I apologize for the long post!

    upload_2019-8-12_22-16-54.jpeg

    I bought this a little while ago (no packaging left) as an Xbox 360 Controller on Amazon, though there is no actual "Xbox" indication on the controller itself. It's been hard to setup because Windows only recognizes it as a "Generic USB Joystick":

    upload_2019-8-12_22-19-25.png

    I'm using Windows 10 with RawInput, and in the code, the Controller's hardwareTypeGuid is equal to Guid.Empty, and is thus an unrecognized controller by Rewired. So, I was hoping to create some kind (I'm not familiar enough with the Rewired API yet since I started yesterday! XD) of custom definition for this controller, instead of relying on the built-in "Unknown Controller" map completely. That way, I could somehow have a way of knowing "Oh, it's that weird controller that's slightly different, but I have a definition/mapping that works with it!"

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

    So, potential solutions?

    1. I thought perhaps I should make a "Custom Controller" in the Rewired Editor, just based off the name. But the docs say "IMPORTANT NOTE: Custom Controllers are NOT meant to be used to create new HID joystick definitions for controllers that Rewired doesn't automatically recognize and map for you... Instead you want to create a new controller definition for that or else define a Joystick Map for Unknown Controller instead."

    2. Based on that info in 1., I created a Hardware Joystick Map (Assets > Rewired > Hardware Joystick Map) with basic "Element Identifiers" for Left Stick X/Y and Right Stick X/Y, and defined 4 axes using those "Element Identifiers" (tested with your awesome Assets/Rewired/DevTools/JoystickElementIdentifier scene!) coming out to use Source Axes: X, Y, and Z, RotationZ. With that new map, I duplicated Assets/Rewired/Internal/Data/Controllers/ControllerDataFiles.asset, moved the new one to another folder outside of Assets/Rewired, and added a new corresponding entry for the map I created (last entry in the following screenshot) -

    upload_2019-8-12_22-39-48.png

    and assigned this to the Data Files field of the (Rewired) Input Manager I use in the scene.

    *** However, after all of that setup, I realized something. When the controller is plugged in and seen by Rewired, it still uses the "Unknown Controller" Joystick Map! How can I tell Rewired to use this Hardware Joystick Map instead? I'm sure there's a way I should be able to do this through code, but I'm not sure how. Basically my reasoning is, I want to be able to customize the axes/buttons for this specific, odd, Xbox 360-like controller, but not adjust those axis/button numbers for the built-in "Unknown Controller" map. Am I close?

    3. Another possibility I saw was to create a "Controller Template", though I slightly pooped out by the time I was reading the docs about it haha.


    So my goal is to add support for this strange unrecognized controller that's very similar to Xbox 360 controllers. My main goal is not to completely interfere with the "Unknown Controller", because I will be several specific axis/button numbers to its mapping that may not be suitable defaults for all unrecognized controllers. Am I on the right path with Solution 2.? Or could Solution 3., or some other solution, be more helpful in solving this?



    P.S. - I'll be getting a wired Xbox One controller directly from Microsoft in the next few days so I can continue on my game in the meantime! Take your time in responding, and also, you can assume I love code and have a great understanding of C#, OOP, etc. :)
     
    Last edited: Aug 13, 2019
  3. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    The best advice I can give you:
    Don't do it.

    Read this:
    https://guavaman.com/projects/rewired/docs/FAQ.html#addding-controller-definitions

    Your generic gamepad definitely falls into this category based on the name "Generic USB Joystick." You add a definition for this, you're asking for problems with countless other controllers.

    1. Custom Controllers is NOT the right solution as the documentation states.

    2. I do not recommend you create a Controller Definition. Creating Controller Definitions is intentionally very difficult because it's not something I ever intended for users to do. There are about 1000 things you have to know to correctly create them and get them working and I don't want to create a gigantic documentation page on this topic considering it's purely a "back-end" thing.

    3. Creating a Controller Template is wrong as well and won't get you any closer to your goal.

    4. If you insist on doing it, the reason it's not working is your Matching Criteria in the Controller Definition for the input source in use is incorrect and doesn't match the identifying information provided by the device. That's the only way it would still appear as an Unknown Controller.
     
    ModLunar likes this.
  4. ModLunar

    ModLunar

    Joined:
    Oct 16, 2016
    Posts:
    374
    Ahhh.. gotcha, wow haha thanks for all the great advice, I'm so glad you answered cause I was gonna be stuck for a while then XD. No worries, I'm sure happy that I'll be getting a standard Xbox One controller then that'll be recognized!
     
  5. B4ttleCat

    B4ttleCat

    Joined:
    Mar 31, 2014
    Posts:
    18
    Sorry for my ignorance but how will Rewired be affected by Unity's upcoming Input system changes? Does it make Rewired more powerful, unaffected, or less useful? I have a bad habit of buying assets right before they're no longer useful and I don't even use them and I can't afford to do it again! Apologies if this has been explained before.
     
  6. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    The new input system will not benefit Rewired in any way without huge changes to take advantage of the new backend (also remapping every single controller on every platform). It will also cause problems if enabled:
    https://guavaman.com/projects/rewired/docs/KnownIssues.html#not-compatible-unity-new-input-system
     
    B4ttleCat likes this.
  7. ModLunar

    ModLunar

    Joined:
    Oct 16, 2016
    Posts:
    374
    @guavaman Also, what's the main difference(s) between Map Categories and Action Categories? I'm wondering which one I should use to separate the different controls between the "Camp" gamemode in my game (played in 3D 3rd-person-perspective) and Dungeons (played in 3D but using a grid system).

    Right now, I have 3 Map Categories defined in total: The Default one, "Camp", and "Dungeon". I want to use the D-pad to move in the grid-based Dungeons, but it seems to be ignoring that input, after I set D-Pad Up, D-Pad Right, etc. to influence the Actions I created.

    Should I be using Action Categories instead, or should I be changing the "User Assignable" and "Check Conflicts..." settings on the Map Categories?
     
  8. atariboy

    atariboy

    Joined:
    Aug 21, 2013
    Posts:
    12
    Hi, I'm having a problem reading right stick axis values from XBox One controller. For some reason when I use Rewired, the working zone is square, like on the old controllers. But the values from Unity's Input.GetAxis are correct:
    rewired -1 1
    unity -0.7637562 -0.74279

    Also, this doesn't happen if I map the same action to the left stick:
    rewired -0.8326558 0.6419709
    unity -0.8225043 -0.6341441
     
    Last edited: Aug 14, 2019
  9. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    Read this:
    https://guavaman.com/projects/rewired/docs/MapCategories.html

    Action Categories are nothing but organization for your purposes in the editor or in lists of Actions for displaying in the UI. They have no impact whatsoever on what controls are mapped or work. There is nothing in the entire Controller Map API that lets you use an Action Category for anything.

    Solving problems:
    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#debug-information
     
    ModLunar likes this.
  10. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    The only thing that can possible affect this is sensitivity:
    1. Input Behavior Joystick Axis Sensitivity.
    2. Calibration axis sensitivity - https://guavaman.com/projects/rewired/docs/HowTos.html#calibrating-controller-axes

    The values you receive for the Xbox stick from a default Rewired installation will definitely not be what you're showing. It has to be your Input Behavior configuration or a script that changed the axis calibration.
     
  11. ModLunar

    ModLunar

    Joined:
    Oct 16, 2016
    Posts:
    374
    Ahh great, thanks so much again! I've just about solved all my major problems on the trial version, so thank you for helping me through that :)
     
  12. Gooren

    Gooren

    Joined:
    Nov 20, 2015
    Posts:
    331
    Hi,
    I encountered a weird thing just now. Even if I remove all maps from my mouse mapping section, the mouse still somehow maps runtime to axes (both horizontal and vertical) and sends values to an action. I figured this out from looking into the InputManager Debug Information inspector field.

    Is that a normal behavior? Or am I missing something?

    I would expect the mouse to not "activate" any actions whatsoever when there are no mouse maps.

    Rewired: 1.1.27.2U2018
    Unity: 2018.4.4f1
     
    Last edited: Aug 14, 2019
  13. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    It is absolutely impossible for the mouse to contribute any value to a Player's Actions if there are no Mouse Maps loaded in the Player. Look at Debug Information again. Open Players -> Player -> Controller Maps -> Mouse Maps. What do you see? Check Player's Action values -- Players -> Player -> Actions -> Action Category -> Action. Click into the game window, move the mouse around. Does the Action value change?

    If you see Mouse Maps loaded in the Player and there are no Mouse Maps assigned to the Player in the Rewired Editor -> Players page, there are only 2 possibilities:

    1. You are assigning / loading Mouse Maps to the Player in a script. (UserDataStore_PlayerPrefs with OLD save data? See warnings in the console telling you saved XML data is being loaded? https://guavaman.com/projects/rewired/docs/UserDataStore.html#clearing-playerprefs)

    2. Your Rewired Input Manager that you are editing is not the same instance that you are loading when doing your testing:
    https://guavaman.com/projects/rewired/docs/InputManager.html
    Important Note: If you make a prefab out of the Rewired Input Manager, always open the Rewired Editor on the prefab, not the one in the scene or your changes will be applied to the scene instance. If you do accidentally make changes to the instance in the scene, you can apply the changes to the prefab and everything will be in sync.
     
    Last edited: Aug 14, 2019
    Gooren likes this.
  14. Gooren

    Gooren

    Joined:
    Nov 20, 2015
    Posts:
    331
    I love you! That was it.
    Just one more thing - I have "Load Mouse Assignments" on the 'UserDataStore_PlayerPrefs' component set to false... since ever. I will look into it later once I free up some time and let you know.
     
  15. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    It's logged to the console every time saved data is loaded because people contact me for support very frequently where this ends up being the cause. It is very common for users to not understand that the differences between the Rewired Editor (developer default data) and saved XML/JSON data and how saved data overrides defaults.

    The Controller Assignment options have nothing to do with Controller Maps. Assignment means assigning the Controller to the Player (Player.controllers.hasMouse, or player.controllers.AddController. What Joysticks / Controllers each Player has currently assigned.), not loading saved Controller Maps. There is no option to disable loading Controller Maps for a particular device type. If your Player is set to have the mouse assigned on Start, it will be assigned the mouse, then when Controller Maps are loaded by UserDataStore_PlayerPrefs, it will load what it finds and the mouse will contribute to input..
     
    Last edited: Aug 15, 2019
    Gooren likes this.
  16. Gooren

    Gooren

    Joined:
    Nov 20, 2015
    Posts:
    331
    I would have noticed, but our console is currently ridden with warnings. So I don't read them all all the time.

    Thanks for info.
     
  17. atariboy

    atariboy

    Joined:
    Aug 21, 2013
    Posts:
    12
    I compared these weird values to the debug info from the manager. I saw that GetAxis and GetAxisRaw return the same value, and this value is 2 * Value from the manager. There's only one default input behavior and axis sensitivity is 1. I also checked the calibration values, they're all Sensitivity type : Multiplier and Sensitivity : 1. What else could possibly affect the value?
    Debug.Log(ReInput.players.GetPlayer(0).GetAxisRaw(RewiredConsts.Action.LookHorizontal)) : 0.7441947
    Debug.Log(ReInput.players.GetPlayer(0).GetAxis(RewiredConsts.Action.LookHorizontal)) : 0.7441947
    Debug info value : 0.3720973
    Debug info value raw : 0.4929199
     
  18. looytroop

    looytroop

    Joined:
    Jun 22, 2017
    Posts:
    69
    Hello, I am having issues with my Xbox One controller vibrating in windows builds. I will provide some background and details.

    I am creating a game, I used to be able to make Windows builds and the controller would vibrate just fine. I have since created Xbox Builds and have gotten vibration working on Xbox as well. Since creating the Xbox builds, I have not been able to get the controller to vibrate on PC builds anymore. I am using Unity version 2018.4.0f1 and rewired version 1.1.19.9.U2018. I have the following code in my rumble manager.


    Code (CSharp):
    1. public void Update()
    2.     {
    3.         Debug.LogError("RumbleSupported: " + RumbleSupported);
    4.         if (false)//!RumbleSupported)// || !RumbleEnabled)
    5.             return;
    6.  
    7.         CurrentRumble = collisionWeight + cinematicWeight + (treeWeight * distanceWeight) + grassWeight + glyphWeight + obeliskWeight + lampWeight + otherWeight;
    8.         if (CurrentRumble < 0)
    9.             CurrentRumble = 0;
    10.         Debug.LogError(player.controllers.joystickCount);
    11.         for (int i = 0; i < player.controllers.joystickCount; i++)
    12.         {
    13.             Debug.LogError(player.controllers.Joysticks[i].name);
    14.             if (player.controllers.Joysticks[i].supportsVibration)
    15.             {
    16.                 player.controllers.Joysticks[i].SetVibration(i, CurrentRumble);
    17.                 Debug.LogError("Vibration : " + player.controllers.Joysticks[i].GetVibration(i));
    18.             }
    19.         }
    20.     }
    I have commented out the rumble supported and enabled, just so I can always get output as to what is going on for sure. Currently, I am getting the output

    Rumble Supported: True
    1
    Xbox One Controller

    It is not printing out the current vibration, I believe this is because the if statement
    Code (csharp):
    1.  if (player.controllers.Joysticks[i].supportsVibration)
    is returning false. I do not understand why the controller would not have vibration supported. Please let me know if you can think of any reason why this would be happening. Thanks!

    EDIT: I was able to get this working, shocker, I had to update rewired.
     
    Last edited: Aug 15, 2019
  19. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    Check the Controller Axis value now instaed of the Player Axis value:

    Debug Information -> Controllers -> Joysticks -> Joystick -> Axes

    Player Raw axis value does not exclude Controller Axis Calibration because that is at the Controller level, not the Player level. Raw Controller Axis values do not include calibration.
     
  20. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    There was nothing changed regarding to the Joystick.supportVibration since that version of Rewired. What I do see here is that your Xbox One Controller is identifying itself as an Xbox One Controller, which it will not do if it is handled by XInput. So it's looks to me that XInput was disabled. If XInput were enabled, XInput would have automatically seen the Xbox One Controller and supported it through XInput and Rewired would have ignored the Raw Input device (the device identifying itself as "Xbox One Controller".) https://guavaman.com/projects/rewired/docs/ControllerMaps.html#xinput-devices-windows
     
    looytroop likes this.
  21. steve_dy

    steve_dy

    Joined:
    Feb 20, 2014
    Posts:
    26
    Hello! I have a question, we are working on a Game for AppleTV and we want to work with siri remote rotated 90 grades in order to use it with both hands. That forces us to change up/down right/left inputs to left/right up/down. I know we can do it with the plugin, however the question is:

    Is there a way we can make the Unity UI navigation work with this change? Or do we have to code it by ourselves? In case we have to code it by ourselves, is there a way we can detect if an input is a siri remote?

    What we want is to be able to play with siri remote (horizontal position, wich changed axis) and to be able to play with mfi controler (no changed axis).

    Hope I can explain, thanks in afvance! :)
     
  22. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    There is nothing in Rewired that supports changing orientation of any controllers except Nintendo Switch. You will have to do this logic change yourself in code.

    Unity UI uses the Action values you define in the Rewired Standalone Input Module inspector. Changing the Controller Map Action bindings will automatically affect the Rewired Standalone Input Module.
     
  23. ModLunar

    ModLunar

    Joined:
    Oct 16, 2016
    Posts:
    374
    Hmm.. I made an Input Behaviour to control the sensitivity of the axes used in some of my Actions. The Mouse XY Axis Sensitivity works very well, but the Joystick Axis Sensitivity doesn't seem to work for values beyond/any higher than 1. If I set the Joystick Axis Sensitivity to 5, for example, the associated axes still are returning values in range [0, 1], instead of [0, 5]. Is there any way to fix that?

    I know for sure it works, if I set it in between 0 and 1, like if I set the Joystick Axis Sensitivity to 0.3, now the associated axes return [0, 0.3] which is perfect! I just want that to work for sensitivity values that are higher than 1 if possible! :)
     
  24. steve_dy

    steve_dy

    Joined:
    Feb 20, 2014
    Posts:
    26
    Hi again, thanks for the reply, sorry I didn't explain very well.

    Our game will be played on Apple TV with siri remote rotated (Horizontal position), we already mapped it that way.

    On the plugin we changed up/down for left/right and left/right for up/down axis.

    The problem we are facing is that Unity UI navigation (moving through menus) does not recognize that change on the axis mapping (left/right). It works perfectly with siri remote in vertical position but not in horizontal position.

    Hope I explain, thanks.
     
  25. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    No. Joystick Axis Sensitivity will not cause a joystick axis to return a value higher than 1. You are trying to use sensitivity incorrectly. You're trying to scale the final value of something in your game and wanting to modify the input values with sensitivity handle that. Scale your value outside the input system. The input system tells you what the user is doing and should not be intertwined with your application logic. It is telling you the user is pressing the joystick and how much he is pressing it in a range from -1 to +1. You now know what the user is doing. Then you take that value and multiply it by some speed, etc. in your script to actually apply the value to whatever you're trying to move.
     
    Last edited: Aug 16, 2019
    ModLunar likes this.
  26. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    I already knew what you were saying.

    >> On the plugin we changed up/down for left/right and left/right for up/down axis.

    What "Plugin" are you referring to? Are you saying you changed the Controller Map bindings in the Rewired Editor?

    As I stated before, Unity UI navigation is handled by the Rewired Standalone Input Module. This module reads Action values from the Player. It doesn't care or know anything about what is giving it these values. If your controller map changes Move Left to to Move Up and Move Right to Move Down, the Rewired Standalone Input Module is going to get the right value when it queries for the Move value.

    Stated another way:
    Change your Controller Map in the Player to change the bindings to your Move Actions when you switch to Horizontal mode to the new directions.

    Are you even using the Rewired Standalone Input Module?
    https://guavaman.com/projects/rewired/docs/RewiredStandaloneInputModule.html

    If you're not, you're using Unity's input system for all Unity UI navigation and not Rewired.
     
    Last edited: Aug 15, 2019
  27. steve_dy

    steve_dy

    Joined:
    Feb 20, 2014
    Posts:
    26
    Ok I got it! Yeah I was talking about this Rewired plugin.

    Thanks, will check it :)
     
  28. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    The easiest way is probably to make Controller Maps in different layouts for the two modes. Use Layout Manager to help manage this.
     
  29. ModLunar

    ModLunar

    Joined:
    Oct 16, 2016
    Posts:
    374
    Oh just a small note: I just read more into one of your previous answers you gave me @guavaman , and you were certainly right about the "Debug Information" field visible in the Inspector of your InputManager script. You probably wrote this stuff a long time ago and are bored with all this by now haha, but I wanna emphasize -- thank you! That debug information is incredibly helpful!
     
  30. jason07

    jason07

    Joined:
    May 10, 2011
    Posts:
    34
    In Control Mapper, is there a way I can swap the Language component while the game is running? It seems to be locked at runtime. In my game the player can change the language at anytime and I want to update the Language component in Control Mapper whenever they set a new language.

    Thanks!
     
  31. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    I don't understand why you think it's locked at runtime. Because the inspector doesn't allow you to make changes at runtime? You wouldn't change inspector settings in a build (inspector doesn't exist outside the editor.)

    Set the ControlMapper.language property. It will reset Control Mapper because all buttons and elements must be redrawn.

    You have the complete source code of Control Mapper.
     
    Last edited: Aug 16, 2019
    jason07 likes this.
  32. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    Debug Information is the single most important tool for figuring out anything with Rewired. I made it because probably 95% of support questions can be answered by looking through these objects and seeing what's happening. I tell nearly everyone who asks for support to use it. It's even a question on the support form on the website -- Did you use Debug Information? Without using it, you're just completely blind. It's ridiculously inefficient to be asked "why is input not working" and I have to ask 101 questions to get to the root cause.
     
    ModLunar likes this.
  33. Gooren

    Gooren

    Joined:
    Nov 20, 2015
    Posts:
    331
    Our game update on Android with Rewired powered controller support is now out and it works amazing!

    One user has encountered a weird issue though. When you connect a controller, the game hides a virtual joystick for you. The way we detect there are any controllers connected is by checking ReInput.controller.joystickCount > 0 (this is a quick conversion from first attempt at adding controller support with native Unity Input where we regularly checked for connected controllers). Back to the user - he has Google Pixel 3 and is 100% positive he has bluetooth off and no controllers connected by any other means. Yet in his case, the 'ReInput.controller.joystickCount' property indeed returns a number that is greater than zero.
    How can this happen? Is that a bug? Or is our code fundamentally unreliable for some reason? Like... is it possible that 'ReInput.controller.joystickCount' will account for paired but disconnected devices as well? I tried that on my phone, but it worked as I expected. When the controller went off-range for example, the 'ReInput.controller.joystickCount' returned 0 again.

    The way I tackled it for now is that I started using 'Player.controllers.*' just to be sure (although our game is single-player and set to auto-assign all joysticks to player0 instantaneously) and when 'Player.controller.joystickCount > 0' then I iterate all joysticks 'Player.controller.joysticks' and check whether at least one is both 'enabled' and 'isConnected'. I also added a dialog that asks the player whether to switch to controller mode when an actual controller is detected.
     
  34. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    It's not a bug in Rewired. As stated here, Rewired uses UnityEngine.Input as the source of all input information on the Android platform. https://guavaman.com/projects/rewired/docs/Overview.html#tested-platforms

    The Joysticks are created from the entries Unity returns from Input.GetJoystickNames(). If Unity is reporting something else on the system as a Joystick, Rewired's going to see it too. List the names of all the Joysticks detected for the user to see to find out what it is.

    Controller.isConnected will never be false for a Joystick that is connected. It's not possible to iterate the joysticks through any Rewired function and have a disconnected Joystick returned. The only purpose of this property is if you store the Joystick object in a variable somewhere and continue to try using it after it's been disconnected. Disconnected Joysticks will never be assigned to Players and cannot contribute input or to the number of Joysticks owned by the Player. Disconnected Joysticks will also never show up in ReInput.controllers.
     
    Gooren likes this.
  35. havchr

    havchr

    Joined:
    Jun 18, 2009
    Posts:
    75
    Hi , we are having some issues with MFI controllers on iOS 13. The reported guid for a ps4 controller is
    3d919cfa-468e-49f4-bce9-f6c43f2e7e62 this corresponds to the AppleiOSMFiController guid and not the Playstation 4 guid. Everything in the game is working fine, except for glyphs/text descriptions for buttons, which gets the MFI names instead of the playstation 4 names. Unless we have misunderstood something, the only way to fix this, would be with a slightly hackish work-around - we're thinking along the lines of :

    Code (CSharp):
    1. #if UNITY_IOS || UNITY_TVOS
    2. if ( controller.hardwareName.Contains("DUALSHOCK 4") ) {
    3. //special-case it
    4. }
    5. #endif
    What I'm asking, is, do you have any good advice on how to best deal with this situation? (we _have_ to deal with it).

    It seems iOS/tvOS is making the ps4 and xbox controllers work by faking them as mfi controllers.

    Looking forward to inputs*.
    Best Regards. *pun not intended, but it made me laugh once I typed it in..
     
  36. steve_dy

    steve_dy

    Joined:
    Feb 20, 2014
    Posts:
    26
    Hi again, we configured and used RewiredEventSystem instead of Unity Event System.

    The problem we have now is that using siri remote on tvOS (mapped with changed up/down axis for left/right and viceversa) still does not work as expected specially moving to right/left on the UI, if we swipe trackpad to real down (right in new mapping) and it is not moving on UI to right.



    Can you please give me a hint on what can we check on the configuration? It seems like everything is configured correctly :(
     
    Last edited: Aug 20, 2019
  37. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    You call it "hackish" but there is no other solution. The fact that Apple made the PS4 controller recognized as an MFI controller itself is a hack. The only controllers supported on iOS are keyboards and MFI controllers. There is no support for general HID devices on the system.

    Controller.name will return the string name reported by iOS for the device. This is the single piece of information available to differentiate one device from another.
     
  38. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    I can't help you but to keep asking questions back and forth until you find the issue. It's much, much faster for you to use Debug Information to figure out what's happening:

    Go through the entire checklist:
    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#debug-information

    You have to see what Controller Maps are loaded and enabled and view the bindings. Whatever Actions you've configured in the Rewired Standalone Input Module are the important ones.
     
  39. Daahrien

    Daahrien

    Joined:
    Dec 5, 2016
    Posts:
    100
    Hello. I will be using rewired for my next game, but I want to know how to change the player that controls the Unity UI elements (buttons). I have a menu with buttons to buy soldiers. and each player will be able to use that menu in their own turn. So, for example when its player 2 turn how do I do so player2 inputs move the selected button and presses it etc

    EDIT.- nevermind, I found how
     
    Last edited: Aug 20, 2019
  40. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    As you have found, everything Unity UI related is handled by the Rewired Standalone Input Module. There are various properties exposed by the class which represent the same settings displayed in the inspector.
     
  41. havchr

    havchr

    Joined:
    Jun 18, 2009
    Posts:
    75
    Yes - Hackish is another word for pragmatic - if a workaround works and one understands why it is needed, it's nothing to overly fear. From Apple's side, there are some api calls to figure out which controller one is dealing with , https://developer.apple.com/videos/play/wwdc2019/616/ around 13:10 in this video -
    https://developer.apple.com/documentation/gamecontroller/gccontroller/3142341-productcategory
    But it's also just string matching - so they are choosing to support ps4 controllers and xbox controllers by masking it behind an mfi driver or something.

    I guess if one wants a "foolproof" way of pragmatically solving it, one would poll on the apple Api to figure out if it's an xbox controller or ps4 controller - but I think we'll end up with just doing controller.hardwareName.contains.

    Thanks for the quick reply. :)
     
  42. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    Their solution looks to be the exact same thing. Controller.name and Controller.hardware name will be identical on iOS and will not have any of the extra information Unity embeds into the joystick name. (FYI, Rewired on iOS uses UnityEngine.Input for all input as shown here, so Apple API calls don't apply in Rewired's case.)

    Rewired has no explicit support for these controllers on iOS. It inherited support through the fact they chose to treat them as MFI controllers. There currently has been no update to Rewired to support these controllers in any other way than as generic MFI controllers. IF I decide to change that and implement them as separate controller definitions for the sole purpose of reporting button element names based on the specific device, that will be done in a future version and listed on the supported controllers page. There are also some very significant disadvantages to doing this including making user mappings no longer universal across MFI devices (when a user changes a mapping for a SteelSeries Nimbus MFI controller, then swaps out with a DS4 or Xbox One controller, it will not inherit those mappings made for the other MFI controller because they would now use different device profiles).
     
    Last edited: Aug 20, 2019
  43. MikeGDev

    MikeGDev

    Joined:
    Dec 19, 2017
    Posts:
    53
    Hi,

    I have problems building due to these errors:

    upload_2019-8-22_11-28-4.png

    I am using Unity 2019.3.0a12 and Rewired version 1.1.27.3.
    I was able to build for a while, but suddenly I cant. After deleting the Library folder I was able to build again for a short while (even though the same errors were thrown) but now I cannot build again. Which steps can I take to make builds again? Thanks!
     
  44. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    Per the Rewired documentation alpha/beta versions of Unity are not supported.

    https://guavaman.com/projects/rewir...ng.html#unity-alpha-beta-preview-experimental
     
    guavaman likes this.
  45. MikeGDev

    MikeGDev

    Joined:
    Dec 19, 2017
    Posts:
    53
  46. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    Last edited: Aug 23, 2019
  47. Gooren

    Gooren

    Joined:
    Nov 20, 2015
    Posts:
    331
    A quick few about Android TV.

    If I want to map just UIHorizontal, UIVertical and UIConfirm for the remote controllers, both known (e.g. Nexus Player Remote) and unknown (some obscure stuff like this for example).
    Is it going to be enough to just map the "Unknown Controller" joystick? Our game is not playable with remote controllers, they are not feasible for it. But Google requires the game's GUI to be usable with the remote controller (at least this is how I understand it after reading the docs).
    Also, do you have any idea what 'buttonX' in case of unknown remote controllers would best correspond to the 'Menu' button? Button I could use to let the player open-up an in-game menu at any time?

    Cheers :)
     
  48. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    Hi,

    I have no real advice for you on generic remotes. There is no way to know anything whatsoever about an unrecognized controller. The entire purpose of the controller recognition system is to identify controllers so metadata on those controllers can be used to understand them. Unknown means unknown. It means no metadata is available whatsoever on the controller. There is no way to guarantee anything about the functionality of an unknown controller.

    Read this about remotes on Android:
    https://guavaman.com/projects/rewired/docs/KnownIssues.html#android-remotes
     
    Last edited: Aug 24, 2019
    Gooren likes this.
  49. Gooren

    Gooren

    Joined:
    Nov 20, 2015
    Posts:
    331
    I understand that unknown means there are no guarantees. I was asking whether there is at least some degree of "consistency" between unknown remote controllers. Just like Axis0 and Axis1 usually refer to left and right thumbsticks respectively on gamepads (AFAIK).
    However the docs link you mention is perfect. The most important thing for me to know is that in order to handle Android TV remote controllers properly I just need to use the mentioned script and create a custom controller. Amazing work! This is all I need.
     
  50. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    That was my way of telling you that there is no way to know if there's any consistency between various remotes -- because they are unknown. Whether there is consistency or not in their axes depends entirely on:

    1) The devices and how they define their HID elements.
    2) How Android maps them in their APIs.
    3) What part of the Android APIs Unity uses to retrieve the input values on these devices.
    4) Whether Unity does any kind of ordering on these elements.

    https://guavaman.com/projects/rewired/docs/Overview.html#tested-platforms

    Joystick axis consistency on Andoird is an assumption. There are many gamepads on Android that were not made for Android that do not map consistently with those made for Android, and even some older ones made for Android are not consistent. I have never tested a variety of remotes to know. If you're talking cross-platform, all assumptions can go out the window. Across the board, consistency is a very, very uncommon thing when you're talking input devices.
     
    Gooren likes this.