Search Unity

  1. Click here to see what's on sale for the "Best of Super Sale" on the Asset Store
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Rewired - Advanced Input for Unity

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

  1. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,406
    @Steve Tack Thanks for the link and info!

    @PsyDev

    Getting last used controller:
    http://guavaman.com/projects/rewired/docs/HowTos.html#last-used-controller

    There's also a new way to get the current contributing sources for an Action:
    http://guavaman.com/projects/rewired/docs/HowTos.html#get-contributing-input-sources

    You can combine that technique with the controller type check to get all kinds of info about what the user is doing.

    There's also a way to track back to find the generalized elements on the Dual Analog Gamepad template that are being activated, though this technique is a bit hacky and will probably be changed at some point. (LMK if you want to know about this.)

    If you build a lookup table of common controller glyphs, I recommend you use the Element Identifier Id to match instead of the string name. Also, for associating your glyph set to a particular joystick, use controller.hardwareTypeGuid to determine the controller being used. The Guid shows up on the settings page of each HardwareJoystickMap. A Guid of all 0's (Guid.Empty) is an Unknown Controller.
     
    Last edited: Nov 13, 2015
  2. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    I've got some code that detects specific hardware maps, and when an Xbox One controller is plugged in, it shows up as an Xbox 360 controller. I'm checking against the hardware map GUID 19002688-7406-4f4a-8340-8d25335406c8 in order to display a specific input prompt on the UI. Everything functions perfectly in terms of mapping the actual player input.

    I was attempting to show the View button (the two overlapping squares), and got the 360-specific "Back" icon, since it matched on the 360 GUID and returned the control name "Back" for my Action mapped to "Center 1".

    That technique does work for a DualShock 4, so I'm pretty sure my code is good.

    Is treating an Xbox One controller as a 360 controller just a Windows thing? Is there a way around that?
     
  3. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,406
    It's an XInput thing. There's no way to differentiate one XInput controller type from another. To XInput, everything is simply Gamepad.

    If you want to be able to identify it, you have to disable XInput, which means you get combined L/R triggers on every X360 and Xbone controller (except Xbone on Windows 10+), and you lose perfect universal XInput controller support as only ones specifically matched for can be identified as compatible with the X360 definition.
     
  4. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    OK, thanks for the info!
     
  5. PsyDev

    PsyDev

    Joined:
    Sep 30, 2015
    Posts:
    31
    @guavaman thanks for the help as well on determining last input type. I hadn't spent enough time digging through the docs to see the answer sitting there in the HowTo's.

    As for differing behaviour on the Start/Options/Center 2 button for Sony and XBox, can you please verify this is the correct approach:
    During gameplay a 'Gameplay' Controller Map category is enabled with Center 2 button mapped to a Pause action.
    When that is pressed, I would then pause the game, disable 'Gameplay' category and enable 'Menu' category.
    • For Sony-type controllers, I create a Joystick mapping that also has Center 2 mapped to Unpause action.
    • For all other controllers, via the template
      • map Center 2 to Submit, so you can advance through menus with it.
      • map Center 1 to Back, and unpause when at the top-level menu
    If there is a better way, please advise.
    If I am on the right track with this approach, is there a way to manage what is basically now two templates, one for Sony and one for everything else? Or do I have to add a unique Joystick map for each Sony joystick that I want to have the same behaviour? I think I can create a new map for each fairly easily with the Create Defaults button, but I can see that becoming a bit of an administrative mess, even though there are only 5 or 6 Sony-specific controllers. You'd still have to make changes in all 5 or 6 each time you made a change, which can be error prone.
     
  6. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,406
    There is no better way. That is the exact intended use for the templates and the specific controller maps. Specific maps override the template if one exists.

    There is one Dual Analog Gamepad template. I see no reason for you to need a 2nd template to handle this. That would be more of a mess to manage from an editor standpoint. You'd have to be modifying all the hardware joystick maps to make them use a different template, then your changes would get overwritten when you update Rewired just to save having to double check your controller layouts on a few devices before you publish your game.

    I don't understand why you are making "Center 2" act differently on all Sony controllers vs other gamepads. All Sony controllers except DS4 have the same Select and Start buttons as most gamepads. Only the DS4 differs, with Share and Option instead. If you're making it function differently because of Share and Option, that's only 1 controller you have to create a specific map for, not 5-6. Why would you want a DS3's Start button, for example, function differently than an Xbox 360 controller's Start button?
     
  7. PsyDev

    PsyDev

    Joined:
    Sep 30, 2015
    Posts:
    31
    From what I've seen, the convention on Playstation is that Start/Option pauses, then once in the pause menu, no matter where you are, Start/Options unpauses. You use X to advance into submenus, O to back out, but you can't back out past the top level menu. If you go into Pause Menu->Options->Graphics, then press Start, you jump right out of pause menu back into gameplay.

    Xbox and PC with XBox controller typically (but not always) follow the convention of Start to pause, then once in the pause menu, Start and A button both advance to submenu. B button or the Back button (centre 1) to back out, and if you go back with either button on the top level pause menu, you unpause and resume gameplay. If you are in Pause Menu->Options->Graphics, you must back all the way out to unpause.

    Maybe I could have two Menu categories, one for Xbox controllers and one for All others, both in the same template?
     
  8. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,406
    So this is really about having different sets of platform-specific controller maps. This isn't about the controller types in question (DS3/4, X360, etc), therefore messing with templates isn't the right approach as these templates would apply to other platforms as well (PC, Linux, OSX, etc). As you can see, platform-specific controller maps are not directly supported in Rewired and you'll have to come up with other means to achieve this. There is no one "right way" to do it.

    Here are a few ways I can think of:

    1. Map your buttons that vary from platform to platform to more generic Actions, for example map "Option" and "Start" to an Action called "Start", then in code choose what behavior to follow based on your platform when "Start" returns a value in the current context.

    2. Create different Layouts for each platform. Load controller maps by category and layout based on your target platform by manually loading the correct set of controller maps on start and controller connect.

    3. Use different Rewired Input Managers for each Platform. Load the prefab at runtime that corresponds to the current platform. You can copy a Rewired Input Manager and make changes to it as with any game object in Unity. Obviously, making changes to one will not affect the other, so its best if you have your input scheme finalized before doing this.
     
    Last edited: Nov 17, 2015
  9. PsyDev

    PsyDev

    Joined:
    Sep 30, 2015
    Posts:
    31
    Thanks for the suggestions @guavaman. I'll try to find a solution with layouts and categories.

    The idea I had was to try to replicate the same controller behaviour on PC as a user was used to if they came across from console. Like if they had a PS4 then brought their controller over to the PC, they would get the same UI experience. Perhaps overkill, but if I can get it to work without too much complication, might as well. I think your Rewired system is great and can probably support this.
     
  10. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,406
    The Layouts approach is probably the most appropriate. It will involve manual management of map loading however, but perfectly doable with a bit of effort.
     
  11. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,406
    @PsyDev

    Something like this:

    Code (csharp):
    1. public class PlatformSpecificLayouts() {
    2.  
    3.         string[] myCategories = new string[] { "Game", "Menu", "Other" };
    4.  
    5.         void Awake() {
    6.  
    7.             // Load our custom maps on start for all joysticks and all Players
    8.             foreach(Joystick joystick in ReInput.controllers.Joysticks) {
    9.                 foreach(Player player in ReInput.players.Players) {
    10.                     if(!player.controllers.ContainsController(joystick)) continue; // controller is not assigned to this player
    11.                     LoadCustomMaps(player, joystick.id, true, false);
    12.                 }
    13.             }
    14.  
    15.             // Subscribe to controller connect events
    16.             ReInput.ControllerConnectedEvent += OnControllerConnected;
    17.         }
    18.  
    19.         void OnControllerConnected(ControllerStatusChangedEventArgs args) {
    20.             if(args.controllerType != ControllerType.Joystick) return;
    21.  
    22.             // Load custom maps for all Players this joystick is assigned to
    23.             foreach(Player player in ReInput.players.Players) {
    24.                 if(!ReInput.controllers.IsJoystickAssignedToPlayer(args.controllerId, player.id)) continue; // joystick is not assigned to this player
    25.                 LoadCustomMaps(player, args.controllerId, true, false);
    26.             }
    27.         }
    28.  
    29.         void LoadCustomMaps(Player player, int joystickId, bool enabled, bool clearMaps) {
    30.             if(clearMaps) player.controllers.maps.ClearMaps<JoystickMap>(false);
    31.    
    32.             // For each of our map categories, load the map in the correct layout
    33.             for(int i = 0; i < myCategories.Length; i++) {
    34.  
    35.                 // Get the categoryId
    36.                 int categoryId = ReInput.mapping.GetMapCategoryId(myCategories[i]);
    37.        
    38.                 // Load the joystick map over any existing in the same category
    39.                 player.controllers.maps.LoadMap<JoystickMap>(joystickId, categoryId, GetPlatformLayoutId());
    40.        
    41.                 // Set enabled state on map
    42.                 if(enabled) {
    43.                     player.controllers.maps.GetMap<JoystickMap>(joystickId, categoryId, GetPlatformLayoutId()).enabled = true;
    44.                 }
    45.             }
    46.         }
    47.  
    48.         int GetPlatformLayoutId(){
    49.    
    50.             string layout;
    51.  
    52. #if !UNITY_EDITOR && UNITY_PS4
    53.             layout = "PS4";
    54. #elseif !UNITY_EDITOR && UNITY_XBOXONE
    55.             layout = "XBOne";
    56. #else
    57.             layout = "Default";
    58. #endif
    59.  
    60.             return ReInput.mapping.GetLayoutId(ControllerType.Joystick, layout);
    61.         }
    62.     }
    You're managing which controller maps get loaded by the Player for each joystick assigned. This essentially replaces the starting Joystick maps you assign in the editor.
     
    Last edited: Nov 17, 2015
  12. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,406
    Rewired 1.0.0.76 is live on the Unity Asset Store! (Finally!)

    1.0.0.76:

    New Controller Definitions:
    - Linux Native: Nyko Playpad Pro
    - Amazon Fire TV: Nyko Playpad Pro
    - P.I. Engineering RailDriver (Windows only currently)

    Modified Controller Definitons:
    - Apple TV Remote (2015): Added Pitch, Rotate, Acceleration X, Y, Z, and Gravity X, Y, Z axes.

    Changes:
    - Added support for more Unity fallback joystick axes in Unity 5+ for upcoming tvOS support.
    - Optimized Unity fallback joystick button code for joysticks 5-8 in Unity 5+.

    API Changes:
    - Added ControllerExtensions.RailDriverControllerExtension
     
  13. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,487
    Thanks. Just got this update.
     
  14. gregorypierce

    gregorypierce

    Joined:
    Jan 21, 2008
    Posts:
    411
    Does Rewired support being somewhere other than the base directory of the Unity Project? I'm putting it in a Plugins folder with all the other 3rd party plugins so they don't clutter up the project - but I don't know if Rewired really supports being in this location.



    System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Rewired_Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
    at Mono.Cecil.BaseAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name, Mono.Cecil.ReaderParameters parameters) [0x00000] in <filename unknown>:0
    at Mono.Cecil.BaseAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name) [0x00000] in <filename unknown>:0
    at Mono.Cecil.DefaultAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name) [0x00000] in <filename unknown>:0
    at Mono.Cecil.MetadataResolver.Resolve (Mono.Cecil.TypeReference type) [0x00000] in <filename unknown>:0
    at Mono.Cecil.ModuleDefinition.Resolve (Mono.Cecil.TypeReference type) [0x00000] in <filename unknown>:0
    at Mono.Cecil.TypeReference.Resolve () [0x00000] in <filename unknown>:0
    at AssemblyUpdater.Steps.MemberReferenceReplacer.MemberReferenceReplacementForProperty (Mono.Cecil.MethodReference method) [0x00000] in <filename unknown>:0
    at AssemblyUpdater.Steps.MemberReferenceReplacer.MemberReferenceReplacementFor (Mono.Cecil.MethodReference methodReference) [0x00000] in <filename unknown>:0
    at AssemblyUpdater.Steps.MemberReferenceReplacer.Visit (Mono.Cecil.MethodReference methodReference, Unity.Cecil.Visitor.Context context) [0x00000] in <filename unknown>:0
    at Unity.Cecil.Visitor.Visitor.Visit (Mono.Cecil.Cil.Instruction instruction, Unity.Cecil.Visitor.Context context) [0x00000] in <filename unknown>:0
    at Unity.Cecil.Visitor.Visitor.Visit (Mono.Cecil.Cil.MethodBody methodBody, Unity.Cecil.Visitor.Context context) [0x00000] in <filename unknown>:0
    at Unity.Cecil.Visitor.Visitor.Visit (Mono.Cecil.MethodDefinition methodDefinition, Unity.Cecil.Visitor.Context context) [0x00000] in <filename unknown>:0
    at Unity.Cecil.Visitor.Visitor.Visit (Mono.Cecil.TypeDefinition typeDefinition, Unity.Cecil.Visitor.Context context) [0x00000] in <filename unknown>:0
    at Unity.Cecil.Visitor.Visitor.Visit (Mono.Cecil.ModuleDefinition moduleDefinition, Unity.Cecil.Visitor.Context context) [0x00000] in <filename unknown>:0
    at Unity.Cecil.Visitor.Visitor.Visit (Mono.Cecil.AssemblyDefinition assemblyDefinition, Unity.Cecil.Visitor.Context context) [0x00000] in <filename unknown>:0
    at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
    at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
    --- End of inner exception stack trace ---
    at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
    at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <filename unknown>:0
    at Unity.Cecil.Visitor.Visitor.Visit[AssemblyDefinition] (Mono.Cecil.AssemblyDefinition node, Unity.Cecil.Visitor.Context context) [0x00000] in <filename unknown>:0
    at Unity.Cecil.Visitor.Extensions.DoAccept[AssemblyDefinition] (Mono.Cecil.AssemblyDefinition definition, Unity.Cecil.Visitor.Visitor visitor) [0x00000] in <filename unknown>:0
    at Unity.Cecil.Visitor.Extensions.Accept (Mono.Cecil.AssemblyDefinition assemblyDefinition, Unity.Cecil.Visitor.Visitor visitor) [0x00000] in <filename unknown>:0
    at AssemblyUpdater.Steps.AssemblyUpdaterStepBase.Apply (AssemblyUpdater.Core.AssemblyUpdaterContext context) [0x00000] in <filename unknown>:0
    at AssemblyUpdater.Core.AssemblyUpdaterPipeline.RunUpdateRound (AssemblyUpdater.Core.AssemblyUpdaterContext context) [0x00000] in <filename unknown>:0
    at AssemblyUpdater.Core.AssemblyUpdaterPipeline.Run (AssemblyUpdater.Core.AssemblyUpdaterContext context) [0x00000] in <filename unknown>:0
    at AssemblyUpdater.Application.Program.CheckForObsoleteAPIUsage (AssemblyUpdater.Application.CommandLineSpec config) [0x00000] in <filename unknown>:0
    at AssemblyUpdater.Application.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
    UnityEditor.Scripting.APIUpdaterHelper:DoesAssemblyRequireUpgrade(String)
    UnityEditorInternal.InternalEditorUtility:projectWindowDrag(HierarchyProperty, Boolean)
    UnityEditor.DockArea:OnGUI()
     
  15. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,406
    Rewired supports being placed in any folder EXCEPT /Plugins. Why? Because /Plugins is a special reserved folder name by Unity that compiles all contents to Assembly-CSharp-firstpass, not Assembly-CSharp. Plugins is a special folder designed for scripts that need to be compiled before any other scripts or for native DLLs, not for organizing your Asset Store downloads.

    The problem you are seeing is because Unity has a bug compiling editor scripts that reside in an Editor folder when placed below /Plugins. When you have editor scripts in a folder in /Plugins/.../Editor, they do not compile in the right assembly and you get the errors that you are seeing. This is a Unity issue and there is no workaround. Simply put: Do not place Rewired in the Plugins folder. Name the folder something else and you will not have any issues except when upgrading Rewired (again, another Unity issue that is explained here.)
     
    Last edited: Nov 21, 2015
  16. noanoa

    noanoa

    Joined:
    Apr 17, 2014
    Posts:
    225
    Is there a method to "consume" key/button input? Like canceling/clearing all the key/button inputs a player is currently throwing. So that no further action will be taken until the player release his key/button he's pressing.
     
  17. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,406
    No there is not. Most of the time GetButtonDown and GetButtonUp are the most appropriate commands to use for momentary button input.

    If this is about state management (for example, when player presses "Fire" and begins to fire, ignore all other buttons until "Fire" is released), that should be done outside the input system in the game logic.
     
    Last edited: Nov 21, 2015
    noanoa likes this.
  18. BlankMauser

    BlankMauser

    Joined:
    Dec 10, 2013
    Posts:
    112
  19. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,406
    If by supports you mean has an included definition for it so it recognizes it, no, just the 2-port version (unless this 4-port also has the same identifying information.) Controller can still be mapped manually via in-game remapping though.
     
  20. Situacao

    Situacao

    Joined:
    Dec 4, 2013
    Posts:
    21
    Hey Guavaman!

    Got a little doubt here, regarding the ConfigHelper class. I want to change its autoAssignJoysticks property at runtime, but I can't findfor the sake of me how to access it. Can you help me with this?

    Thanks in advance!
     
  21. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,487
    guavaman and Situacao like this.
  22. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,406
  23. Situacao

    Situacao

    Joined:
    Dec 4, 2013
    Posts:
    21
  24. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,406
    Please see this for an explanation of the static class structure in Rewired:
    http://guavaman.com/projects/rewired/docs/HowTos.html#important-classes

    ALL access to Rewired's static methods happens through ReInput first and foremost. All other classes are accessed via properties in ReInput:
    http://guavaman.com/projects/rewired/docs/api-reference/html/T_Rewired_ReInput.htm

    The one you are looking for is:
    http://guavaman.com/projects/rewired/docs/api-reference/html/P_Rewired_ReInput_configuration.htm

    ReInput.configuration.autoAssignJoysticks
     
    Last edited: Nov 25, 2015
  25. Situacao

    Situacao

    Joined:
    Dec 4, 2013
    Posts:
    21
    Right, but "configuration" doesn't seem to be working either. I access, for example, the controllers property just fine, but the configuration property seems to be strangely absent.

     
  26. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,406
    Update to the latest version on the asset store. If the API doesn't match, you're using an old version.
     
  27. lumeneo

    lumeneo

    Joined:
    Mar 3, 2014
    Posts:
    53
    In the latest version of Rewired:
    Version: 1.0.0.76 (Nov 17, 2015)

    XCode was reporting:
    "UnityDefaultViewController should be used only if unity is set to autorotate" at runtime for iOS even though it was set to autorotate in the Player Settings.

    The issue occurred when running the CustomControllersTouch Scene for iOS.

    To fix it, I removed the forced setting of the Screen orientation:
    EG: Screen.orientation = ScreenOrientation.Landscape;
     
  28. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,406
    This would depend on your settings in your Unity iOS Player. It's set to Auto Rotate by default when you create a new project in Unity. If you've changed the Unity iOS Player setting in your project, that would be why you got the error. Rewired does not change your Player settings.
     
  29. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,406
    Announcement:
    Support will be unavailable for the next 3 days during the Thanksgiving holiday weekend.

    Happy Thanksgiving!
     
  30. lumeneo

    lumeneo

    Joined:
    Mar 3, 2014
    Posts:
    53
    I did not change it. As I stated in my original post "it was set to autorotate in the Player Settings"

    Have a nice turkey day. I know I've got lots to be thankful for!

    Peace.
     
  31. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,406
    Oh, I didn't catch that part, sorry. Well, sounds like a new Unity bug to me because it does not happen in 4.3 or 5.0 (or 5.2.2 I believe, definitely not 5.1.1). Not sure what to do about it. The example was not designed for Autorotate to be turned on. If this prevents building in iOS, then I have no choice but to remove it, but the example will be broken.

    Thanks! You too!

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

    Support will be unavailable for the next 3 days during the Thanksgiving holiday weekend.

    Happy Thanksgiving!
     
    Last edited: Nov 26, 2015
  32. jackmott

    jackmott

    Joined:
    Jan 5, 2014
    Posts:
    167
    Mouse input behavior question - I've got a spaceship game, and would like the mouse to be able to steer the ship such that if the mouse is above the center of the screen a bit, the ship will pitch up slowly, forever. Move the mouse up more, it will pitch up faster. Center the mouse, pitching stops.

    None of the available input behaviors seem to make that possible directly. Am I missing something? I'd love to not have to special case the mouse in my own code.
     
  33. devotid

    devotid

    Joined:
    Nov 14, 2011
    Posts:
    422
    I have just figured out that the mapping editor does not show the individual axis in the list. It shows the full axis (the one that you can invert) but not the (-) and (+) axis.

    Is there a way to get them working? I have gone in the actual text object in the inspector and there is no data.... as I thought it was just a font problem.

    Any advice you may have would be great. I had to make the below pick to make it clear for my Steam users how to map half of an axis.

    Thanks

    Kevin

     
  34. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,007
    When using the steam link, is there any way to use 6 controllers? I can only get up to 4 wired-Xbox360 controllers working and read in the rewired FAQ about some limitations.
    I just want it verified: Is it correct that it is impossible at the moment to use 6 controllers over steam link? Otherwise: what settings must I use?
     
  35. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,487
    This is an issue with control mapper correct? Is this for unknown controllers or controllers (with extended support) with Rewired? What version of Rewired are you using?
     
  36. devotid

    devotid

    Joined:
    Nov 14, 2011
    Posts:
    422
    Im using Rewired Version 1.0.0.72.U5

    It has always been like this. Doesnt matter what controller it is. XBOX360, XBOXONE windows 10, Dualshock, Universal USB COntroller.....etc

    Even changed the Font colors, alpha layer, Style template.... all with no success. It seems the data is simply not getting written or filled into the lists. I mean the thing works great if you click on the (-) and (+) buttons to map them but users are not even seeing them and realizing they can map half of an axis.

    Thanks.

    Kevin
     
  37. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,406
    There is nothing in Rewired that will handle this very special-case behavior for you. The only solution is to implement this in your code. If the Action can be mapped to other devices besides the mouse, you can detect the input source of the Action like this:

    http://guavaman.com/projects/rewired/docs/HowTos.html#get-contributing-input-sources

    This will allow you to treat joystick/keyboard input differently than mouse deltas.
     
    Last edited: Nov 29, 2015
  38. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,406
    The link to the image you posted is broken so I cannot see what you are referring to. In addition, I do not know what the "mapping editor" is referring to. Rewired's Unity editor? Control Mapper? A custom user remapping screen you've created? Please clarify your issue so I can determine what is happening.

    Assuming Control Mapper, users can map a single side of a split axis by assigning the axis to the +/- version of the Action (or, if you've provided Positive Descriptive Name and Negative Descriptive Name, those axes that are labeled "Move Left" or "Move Right" or somesuch.)

    If you are not seeing the +/- versions of the Actions appear in the list, it's likely you have set the Action type to Button instead of Axis. Button-type Actions do not support +/- split axis bindings.

    Edit:
    After doing my own investigation and finding your issue on Steam, I've determined the reason you are not seeing anything in the +/- fields of the Action is that you have not provided a Positive Descriptive Name and Negative Descriptive Name in your Action in the Rewired Input Manager. Control Mapper apparently does not automatically add the +/- variants to your Action descriptive name. I will add this in the next update.
     
    Last edited: Nov 29, 2015
  39. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,406
    There is no way to support more than 4 controllers on Steam Link via Xinput. This is a Steam limitation and an XInput limitation.

    • Steam Link only works with XInput-compatible devices and the Steam Controller (which is emulated as an XInput device). This is advertised on the Steam Link product page.
    • XInput only supports 4 controllers maximum.
    • Because Steam Link only works with XInput, RawInput/DirectInput devices, which do not have the same 4-controller limitation, do not work at all. There is no workaround because Steam simply does not support these devices via streaming.
    Note: It may be possible to support more than 4 Steam Controllers if supported natively and not as XInput devices. Additionally, mixing Steam Controllers and XInput controllers is not advised as each Steam Controller also shows up as an XInput device (with no way to tell which XInput devices are actually Steam Controllers), thereby contributing to that 4 XInput device limit.
     
    Last edited: Dec 5, 2015
    Arkade likes this.
  40. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,406
    A couple of simple changes to Rewired/Extras/ControlMapper/Scripts/ControlMapper.cs will solve your issue:
    Code (csharp):
    1. Change at line 623:
    2.             } else if(action.type == InputActionType.Axis) {
    3.                 if(fieldInfo.axisRange == AxisRange.Full) actionName = action.descriptiveName;
    4.                 else if(fieldInfo.axisRange == AxisRange.Positive) actionName = action.positiveDescriptiveName;
    5.                 else if(fieldInfo.axisRange == AxisRange.Negative) actionName = action.negativeDescriptiveName;
    6.                 else throw new System.NotImplementedException();
    7.             } else throw new System.NotImplementedException();
    8.            
    9. Change to:            
    10.             } else if(action.type == InputActionType.Axis) {
    11.                 if(fieldInfo.axisRange == AxisRange.Full) actionName = action.descriptiveName;
    12.                 else if(fieldInfo.axisRange == AxisRange.Positive) {
    13.                     if(string.IsNullOrEmpty(action.positiveDescriptiveName)) actionName = action.descriptiveName + " +";
    14.                     else actionName = action.positiveDescriptiveName;
    15.                 } else if(fieldInfo.axisRange == AxisRange.Negative) {
    16.                     if(string.IsNullOrEmpty(action.negativeDescriptiveName)) actionName = action.descriptiveName + " -";
    17.                     else actionName = action.negativeDescriptiveName;
    18.                 } else throw new System.NotImplementedException();
    19.  
    20. Change at line 1580:
    21.                                 label = CreateLabel(action.positiveDescriptiveName, columnXform, new Vector2(0, yPos));
    22.                                 label.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, _inputRowHeight);
    23.                                 inputGrid.AddActionLabel(set.mapCategoryId, action.id, AxisRange.Positive, label);
    24.                                 yPos -= _inputRowHeight;
    25.  
    26.                                 label = CreateLabel(action.negativeDescriptiveName, columnXform, new Vector2(0, yPos));
    27.                                 label.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, _inputRowHeight);
    28.                                 inputGrid.AddActionLabel(set.mapCategoryId, action.id, AxisRange.Negative, label);
    29.                                 yPos -= _inputRowHeight;
    30.  
    31.  Change to:
    32.  
    33.                                 string positiveDescriptiveName = !string.IsNullOrEmpty(action.positiveDescriptiveName) ? action.positiveDescriptiveName : action.descriptiveName + " +";
    34.                                 label = CreateLabel(positiveDescriptiveName, columnXform, new Vector2(0, yPos));
    35.                                 label.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, _inputRowHeight);
    36.                                 inputGrid.AddActionLabel(set.mapCategoryId, action.id, AxisRange.Positive, label);
    37.                                 yPos -= _inputRowHeight;
    38.  
    39.                                 string negativeDescriptiveName = !string.IsNullOrEmpty(action.negativeDescriptiveName) ? action.negativeDescriptiveName : action.descriptiveName + " -";
    40.                                 label = CreateLabel(negativeDescriptiveName, columnXform, new Vector2(0, yPos));
    41.                                 label.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, _inputRowHeight);
    42.                                 inputGrid.AddActionLabel(set.mapCategoryId, action.id, AxisRange.Negative, label);
    43.                                 yPos -= _inputRowHeight;
     
  41. PartyBoat

    PartyBoat

    Joined:
    Oct 21, 2012
    Posts:
    91
    Hello Everyone,

    I just purchased Rewired the other day and so far everything seems fantastic, especially compared to Unity's input manager. However, there is one thing that has been tripping me up. I am currently trying to figure out the best way to implement a dead zone for my controller's joystick and I'm not sure if Rewired has its own implementation of dead zones or if it intends the user to program their own. I would go ahead and code my own dead zone solution (it's not that difficult) but it seems like Rewired already has some sort of functionality in place, implied by the "Default Joystick Dead Zone Type" parameter in the setting menu. I would rather use Rewired's implementation (if there is one) to keep things clean, but I can't seem to figure out how to change the dead zone value in the editor, and the API doesn't seem to have anything useful for setting this value either.

    Thanks!
    ~PartyBoat
     
  42. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,406
    Calibrating Controller Axes:
    http://guavaman.com/projects/rewired/docs/HowTos.html#calibrating-controller-axes

    Handling dead zones can either be done by Rewired or by you in code. The choice is up to you.

    By default, Rewired applies axis calibration and dead zones based on pre-defined joystick definitions. That is, all the dozens of joysticks I've explicitly added support for have default dead zones based on the hardware I had in hand. Any Unknown Controller uses a default dead zone value as well. Default dead zone calculation type for recognized joystick axes is Radial, where as dead zones for triggers and other axes on recognized controllers or all axes on unknown controllers is Axial. The setting you mentioned in the Rewired Input Manager is a quick way of forcing either a Radial or Axial dead zone for recognized joysticks because your game might be better suited to an Axial dead zone depending on its style.

    Axis calibration is an inherently individual thing. Each device is going to have its own optimal settings based on the hardware which can be affected by things such as wear and tear or inconsistencies in manufacturing. Because of this it's extremely important to provide your users with the ability to calibrate their axes. Rewired shows you how in both the Controller Remapping 1 example and the Control Mapper system.

    There is no way to set your dead zone in the Rewired Input Manager -- the input manager is an Action mapping manager, not a hardware setting manager. Dead zones are individual to each joystick's hardware and cannot not be created in a generic way for all joysticks. Dead zones are stored in the HardwareJoystickMap (controller definition) for each recognized joystick. Modifying these is not recommended because you will lose your changes each time you update Rewired. Instead, if you must implement your own dead zone system, do it at runtime in code by clearing existing dead zones on start and controller attach and setting your own at that time based on your own matching criteria. Or provide the user with a means to calibrate their axes manually. These configurations can be saved to XML and loaded the next time the controller is attached.

    If you do want to just do a blanket dead zone for all axes on all joysticks that use a particular Action, you can do that by simply applying it in code after getting the value of the Action(s) in question. You'll probably want to clear the existing dead zones in this case as well.
     
  43. PartyBoat

    PartyBoat

    Joined:
    Oct 21, 2012
    Posts:
    91
    Thank you for the speedy and thorough response! This seems to have cleared everything up.

    Thanks again for the great support,
    ~PartyBoat
     
    guavaman likes this.
  44. gregorypierce

    gregorypierce

    Joined:
    Jan 21, 2008
    Posts:
    411
    HAving issues with Rewired imports from the AssetStore in a brand new project. Complains still about failing to resolve assembly. I'm on OSX running Unity 5.3.0f1/2/3.
    Rewired 1.0.0.76.U5

    :

    ethodReference methodReference, Unity.Cecil.Visitor.Context context) [0x00000] in <filename unknown>:0
    at Unity.Cecil.Visitor.Visitor.Visit (Mono.Cecil.Cil.Instruction instruction, Unity.Cecil.Visitor.Context context) [0x00000] in <filename unknown>:0
    at Unity.Cecil.Visitor.Visitor.Visit (Mono.Cecil.Cil.MethodBody methodBody, Unity.Cecil.Visitor.Context context) [0x00000] in <filename unknown>:0
    at Unity.Cecil.Visitor.Visitor.Visit (Mono.Cecil.MethodDefinition methodDefinition, Unity.Cecil.Visitor.Context context) [0x00000] in <filename unknown>:0
    at Unity.Cecil.Visitor.Visitor.Visit (Mono.Cecil.TypeDefinition typeDefinition, Unity.Cecil.Visitor.Context context) [0x00000] in <filename unknown>:0
    at Unity.Cecil.Visitor.Visitor.Visit (Mono.Cecil.ModuleDefinition moduleDefinition, Unity.Cecil.Visitor.Context context) [0x00000] in <filename unknown>:0
    at Unity.Cecil.Visitor.Visitor.Visit (Mono.Cecil.AssemblyDefinition assemblyDefinition, Unity.Cecil.Visitor.Context context) [0x00000] in <filename unknown>:0
    at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
    at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
    --- End of inner exception stack trace ---
    at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
    at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <filename unknown>:0
    at Unity.Cecil.Visitor.Visitor.Visit[AssemblyDefinition] (Mono.Cecil.AssemblyDefinition node, Unity.Cecil.Visitor.Context context) [0x00000] in <filename unknown>:0
    at Unity.Cecil.Visitor.Extensions.DoAccept[AssemblyDefinition] (Mono.Cecil.AssemblyDefinition definition, Unity.Cecil.Visitor.Visitor visitor) [0x00000] in <filename unknown>:0
    at Unity.Cecil.Visitor.Extensions.Accept (Mono.Cecil.AssemblyDefinition assemblyDefinition, Unity.Cecil.Visitor.Visitor visitor) [0x00000] in <filename unknown>:0
    at AssemblyUpdater.Steps.AssemblyUpdaterStepBase.Apply (AssemblyUpdater.Core.AssemblyUpdaterContext context) [0x00000] in <filename unknown>:0
    at AssemblyUpdater.Core.AssemblyUpdaterPipeline.RunUpdateRound (AssemblyUpdater.Core.AssemblyUpdaterContext context) [0x00000] in <filename unknown>:0
    at AssemblyUpdater.Core.AssemblyUpdaterPipeline.Run (AssemblyUpdater.Core.AssemblyUpdaterContext context) [0x00000] in <filename unknown>:0
    at AssemblyUpdater.Application.Program.CheckForObsoleteAPIUsage (AssemblyUpdater.Application.CommandLineSpec config) [0x00000] in <filename unknown>:0
    at AssemblyUpdater.Application.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
    UnityEditor.Scripting.APIUpdaterHelper:DoesAssemblyRequireUpgrade(String)
     
  45. gregorypierce

    gregorypierce

    Joined:
    Jan 21, 2008
    Posts:
    411
    Note: There is additional information for this that has been sent via PM due to the nature of the information.
     
  46. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,406
    Unity 5.3 is beta. Beta releases are generally not supported as Unity makes frequent breaking changes to betas.

    I can see by the stack trace this is Unity choking on its automatic API upgrade scan. Looks like Unity did something to break the upgrade check system in some cases. This is going to require contacting Unity to solve because there is no clue about what or where in my code (if anything) caused this.

    Edit: Confirmed this is an OSX-only bug (or at least it's not present in Windows in 5.3.0f2).

    Edit2: I have sent a message to Unity support about this issue. Sorry for the trouble.
     
    Last edited: Dec 2, 2015
  47. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,406
    @gregorypierce

    I tested in OSX today and indeed verified your report. This happens in OSX but not Windows. However, it appears to be entirely cosmetic and does not affect the functioning of Rewired in any way that I've been able to determine. The message appears the first time you import from the asset store but never again. It doesn't even prevent the installer from running, so there should be no side effects.

    Hopefully Unity will fix whatever issue is wrong with the API upgrade checker in OSX and get rid of this annoying but ultimately harmless message.
     
  48. gregorypierce

    gregorypierce

    Joined:
    Jan 21, 2008
    Posts:
    411
    The problem is that is causes the build for a certain Apple TV platform to fail because the build system believes that it cannot find the assembly reference. Screen Shot 2015-12-03 at 6.27.02 PM.png Screen Shot 2015-12-03 at 6.27.02 PM.png

    You get that as soon as you perform the build step itself. Note that this is an empty project and the only thing done is importing Rewired in order to isolate the issue.
     
  49. gregorypierce

    gregorypierce

    Joined:
    Jan 21, 2008
    Posts:
    411
    @guavaman

    Just ran through the "particular Apple platform" build process and its definitely fubar. You can't do anything to get your app on the device so long as Rewired is in your project. I would love to dig in more, but I can't tell what this particular function is doing so I can't engineer around it at all.
     
  50. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,406
    I don't think the above error is related to the import/API upgrade error you reported even though it's still showing in your console. This sounds more like this issue:
    http://guavaman.com/projects/rewired/docs/Troubleshooting.html#compile-errors-ps4-xbone

    It's a compiler error because it can't find the DLL when you've got the build target set to Apple TV. This happens because Rewired was built with a version of Unity that does not include Apple TV support (a non-beta) so there is no way for me to check the DLL to be included for that platform because it doesn't exist (without a behind-the-scenes editor script to do it for you, which I did do for Xbox One, PS4, and others). Simply check Apple TV support on the Rewired_Core.dll in the inspector and it should build. This is all part of Unity's new per-platform DLL handling system in Unity 5.x.

    I'm going to add tvOS to the list of platforms that is checked in the editor script mentioned above.
     
    Last edited: Dec 4, 2015
unityunity