Search Unity

Rewired - Advanced Input for Unity

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

  1. maxxa05

    maxxa05

    Joined:
    Nov 17, 2012
    Posts:
    186
    It's ok, at first I didn't know it was an issue on Unity's side. Thing is, the mouse is hidden and locked, but since it's in the middle of the screen, it works. Kind of a hack, I know, but since I could get away with keeping the mouse hidden, I thought I would just let it be that way.

    I just thought it was weird this was the only case where the gesture didn't work on my computer and that maybe you knew why. Anyway, it's not that big of an issue. I may submit a bug to Unity about it when I get the time.
     
  2. Domanxs

    Domanxs

    Joined:
    Jul 25, 2014
    Posts:
    76
    Hey there, I am experiencing an issue. Most of our players about 90% of them do not have absolutely any issue, as well as I do not, but some just can not send any input to the standalone games, I'm sorry if this has already been answered, but 40 pages is a bit lot to try and shift trough. So basically any Rewired input is not working whatsoever, if I go back and type the standard Input.Get..... that input is received for those affected, but if I am using Rewired, then that input is not received, so it is a bit strange, I am feeling that this is an issue on the player side, with either OS or software, could you shed any light on this? Would really love to not have to remove such an awesome system, especially when I am half way in making the Xbox controller fully functional.
    Have an awesome day!

    P.S. we are seeing this issue in Older Windows versions than Windows 10
     
    Last edited: Apr 23, 2016
  3. pjburnhill

    pjburnhill

    Joined:
    Mar 2, 2016
    Posts:
    27
    Hey Guavaman/all,

    I'm using Rewired and its PlayMaker actions to read controller values (ranging -1 to 1 as you know). I'm also using JellyMesh to move my player which uses AddForce method to move the player requiring Vector 3 as input. Now, I'd like to move the player in relation to the Camera so I thought Get Angle to Target would be the one to use..

    But I just can't figure it out; how do I use the angle to camera to offset my input axis for the Vector 3? I'm being bit daft today and my brain hurts.. could someone tell me how to get around this? Or should I be using Get Axis Vector instead (couldn't get this working with Rewired at all)?
     
  4. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    I can't help you without a great deal more information.
    1. Unity version
    2. Build target
    3. 32/64 bit
    4. Scripting backend
    5. Rewired version
    6. Input sources chosen
    7. Settings options like "use XInput", "Native Mouse Handling", "Enhanced Device Support", etc.
    8. No input in keyboard, mouse, joystick or all of the above?
    9. Get log files. It is absolutely critical to know whether or not Rewired is having some kind of exception and this isn't simply a simple joystick recognition or mapping issue.
    10. Find out what controllers are being used by these players.
    11. Any other information about these users setups that may narrow down the issue (what types of keyboard and mouse are they using? Windows versions? 3rd party input software running in the background? 3rd party Bluetooth stacks? Running on a MacBook under bootcamp? Running under a sandbox? Whatever else seems useful.)
    12. More information about your game. Running on Steam?
    Issues like this are best handled by email due to the number of back and forth required. Please contact me through the support form on my website.
    There is absolutely no need to remove Rewired even if you are having issues. If you say UnityEngine.Input works correctly, then you can simple disable native input or select Unity as the input source for your platform and it will use UnityEngine.Input as the input source. (This is assuming the problem is at the input source level. It could also be something unrelated to input sources and native input, but I have no way of knowing at this time.)
     
    Last edited: Apr 24, 2016
  5. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    This isn't really a Rewired issue. You'd have much better luck asking this question in the PlayMaker forum. It's a PlayMaker and a conceptual issue of transforming a 2D unit Vector into world space coordinates based on the camera transform to move an object. Whether you get this 2D vector from Rewired or from Unity Input or anywhere else makes no difference and none of Rewired Actions come into play here except player.GetAxis2D to get the input vector.

    I do not know PlayMaker or the Actions they provide well at all. I do all my game programming in C#. Without knowing how you intend for this control to behave, I couldn't give you an answer in C# either. "I'd like to move the player in relation to the Camera" could mean a very many things. For example, pressing up could mean you want it to move directly in the direction of camera forward (into the screen) down a ray coming out of the camera (an object moving freely in space). Or it could also mean you want up to move the object along the world XZ plane (someone running for example) but modified by the current camera orientation so that pressing left always moves the character toward the left edge of the screen. It could also mean something totally different if you're talking about a 2D game.

    I suspect PlayMaker comes with the transformation Action you need to do this because it's designed to make such tasks simple. But again, I know very little about PlayMaker itself or the Actions it comes with.
     
  6. _met44

    _met44

    Joined:
    Jun 1, 2013
    Posts:
    633
    Hello there, @guavaman was wondering if would you consider adding a checkbox to force enable the use XInput option on windows when there is a Steam Controller connected ?
     
  7. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    There's no way I can detect whether there's a Steam Controller connected to the system without integrating the Steam library. At this point, Rewired does not do that, and in past testing I discovered quite a few major gotchas with trying to do so because it could interfere with the user's own initialization of Steam.

    You could implement this fairly easily though since you're already using a Steam library. You can change Use Xinput through ReInput.configuration along with many other options.
     
    Last edited: Apr 25, 2016
  8. _met44

    _met44

    Joined:
    Jun 1, 2013
    Posts:
    633
    Ah damn ok I thought you might have some cool system call to get the information ^^.

    About ReInput.Configuration, it says in comment that we must reload rewired when changing it, but then it would be after steam has been initialized and wouldn't work no ?

    Currently found a crappy work arround until I figure something better, when a player starts the game without the XInput option and has a Steam Controller plugged in there's an exception in rewired initialization (as it tries to hook with it using DirectInput) so I check wether rewired is initialized or not after having instantiated it and spawn a XInput version if not, it works but yeah.. not the cleanest feature in the world.
     
  9. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    Why wouldn't it work? Rewired rests itself automatically when you change an option like Use XInput.

    When did this start happening? There have been no exceptions when a Steam Controller is attached. There are many games that use Rewired and there haven't been any issues with the Steam Controller. There was one beta update of the Steam client that was causing a crash in the Vulcan graphics overlay system they use if a Steam Controller was attached and XInput was called, but I reported that to them and they fixed it. Are you using the latest version of Rewired? Please provide complete details on how to make this happen including all settings and order of initializations.
     
  10. _met44

    _met44

    Joined:
    Jun 1, 2013
    Posts:
    633
    Hmmm as far as we've had steam controllers to test i think it's been an issue. It's just never been a priority since it was possible to go arround with the XInput option in settings.

    I kept the error just in case last time I saw it, here it is:
    Rewired: Rewired: An exception occurred during initialization. Input will not function.

    Message: HRESULT: [0x80004001], Module: [Unknown], ApiCode: [Unknown/Unknown], Message: Non implémenté


    Stack Trace: at Rewired.Libraries.SharpDX.Result.CheckError () [0x00000] in <filename unknown>:0
    at Rewired.Libraries.SharpDX.DirectInput.Device.GetProperty (IntPtr arg0, IntPtr arg1) [0x00000] in <filename unknown>:0
    at Rewired.Libraries.SharpDX.DirectInput.PropertyAccessor.GetInt (IntPtr guid, Int32 objCode) [0x00000] in <filename unknown>:0
    at Rewired.Libraries.SharpDX.DirectInput.PropertyAccessor.GetInt (IntPtr guid) [0x00000] in <filename unknown>:0
    at Rewired.Libraries.SharpDX.DirectInput.DeviceProperties.get_JoystickId () [0x00000] in <filename unknown>:0
    at pJPEYnFMbGEozVvYaZioqMqEmxyf.MMfyZdEskhiEnFdIVrrYGJOYqLs (IList`1 ) [0x00000] in <filename unknown>:0
    at pJPEYnFMbGEozVvYaZioqMqEmxyf.MMfyZdEskhiEnFdIVrrYGJOYqLs () [0x00000] in <filename unknown>:0
    at pJPEYnFMbGEozVvYaZioqMqEmxyf.Initialize () [0x00000] in <filename unknown>:0
    at xKzNYJJdLLsDFuJGuiMwacBpXAl.Initialize () [0x00000] in <filename unknown>:0
    at Rewired.ReInput.rIGMDuTfrmXhVQLVWErIoORSOFV () [0x00000] in <filename unknown>:0
    at Rewired.ReInput.hJKRaZQWRmVnUbKLWanxDoskHqAI (Rewired.InputManager_Base , System.Func`2 , Rewired.Data.ConfigVars , Rewired.Data.ControllerDataFiles , Rewired.Data.UserData , Rewired.Data.UserDataStore ) [0x00000] in <filename unknown>:0
    UnityEngine.Debug:LogError(Object)
    Rewired.Logger:LogError(Object)
    Rewired.InputManager_Base:HandleException(ExceptionPoint, String, Exception)
    Rewired.InputManager_Base:Initialize()
    Rewired.InputManager_Base:Awake()

    About the rewired config option, I guess I got a bit confused with the intellisense tooltip, assumed the reset had to be done from my end but it's good to know it's not !
     
  11. Alverik

    Alverik

    Joined:
    Apr 15, 2016
    Posts:
    417
    Hi! sorry to bother you guys, but does anyone know how you'd go about connecting rewired to NGUI?

    In NGUI's forum there's this post which shows how to connect NGUI to InControl, and they say the code can be re-purposed to connect NGUI to Rewired: (http://www.tasharen.com/forum/index.php?topic=13047.0) but unfortunately I'm not much of a coder... so I'm having a hard time understanding what I'd need to do. Anyway, I'm sure there's plenty people out there (other non coders) who would also like to know how to do this...
     
  12. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    Thanks! I'll look into it when I can. Just by the looks of the log, it's choking on a standard Direct Input call. This has to be Steam's bad, so it means I have to try to find some kind of workaround for their controller breaking Direct Input. At the least, this should no longer cause an exception. I'll work on it for the next update.
     
    Last edited: Apr 27, 2016
  13. _met44

    _met44

    Joined:
    Jun 1, 2013
    Posts:
    633
    Yeah figured it would be something like that, all other gamepads I have (and I'm starting to have a few) work just fine thanks to rewired with either option checked.

    I'll let you know if I find out anything else.
     
  14. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    Sorry, I do not have NGUI and can't help you with this. Hopefully someone else here can.
     
  15. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    On the NGUI mapping thing, I came up with essentially the equivalent of the InControl integration posted in the NGUI forum. I haven't tested it *at all*, but there's not a whole lot going on.

    You'd have to create Rewired actions that match the strings at the top (or change the code), setting up the buttons as buttons and the axes as axes. You'd also need to map them to the appropriate control names in the "Dual Analog Gamepad" template. You aren't limited to that of course.

    It feels a little "dirty" to use Rewired actions in that way, since those are generally named something nice that's applicable to something in your game. :)

    Here's the code. I think you could just attach it to any GameObject in your scene - I suppose the Rewired Input Manager would be as good as anything.

    Code (csharp):
    1.  
    2. using UnityEngine;
    3.  
    4. public class RewiredNGUI : MonoBehaviour
    5. {
    6.     // Rewired Button Actions
    7.     private static string _actionBottomRow1 = "NGUI Action bottom row 1";    // Map this action to "Action bottom row 1", etc.
    8.     private static string _actionBottomRow2 = "NGUI Action bottom row 2";
    9.     private static string _actionTopRow1 = "NGUI Action top row 1";
    10.     private static string _actionTopRow2 = "NGUI Action top row 2";
    11.     private static string _leftShoulder1 = "NGUI Left Shoulder 1";
    12.     private static string _rightShoulder1 = "NGUI Right Shoulder 1";
    13.     private static string _center1 = "NGUI Center 1";
    14.     private static string _center2 = "NGUI Center 2";
    15.     private static string _leftStickButton = "NGUI Left Stick Button";
    16.     private static string _rightStickButton = "NGUI Right Stick Button";
    17.  
    18.     // Rewire Axis Actions
    19.     private static string _leftStickX = "NGUI Left Stick X";
    20.     private static string _leftStickY = "NGUI Left Stick Y";
    21.     private static string _rightStickX = "NGUI Right Stick X";
    22.     private static string _rightStickY = "NGUI Right Stick Y";
    23.     private static string _dPadX = "NGUI Dpad X";
    24.     private static string _dPadY = "NGUI Dpad Y";
    25.     private static string _leftShoulder2 = "NGUI Left Shoulder 2";         // Left Trigger
    26.     private static string _rightShoulder2 = "NGUI Right Shoulder 2";    // Right Trigger
    27.  
    28.     void OnEnable ()
    29.     {
    30.        UICamera.GetKey = GetKey;
    31.        UICamera.GetKeyDown = GetKeyDown;
    32.        UICamera.GetKeyUp = GetKeyUp;
    33.        UICamera.GetAxis = GetAxis;
    34.     }
    35.  
    36.     static bool GetKeyDown (KeyCode key)
    37.     {
    38.         if (key >= KeyCode.JoystickButton0)
    39.         {
    40.             Rewired.Player rewired = Rewired.ReInput.players.GetPlayer(0);
    41.  
    42.             switch (key)
    43.             {
    44.                 case KeyCode.JoystickButton0: return rewired.GetButtonDown(_actionBottomRow1);        // Action bottom row 1 (Xbox "A" button, for instance)
    45.                 case KeyCode.JoystickButton1: return rewired.GetButtonDown(_actionBottomRow2);        // Action bottom row 2 (Xbox "B" button, for instance)
    46.                 case KeyCode.JoystickButton2: return rewired.GetButtonDown(_actionTopRow1);            // Action top row 1 (Xbox "X" button, for instance)
    47.                 case KeyCode.JoystickButton3: return rewired.GetButtonDown(_actionTopRow2);            // Action top row 2 (Xbox "Y" button, for instance)
    48.                 case KeyCode.JoystickButton4: return rewired.GetButtonDown(_leftShoulder1);            // Left Bumper
    49.                 case KeyCode.JoystickButton5: return rewired.GetButtonDown(_rightShoulder1);        // Right Bumper
    50.                 case KeyCode.JoystickButton6: return rewired.GetButtonDown(_center1);                // Back
    51.                 case KeyCode.JoystickButton7: return rewired.GetButtonDown(_center2);                // Start
    52.                 case KeyCode.JoystickButton8: return rewired.GetButtonDown(_leftStickButton);        // Left stick click
    53.                 case KeyCode.JoystickButton9: return rewired.GetButtonDown(_rightStickButton);        // Right stick click
    54.             }
    55.         }
    56.         return Input.GetKeyDown(key);
    57.     }
    58.  
    59.     static bool GetKey (KeyCode key)
    60.     {
    61.         if (key >= KeyCode.JoystickButton0)
    62.         {
    63.             Rewired.Player rewired = Rewired.ReInput.players.GetPlayer(0);
    64.  
    65.             switch (key)
    66.             {
    67.                 case KeyCode.JoystickButton0: return rewired.GetButton(_actionBottomRow1);        // Action bottom row 1 (Xbox "A" button, for instance)
    68.                 case KeyCode.JoystickButton1: return rewired.GetButton(_actionBottomRow2);        // Action bottom row 2 (Xbox "B" button, for instance)
    69.                 case KeyCode.JoystickButton2: return rewired.GetButton(_actionTopRow1);            // Action top row 1 (Xbox "X" button, for instance)
    70.                 case KeyCode.JoystickButton3: return rewired.GetButton(_actionTopRow2);            // Action top row 2 (Xbox "Y" button, for instance)
    71.                 case KeyCode.JoystickButton4: return rewired.GetButton(_leftShoulder1);            // Left Bumper
    72.                 case KeyCode.JoystickButton5: return rewired.GetButton(_rightShoulder1);        // Right Bumper
    73.                 case KeyCode.JoystickButton6: return rewired.GetButton(_center1);                // Back
    74.                 case KeyCode.JoystickButton7: return rewired.GetButton(_center2);                // Start
    75.                 case KeyCode.JoystickButton8: return rewired.GetButton(_leftStickButton);        // Left stick click
    76.                 case KeyCode.JoystickButton9: return rewired.GetButton(_rightStickButton);        // Right stick click
    77.             }
    78.         }
    79.         return Input.GetKey(key);
    80.     }
    81.  
    82.     static bool GetKeyUp (KeyCode key)
    83.     {
    84.         if (key >= KeyCode.JoystickButton0)
    85.         {
    86.             Rewired.Player rewired = Rewired.ReInput.players.GetPlayer(0);
    87.  
    88.             switch (key)
    89.             {
    90.                 case KeyCode.JoystickButton0: return rewired.GetButtonUp(_actionBottomRow1);        // Action bottom row 1 (Xbox "A" button, for instance)
    91.                 case KeyCode.JoystickButton1: return rewired.GetButtonUp(_actionBottomRow2);        // Action bottom row 2 (Xbox "B" button, for instance)
    92.                 case KeyCode.JoystickButton2: return rewired.GetButtonUp(_actionTopRow1);            // Action top row 1 (Xbox "X" button, for instance)
    93.                 case KeyCode.JoystickButton3: return rewired.GetButtonUp(_actionTopRow2);            // Action top row 2 (Xbox "Y" button, for instance)
    94.                 case KeyCode.JoystickButton4: return rewired.GetButtonUp(_leftShoulder1);            // Left Bumper
    95.                 case KeyCode.JoystickButton5: return rewired.GetButtonUp(_rightShoulder1);            // Right Bumper
    96.                 case KeyCode.JoystickButton6: return rewired.GetButtonUp(_center1);                    // Back
    97.                 case KeyCode.JoystickButton7: return rewired.GetButtonUp(_center2);                    // Start
    98.                 case KeyCode.JoystickButton8: return rewired.GetButtonUp(_leftStickButton);            // Left stick click
    99.                 case KeyCode.JoystickButton9: return rewired.GetButtonUp(_rightStickButton);        // Right stick click
    100.             }
    101.         }
    102.         return Input.GetKeyUp(key);
    103.     }
    104.  
    105.     static float GetAxis (string name)
    106.     {
    107.         Rewired.Player rewired = Rewired.ReInput.players.GetPlayer(0);
    108.  
    109.         switch (name)
    110.         {
    111.                 case "LX": return rewired.GetAxis(_leftStickX);        // Match UICamera.horizontalAxisName
    112.                 case "LY": return rewired.GetAxis(_leftStickY);     // Match UICamera.verticalAxisName
    113.                 case "RX": return rewired.GetAxis(_rightStickX);    // Match UICamera.horizontalPanAxisName
    114.                 case "RY": return rewired.GetAxis(_rightStickY);    // Match UICamera.verticalPanAxisName
    115.                 case "DX": return rewired.GetAxis(_dPadX);
    116.                 case "DY": return rewired.GetAxis(_dPadY);
    117.                 case "TX": return rewired.GetAxis(_rightShoulder2) - rewired.GetAxis(_leftShoulder2);
    118.         }
    119.         return Input.GetAxis(name);
    120.     }
    121.  
    122. }
    123.  

    EDIT: fixed the top row/bottom row stuff.
     
    Last edited: Apr 28, 2016
    Alverik and guavaman like this.
  16. Alverik

    Alverik

    Joined:
    Apr 15, 2016
    Posts:
    417
    Hey, thanks! This helps me a lot! I'll be testing it momentarily :)

    Ah, though, just one thing. I don't mean to sound greedy, but will this work with keyboard/touch too? I ask because I see the "case KeyCode.JoystickButton0" lines, or do I need to create equivalent "if" statements but for keyboard/touch? (I ask because I imagine there should be equivalents, but I've never used code like this so I'm just speculating xD)

    Anyways, one way or another this'll be of great help when needing to port a game to consoles (or someone using a pc with controller), so thanks!
     
  17. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    The JoystickButton0, etc is coming from NGUI and is just how the NGUI guy decided to do it. You can still map your actions to whatever you want in Rewired. I named the actions the same as the joystick template input names to give some context and make it easier to map for gamepads, but that's just a starting point.
     
    Alverik likes this.
  18. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    Rewired 1.0.0.85 is now available for download for registered users. If you would like to register to receive early access to updates, please contact me here. The update should be available on the Unity Asset Store in 5-10 business days.

    Important:
    Due to changes to some serialized data classes, it is very important that you follow the recommended updating procedure outlined here.

    Unity Input Override:
    One interesting new feature is the Unity Input Override script. This is based on a script I created for @Xander Davis here and posted here in this thread.

    The Unity Input Override script reroutes calls to Unity input from most scripts over to Rewired. Simply install it and every script that calls Input.GetButton, Input.GetAxis, etc. will now use Rewired instead of Unity input. This allows you to use Rewired for input without having to change any code in the scripts. This will even work for most assets downloaded from the Unity Asset Store, allowing you to use Rewired as the input source instead of Unity input. (Tested and works perfectly with uFS - Flight Simulation Engine.) Read more about it in the documentation.

    Windows 8.1 Universal Publishing:
    I have added a Windows 8 Phone DLL for use when building to Windows 8.1 Universal. This is required because the Windows 8.1 DLL includes calls to XInput which is not allowed in Windows Phone 8.1. Due to a bug in versions of Unity below 5.4.3p2, it is impossible to build to Windows 8.1 Universal and pass WACK. In versions after 5.4.3p2, it will use this new Windows 8 Phone DLL and pass WACK. Details of this issue are outlined here.


    Release notes:

    1.0.0.85:

    Changes:
    - Added Unity Input Override script to reroute calls to Unity input to Rewired in most scripts with no code changes required. (optional install)
    - Rewired Standalone Input Module: Updated to include changes to Unity 5.3 Standalone Input Module including incorporating touch input.
    - Removed Touch Input Module component from Rewired Event System prefab.
    - Updated Control Mapper demo scenes due to changes to the Rewired Standalone Input Module.
    - Added controller definition variant system.
    - Added Windows Phone 8.1 DLL for building to Windows 8.1 Universal platform. (Requires Unity 5.3.4p2+)
    - Getting input for an Action that doesn't exist every frame no longer spams the log.

    API Changes:
    - Added Player.ControllerHelper.MapHelper.ContainsMapInCategory(string categoryName) method overload
    - Changed Player.ControllerHelper.MapHelper.SetMapsEnabled methods to return the number of maps that changed state.
    - Changed Player.ControllerHelper.MapHelper.SetAllMapsMapEnabled methods to return the number of maps that changed state.
    - Changed ControllerExtensions.DualShock4ControllerExtension.GetAccelerometerValueRaw method to return unmodified data directly from hardware.
    - Added ControllerExtensions.DualShock4ControllerExtension.GetAccelerometerValue method.
    - Changed ControllerExtensions.DualShock4ControllerExtension.GetGyroscopeValueRaw method to return unmodified data directly from hardware.
    - Added ControllerExtensions.DualShock4ControllerExtension.GetGyroscopeValue method.
    - Added ControllerExtensions.DualShock4ControllerExtension.GetLastGyroscopeValue method.
    - Added ControllerExtensions.DualShock4ControllerExtension.GetLastGyroscopeValueRaw method.
    - Added ControllerExtensions.DualShock4ControllerExtension.GetOrientation method.
    - Added ControllerExtensions.DualShock4ControllerExtension.ResetOrientation method.

    Controller Definitions:
    - Linux Native: Added SteamOS variant for Microsoft XBox 360 Controller.
    - Windows Raw Input: Merged XBox One Controller (Windows 10+) into XBox One Controller definition.
    - Windows Direct Input: Merged XBox One Controller (Windows 10+) into XBox One Controller definition.
    - Windows Raw Input / Direct Input: Added Thrustmaster T300 RS definition variant for controller with Thrustmaster driver installed.
    - Android: Added SteelSeries Stratus XL (Unity 5+ required).
    - Android: Added Xiaomi Wireless Game Controller mappings for Unity 5+.
    - Android: Merged Samsung EI-GP20 controller definitions for Unity 4.x and Unity 5.x.
    - Removed Xbox One Controller (Windows 10+) definition (obsolete).
     
    Last edited: Apr 30, 2016
    _met44 and John-G like this.
  19. RyanSpicer

    RyanSpicer

    Joined:
    Jun 5, 2013
    Posts:
    1
    Hi Guavaman,
    Awesome package! One of the few paid assets I've bought while tinkering with Unity, but seems totally worth it! I'm encountering an odd issue that I suspect is really easy to fix -- I just don't know exactly where in Rewired to poke in order to fix it.

    Unity 5.3.4f1, 64-bit, Rewired 1.0.0.84, Windows 10 Pro.

    Symptoms: I have several USB input devices connected to my dev machine. Using the Control Remapper prefab and the UserDataStore_PlayerPrefs datastore, I have successfully mapped one of my controllers in my game. I'm using the "unknown device" joystick profile since my device is pretty esoteric (a radio control transmitter acting like a USB gamepad). However, any time I stop and restart play mode in the editor (or restart the binary build), rewired defaults back to my Default joystick as the input source for player1. If I select the controller I want to use in Control Remapper, then it loads up the correct axis bindings (and uses that controller until I exit playmode), but I don't want to make my players reselect the controller they want to use every time they restart the game! Is there a way to tell Rewired / UserDataStore "Always use the currently selected controller for this player, if it's present" ?
     
  20. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    Rewired cannot persist controller assignments reliably. Control Mapper (and UserDataStore) is not written to even try to do this (controller assignment on start/load is not a task of Control Mapper -- it's left up to Rewired's auto-assignment system or up to the developer to manually assign them), but doing so would be full of problems because there's no way to know which controller is which from session to session. Each input source has it's own issues in this area and no two are alike. In general, controllers are not guaranteed to have the same id's on any input source from reboot to reboot, unplug to plug, etc.

    When using Raw Input, Rewired does sort devices by physical hardware port, so if you're making an arcade or something where controllers should be assigned to Players in a specific order, it can handle that. XInput and Direct Input however, are not reliable and cannot be counted on to keep the same sort order from reset to reset.

    If you want to try to implement some kind of persistent controller-to-Player assignment, you can certainly try, but you will definitely run into problems when you have multiple devices of the same type attached. It might work as long as the user leaves all controllers plugged in the same way from session to session, but if they start moving them around while the game isn't running, it's not going to work very well. You will have to take over controller assignment instead of letting Rewired auto-assign to do this.
     
    Last edited: May 2, 2016
  21. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    Looking forward to testing the override script with uFS. Using uFS was a good choice. Hope that the asset store can release it today. Keep up the good work.
     
    John-G likes this.
  22. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    @guava

    We should get a prefab for the Rewired input manager for those who want to use Rewired with uFS with the new override option in Rewired 1.0.0.85.
     
  23. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    Thanks for the suggestion. Rewired does not currently come with a uFS integration. If I do so in the future, I will include a prefab.
     
  24. TheGoodDrive

    TheGoodDrive

    Joined:
    Sep 23, 2015
    Posts:
    9
    Hi @guavaman

    I have a little with my steering wheel. I have a T300 ThrustMatster in ps3 mode but Rewired know him as B66E and because of that Input not working.

    Any ideas ?

    Thks
     
  25. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    I believe that is fixed with Rewired 1.0.0.85 (which just waiting to be cleared by the unity asset store).

    >> Windows Raw Input / Direct Input: Added Thrustmaster T300 RS definition variant for controller with Thrustmaster driver installed.<<

    This is using the latest driver and firmware for T300 RS racing wheel.
     
    guavaman likes this.
  26. TheGoodDrive

    TheGoodDrive

    Joined:
    Sep 23, 2015
    Posts:
    9
    oh I missed it,nice.
    Thanks
     
  27. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
  28. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
  29. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    I wonder if they're tired of my constant updates... :D
     
    _met44 likes this.
  30. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    They shouldn't be. So when is your next update coming? :)

    @TheGoodDrive

    Does the new update 1.0.0.85 solve the your T300RS racing wheel issue?
     
  31. adamhill

    adamhill

    Joined:
    May 30, 2008
    Posts:
    26
    Does Rewired work with Unity games on the XBox One in Consumer Dev mode?

    Didn't want to assume, but all the bits seem to be lined up now.
     
  32. TheGoodDrive

    TheGoodDrive

    Joined:
    Sep 23, 2015
    Posts:
    9
    Yep :)

    @guavaman
    We have found a little problem with variant 1 of T300 mapping asset. there are twice L2 ( missing R2) so R2 not working.
     
  33. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    I do not know. It has not been tested. According to info I find, Consumer Dev mode (preview) uses a Windows UWP build limited to accessing only 448MB of the 8GB of RAM. The full release this summer will still be limited to 1GB RAM, so this is pretty much limited to casual gaming which is disappointing. You can always download and try the free trial: http://guavaman.com/rewired/trial

    According to this article, http://www.polygon.com/2016/3/30/11318568/xbox-one-dev-kit:
    "When a UWP app is running, it doesn't know it's running on an Xbox," Charla said. "It just knows it's a Windows 10 device."

    If that's the case, you'd build to UWP and I assume it would work.
     
    Last edited: May 3, 2016
  34. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    I checked and the error is in Raw Input only. I've fixed it. It will be in the next update. (Just change the 2nd L2 to R2).
     
  35. CrossHanded

    CrossHanded

    Joined:
    Jul 31, 2013
    Posts:
    9
    Hey, remember me? :D Sorry I wasn't able to send a reply or thank you sooner, but I went into mega crunchtime mode pretty much right when I was finishing up the controller assignment problem. I DID THE THING, and actually had 11 or so controllers hooked up to my machine, and integrated the joystick id check code right into our startup screen. It worked; pressed buttons on each one, joystick numbers were identified and their order on the motherboard was taken note of as you described. I then did it with the hardware intended for the installation. Changed over my assignments to rawinput, and things became very consistent from that point on.



    Out in the field, the controls worked without a hitch. No more worrying about my 1p/left stick doing what my 2p/right stick should be doing and vice versa; and it all worked out just as you said it would! We had a very impressive and successful first showing of our game, and were able to use a "unique" 2-joystick control setup that might not normally have been possible with Unity (or reliable) without your help, so many thanks are in order. :) Our project "Strike Harbinger" is still super early and over a year away from release, but we wanted to have something special for the first time it would be seen and having nice arcade controls was part of that. I'm still dying from the self-imposed crunch but I made it a priority to write this update and express my appreciation. I'll be leaving a 5 star review for your help and tool as soon as I can muster a writeup that will do it justice. Thanks again!
     
    Karearea, _met44 and guavaman like this.
  36. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    @CrossHanded

    I'm really glad to hear everything worked out as expected! Thanks for posting those pics and background on your project. It's always exciting to see the awesome work everyone is doing. Sounds like you're due for a well-deserved rest. Cheers!
     
    CrossHanded likes this.
  37. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    @CrossHanded

    Thanks for posting pictures of your project. This is amazing work and those arcade controls look just perfect for game at hand. Keep us posted on your project as you get closer to release. Keep up the good work.
     
    CrossHanded likes this.
  38. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    @TheGoodDrive

    Are you using T3PA or T3PA-PRO pedals with your T300 RS racing wheel? Also are you using the ThrustMaster TH8A Add-On Shifter?
     
  39. imaginationrabbit

    imaginationrabbit

    Joined:
    Sep 23, 2013
    Posts:
    349
    I'm trying to use Rewired with a Usb NES controller I got off of ebay like this http://www.ebay.com/itm/Classic-Gam...121736?hash=item41a4d25408:g:~O0AAOSwG-1WxC2t

    It works perfectly with Unity's input system but I cannot get Rewired to retrieve any data from it-

    I followed the docs and set things up like the quickstart- I can get keyboard and mouse input working but the gamepad doesn't give me anything from any axis or button through rewired-

    I'm using rewired with the playmaker actions- if I use the get axis 2d action I can see the input with the keyboard- but the gamepad does nothing- I only have one gamepad plugged in- trying to use input from Player0

    Using your prefab in the devtools I can see the input working- here's the info from that


    Would appreciate any tips- thx
     
    Last edited: May 6, 2016
  40. Lnoldori

    Lnoldori

    Joined:
    Jan 19, 2013
    Posts:
    9
    Hi Guavaman,

    i was struggling with a specific problem which i have described in http://forum.unity3d.com/threads/bluetooth-controller-problem.399819/ and finally i gave up. After reading all the feedback about your asset Rewired, i bought it in order to avoid further headaches.
    Unfortunately i have the same problem again, even when using your ControlRemapping demo. The L2/R1/R2 keys are being ignored totally. Note that the 2 controllers i am using to test this are an Ωmega controller with OTG connector and a hama droid controller with bluetooth connection. Also this happens only in an android build although in windows work like a charm.

    I downloaded also some apps from playstore which can help you to read the controller default mapping and i saw that except one who was being written in android java all of the others, written in unity, had the same problem.

    Am i missing something here? Is the problem the controllers?Unity? I would really appreciate your help.

    Thanks for your time.
     
  41. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    Did you read the page on Controller Maps and how Rewired handles Unknown Controllers?
    http://guavaman.com/projects/rewired/docs/ControllerMaps.html

    Troubleshooting - My Controller Doesn't Work:
    http://guavaman.com/projects/rewired/docs/Troubleshooting.html#controller-doesnt-work

    This is an extremely common misunderstanding. Your controller is working, but it is not recognized and cannot be automatically mapped to the Dual Analog Gamepad Template. Read this section of Controller Maps to understand what this means: http://guavaman.com/projects/rewired/docs/ControllerMaps.html#unknown-controllers

    Your controller is not a candidate for auto-recognition. The reason why is explained here. You can only use that controller via in-game user mapping or with the creation of an Unknown Controller map.
     
    Last edited: May 6, 2016
  42. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    "2) Some specific buttons, like the L2,R1,R2, although they work normally at pc version at android version throw the following error (D/Unity ( 5948): Input: dropping joystick keypress - out of resources [1, 20, 1])"

    I see you mention a Unity error that is logged when you press one of these buttons on Android. If Unity is throwing an error when you try to use one of these buttons, Rewired will not work for them either because Rewired does not implement a native input solution on Android. (This is mentioned on the website and in the documentation.) Rewired uses UnityEngine.Input for all input on Android so if there's a device that doesn't work with UnityEngine.Input, it will not work with Rewired on Android either.

    Please clarify what you are saying here. I can't tell whether you're saying L2/R1/R2 work on Windows but not Android, or they don't work on either.

    To determine whether or not the hardware buttons are returning any data through the input system, use the Rewred/DevTools/JoystickElementIdentifier tool. Place it in a blank scene, create an empty Rewired Input Manager, and build. It will show you what shows up at the lowest input source level. Do this on Windows and on Android. If your controllers do not return any joystick button numbers when you press L2/R1/R2, then they will not work in Unity or Rewired.

    Many joysticks do not work well or at all on Android if they were not made specifically for Android. For example, most old PC USB joysticks cannot be used because of button index mapping issues in UntyEngine.Input. You can see how many supported joysticks have only partial mappings on Android because of this problem: http://guavaman.com/projects/rewired/docs/SupportedControllers.html
     
    Last edited: May 6, 2016
  43. imaginationrabbit

    imaginationrabbit

    Joined:
    Sep 23, 2013
    Posts:
    349
    I did read the docs and I did create an unknown controller map/assigned it to the player etc- but it still did not get any input- I was able to get it working in game by using the mapper you include- but if I ran the game again the mapping was lost and I had to do it over again- I read in the docs there is a way to save the user mapping to XML so I will look into that-

    Is there a specific part of the docs or a tutorial you could point me to- to help me set up an unknown controller map? Thx
     
  44. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    If the controller is not recognized, which yours is not based on the name it returns, Rewired will load the Unknown Controller Map if you have created one and assigned it to a Player. I suggest you test again. It cannot be detecting the controller as an Unknown Controller and not loading the Unknown Controller map.

    There is no tutorial on creating an Unknown Controller map because it's the exact same process as creating any map in Rewired. Create the map, assign it to the Player, and when the controller is detected and auto-assigned to the Player, the map will be loaded.

    This checklist shows every step to take when Joystick input does not work:
    1. Did you create one or more Players in the Rewired input manager?
    2. Is Auto-assign Joysticks enabled in the Rewired Input Manager Settings page or have you manually assigned joysticks to the Player(s) during runtime through scripting? (See "My Controller Doesn't Work" also.)
    3. Did you create any Joystick Maps compatible with the controller(s) you're using?
    4. Did you assign those Joystick Maps to your Player(s) on start?
    5. Are those Joystick Maps enabled on start in the Player(s)?
    6. Is the joystick you're using a recognized controller? If not, please read about the Unknown Controller map and how unrecognized controllers are handled.
    7. Please go through the Quick Start guide and ensure you haven't missed any steps.
    8. Read the documentation to learn more about how Controllers and Controller Maps work.
    If you still do not get any input from the Unknown Controller, then you will have to debug to figure out what is wrong and whether it's an assignment problem, a mapping problem, or a hardware problem (it does not look like a hardware problem based on the JoystickElementIdentifier.)

    The debug code you can run is found here:
    http://guavaman.com/projects/rewired/docs/Troubleshooting.html#controller-doesnt-work

    Code (csharp):
    1. // Log assigned Joystick information for all joysticks regardless of whether or not they've been assigned
    2. Debug.Log("Rewired found " + ReInput.controllers.joystickCount + " joysticks attached.");
    3. for(int i = 0; i < ReInput.controllers.joystickCount; i++) {
    4.     Joystick j = ReInput.controllers.Joysticks[i];
    5.     Debug.Log(
    6.         "[" + i + "] Joystick: " + j.name + "\n" +
    7.         "Hardware Name: " + j.hardwareName + "\n" +
    8.         "Is Recognized: " + (j.hardwareTypeGuid != System.Guid.Empty ? "Yes" : "No") + "\n" +
    9.         "Is Assigned: " + (ReInput.controllers.IsControllerAssigned(j.type, j) ? "Yes" : "No")
    10.     );
    11. }
    12.  
    13. // Log assigned Joystick information for each Player
    14. foreach(var p in ReInput.players.Players) {
    15.     Debug.Log("PlayerId = " + p.id + " is assigned " + p.controllers.joystickCount + " joysticks.");
    16.  
    17.     // Log information for each Joystick assigned to this Player
    18.     foreach(var j in p.controllers.Joysticks) {
    19.         Debug.Log(
    20.           "Joystick: " + j.name + "\n" +
    21.           "Is Recognized: " + (j.hardwareTypeGuid != System.Guid.Empty ? "Yes" : "No")
    22.         );
    23.  
    24.         // Log information for each Controller Map for this Joystick
    25.         foreach(var map in p.controllers.maps.GetMaps(j.type, j.id)) {
    26.             Debug.Log("Controller Map:\n" +
    27.                 "Category = " +
    28.                 ReInput.mapping.GetMapCategory(map.categoryId).name + "\n" +
    29.                 "Layout = " +
    30.                 ReInput.mapping.GetJoystickLayout(map.layoutId).name + "\n" +
    31.                 "enabled = " + map.enabled
    32.             );
    33.             foreach(var aem in map.GetElementMaps()) {
    34.                 var action = ReInput.mapping.GetAction(aem.actionId);
    35.                 if(action == null) continue; // invalid Action
    36.                 Debug.Log("Action \"" + action.name + "\" is bound to \"" +
    37.                     aem.elementIdentifierName
    38.                 );
    39.             }
    40.         }
    41.     }
    42. }
    Do not get confused by Control Mapper or ControlRemappingDemo1. They are not meant to permanently map controllers that are not recognized by the developer. They are only to remap controllers by the end-user. You cannot make a mapping in Control Mapper and save that permanently so that all your players also get that custom mapping. Each player that plays your game must make their own custom mappings which will be saved in the registry if using UserSaveData_PlayerPrefs (the default saving/loading system on Control Mapper).
     
    imaginationrabbit likes this.
  45. imaginationrabbit

    imaginationrabbit

    Joined:
    Sep 23, 2013
    Posts:
    349
    Thank you for the detailed explanation- I will go through the process again and yes I think I'm a bit confused with the terminology- thx
     
  46. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    Rewired 1.0.0.86 is available for registered users on the Rewired website. If you'd like to receive early access to updates, please contact me here. The Unity Asset Store will have the update in 5-10 business days.

    3D Rudder Support:

    This update adds support for 3D Rudder, a foot-controlled VR and 3D navigation and motion controller. It also includes default mappings for the 3D Rudder in the Rewired UFPS Input Manager.

    3DRud_R5-Blanc_6_HD2.png



    1.0.0.86:

    Changes:
    - Added Rewired.UnityInputOverride class to allow changing UnityInputOverride settings at runtime.
    - Thrustmaster Dual Analog 3: Added Left Trigger / Right Trigger mappings to Dual Analog Gamepad Template.
    - UFPS Rewired Input Manager prefab: Added default mapping for 3D Rudder.

    New Controller Definitions:
    - 3D Rudder
    - Thrustmaster TH8A Add-on Shifter
    - Thrustmaster T150 Racing Wheel

    Modified Controller Definitions:
    - Windows Standalone Raw Input: Fixed Thrustmaster T300RS controller definition missing R2 binding in Variant 1.
    - Added Clutch to Thrustmaster T300RS controller definition.
    - Changed Logitech G29 controller definition Clutch element identifier type to Axis.
     
    Last edited: May 7, 2016
  47. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    Thanks for another great Rewired update.

    That 3D Rudder sounds very exciting especially to run around in UFPS's skycity. I was thinking the 3D Rudder would also be great for a horse controller (using something like Horse Animset Pro). So you could control the horse via your feet and then use a joystick to control the rider. Good for firing various weapons from the rider while controlling your horse independently with your feet. It seems like it would be much more natural for horse controller instead of using flight controller (rudder pedals). You could also use HOTAS setup with joystick control for the rider and the use the throttle to control the speed of the horse.
     
    Malbers likes this.
  48. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    You've got a lot of great ideas for novel control schemes, longroadhwy. I've never thought about a horse riding simulator before. That would make a very interesting specialty controller.
     
  49. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    I started thinking about horse riding more since opsive's Third Person Controller v1.3 now includes a horse.

    Opsive's Third Person Controller v1.3 upgraded their Rewired integration so it is much closer to your version for UFPS. It makes it much better overall integration experience.
     
  50. Lnoldori

    Lnoldori

    Joined:
    Jan 19, 2013
    Posts:
    9
    Hi Guavaman, i had read both the website and the documentation and i was hoping that the input wrapper i had created had a mistake somewhere. It seems that the actual problem is Unity and their half made input system. Either way your asset is fantastic and even if i will not use it in my current project i will use it sometime in the future.

    English as you can see, is not my main language :). What i wanted to say is that they work normally On Windows and not at all on Android.


    I tried that and the problem is the same. On Windows it can recognize the key presses but on Android it can not. So at the end we can only hope that one day the Unity team will fix this mess.
    At least a logitech and an XBox controller i tried they both work fantastic :)

    Thank you again for your time.