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. TryHarder

    TryHarder

    Joined:
    Jan 1, 2013
    Posts:
    121
    Ok thank you for the fast response, I'll figure it out and post back the results, I just didn't want to spend time on this for someone to say ........ You just need to ....... Anyway that's all good I'll work it out and post back how I did it. I just need a way to put a menu option in the startup screen, use touch screen or use game pad then either use UFPS Mobile or at least my modded version of it, or Use game pad via Rewired and turn off the touch controls :)

    I'll keep you posted !

    Thank you for your help
     
  2. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    You could also consider using a CustomController to send in the data from the on-screen controls to Rewired.
     
  3. TryHarder

    TryHarder

    Joined:
    Jan 1, 2013
    Posts:
    121
    Hello,

    Ok quite a productive day, so I think I've got everything working. I use NGUI for my game menus, and it has its own controller scripts so I used them, I've mapped the controller to use the menus and that all works fine, so my menus work with touch or controller. In the menu there is an option to use either the touch controls or the controller in the game, I store the choice. In the game I then read that value in UFPS Helper and dependant on the choice I choose whether or not to use Rewired, yes for controller but default back to UFPS Mobile if not. I dont allow controller/touch controls switching in game, you have to quit to the main menu which is fair enough I think.

    Thank you for your help its all working fine, jsut need to polish it all now !

    Rewired has been the answer to all my problems, its fantastic !!!
     
    guavaman likes this.
  4. Darkkingdom

    Darkkingdom

    Joined:
    Sep 2, 2014
    Posts:
    81
    Hey guavaman^^

    I'm using rewired since a while and it just works perfectly :) Great job!
    But now I want to make a settingsmenu for my controls.
    I've looked a quite time at your remapping example script.
    But... to be honest your coding skills are about 1000 times better than mine and I just don't get it^^'
    I'm basically looking for 2 things:

    1. How to invert an axis for a single player?
    2. How can I change the current button for an action, with the button the player pressed? (mainpart of remapping^^)

    Could you please show me the simplest way to realize this? :)

    Sorry and thanks in advance^^'
     
  5. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    I spent a tremendous amount time developing both the example included with Rewired and Control Mapper, the latter because many developers wouldn't read through code to learn how to use the API and kept asking for something simpler. I cannot make this simpler because it is not a simple process and cannot be reduced to a few lines of code or a tutorial. There are too many variables you have to account for when doing control remapping, many of which are not obvious from the outside until you start digging in. You simply cannot short cut it. Please look at the source code if you want to build your own control remapping system or better yet use Control Mapper instead which requires zero coding.

    As stated in the documentation:
    Creating your own control remapping system is not for beginners and requires patience and a certain level of programming skill. If you do not have the necessary programming skills, patience, or willingness to roll up your sleeves and dig into the code to learn how to do it, you shouldn't attempt it. If your programming skills are at a level where you need a step-by-step tutorial, this topic is too advanced for you. The purpose of this example is to learn the API. If you are looking for a drop-in control remapping system that doesn't require coding, please see Control Mapper.
     
    Last edited: Mar 21, 2016
    Hodgson_SDAS and Darkkingdom like this.
  6. Darkkingdom

    Darkkingdom

    Joined:
    Sep 2, 2014
    Posts:
    81
    Okay I got it, thanks guavaman :)
    I'll take a look at Control Mapper^^
     
  7. Hodgson_SDAS

    Hodgson_SDAS

    Joined:
    Apr 30, 2015
    Posts:
    123
    On this topic, could you add support for line spacing in ThemeSettings.cs?

    All it would take is updateing the TextSettings class:
    Code (CSharp):
    1.         [System.Serializable]
    2.         private class TextSettings
    3.         {
    4.             [SerializeField]
    5.             private Color _color = Color.white;
    6.             [SerializeField]
    7.             private Font _font;
    8.             [SerializeField]
    9.             private float _lineSpacing = 1f;
    10.  
    11.             public Color color { get { return _color; } }
    12.             public Font font { get { return _font; } }
    13.             public float lineSpacing { get { return _lineSpacing; } }
    14.         }
    And adding this in the Apply method:
    Code (CSharp):
    1.  
    2.         private void Apply( string themeClass, Text item )
    3.         {
    4.             if( item == null )
    5.                 return;
    6.  
    7.             TextSettings settings;
    8.  
    9.             switch( themeClass )
    10.             {
    11.                 case "button":
    12.                     settings = _buttonTextSettings;
    13.                     break;
    14.                 case "inputGridField":
    15.                     settings = _inputGridFieldTextSettings;
    16.                     break;
    17.                 default:
    18.                     settings = _textSettings;
    19.                     break;
    20.             }
    21.  
    22.             if( settings.font != null )
    23.                 item.font = settings.font;
    24.             item.lineSpacing = settings.lineSpacing;
    25.             item.color = settings.color;
    26.         }
    27.  
    Thanks :)
     
  8. RobGraat

    RobGraat

    Joined:
    Oct 12, 2014
    Posts:
    11
    Thank you for the asset, money well spent!

    According to http://guavaman.com/projects/rewired/docs/RewiredEditor.html#Actions there should be a "Export Actions to Consts" button in Rewired Editor > Actions. But it's not visible for me. Any idea how that could happen or how I could it?

    I'm using Unity 5.3.04f Personal with Rewired 1.0.0.81.
     
  9. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    You're using an outdated version. The latest version on the Asset Store is 1.0.0.82.
     
  10. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Okay, I'll add that in the next update along with a few other options.
     
    Last edited: Mar 22, 2016
    Hodgson_SDAS likes this.
  11. RobGraat

    RobGraat

    Joined:
    Oct 12, 2014
    Posts:
    11
    Doh. I even read the release notes and didn't notice it was only added in the last version. Fixed that.

    But I do have a new error now:
    Code (CSharp):
    1. Rewired: Native DLL bytes null!
    2. UnityEngine.Debug:LogError(Object)
    3. Rewired.Logger:LogError(Object)
    4. Rewired.InputManager_Base:GetNativeAssembliesByReflection()
    5. Rewired.InputManager_Base:InitializePlatform(ConfigVars)
    6. Rewired.ReInput:UFykGjlwVblqqwuVNENsJrwGjkm(Func`2)
    7. Rewired.ReInput:lEQaOpdSaTxfPeSVGJiaMyuHBsU(InputManager_Base, Func`2, ConfigVars, ControllerDataFiles, UserData, UserDataStore)
    8. Rewired.InputManager_Base:Initialize()
    9. Rewired.InputManager_Base:Awake()
     
  12. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    You could only possibly get this message if this DLL is missing or has settings preventing it from being included for the Unity Editor:
    Assets\Rewired\Internal\Libraries\Runtime\Rewired_Windows_Lib.dll

    (Assuming you're using Windows and not OSX. If OSX it would be Rewired_OSX_Lib.dll.)

    These DLLs are included in the Unity 5 distribution, but not the 4.x distribution.

    1. How did you download this? The Unity Asset Store?
    2. I can see no way that this would this issue, but did you move the Rewired folder somewhere before you installed the update? If so it would have logged warnings saying GUIDs were changed. The proper procedure is outlined in Updating Rewired notes in the docs.
    I can imagine no scenario where this could happen. Those DLLs are simply part of the Unitypackage generated for Unity 5 when uploading to the asset store. If those DLLs are not in the package and others are shown in the Assets\Rewired\Internal\Libraries\Runtime\Resources\Libs folder during import, then Unity is serving the 4.x version, which would be a major error.

    The only other way I can imagine this being possible is if you unchecked these DLLs on the Unitypackage import dialog when importing the new version of Rewired from the Asset Store. That sounds very unlikely.
     
    Last edited: Mar 22, 2016
  13. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    @RobGraat

    Do you happen to be in Webplayer build target?

    I changed the system to use DLL's because of user complaints about 1 MB of extra data being included in builds because of the Resources system being used for platform-specific DLLs. I changed this system in 1.0.0.82 for Unity 5+ so that it uses Unity's DLL inspector settings so that DLLs are only included for the current build platform, saving that 1 MB of build size.

    Well, it looks like it broke Webplayer mode in the editor. Edit: Not totally broken, but it will log an error on start. Input will still work.
     
    Last edited: Mar 22, 2016
  14. RobGraat

    RobGraat

    Joined:
    Oct 12, 2014
    Posts:
    11
    I did indeed move it to a Plugins folder and updated it afterwards with Rewired still in the Plugins folder. Removing the asset and re-importing it fixed it. Didn't know about assets needing to be in the root folder before updating.

    Thank you again.
     
  15. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Good. Indeed it's been a total mess since Unity changed the Unitypackage import system with 5.0. The old 4.x system was far, far better.
     
  16. TryHarder

    TryHarder

    Joined:
    Jan 1, 2013
    Posts:
    121
    Hello Guavaman

    I was getting on well using Nvidia Shield TV but today I've had all sorts of issues with the controller not being recognised. I've gone back to old builds no joy, I rebooted my laptop rebuilt and it worked then for no reason 3 builds later wouldn't work, I've done no controller changes in builds just adding other features. Go back to older builds nothing works again, so I'm wondering since the shield is android and in your docs I says android uses unity input, and that it's not so special do you think it's that ? I've read all your docs I note you said you'd write platform specific input if enough demand would you do that for Android ?? Any ideas would be appreciated I'm lost don't understand why it works sometimes and not others. Interestingly my menu screen always works that's not using Rewired that's using NGUI controller support. I replaced all my scripts with you standard ones still won't detect controller sometimes. :(

    Thank you
     
  17. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    In situations like this, you have to figure out why it's not working before any solution can be proposed.

    You need to determine at what level it's failing:
    1. Low-level: UnityEngine.Input not detecting controller or it being assigned to the wrong id, etc.
    2. Mid-level: Mapping errors, loading outdated mappings from saved XML data, etc.
    3. High-level: Controller assignment, etc.

    I cannot tell you until we figure out where the problem is. UnityEngine.Input MAY be a problem, but I have not had any major issues with it on Android for joysticks in recent versions.

    1. Test UnityEngine.Input. Input.GetJoystickNames() is the single usable piece of information on this platform.

    Either do a Debug.Log to show every entry in UnityEngine.Input, or:
    1. Create a blank scene
    2. Add Rewired/DevTools/JoystickElementIdentifier to the scene at 0,0,0
    3. Add a blank Rewired Input Manager to the scene
    4. Build it to the Shield TV
    You will see a list of detected controllers displayed along with an element list. Rewired expects Unity Joystick Id's to be aligned to the UnityEngine.Input.GetJoystickNames() array fields on Android. If the Shield Controller is detected, it will show up as one of these array entries. The position of this element in the Array is important. Take a screenshot or a picture with a cell phone or something and upload it here. If you have a USB keyboard attached, you can step through the Unity joystick id's one at a time and see if the joystick does align with the array entry by moving the sticks on the joystick and pressing +/- to step through Id's. When you see data coming back, you've found the Unity Id for that joystick.

    It strikes me this may also be simply a controller assignment issue. This comes up nearly every day it seems:
    Troubleshooting - My Controller Doesn't Work
    (See the section More reasons why your controller may appear not to work)

    Why do I suspect this? Because you probably have the Shield Remote also attached to the system. What's probably happening is you have Auto-Assignment set to 1 controller per player, and sometimes the Shield Remote may very rarely show up with a name instead of being blank as explained in this known issue. If the Remote shows up in slot 0 and the gamepad in slot 1, the Remote will be seen first, assigned to Player 0, and the controller will be left unassigned.

    All mid and high-level issues can always be resolved with a little debug code to show what's assigned to Players and what bindings are in each map. It's a simple matter of foreach Player, foreach Joystick, foreach ControllerMap, foreach ActionElementMap. Or use the attached debug tools.

    Code (csharp):
    1. foreach(var p in ReInput.players.Players) {
    2.     Debug.Log("PlayerId = " + p.id);
    3.     foreach(var j in p.controllers.Joysticks) {
    4.         Debug.Log("Joystick: " + j.name);
    5.         foreach(var map in p.controllers.maps.GetMaps(j.type, j.id)) {
    6.             Debug.Log("Controller Map: Category = " + ReInput.mapping.GetMapCategory(map.categoryId).name + " Layout = " + ReInput.mapping.GetJoystickLayout(map.layoutId).name);
    7.             Debug.Log("enabled = " + map.enabled);
    8.             foreach(var aem in map.GetElementMaps()) {
    9.                 var action = ReInput.mapping.GetAction(aem.actionId);
    10.                 if(action == null) continue;
    11.                 Debug.Log("Action \"" + action.name + "\" is bound to \"" + aem.elementIdentifierName);
    12.             }
    13.         }
    14.     }
    15. }
    Almost certainly the NGUI code is set to either a fixed Joystick Id of 1 or it's set to get input from all joysticks at the same time. Most likely the latter.
     

    Attached Files:

    Last edited: Mar 23, 2016
  18. Wouter_Eskens

    Wouter_Eskens

    Joined:
    Feb 21, 2014
    Posts:
    3
    Guavaman

    I was wondering if it was possible to load a controller map from a joystick which isn't connected at that moment in time. For example the XBOX 360 Controller which has a joystick map assigned in the Rewired Editor. It is for the control remapping screen, whenever no joystick is connected I want to show all the assigned controls of the XBOX 360 controller.

    Thank you in advance.
    Wouter
     
  19. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    ReInput.mapping.GetJoystickMapInstance

    This would load an instance of a JoystickMap from the Rewired Input Manager. However, since you say this is for a remapping screen, if the user has modified the mapping, you would have to load this from XML, not the Rewired Input Manager since that only stores developer-defined defaults.

    Edit: Actually that will not work. It requires you pass the joystick id or the joystick object itself to the function. There is no function that takes a GUID to look up the joystick map. At the present time what you want is not possible without using reflection to get the data out of UserData. Complicating this, Rewired needs to know the input source for the joystick so it can find which map to load, which can vary greatly depending on which input source(s) are being used for the current platform and what the particular joystick is. This information cannot be sensibly looked up outside the input source system because its normally generated by the input source trying to retrieve the controller definition for a Joystick it found. Trying to do it from the outside would amount to ugly hard-coding of assumed input sources per controller type.
     
    Last edited: Mar 23, 2016
    Wouter_Eskens likes this.
  20. TryHarder

    TryHarder

    Joined:
    Jan 1, 2013
    Posts:
    121
    Thank
    Thank you so much for this detailed reply, I rebuilt just one scene of the game and transferred it and the controller worked again, I then added all scenes again in build settings rebuilt and it all worked, I've been playing with that version all day and deleting controllers adding them and the remote in different orders and rebooting the box and its worked all day,so for some reason now and again when I build a version it just doesn't worked until I build one scene and run that and then build again, really strange, but it appear to be a Unity build issue

    Again thank you so much I've learnt so much from your reply I can't thank you enough.

    As my game is only ever going to be for shield with one controller how can I set it to always use controller 1 or all controllers like NGUI appears too ? I think that might be better than auto assign ?? Just a thought.

    Thank you for your time in responding I really appreciate it your support for your amazing product is just brilliant.
     
  21. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    You're welcome and thank you for the compliments!

    Rewired cannot do anything like "get input from all controllers." However, the linked documentation in the previous reply showed how to deal with this:

    You have multiple controllers connected, one Player, and have left the default Joystick Auto-Assignment Settings in the Rewired input manager: Based on the default settings, Rewired will assign only one controller per-Player. If multiple controllers are present, only one will be assigned to each Player. If you only have one Player, the second controller will be left unassigned. In order to allow auto-assignment of multiple Joysticks to the same Player, Max Joysticks Per Player must be raised to a value greater than 1. See this page for information on Controllers.

    Set Max Joysticks Per Player to 100 or something.

    As for intermittent problems, I very much suspect this is the Remote issue. If the Remote decides to show up with a name of "", the Nvidia controller would be assigned to the first Player because that's the only controller Rewired is aware of. However, if the Remote decided to show up with a proper name which it can do on a very rare occasion, it would probably show up first in the list, be assigned to Player 1, and the Nvidia controller would be ignored. Because this is a Unity issue/bug, there's nothing that can be done about it but to set the Max Joysticks Per Player higher and just let them all be assigned to Player 1. You shouldn't have any issues after that.
     
    Last edited: Mar 23, 2016
  22. TryHarder

    TryHarder

    Joined:
    Jan 1, 2013
    Posts:
    121
    Thank you, I've done what you suggested and have done 6 builds of different types and it's worked every time now !! :) so yep it looks like it was the remote as you said. Thank you for your help it makes sense now, thank you for your time, I was worried it wasn't going to work for me on the shield but it's all good now !

    I have to say the control is so smooth and the flexibility to change the mappings and your API is brilliant, I wished I'd found this asset long ago, it's just so much better than all the rest. It must have taken you a long time to get the asset to this point, Well done !

    Thank you
     
  23. _eternal

    _eternal

    Joined:
    Nov 25, 2014
    Posts:
    303
    Awesome job with the ControlMapper; it's made things easier than expected. Couple questions:

    1) How can I change the default text for the buttons? The text in the hierarchy gets overwritten at runtime. I also tried changing the strings in LanguageData.cs, but the button text remained the same.

    2) How can I disable/hide the Pre-Input Assignment Time screen? I don't really need it because my game doesn't use analog input. I tried setting the time to 0 but it still flashes for a moment.
     
  24. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Glad it works!

    http://guavaman.com/projects/rewired/docs/ControlMapper.html#language

    There is no way to disable that without changing the source code.

    Even if your game doesn't use analog input, your players may still use physical analog controls. Disabling this would be a bad idea because the purpose of it is to prevent any inadvertent assignments such as when releasing a stick and its action of auto-centering itself registers as a negative stick movement mapping that to your Action.
     
    Last edited: Mar 24, 2016
  25. _eternal

    _eternal

    Joined:
    Nov 25, 2014
    Posts:
    303
    Ah, I understand. I've had that issue in the past, in fact.

    When I open the ControlMapper at runtime now, it's throwing an error:
    "Trying to add (Layout Rebuilder for) ScrollRect (UnityEngine.RectTransform) for layout rebuild while we are already inside a layout rebuild loop."

    There's no traceback so I can't tell what part of building the GUI it's having trouble with. Any ideas? This happened as soon as I started working today, so I'm not sure at what point the mistake was made yesterday.
     
  26. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    I've never seen this message before. Have you been doing heavy customization of the UI elements? This is a Unity UI message. Open the demo Control Mapper and see if it gives you this message.
     
  27. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Rewired 1.0.0.83 is now available for download for registered users on the website. If you'd like to register to get early access to updates, please contact me here. The update should be available on the Unity Asset Store sometime next week.

    1.0.0.83:

    Changes:
    - Added Windows 10 Universal (UWP) platform native input support for joysticks. (.NET scripting backend)
    - Added Windows 10 Universal (UWP) platform native input support for joysticks. (IL2CPP scripting backend)
    - Added Windows 10 Universal (UWP) platform fallback input support for joysticks.
    - Control Mapper: Added additional options to theme text settings.

    API Changes:
    - Added ReInput.ConfigHelper.windowsUWPPrimaryInputSource property.
    - Added Platforms.WindowsUWPPrimaryInputSource enum.
    - Added Player.ControllerHelper.MapHelper.GetFirstButtonMapWithAction(Controller controller, int actionId, bool skipDisabledMaps)
    - Added Player.ControllerHelper.MapHelper.GetFirstButtonMapWithAction(Controller controller, string actionName, bool skipDisabledMaps)
    - Added Player.ControllerHelper.MapHelper.GetFirstAxisMapWithAction(Controller controller, int actionId, bool skipDisabledMaps)
    - Added Player.ControllerHelper.MapHelper.GetFirstAxisMapWithAction(Controller controller, string actionName, bool skipDisabledMaps)
    - Added Player.ControllerHelper.MapHelper.GetFirstElementMapWithAction(Controller controller, int actionId, bool skipDisabledMaps)
    - Added Player.ControllerHelper.MapHelper.GetFirstElementMapWithAction(Controller controller, string actionName, bool skipDisabledMaps)
    - Added Player.ControllerHelper.MapHelper.ButtonMapsWithAction(Controller controller, int actionId, bool skipDisabledMaps)
    - Added Player.ControllerHelper.MapHelper.ButtonMapsWithAction(Controller controller, string actionName, bool skipDisabledMaps)
    - Added Player.ControllerHelper.MapHelper.AxisMapsWithAction(Controller controller, int actionId, bool skipDisabledMaps)
    - Added Player.ControllerHelper.MapHelper.AxisMapsWithAction(Controller controller, string actionName, bool skipDisabledMaps)
    - Added Player.ControllerHelper.MapHelper.ElementMapsWithAction(Controller controller, int actionId, bool skipDisabledMaps)
    - Added Player.ControllerHelper.MapHelper.ElementMapsWithAction(Controller controller, string actionName, bool skipDisabledMaps)

    New Controller Definitions:
    - Added Windows UWP Fallback definitions for the following controllers:
    Microsoft XBox 360 Controller (Includes many generics/clones, XBox One Controller, etc.)
    - Added Windows UWP Native definitions for the following controllers:
    8Bitdo NES30 / FC30 (Bluetooth, Joy Mode)
    8Bitdo NES30 / FC30 (Wired)
    8Bitdo NES30 Pro / FC30 Pro (Bluetooth, Mode 1)
    8Bitdo NES30 Pro / FC30 Pro (Wired)
    8Bitdo SNES30 / SFC30 (Bluetooth, Joy Mode)
    8Bitdo SNES30 / SFC30 (Wired)
    8Bitdo Zero
    Amazon Fire Game Controller
    Arcade Guns G-500 AimTrak Light Gun
    Buffalo BGCFC801 (NES/Famicom Gamepad w/ Turbo)
    Buffalo BSGP801 (SNES Gamepad w/ Turbo)
    CH Products Eclipse Yoke
    CH Products Fighterstick USB
    CH Products Pro Pedals
    CH Products Pro Throttle
    CH Products Throttle Quadrant
    Game Elements GGE909 Recoil
    GameCube Controller (Mayflash 2-port USB adapter, Mayflash 2-port adapter for WiiU & PC, Mayflash 4-port adapter for WiiU & PC)
    GameStick Controller
    idroid:con Snakebyte (Mode 1)
    idroid:con Snakebyte (Mode 2)
    ípega BLUETOOTH Classic GamePad (full-size gamepad)
    ípega Multi-Media Bluetooth Controller
    ípega Wireless GAMEPAD Controller (mini gamepad)
    Logitech Dual Action
    Logitech Extreme 3D Pro
    Logitech F310 (X mode)
    Logitech F310 (D mode)
    Logitech F710 (X mode)
    Logitech F710 (D mode)
    Logitech G27 Racing Wheel
    Logitech G29 Driving Force Racing Wheel
    Logitech RumblePad 2 USB
    Mad Catz C.T.R.L.R
    Mad Catz C.Y.B.O.R.G. V1
    Mad Catz Micro C.T.R.L.R
    Microsoft XBox 360 Controller (Wired) (Includes many generics/clones)
    Microsoft XBox 360 Controller (Wireless) (Includes many generics/clones)
    Microsoft XBox One Controller
    Moga Hero Power
    Moga Pro Power
    Nvidia Shield Controller (Wired)
    Nyko Playpad
    Nyko Playpad Pro
    Nyko AirFlo EX
    Ouya Gamepad
    P.I. Engineering RailDriver
    P.I. Engineering XK-24
    PS3 Controller (Gasia Wireless USB Adapter. Includes Trust GXT 39)
    PS3 Controller (Mayflash Wireless USB Adapter)
    Radio Shack PC Gaming Controller
    Razer Serval
    Red Samurai Wireless Android Gamepad (G mode)
    Saitek Heavy Equipment Control Panel (Pro Farming)
    Saitek Heavy Equipment Wheel and Pedals (Pro Farming)
    Saitek JI3 Cyborg 3D Gold
    Saitek P880
    Saitek P990
    Saitek Pro Flight Cessna Rudder Pedals
    Saitek Pro Flight Cessna Trim Wheel
    Saitek Pro Flight Combat Rudder Pedals
    Saitek Pro Flight Rudder Pedals
    Saitek Pro Flight Throttle Quadrant
    Saitek Pro Flight TPM Panel
    Saitek Pro Flight Yoke System
    Saitek X45 Digital Joystick & Throttle
    Saitek X52 Flight Control System
    Saitek X52 Pro Flight Control System
    Saitek X-55 Rhino Stick
    Saitek X-55 Rhino Throttle
    Samsung EI-GP20 Smartphone Game Pad
    Satechi Bluetooth Wireless Universal Gamepad (ST-UBGC)
    Sony DualShock 2 (Insten Adapter)
    Sony DualShock 2 (My-Power CO., LTD Adapter)
    Sony DualShock 4 (Bluetooth)
    Sony DualShock 4 (Wired)
    SteelSeries FREE
    SteelSeries Stratus XL (Windows/Android version)
    Thrustmaster Dual Analog 3
    Thrustmaster F430 Racing Wheel
    Thrustmaster HOTAS Warthog Joystick
    Thrustmaster HOTAS Warthog Throttle
    Thrustmaster Score-A
    Thrustmaster T.16000M
    Thrustmaster T.Flight Hotas X
    Thrustmaster T100 Racing Wheel
    Thrustmaster T300 RS Racing Wheel
    Thrustmaster USB Joystick
    VRinsight Ship Console
    WiiU Pro Controller (Mayflash Wireless USB adapter)
    XiaoMi Wireless Game Controller
    Zhidong N (XInput mode)
    Zhidong N (Android mode)
    Zhidong N (Direct Input mode)
    Zhidong V+ (XInput mode)
    Zhidong V+ (Direct Input mode)

    Bug Fixes:
    - Fixed exception when an unrecognized controller is attached when native input is disabled in a Windows Standalone build.
    - Fixed issue causing input event delegate removal to fail in Player.RemoveInputEventDelegate functions.
     
    Hodgson_SDAS likes this.
  28. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    Wow!. Simply Amazing! One great update after another. Only with Rewired! Keep up the good work.

    Hopefully the asset store will release it tomorrow.
     
  29. Doghelmer

    Doghelmer

    Joined:
    Aug 30, 2014
    Posts:
    120
    A simple question: I just started using Rewired, and I already have a control mapper screen set up in my game from a previous plugin that I was using, so I'd rather not use the Control Mapper prefab. I'm able to read in my current control scheme from Rewired from each player just fine, but I cannot for the life of me figure out how to simply take in an input from the player and assign that key to the current controller scheme. I've been reading over the code and documentation for a couple of hours now and I feel a bit stuck. What's the quickest, simplest way to get this working (not necessarily accounting for conflicts, etc. just the absolute basics)?
     
  30. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Actually, that's not a simple question (or rather, the question may be simple but the answer is far from it). It's a very complex topic and there is no way to shortcut this or create a simple quick tutorial. I've provided two complete working examples with Rewired that you can read the code and learn everything you need to know. The documentation on this topic is right here:
    http://guavaman.com/projects/rewired/docs/HowTos.html#controller-mapping-screen
     
    Last edited: Mar 25, 2016
  31. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Remapping controls in Rewired is very complex because of Rewired's Controller Map and Player systems. It is a very powerful system that allows you to do things simple static input configuration systems could never do, but it comes at the price of making tasks like this very complex. That is why I have provided both a complete working example that is intended for experienced programmers to read and learn the process from and a complete working UI for those that don't have the programming skills can use directly in their games. I simply cannot make this topic simple and easy, so I choose not to attempt to write what would end up being an extremely long and complex tutorial on the subject.

    I have attached a super minimalist joystick remapping example that I made for another user a long time ago. I do not endorse using the attached example to learn how to use the Rewired API for controller remapping because it is a gross over-simplification of the process and completely disregards many very important issues with regard to remapping controls, all of which are handled properly and demonstrated in both the ControlRemapping1 demo code and in the Control Mapper code.
     

    Attached Files:

  32. Wouter_Eskens

    Wouter_Eskens

    Joined:
    Feb 21, 2014
    Posts:
    3
    Guavaman

    It's a pity you can't just load the joystick maps without the joystick being connected.
    It must be stored somewhere though or am I wrong? For example all the default maps for the XBOX 360 controller, they must be somewhere in a file or not?

    Another question: When I try to map the scroll wheel of the mouse I have to scroll like 4 times before the polling actually starts working. It's the same in your ControlMapperDemo. Is there any way I can fix this so I can just scroll up (or down) one time before it gets mapped?
     
  33. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Of course it's stored somewhere. It's in the Rewired Input Manager. What I tried to explain to you before is that it can't know which hardware definition to load and create a mapping for if you don't pass it both the GUID of the joystick AND the current input source that that joystick will be using. Current input source is a completely internal thing at this time. If you're using Raw Input and XInput on Windows, you've got two input source there working at the same time. Only if you know which input source that particular controller is going to use can you create the controller map. However, there's no way you could know which input source that joystick was going to use except by hard coding it to use XInput for XInput compatible controllers and Raw Input for others. You change platforms or active input sources and all of this changes. Further complicating this, if XInput is enabled, it would be loading the Xbox 360 controller map for ALL XInput devices. If not, it would load the device-specific map for each individual controller (Logitech F310, etc).

    What you probably don't understand is that a Joystick Map is generated at the time the Joystick is detected and loaded from the Rewired Input Manager. When you're creating a Joystick Map in Rewired's input manager, you're creating a mapping of Actions to Element Identifier Ids. These element identifier IDs are generalized for the specific controller and match on all platforms. Once the Joystick Map is loaded though, it loads a platform-specific hardware definition which maps from Element Identifier ID's directly to button and axis index for that controller on that specific input source. It's essentially two different maps on top of each other. This low-level mapping is baked into the Joystick Map when it's loaded from the Rewired Input Manager. In Rewired, what you see in the Rewired Input Manager only half the story. (There's also 3rd translation that happens with the Dual Analog Gamepad Template map.)

    If I were to let you grab an instance of a Joystick Map from the Rewired Input Manager just by using the GUID of the joystick you want to know about, the best I could possibly do is pass an incomplete mapping that doesn't actually work but only lists the Action to Element Identifier Id relationships. It could not have the true Axis and Button indices baked in. You couldn't pass this Joystick Map to a Player and have it work.

    This is dependent on the data your mouse is generating. Mouse wheel is a delta value. Polling requires filtration of small values to prevent error in detecting axes and such. I believe the minimum polling requirement is a movement of 0.5 for an axis before it will register as an assignment. Your wheel is obviously returning small values. It is intentional that you need to roll the wheel somewhat before it will register. (Because the mouse wheel is a delta, it really is based more on speed.) Be aware that some wheels don't have detents. For those users, having a hyper-sensitive assignment on the wheel would be very annoying because the wheel may roll accidentally. There is no way to detect how one's wheel will behave, so I chose to make it such that you need to be deliberate when assigning the wheel. The same is true for X/Y mouse movement assignment.
     
    Last edited: Mar 25, 2016
    Wouter_Eskens likes this.
  34. ftejada

    ftejada

    Joined:
    Jul 1, 2015
    Posts:
    695
    Hello!!
    do not know if this has already been asked. Can from its asset values change as Sensitivity, Gravity, etc., by script at runtime? Unity does not currently have any function in your API to do this

    Not if you understand me

    regards
     
  35. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Yes and a lot more. (In Rewired, these settings are set in the Input Behavior - API reference here.) See the documentation for a better overview of all the features, then download the free trial to see if Rewired would be right for your project.
     
  36. CrossHanded

    CrossHanded

    Joined:
    Jul 31, 2013
    Posts:
    9
    Hello, I've recently begun to use Rewired and have successfully used it for a few things but I've hit a problem I can't seem to solve regarding recognition of joystick axes. I have a joystick that has 8 buttons and 2 axises that are analog. The stick has been intentionally firmware hardcoded to send its axises as axis 10 and axis 11 for horizontal and vertical respectively. This joystick isn't a recognized type (its a Ultimarc Ultrastik), but it is usable by Rewired as an "Unknown Controller" and I've been able to verify that it maps under that scheme, and works fine when its hardcoded to send to axis 0 and 1. However, no matter what I do, I cannot get axis 10 or 11 to be recognized, even though I've set it up in Rewired with the correct axis pulldown, and have also tried to use the standard Unity Input Manager set to "Get Motion from all Joysticks" which would not work either. I've tested the stick in HTML5 Gamepad Tester (http://html5gamepad.com) and it reports expected values for axis 10 and axis 11 as well as its buttons.

    In Rewired I'm sure I have the players set up right; button presses do register from the device, just not those axises. I have no idea why this isn't working - and was hoping you might have some insight as to why axis 10 and 11 aren't working, or what might fix it. I'm using Rewired 1.0.0.82.

    One other question... I need a code example of how I can get a string return value for what joystick map a player is using. For instance if player0 is using an Xbox 360 controller/Unknown Controller/Sony Dualshock3 etc., I want to be able to run a string check or similar against it and if the corresponding controller map is being used, to change some variables in my script. I looked around in the documentation for long time but didn't see a clear way of how to do this.

    Thanks for your attention and assistance.
     
  37. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Raw Input uses HID usage id's for axes, not sequential axis indices. If the joystick firmware returns values for axes in the accepted HID usage id range, they will work. If it uses some unknown usage id, it will not. The easiest way to check is to add the Rewired/DevTools/JoystickElementIdentifier to the scene, add a blank Rewired Input Manager, and press Play. This will show real-time data from the attached devices.

    Joystick.hardwareTypeGuid - The Rewired GUID associated with this device. A GUID of all zeros is an Unknown Controller.
    Joystick.name - The name the controller hardware returns.
    Joystick.hardwareName - The name of the controller. This is drawn from the controller definition for recognized controllers. For unrecognized controllers, the name returned by the hardware is used instead.

    The preferred method is hardwareTypeGuid. This can be found in the HardwareJoystickMap controller definition of each recognized joystick. Obviously, since your controller is unrecognized, you'd want to use Joystick.hardwareName after determining it is an Unknown Controller.
     
  38. CrossHanded

    CrossHanded

    Joined:
    Jul 31, 2013
    Posts:
    9
    Wow, thanks for the fast and informative reply! I got the raw input data back from the Rewired Joystick Element Identifier, and it gave some possibly useful info, this comes from the axis 10/11 variation:

    >Product Name = "Ultimarc Ultra-Stik Player 2"
    >Is Bluetooth Device = False
    >Device Type = Joystick
    >Product GUID = 0512d209-0000-0000-0000-504944564944
    >Product Id = 1298
    >Vendor Id = 53769
    >Axis Count = 0
    >Button Count = 15
    >Hat Count = 0

    Note the Axis Count is zero. Compared to the standard variation:

    Product Name = "Ultimarc Ultra-Stik Player 1"
    Is Bluetooth Device = False
    Device Type = Joystick
    Product GUID = 0511d209-0000-0000-0000-504944564944
    Product Id = 1297
    Vendor Id = 53769
    Axis Count = 2
    Button Count = 15
    Hat Count = 0

    Seems like this one has 2 axis' while the 10/11 axis does not. Is this something that can be fixed in the USB headers/ firmware? Or is it out of spec for accepted(?) usage range? I can see if I can get the firmware fixed by the author but if I know what to ask for, it might be helpful. Thanks so much!

    I'll give the hardwareTypeGuid/ Joystick.hardwareName a try - sounds like exactly what I was looking for. Really appreciate the help!
     
  39. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Because the axis count is 0, yes, that would mean the axes are mapped to some HID usage id that I do not allow as an axis in my Raw Input implementation. And since it doesn't show up in Unity input, neither do they. Direct Input recognizes even fewer axis usage id's, so they wouldn't show up there either (but you can check by switching to Direct Input mode). If this device is designed to work with Direct Input or Windows in general, I would assume the axes would be mapped to a standard HID usage id. Do the axes show up in the Windows Control Panel game controller tool?

    You said this stick was intentionally encoded to use axis 10 and 11. Is this a custom firmware? What is the reason the axes need to be at those specific indices? If this stick/firmware was designed to work only with some specific arcade board or software, it's possible they used custom usage id's that are outside the HID spec. You could find out what the usage page and usage id's are, but I would be very (very) reluctant to add them to Rewired's spec because it could possibly mean detecting new axes (even if not true axes) on devices that are already recognized therefore breaking recognition for those devices including potential user-defined definitions over which I have no control to fix.
     
    Last edited: Mar 28, 2016
  40. CrossHanded

    CrossHanded

    Joined:
    Jul 31, 2013
    Posts:
    9
    The axis does not show up in windows control panel. The firmware is custom, though I wonder if there's a way to change it so it can be recognized by your/Unity input properly... it needs to match some kind of HID spec I guess? It would be very useful to me if I could have the axis detected as something beyond the standard 3. I was hoping I could use the axis 10/11 version so it would consistently work without interfering with existing axis' on joypads and not have to match a specific player number like the standard firmware that uses axis 0 & 1. I'm trying to create a setup where each controller can correspond to a specific axis no matter what their controller ID; as you know the windows/unity problem where it randomly assigns ID's is a huge problem without a clear solution. I've made a workaround using Rewired but it requires user input; if I could specify a custom axis and have it recognized it might make that unnecessary; to give you a quick background on my eventual goal.
     
  41. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    http://www.usb.org/developers/hidpage/Hut1_12v2.pdf

    The axes recognized by Unity and Direct Input are on page 8 - Generic Desktop. 30 - 36, 40 - 46 (can't quite remember if 43-46 work in DI/Unity). Check by running the JoystickElementIdentifier tool in DI mode and it will list the axes by name. (Technically Hat also works but it's processed in a different way.)

    Is this going to be an arcade cabinet with fixed hardware? If so, would gamepads be attached also and are they also fixed or removable? I'm assuming a fixed cabinet setup because you're going to the trouble of getting special firmware made for your joysticks.

    Rewired will sort the USB devices in a fixed order if using Raw Input that will not vary from run to run as long as you leave them in the same USB ports. (Obviously if the underlying hardware changes, this does not apply.) The exception is if you attach an XInput device and have XInput enabled -- the XInput devices cannot be sorted that way (unless you disable XInput). But if it's a standard USB HID device, the sort ordering should not vary from reboot to reboot. I'm assuming this is the problem you are referring to when you say id's are random. (Unity Input's issues is an entirely different story from Windows itself.)
     
    Last edited: Mar 28, 2016
  42. CrossHanded

    CrossHanded

    Joined:
    Jul 31, 2013
    Posts:
    9
    Thanks again for the responses. If the axes need to correspond to a USB usage ID, that would seem to explain why the straight axis number wouldn't work, though I find it odd and a bit frustrating that I can plug my stick in, and that website can properly read axis 10 and 11 and return good numbers, but other things won't. I guess I'll have to look into it more, but if I can't get that to work, my workaround isn't ideal but its better than nothing. Its good to know that raw input shouldn't vary from run to run; I wasn't sure what settings I was having problems under, but the stick ID's would swap constantly, almost intelligently doing the exact opposite I needed them to do, so I really needed to find a reliable way to stop that from happening. I was using XInput just now with my failsafe and the very act of switching it back to Raw broke everything. I managed to re-designate my axis', however - and if what you say is correct about raw not changing, I might be okay with that.

    Yes, this is going to be in an arcade cabinet - the hardware is partially fixed; in this current incarnation there's 2 analog sticks, but with the ability to plug in an Xbox 360 pad and play with that instead. Since one stick is for movement and the other is for aiming, having them swap randomly between launches, power cycles, or on a whim is unacceptable as you can imagine. Future incarnations may have up to 4 analog sticks, you can imagine the fun that will be if the swap problem isn't solved. My current workaround using Rewired looks for a start button. If the start button comes from the wrong place (i.e controller 1 instead of controller 0), it swaps all the axes functions and behavior via scripting. If the start button comes from a third controller; assuming an external gamepad was plugged in, it reassigns the axis behavior to match that configuration. (hence why I want to identify and check against known sources to confirm). You can go back to the arcade stick but the player has to press start to switch back. As I said, not ideal, but a step in the right direction..?
     
    Last edited: Mar 28, 2016
  43. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    This is a very interesting project you have.

    Are you using a specific ultimarc board with this or using a custom designed board? And with this particular board are you are using custom firmware? Or is this just firmware from ultimarc?

    In the configuration they have on the ultimarc website they have show two joysticks showing up correctly under the windows control panel. This is the URL I am referring to.

    https://www.ultimarc.com/ultrastik_inst.html
     
  44. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    The website tool must just reading every HID value if finds regardless of the usage id. The fact that Windows Control Panel, Unity, Direct Input, and Raw Input do see the axes says something. It's very likely most joystick implementations using OSX I/O kit and Linux also would not use these axes, but there's no way to know that without knowing the HID usage page and usage id they're set to -- there are axes that are valid on Android that aren't on Windows's implementations for example. But you can't just read all HID usages as axes or you will have all kinds of problems with devices that use custom data for various other purposes. For example, the Logitech F710's vibration and mode buttons and vibration levels are on custom HID usage id's. If you just read all possible report elements and considered them axes and buttons, you'd get data back for those items which would be wrong. Custom usages are reserved for special purposes and should not be read as axes or buttons unless you know you're reading from a specific device.

    Just to clarify something: There is no way to just specify an axis index without a HID usage page and id. Your joystick has to be setting both for these axes or it wouldn't be a valid item in a HID report. It's not an "indexed" vs "HID usage" thing. All items in a HID report must specify usage page and usage id. The fact that these axes are at a certain index only reflects on how that software chose to sort the items in the HID report for presentation to the user which doesn't necessarily correspond to the HID usage id.

    Without XInput enabled, this should never happen on Raw Input. However, there are two-levels you have to be concerned with in Rewired:

    1. Low-level joystick order. This is what you would see from ReInput.controllers.Joysticks.
    2. Joystick to Player assignment. This is when Joysticks are assigned to Players, either manually or automatically by default.

    #1 would not be affected by hot-plugging joysticks, but #2 would. Even though the joystick order will not vary if plugged into the same USB port, order of assignment of joysticks by the auto-assignment system will depend on your settings. By default, it will give each Player a joystick sequentially as it is found. If joysticks are connected to the system at all times this would not be an issue. It would only cause problems for you when hot plugging because it would be set by default to try to assign joysticks back to the last owner of that stick. (Can be disabled as well.)

    By disabling XInput all joysticks are now going to be handled by Raw Input. You will lose the ability to detect separate L/R trigger values, not be able to use vibration, and some generic joysticks may not be recognized as 360 pads. However, if XInput is enabled, Rewired sorts those last in joystick order after all Raw Input devices. If disabled, they are sorted with all other Raw Input devices in a fixed order. Additionally, when XInput is enabled XInput order is at the whim of Windows to assign those devices sequentially (the light on the controller). This is not predictable, so there would be no guarantee of arcade cabinet hardware to XInput ID order.

    This is an interesting set up and as you say is going to be very prone to problems since you do allow hot-plugging of devices. I can think no way to make this automatically work in all cases because what you really need here is fixed Joystick to Player assignment based on a hardware port. 2 joysicks in fixed ports tied to fixed Players and 2 open USB ports tied to fixed Players which is not possible. Rewired's auto-Player assignment will cause problems here most likely because a user may plug a gamepad into Player 2's port leaving the other empty and it would get assigned to Player 1. Even if you disabled auto-assignment and manually assigned them sequentially, there are some cases where the order may become inconsistent when moving the same device to a different port at runtime (device re-connection to a different port can potentially be paired to a previously known Joystick which would not be resorted based on the hardware). The best you could really do is have the 2 built-in joysticks fixed to Players 1-2, but the gamepads (or anything hot-pluggable) would need to be queried for a Player ID first as you are currently doing. And if you're going to have to do that anyway, you might as well re-enabled XInput to get the other advantages it offers.

    If you don't mind the fact that the gamepads would be assigned sequentially to the next available Player regardless of the USB port it's plugged into, then it should work okay. (Joy 1-2 are fixed, additional gamepads are auto-assigned first to P1 then to P2 regardless of USB port used.) You can just leave auto-assignment as is, use XInput, and not bother with the on-attach Player query. But you need to change your Max Joysticks Per Player setting in Joystick Auto-Assignment to at least 2 so that when a gamepad is attached, the Player can use both the fixed joystick and the gamepad and it gets assigned properly.

    Another issue you will need to watch out for:
    You need to make sure your 2 fixed joysticks always appear first even with other gamepads in the other ports. Because of the joystick-auto assignment system, when the game is started with the 2 joysticks plugged in alone, then gamepads are added, the fixed joystick ordering will not be affected. But if you were to then quit the game and restart, the gamepads may come before the joysticks depending on the usb port order. So to find the order of the ports, you should 1) disable XInput temporarily 2) plug in all possible joysticks 3) start the game. Then you can know which ports come first and plug your 2 fixed joysticks into those.
     
    Last edited: Mar 28, 2016
  45. _eternal

    _eternal

    Joined:
    Nov 25, 2014
    Posts:
    303
    For anyone else who finds this, updating to 5.3.4 fixed the issue. Might have had something to do with nested Canvases.
     
  46. CrossHanded

    CrossHanded

    Joined:
    Jul 31, 2013
    Posts:
    9
    Very much appreciative of your kind and detailed reply. I guess the custom axis thing won't work out - it also added the extra step of having to program custom firmwares which adds more points of failure and complexity to installations. Switching or reassigning on an input seems like it might work out okay, and before you updated your last reply, I was just going to say that DirectInput/XInput was working out far better for me than raw was, and I just reverted back. When set to raw, if I plugged in the 360 pad with the game already started and pressed start, it would switch over fine, but if I started the game with all 3 devices plugged in, nothing would work. Currently under DirectInput, I can have the external pad plugged in before it starts or after, and it seems to assign consistently. I haven't tried switching USB ports but that's not likely to happen in the field. The USB port users would have access to is just an extension with a panel mount so it will always be the same one going to the motherboard.

    I do need to find a way to get the permanent sticks detected before an external consistently. Perhaps using a different USB or thru an alternate bus/card reader may achieve that. I just have to do a lot of trial and error testing. Luckily my current efforts are just for the game's first showing (oddly in an arcade environment), and I'll have more time before it goes into actual release or production.

    Once again, many thanks for your superb support and educated replies. Even before I decided to post here I was consistently impressed with your work leading up to the release of Rewired, your persistence really shows. Incidentally I wonder if somehow I met you in person as I was looking in some old business cards from last year's GDC and in them was a business card for Rewired and I don't remember how I got it!
     
  47. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    By nothing would work, do you mean joysticks are not returning values?

    Issues with hot-plugging are probably more a result of Player assignment than anything else. Ignore the Player assignment for a moment. Just go by ReInput.controllers.Joysticks when evaluating what Raw Input is doing. Determine the order of the USB ports before you add the extra layer of Player assignment to the equation or this will be quite confusing.

    First you need to determine which ports come in which order. If you have enough controllers, plug all in at once, disable XInput, enable Raw Input, then iterate the ReInput.controllers.Joysticks array, possibly debug logging when you press button 0 or something so you can find out which one is which, then write down which USB ports showed up in which order. This will tell you which ports need to be used for the 2 fixed joysticks -- use the 2 that appeared in the list first. If you don't have enough joysticks to test all ports at once, test several different times with as many joysticks you have plugged in at start. Don't do any hot-plugging when determining order because this will throw it off.

    Code (csharp):
    1. void Update {
    2.     foreach(var joystick in ReInput.controllers.Joysticks) {
    3.         if(joystick.GetButtonDown(0)) {
    4.             Debug.Log("Button 0 pressed on Joystick " + joystick.id);
    5.         }
    6.     }
    7. }
    After the order is determined, you should be safe to use auto joystick assignment. Make sure your two fixed sticks are plugged into whichever ports corresponded to the lowest joystick id's above.

    There is no guarantee device order will not change under Direct Input. I am specifically ordering devices in Raw Input by the USB port, but no such thing is happening in Direct Input unless Microsoft is doing it under the hood. I have no way of determining that. Use Direct Input for this purpose at your own risk.

    Follow the directions above using Raw Input and you should be able to determine the USB sort order when using Raw Input.

    Thanks! Glad to help. Rewired has been a real passion project for almost the last 2 years now (including pre-release dev time).

    I was at GDC last year handing out Rewired business cards near the Unity booth. Several of the games on display at the time were also using Rewired such as Gang Beasts and I think I left some cards on the kiosk table. I was surprised at how many people already knew of Rewired at the time. Unfortunately I didn't get to go this year.
     
    Last edited: Mar 29, 2016
  48. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Thanks for the tip!
     
  49. Wouter_Eskens

    Wouter_Eskens

    Joined:
    Feb 21, 2014
    Posts:
    3
    It was never my intention to pass the the Joystick Map to a Player and have it work. It was just my intention for when there is no controller connected the user still gets to see a map. The same as in Rocket League (http://orcz.com/images/d/d3/RocketLeagueKeyboardMouseGamepadControls.jpg). When you disconnect your controller the assigned buttons are still there. How I'm doing it now is just by getting the action and based on the descriptive name of the action I show an icon of the XBOX One Controller.

    Thank you for all the information you've given, it has been a huge help!
     
  50. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    I know that's how you intended to use it, but I am very hesitant to expose a method that can only return a broken/incomplete Joystick Map just for this use case. It would have to be noted that the function returns an unusable joystick map only to be used for determining the default mappings of an unconnected joystick, plus it wouldn't even reflect the last-saved mappings if the player customized the layout at some point. To me, that makes it feel like a hack.
     
    Wouter_Eskens likes this.