Search Unity

Rewired - Advanced Input for Unity

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

  1. iamarugin

    iamarugin

    Joined:
    Dec 17, 2014
    Posts:
    883
    Is there any way to create ControllerMap from Json string? I see ControllerMap.CreateFromXml() but can't find any method for json. Am I missing something?
     
  2. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    Only directly in the Player:
    https://guavaman.com/projects/rewir...ControllerHelper_MapHelper_AddMapFromJson.htm

    ControllerMap.CreateFromXML really should never have been public, but I left it so as to not break projects that might happen to use it. Creating Controller Maps outside a Player isn't useful.
     
    iamarugin likes this.
  3. jbabineau

    jbabineau

    Joined:
    Jan 7, 2019
    Posts:
    8
    Having an issue regarding Controller Maps.

    I am trying to build a game that allows creating new users who each get their own controller configuration map. In order for this to work correctly though, I need to create a default joystick map for each new user that is added to the game. The keyboard will also be in use, so if no joysticks are currently connected, the user will still need info about their default joystick assignments.

    The main issue comes from me trying to get the default joystick map from the RewiredInputManager, which I think starts with getting from the ReInput.mapping property. I have joystick maps from two templates, the [T] Gamepad Template and the Unknown Controller. So far, the closest objective I have to pull this off would be to use ReInput.mapping.GetJoystickMapInstance(Guid joystickTypeGuid, int mapCategoryId, int layoutId). For the Guid, typed the following:

    Code (CSharp):
    1. //Assign the guid of [T] Gamepad Template.
    2. Guid gd = new System.Guid("83b427e4-086f-47f3-bb06-be266abd1ca5");
    3. ControllerTemplateMap ct = ReInput.mapping.GetControllerTemplateMapInstance(gd, 1, 0);
    4. JoystickMap defaultJoystickMap = ReInput.mapping.GetJoystickMapInstance(ct.templateTypeGuid, 1, 0);
    When I check the results though, the JoystickMap's hardware guid reads as the Unknown Controller guid of 00000-000...etc. In addition, it gathers the AEMs from the Unknown Controller Map when I actually wanted the traditional Gamepad Template Map's AEMs.

    I also tried getting the instance through an override with a ControllerIdentifier struct, but the information on how to apply this is completely vague.

    Is there an example I can be provided with to get the default map of a joystick when no controllers are connected?
     
  4. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    Duplicating my response to your email of the same question:

    You can't do what you're trying to do.

    A controller map cannot belong to the Gamepad Template and you cannot make a Gamepad Template controller map at runtime. The Template system is entirely separate from the Controller Map system. Every controller in Rewired is completely unique and has a unique set of elements, indices, etc. When the Controller Map is instantiated for a particular Controller, if there is a Template map that applies, that Template map will be converted to the controller-specific map when loading it from the Rewired Input Manager. At that point, the controller map is specific to that particular controller and cannot be used with any other controller.

    You are also going to face severe limitations trying to define controller maps without having the joystick it belongs to attached. The GetJoystickMapInstance function documentation explains it:

    "Gets a copy of a joystick map from the default controller maps. This overload can be used when no Joystick is actually connected and available to be used to look up the correct Controller Maps to load. The Controller Map returned by this method is not guarateed to be consistent with the Controller Map that would be loaded were the actual device to be connected. This is due to the fact that different Controller Maps may be loaded depending on the actual device connected, properties returned by this device, the current input source(s) in use, and more factors. This can be used to view the default Joystick Map setup in the Rewired Input Manager. NOTE: Element indices in ActionElementMaps may not match to to a Controller Map created with the actual controller connected. Do not rely on ActionElementMap.elementIndex being accurate in Controller Maps returned by this method. This method can only be used to load Controller Maps for recognized Controllers. Unrecognized Controllers are not supported. "

    >> I am trying to build a game that allows creating new users who each get their own controller configuration map. In order for this
    >> to work correctly though, I need to create a default joystick map for each new user that is added to the game. The keyboard will also be in
    >> use, so if no joysticks are currently connected, the user will still need info about their default joystick assignments.

    If I understand what you're trying to do, Rewired is already set up to do exactly what you want it to do without trying to reinvent the wheel.

    1. Every Player you define in the Rewired Input Manager can be assigned default controller maps for each controller type in the Rewired Editor.
    2. Every Player can save customized controller bindings to XML/JSON and load them the next time they play.
    3. Loading the default controller maps you've defined for a Player is a single function call in the player.controllers.maps helper class.
    4. Map Enabler and Layout Manager can be used to manage different Layouts, especially useful for multiple Players sharing the keyboard.
    5. A Player can be excluded from Joystick auto-assignment if keyboard/joystick exclusivity is required.
     
  5. Roman-Ilyin

    Roman-Ilyin

    Joined:
    Oct 9, 2013
    Posts:
    29
    Hello.

    "Rewired: The version of Rewired installed (1.1.38.4.U2020) was not designed for Unity 2021. Please install Rewired for Unity 2021."
    Please tell me when will the Rewired version for Unity 2021.1.0f1 be released?
     
  6. liandris

    liandris

    Joined:
    Mar 23, 2021
    Posts:
    8
    Hello.

    I'm not a developer but here seems the best place to ask such a question. A recent game I played (based on Unity 2019.4.1.x) uses Rewired plugin and it refuses to read any input from ps4 controller while ds4windows is active in its default configuration. Although the joystick menu shows when it's connected.

    I know it might be the problem on ds4windows side. But in my experience it worked with 100% games I tried, including many Unity based games. It just seems to me that Rewired is doing something extra special to ensure that it reads data from a real hardware, while ignoring any other cases. Like, it may be able to detect emulation software like ds4windows and refuse reading data from it.

    I realize it's not the best thing to ask to support solutions like ds4w, and I realize the game may never get patched even if Rewired somehow gets an update that would solve the issue. But I'd like to ask for some kind of explanation and technical information that could potentially help me, or developers (game devs or ds4w devs), fix such cases.

    Thanks.
     
  7. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    I see Unity 2021 was just released today. I don't start working on new branches until they are actually released due to massive problems and time wasting in the past trying to support betas as they change and break. I will have to start working on this. It's going to take a while because of the huge number of platforms I support and all the plugins.

    Ignore the message. It will likely work.
     
    Last edited: Mar 24, 2021
    Grumpy-Dot and Roman-Ilyin like this.
  8. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    There are many possible reasons why a controller may not work in a particular game. It's impossible to know why it's not working without having that specific game and seeing their configuration and how they choose to handle controllers. A whole lot is up to the developer.

    There are just so many variables at play here. It's extremely likely you're also using Steam, which is a whole other can of worms and adds tremendous complexity to understanding why a controller isn't working. Some documentation on Steam is here.

    Rewired can and does read information from whatever controllers are available to it from the input sources the developer has chosen to use. This is impacted by anything that might take over what input it can see like Steam.

    The most likely cause -- many games make the mistake of not allowing users to choose which controllers they want to use as advised in the Best Practices. This means they leave it up to Joystick Auto-Assignment to determine which controller the player is using. They will frequently only allow one controller to be assigned to the Player, leaving all others ignored. That approach can never work in all cases on PCs because of the ridiculous complexity of PC input, made much more complicated by software like DS4Win, VJoy, some drivers, etc. These applications can and do all sorts of "bad" things like creating unused XInput devices that still appear connected through the API to when no controllers are connected. This causes Rewired to see these phantom controllers and use them even though they provide no input and have no associated physical device. They also can cause more than one device to be exposed for the same device -- for example, an XInput device and a HID device. When this happens, a game that doesn't allow users to assign the controllers they want to use to Players will end up having two players controlled by the same controller.

    Rewired cannot detect whether or not a controller is physical or virtual. That is a major problem that I wish were solvable, but it's not. If it could, phantom controllers created by drivers or controller mapping software wouldn't be such a big issue.

    As you can see, this is mostly up to the developer whether these situations work or not. Rewired provides the means to do so, but Rewired is made to be extremely flexible and customizable for the specific needs of a game. A single-player game made with Rewired could easily be set to assign all controllers to the Player, and a multiplayer game could give you a way to choose which controllers each player is using and none of these problems would exist. Too many developers I have seen, even big ones, just use the out-of-the-box settings and don't bother to provide the customization required to prevent issues like this.

    Then there's control mapping. Rewired's Player-Action system requires controller maps be set up that bind Actions to elements on the controller. Again, Best Practices advises the developer to always provide a means for users to remap their controls so controllers that can't be supported through detection and use of a controller definition can work. Too many ignore those guidelines, so many games made with Rewired cannot be played with controllers that aren't explicitly recognized and pre-mapped.

    Other games may work because they handle input in a completely different way. For example, Unity provides a function to read Button 0 from all joysticks at the same time. This is quite common to see in single player games and similar assigning all controllers to the same Player in Rewired. There's really no way to know why other games work with your controller and software setup and others don't.
     
    Last edited: Mar 24, 2021
  9. Venominus

    Venominus

    Joined:
    Sep 5, 2015
    Posts:
    25
    When I use
    asyncoperation = SceneManager.LoadSceneAsync("lvl"); asyncoperation.allowSceneActivation=false;
    the rewired stops working, I can't use buttons, or anything.
    When I comment out asyncoperation, Rewired is working again, why?
     
    Last edited: Mar 25, 2021
  10. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    I can't tell you what is wrong with your setup because there's too little information here for me to understand what you're doing.

    Rewired works like any other GameObject + MonoBehavior in Unity. It runs in the standard Unity events: Awake, Start, Update, LateUpdate, FixedUpdate. Anything that can affect a GameObject can affect Rewired. If something disabled or destroys the Rewired Input Manager game object, Rewired will stop working.

    Loading a scene in Unity without using the "additive" version of the function destroys all GameObjects in the scene when the new scene is loaded. The Rewired Input Manager game object defaults to "Don't Destroy On Load" so it remains in the scene on level load. If you've disabled this, Rewired will be destroyed when you load the level.

    Beyond that, any of your scripts that are reading input from Rewired may be getting destroyed, so while Rewired is still working, your scripts that are reading input are not and therefore, it seems like Rewired stops working.

    There are far too many variables involved here for me to make guesses about every possible cause. Use Debug Information to see the entire state of Rewired live at runtime:
    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#debug-information

    Information on how to manage the Rewired Input Manager in your game can be found here:
    https://guavaman.com/projects/rewired/docs/InputManager.html
     
    Last edited: Mar 25, 2021
  11. ArachnidAnimal

    ArachnidAnimal

    Joined:
    Mar 3, 2015
    Posts:
    1,815
  12. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    1) Depends on what you mean by supported and what platform your are talking about. "Supported" is a deceptive term. Any controller can work, but only those with controller definitions that define everything about the controller can be pre-mapped by the developer before runtime. Anything else can be mapped by the user at runtime. If it's not in that list, it does not have a controller definition and does not automatically get mapped. But that's also deceptive because it depends on what platform you're talking about. iOS uses UnityEngine.Input which in turn uses GCController framework and every single controller supported by iOS is treated as an MFi controller and can be mapped using the Gamepad Template.

    2) The asset store changed their path structure and didn't retain permalinks to the old paths, so every link on the web broke. https://assetstore.unity.com/packages/tools/integration/logitech-gaming-sdk-6630
     
  13. Grumpy-Dot

    Grumpy-Dot

    Joined:
    Feb 29, 2016
    Posts:
    93
    Hello, I have a question / suggestion related to RewiredPointerInputModule class.

    When I'm doing some UI transitions, or showing / hiding panels, I usually disable the UI interactions to prevent double clicking issues. I'm doing this by setting the EventSystem.enabled = false then back to true when I'm done.

    As a side effect the RewiredPointerInputModule also clears the currently selected object, which is not something I want in most cases.

    Anyway, I could cache it myself before disabling/enabling the EventSystem, but it would be nice to be able to fix this directly in the RewiredPointerInputModule by having a flag that would prevent clearing of the selected object.
     
  14. Grumpy-Dot

    Grumpy-Dot

    Joined:
    Feb 29, 2016
    Posts:
    93
    Also on a totally unrelated issue, it would be nicer if the submitAction would work the same way as the mouse does for buttons and press the button for the button down state and submit only for the button up state. At the moment we directly submit on button down state. Same thing for the cancel Action. To fix this I've changed the code to look like this:

    Code (CSharp):
    1. if (GetButtonUp(player, submitActionId)) {
    2.     ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, data, ExecuteEvents.submitHandler);
    3.     break;
    4. }
    5.  
    6. if (GetButtonUp(player, cancelActionId)) {
    7.     ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, data, ExecuteEvents.cancelHandler);
    8.     break;
    9. }
    Unfortunately this does not work for the button down state to show the button as "pressed". Perhaps you have an idea how to send that event as well.
     
  15. RakNet

    RakNet

    Joined:
    Oct 9, 2013
    Posts:
    315
    In the control mapper, how do you allow the user to invert the mouse? If I press the circle next to mouse vertical, I no longer get a callback from
    player.AddInputEventDelegate(UIHook_CameraRotateX, UpdateLoopType.Update, InputActionEventType.AxisActive, RewiredConsts2.Action.AvatarRotateX);

    upload_2021-3-31_8-26-7.png

    *Update*
    Looks like a code problem on Rewired's end, callbacks get broken by setting invert. This is with
    1.1.38.4 (Current) - released on March 10, 2021

    upload_2021-3-31_9-2-42.png
     
    Last edited: Mar 31, 2021
  16. RakNet

    RakNet

    Joined:
    Oct 9, 2013
    Posts:
    315
    As a followup to this, if ActionElementMap.invert is set, the delegate added by AddInputEventDelegate will never get called. This is true even if removing the delegate and adding it again, or if restarting the editor.
     
  17. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    If you look at the source code to Unity's own Standalone Input Module upon which the Rewired Standalone Input Module is built, you will find the cause:

    Code (csharp):
    1. /// <summary>
    2. /// See BaseInputModule.
    3. /// </summary>
    4. public override void DeactivateModule()
    5. {
    6.     base.DeactivateModule();
    7.     ClearSelection();
    8. }
    This is part of their design. It was never my purpose with the Rewired Standalone Input Module to redo their design. The vast majority of the code is copied directly from the Unity PointerInputModule and StandaloneInputModule, only modified where necessary to accommodate multiple Players and software mouse pointers.

    Changing the system to retain the old selection could have unintended consequences that I am not aware of because I didn't write the entire system. I also am not overriding BaseInputModule, and there may be some purpose for this functionality in the BaseInputModule also.
     
  18. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    This is how Unity UI functions. The UI Selectables are completely independent of the Input Modules that are sending them events through the Event System. How the Selectables respond to events is in their code and cannot be modified through changing the Input Module.
     
  19. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    I can't reproduce the problem you are reporting doing the exact same thing both using a new scene and inverting through code and separately using Control Mapper. In both cases, it works as expected.

    Code (csharp):
    1. player.AddInputEventDelegate(OnAxisActive, UpdateLoopType.Update, InputActionEventType.AxisActive,  "Move Vertical");
    Inverting the binding does not cause the event to stop firing, and the axis is inverted as expected.

    The function that fires the callback for InputActionEventType.AxisActive does not care about the sign of the value returned.

    Code (csharp):
    1. case InputActionEventType.AxisActive:
    2. if(!MathTools.ApproximatelyZero(vc.GetAxis())) send = true;
    Watch the live value of the AvatarRotateX Action live at runtime using Debug Information. (Shouldn't this be Rotate Y if it's the "Look Up/Down Action"?) Also look at the Action Element Map that binds the Action.
     
    Last edited: Mar 31, 2021
  20. RakNet

    RakNet

    Joined:
    Oct 9, 2013
    Posts:
    315
    Not inverted:
    upload_2021-3-31_14-33-53.png
    upload_2021-3-31_14-36-0.png
    upload_2021-3-31_14-37-35.png


    Inverted

    (Invert is false in axis maps)
    (Joystick axes is the same)
    upload_2021-3-31_14-38-45.png

    I can try reinstalling, not sure what else to do
     

    Attached Files:

  21. RakNet

    RakNet

    Joined:
    Oct 9, 2013
    Posts:
    315
  22. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    I suggest you clear your Player Prefs:
    https://guavaman.com/projects/rewired/docs/ControlMapper.html#saving-and-loading

    This will wipe out any odd saved joystick calibration that may be affecting it. (You can also view calibration maps using Debug Information.)

    Then, if that doesn't solve it, please send me the Rewired Input Manager prefab asset file, or export JSON data from Rewried Input Manager from the Settings -> Tools -> Data Management -> Export Data and send it to me.
     
  23. RakNet

    RakNet

    Joined:
    Oct 9, 2013
    Posts:
    315
    This happens with both mouse and joystick, in any event I've never manually created calibration maps, and have cleared the player prefs many times.

    File attached
     

    Attached Files:

  24. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    Thanks.

    I set everything up and found out that I could also reproduce the problem with your data. I added some debugging code to Rewired when the Action values are generated and found out the reason.

    You have 2 Controller Maps that are binding Right Stick Y to AvatarRotateX, one in the FirstPersonExclusive map category and one in the UnitOrderMenu map category. Both Controller Maps are enabled, therefore both are contributing input. When you disable invert on one binding, the other binding is not inverted so the two inputs are cancelling each other out.

    The only way you would be able to detect this kind of issue would be this:
    https://guavaman.com/projects/rewired/docs/HowTos.html#get-contributing-input-sources
     
  25. RakNet

    RakNet

    Joined:
    Oct 9, 2013
    Posts:
    315
    The reason I have it setup like this is because I disable the FirstPersonExclusive Map while the UnitOrderMenu is open, but I still want the player to be able to look around (AvatarRotateX)

    Is it possible to have both callbacks called in such a case, with an inverted value in one case and not the other? I would not expect the user to want to invert rotation with one map and not the other, but you never know.

    For now I'll disable the UnitOrderMenu while FirstPersonExclusive is open.
     
  26. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    No, it's not possible. Using Action callbacks or querying the Action value, you are getting the combined value of the virtual controller element (Action) from all input sources. Rewired's Action system does not allow you to retrieve individual underlying contributing controller element values by querying the Action value. If you want to do something like that, use two different Actions.
     
  27. RakNet

    RakNet

    Joined:
    Oct 9, 2013
    Posts:
    315
    What about an easier way to debug this, such as through the inspector, especially an inspector warning about this circumstance?
     
  28. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    There are innumerable scenarios where you could have countless different kinds of problems I can't predict because Controller Maps are so open to you using them how you see fit. That's why Debug Information exists -- so you can view every single runtime object spawned by Rewired and search through it to find issues.
     
  29. _eternal

    _eternal

    Joined:
    Nov 25, 2014
    Posts:
    304
    Hey again, got a quick question about the Input Mapper.

    So, I had previously built an input mapper using your ControlMapper prefab as a base (the one in Rewired/Extras/ControlMapper/Prefabs). I had to move/delete a bunch of objects to make it work with my layout, so I'm trying to avoid deleting and re-importing the whole thing.

    Now, I'm trying to switch to the TextMeshPro version of the input mapper, which didn't exist back when I first made this. I installed it from Window -> Rewired -> Extras, and I'm on Rewired 1.1.38.4, so I believe everything is up to date.

    But, when I try to open the menu at runtime, I'm getting an error on line 2663 of ControlMapper.cs: "Rewired Control Mapper: Label prefab is missing Text component!"

    Is this warning supposed to exist in the TextMeshPro version of the Control Mapper? I'm wondering if the TMP version didn't install correctly over the old version, because it's strange that it's checking for Text components.
     
  30. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    No. You're going to have big problems trying to use the standard Control Mapper GameObject hierarchy with the TMPro version of Control Mapper. They're not the same. You have to replace a lot of components to make it work. You can open the demo scenes and see there are no error reported.
     
  31. Jamez0r

    Jamez0r

    Joined:
    Jul 29, 2019
    Posts:
    205
    I'm using the Rewired Standalone Input Module, and everything appears to be configured correctly (menu navigation and all is working great).

    I am now looking to add some audio events to my UI. I have a gameobject with a Button on it, and I am adding a script to it - in my script I am using the IPointerDownHandler interface and the OnPointerDown(...) function.

    When using the Mouse to click on the button, OnPointerDown(...) is called, but when using a Gamepad and pressing the Submit Button it is not. (and like I mentioned before, the OnClick() events on the Button component are still called when using the Gamepad, so navigating through the menu works fine. So I feel like my configuration is set up correctly).

    Should I be using OnPointerDown(...) in my script as a callback for both Mouse clicking and Gamepad Submit-Button, or is there another Interface/callback that I should be using? I tried searching the forums/googling to figure it out, and it seems that the Selectable interface is indeed what should be used, and looking at this https://docs.unity3d.com/2017.4/Documentation/ScriptReference/UI.Selectable.html the OnPointerDown(...) function appears to be the only relative one.

    Would appreciate any advice!! Thank you!

    (Edit: Just another quick note - the same script I'm using for the UI SFX uses ISelectHandler and OnSelect(...), which does work with the Gamepad. And in case it matters I'm on version 1.1.35.3.U2019.)
     
    Last edited: Apr 4, 2021
  32. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    Your question is entirely pertaining to Unity UI and not Rewired. Rewired sends the events to the Event System from the RewiredStandaloneInputModule in exactly the same way events are sent through the StandaloneInputModule. Rewired does not change the design of the Unity UI system in any way.

    Mouse pointer and controller/keyboard navigation are two completely separate concepts in Unity UI. You cannot use one single interface to handle everything. Handle both.

    https://docs.unity3d.com/2019.1/Documentation/ScriptReference/EventSystems.ISubmitHandler.html
    https://docs.unity3d.com/2019.1/Documentation/ScriptReference/EventSystems.IPointerClickHandler.html
     
    Last edited: Apr 4, 2021
  33. Jamez0r

    Jamez0r

    Joined:
    Jul 29, 2019
    Posts:
    205
    Thank you @guavaman for the quick response! I understand the setup better now, and I didn't realize Unity had ISubmitHandler. Just popped it in and it's working great. Appreciate the info :D
     
  34. RakNet

    RakNet

    Joined:
    Oct 9, 2013
    Posts:
    315
    Short question: I have two different actions in two different maps. The first map is exposed to ControlMapper, the second not. I want key in the second map always match the key in another map. How?

    Long version: I have a map called FirstPersonExclusive where 'X' invokes the action EnterCommanderMode.
    Within CommanderMode, the map FirstPersonExclusive is disabled and a different map is enabled. However, I want whatever key that was pushed to trigger EnterCommanderMode to also invoke ExitCommanderMode, without having to expose both maps to ControlMapper.

    The reason I don't want to expose both maps to ControlMapper because this second map only has one command, and I don't want to add another tab just for that.
     
  35. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    That functionality does not exist in Control Mapper or Rewired. You will have to manage synchronizing the bindings completely manually. Get the controller map and replace the existing binding with the a new binding that copies the values from the source binding. Every function you need is in the Controller Map class:
    https://guavaman.com/projects/rewired/docs/api-reference/html/T_Rewired_ControllerMap.htm
    https://guavaman.com/projects/rewir...d_Rewired_ControllerMap_ReplaceElementMap.htm
     
    Last edited: Apr 5, 2021
  36. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    889
  37. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    It is recognized unless they changed the controller identifying information when Logitech bought it from Saitek.

    https://guavaman.com/projects/rewired/docs/SupportedControllers.html

    farm-controller.png

    Controllers with Extended Support
    Controllers with hardware definitions are recognized on each platform and are fully mappable by element name, have standardized axis directions, and may be compatible with a Controller Template for easy mapping. For all other controllers that do not appear in the following tables, please see this important note.

    All other controllers not listed above
    Any controller which does not have a hardware definition will be usable only through user mapping or by mapping actions to numbered axes and buttons in the Unknown Controller map. These unrecognized controllers can only be supported if you provide your users a way to remap their controls, such as by using the included Control Mapper or by creating a custom control remapping screen. If you do not provide users with a way to map their controls, only the above listed recognized controllers will be usable. If you do provide your users a way to map their controls, virtually any controller will be usable.

    You can also create your own controller definitions to add extended support for more controllers, but the process can be involved, especially if you want to support all platforms. (See Creating new controller definitions for more information.) However, be advised that not all controllers are candidates for controller recognition. (See Can I add support for this controller? for more information.)
     
  38. RakNet

    RakNet

    Joined:
    Oct 9, 2013
    Posts:
    315
    If I call
    Code (CSharp):
    1. player.AddInputEventDelegate(UIHook_OrderMenuLeftRight, UpdateLoopType.Update, InputActionEventType.Update, RewiredConsts2.Action.OrderMenuLeftRight);
    2. public void UIHook_OrderMenuLeftRight(InputActionEventData data)
    3.     {
    4.         float axis = data.GetAxis();
    5. }
    6.  
    axis returns fractional values as expected.

    But if in my own Update() look I call player.GetAxis(RewiredConsts2.Action.OrderMenuLeftRight) it only returns 0 or 1. How do I fix it, so I can get the same value in Update() that I do from AddInputEventDelegate?
     
  39. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    889
    Thanks for your reply.. Didn't understand exactly. I only want to support PC currently. Also Win7, perhaps Mac later. Not Android, Linux, or other non real existent OS below 5% on the market.

    For sure the mapping of each button is completely open because the Saitek controller is the only one has this unique functionality.

    * Did you have any demo.exe where I could plug the controller and see if unity and Rewired the recognizing buttons generally and the controller itself?

    Do I need require Rewire in this case? What can Rewired do for me if I plug a unique controller, where mapping is completely static and ppl never change any mapping in real-time or other OS anyway? Thank you.
     
    Last edited: Apr 6, 2021
  40. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    If you go to the link I sent you, you can see the giant table of controllers that support recognition and can be mapped before runtime by the developer. The controller you sent me is in that list. If you look at the table columns on that page, you will see the five colums "Yes" in the image I sent you are referring to Windows, OSX, Windows 8.1 Store, Windows 10 UWP, and Linux.

    No controller that allows driver-level remapping can work correctly with controller recognition. The systems are just incompatible. Controller recognition is based on the assumption that the controller elements are all fixed. The controller definition is a file I create that contains mappings of element indices to ids that match up to named element names. If the driver allows element remapping, controller recognition will result in it reporting incorrect elements because of the remapping.

    The buttons are recognized. It is just a HID device like any other joystick or steering wheel. It will most likely work in Untiy as well.

    If you want to test anything in Rewired, the trial is always the solution:
    https://guavaman.com/projects/rewired/trial.html

    No.

    https://guavaman.com/projects/rewired/docs/Controllers.html

    ------
    When a controller is attached to the system, Rewired will attempt to identify that controller and load a hardware definition. If a hardware definition is found, it will have human-readable element names, standardized axis directions, can have default mappings created for it in the Rewired Editor so your players can just connect and go, and even may be compatible with a Controller Template for even quicker mapping. Please see Supported Controllers for more information about recognized controllers. For all other controllers that are not recognized, see this for more information.
    ------

    This is the purpose of the controller recognition system. It is what allows you to create pre-made mappings for controllers using the Rewired Editor so users can just plug in controllers and start playing without having to map them at runtime.
     
  41. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    There is no difference between calling player.GetAxis(actionId) vs receiving the Update callback and calling data.GetAxis(). They are the exact same code path underneath. They can't return different values in the same frame and the same Update loop because the Action itself has a single axis value until the next frame. The axis value returned in Debug Information -> Player -> Actions -> Your Action -> Axis Value is also the exact same code path and returned by polling player.GetAxis. View this at runtime and verify the value.

    It is rarely ever useful to use InputActionEventType.Update as the callback event type. That is equivalent to simply polling every frame. The one you want is InputActionEventType.AxisActiveOrJustInactive for reading axis values.
     
    Last edited: Apr 6, 2021
  42. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    889
    Thanks for the reply.
    And Win7 is not supported? Didnt see it on the chart.
     
  43. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    The first column is Windows Standalone. These columns are all Unity build targets, not OS versions.
     
  44. samanabo

    samanabo

    Joined:
    Mar 10, 2015
    Posts:
    51
    Hi,
    I was curious if rewired supports (or are there plans to support) unity's new runtime UI Toolkit (previously known as UI Elements)?
    Currently it is experimental, but Unity seems to indicate they plan on making this the new default across the editor and player in 2021.2 and 2021.LTS
    It appears as though the StandaloneInputModule may be different in UI Toolkit, so I would think Rewired won't work in UI Toolkit without some updates. Is that right?
    Thanks!
     
  45. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    No, there are no plans to support UI Toolkit. I have never even heard of it before.

    The included ReewiredStandaloneInputModule and Unity UI support are nothing more than a convenience. Anyone who can write code can make Rewired work with any system in existence. The idea that "Rewired won't work with" simply because it doesn't include an automatic bridge to make it work with "package du jour" out of the box is missing the big picture. Rewired is an input system. It can be used with anything and everything. It doesn't require that I add a built-in integration before it can be used for whatever purpose you desire.
     
    Last edited: Apr 8, 2021
  46. SonicBloomEric

    SonicBloomEric

    Joined:
    Sep 11, 2014
    Posts:
    1,087
    Hi @guavaman! I have an Xbox Wireless Controller that Rewired appears to be struggling with. My problem is that only the right analog stick appears to respond in Rewired.

    I'm currently running macOS 10.14.6 and have the controller connected via Bluetooth. I do not have the 360Controller driver installed as I understand that it is for wired connections and they claim it is not needed for controllers connected wirelessly.

    macOS appears to correctly recognize the controller as the Bluetooth connection settings look like this:
    upload_2021-4-8_17-19-37.png
    I can verify that the buttons are correctly handled somewhere as the Gamepad Tester website (running in Chrome) is able to verify that the controller is connected and all buttons of which it is aware work as expected (including vibration). See:

    upload_2021-4-8_17-25-47.png

    Notes:
    1. Sometimes that website does correctly identify the controller as "Xbox Wireless Controller". I have no idea why this only happens sometimes...
    2. I was interacting with several elements of the controller when this screenshot was taken to show that it is correctly detecting and mapping the buttons.

    At any rate, the Xbox Wireless Controller does appear to work in some capacity with this configuration. What I don't understand is why Rewired only handles the Right Analog Stick.

    How can I get this controller to work with Rewired?
     
  47. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    Using web-based tools to test controllers doesn't tell you anything about the results of the OS input APIs being used. Web browsers can and do implement drivers and mappings internally that make them behave very differently from direct interaction with OS input APIs. There are also multiple input APIs available on almost every platform and no way to know what APIs are being used by web browsers.

    By "only the right analog stick appears to respond in Rewired," are you saying you are testing end-result Actions through the Player or the direct controller elements? They're very different things. Debug Information allows you to view every single aspect of the Rewired system live at runtime. Follow the checklist and determine exactly what isn't working.

    If it is indeed the controller-element level not working, then the only thing that could explain that is some kind of change to MacOS or the controller firmware. View the low-level information returned by IO Kit using Rewired/DevTools/JoystickElementIdenfitier.
     
  48. SonicBloomEric

    SonicBloomEric

    Joined:
    Sep 11, 2014
    Posts:
    1,087
    Through the Player. I followed the Quick Start guide to set things up. My use case is exceedingly simple at this time so it seems sufficient*.


    That link is broken. I assume you meant this link?

    If so, I followed the checklist and found that the Debug Information showed an issue at this stage:

    Does that Controller Map map the Actions which you are querying for values?

    Debug Information -> Players -> [Player #] -> Controller Maps -> [Controller Type] -> [The Controller] -> [The Map] -> [The Binding]

    The binding maps are empty. See:

    upload_2021-4-9_11-58-16.png


    As a note, this step:

    Check that the Controller elements are actually returning some value.

    Debug Information -> Controllers -> [Controller Type] -> [The Controller] -> Axes
    Debug Information -> Controllers -> [Controller Type] -> [The Controller] -> Buttons

    With the fields open, click back into the game window and start using the joystick. Do the values in the inspector change for those axes? Do the values look to be the correct values? -1 to +1 for an axis. Are any axes returning non-zero value when you're not expecting them to?

    didn't work at all for me. All input attempts (buttons and axes) showed "Time Inactive" fields constantly updating and the values never changed from 0. This happened for both the DualShock 4 and the Xbox Wireless Controller. As I was playing with the inputs, they were properly being sent to the scripts as the game was responding to the input. The Debug UI never seemed to respond, however.

    Poking around a bit more, I have found that the Xbox Wireless Controller is not "Recognized" by Rewired:

    upload_2021-4-9_12-12-31.png

    Is there something I can do on my end here? Is this something that can/should be addressed in Rewired itself? (I assume that more and more people will start using Xbox Wireless Controllers as they're now the defacto controller sold by MS and other retailers. In addition, macOS 10.14 [Mojave] may be around for a bit longer as it's the last version of macOS to support 32bit apps...)


    Information returned by the JoystickElementIdentifier scene:

    upload_2021-4-9_12-23-16.png

    All buttons and axis reported as expected with this interface.


    I will further note that the "Xbox Wireless Controller" is not listed on the Supported Controllers list. That list shows two Xbox 360 controllers and two Xbox One controllers, but it does not list the Xbox Wireless Controller (which is the one Microsoft recently released for the Series X|S (and Windows 10, Android, and iOS, according to the box). Is this expected?


    * After looking into the Debug Information, I found that only the Sony DualShock 4 controller (which is also connected to my machine) was "assigned" to the player. I updated the maximum number of controllers assigned per player to 100 as per the Best Practices and the Xbox Wireless Controller was assigned as expected. What was surprising was that the right analog stick still affected the player even though the controller wasn't previously assigned. Assigning the controller also made no difference - the right analog stick continued to work as before (and no other buttons, also as before).
     
  49. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    There's no possibility the UI would not work and the scripts would unless Unity broke something in the inspector redraw function. The exact same code path is used to get the controller input in the UI as what feeds the Action values that your scripts are consuming. Did you click back in the Game window before you started pressing buttons as it instructs?

    All variants of the Xbox controller has been supported for a very long time. I always add support for new major revisions the moment they were released.

    The controller list doesn't show "Xbox Wireless Controller" because it's lumped into Xbox One and Xbox One S. I already added Xbox Wireless Controller (new Series S/X) support to the OSX Xbox One S controller definition. The Xbox One S controller when connected by bluetooth has always identified itself in hardware as "Xbox Wireless Controller" even though the retail marketing didn't use that name. Now they use that name in the marketing too. They are identical in terms of mappings and identifying information, so there is no reason to make a whole new controller definition for the slight variant and the new naming (and it would even be impossible to differentiate the two controllers by name alone, only by comparing product ids would you possibly be able to differentiate them, but that means I couldn't match on name and cover new product ids they release [or international variants] without explicitly having those product ids and adding them as discovered.) In looking at the definition comparing it to the information you are showing, I see exactly what I suspected in my last message: Microsoft changed something in the firmware. The controller I mapped with reported 17 buttons. Your controller is reporting 16 buttons. This is enough to break the controller definition. I will have to modify the controller definition for this new firmware.

    There is no code path that can possibly lead to an Action value being returned non-zero when 1) The controller is not assigned to the Player and 2) a Controller Map mapping that element is not present and enabled in the Player. The only possible explanation is your script that is controlling something with the right stick is not reading input from Rewired. (There is also the extremely remote possibility that the Mac driver is producing mouse input using the right stick and you have mapped something to mouse X/Y as it does that with some controllers.)
     
    Last edited: Apr 9, 2021
  50. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624