Search Unity

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:
    3,833
  2. IceBeamGames

    IceBeamGames

    Joined:
    Feb 9, 2014
    Posts:
    116
    Hey @guavaman

    I was wondering if I can do either of this things:
    • Find out through rewired if all of the mappable actions in the control mapper screen have been assigned? I want to prevent the player from leaving vital in-game controls without an assignment. I can see you can check if there is conflicts though the player conflictChecking function, but this doesn't apply.
    • Add the ability to SWAP conflicting controls. I tried to modify the OnElementAssignmentConflictReplaceConfirmed function to replace the old conflicted control map with the old button assignment but that seems to fail for some reason I cannot understand. Is there an easy way to do this? (I realise that you could have multiple conflicts, but I am going to modify the control mapper screen to prevent any controls being assigned to more than one element on the joystick.
    Thanks in advance.

    Tom.
     
  3. NitromeSteed

    NitromeSteed

    Joined:
    Jul 28, 2017
    Posts:
    15
    Hi. I've spent the past two hours trying to find out the code to detect if a gamepad is plugged in.

    I do not want to detect when a gamepad is connected - if the gamepad was connected before the game was started then then detecting this is pointless.

    I simply want to detect that a joystick is plugged in so I can display a different tutorial graphic. I've searched everywhere but there doesn't seem to be any straight forward method. I can't find anything in the documentation that doesn't over-complicate the issue. I can't check Unity's Input manager because apparently it's crap.

    I'm literally looking for something like: IsGamepadConnected(), and I can't find anything. At all. I assume the terminology I'm looking for is wrong.

    Can anyone tell me what I should be doing?
     
  4. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,833
    Not sure what you mean by this. There's nothing in the documentation that tells you how to do something in an over-complicated way. If there's a one-line way to do something, it will tell you that. If there isn't, there isn't and it will require more than one line to achieve.

    Some sections of the documentation show you various methods illustrating the API to work with some concept like Controller Templates meant to teach you the API so you can then use that API to achieve your specific goal. Other sections of the documentation are explicit "how to do this specific task" tutorials. There is no how-to tutorial on telling if a Gamepad is connected to the system, but the concepts shown in the examples would allow you to do that as well as many other things one would potentially want to do.

    Check the Controller Templates - Scripting documentation.

    It depends on if you want to know if a Gamepad is connected period or if you want to know if a Player has a Gamepad assigned.


    Code (csharp):
    1. // Check for a Gamepad connected to the system.
    2.  
    3. // Check the count of Gamepads
    4. if(ReInput.controllers.GetControllerTemplates<IGamepadTemplate>().Count > 0) {
    5.     // A gamepad is connected to the system.
    6. }
    7.  
    8. // Or you could check each Joystick for the Gamepad Template
    9. for(int i = 0; i < ReInput.controllers.joystickCount; i++) {
    10.     if(ReInput.controllers.Joysticks[i].ImplementsTemplate<IGamepadTemplate>()) {
    11.         // This is a Gamepad
    12.     }
    13. }
    Code (csharp):
    1. // Check for a Gamepad assigned to a Player
    2.  
    3. if(player.controllers.GetFirstControllerWithTemplate<IGamepadTemplate>() != null) {
    4.     // A gamepad is assigned to the Player.
    5. }

    All you have to do is check both on Awake/Start and in the Controller connected event like it says here or enable Deferred Controller Connected Events on Start and just use the event by itself:

    Code (csharp):
    1.     void Awake() {
    2.        ReInput.ControllerConnectedEvent += OnControllerConnected;
    3.  
    4.        // Check all joysticks that are already connected
    5.        for(int i = 0; i < ReInput.controllers.joystickCount; i++) {
    6.            if(ReInput.controllers.Joysticks[i].ImplementsTemplate<IGamepadTemplate>()) {
    7.                // Joystick is a Gamepad
    8.            }
    9.        }
    10.    }
    11.  
    12.    void OnControllerConnected(ControllerStatusChangedEventArgs args) {
    13.         if(ReInput.controllers.GetController(args.controllerType, args.controllerId).ImplementsTemplate<IGamepadTemplate>()) {
    14.             // Controller is a Gamepad
    15.         }
    16.     }
    17.  
    18.    void OnDestroy() {
    19.        ReInput.ControllerConnectedEvent -= OnControllerConnected;
    20.    }
     
    Last edited: May 22, 2018
  5. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    396
    Also, you can subscribe to ReInput.controllers.AddLastActiveControllerChangedDelegate() to know which controller type the player is currently using. We use this in our single player game to dynamically change onscreen text based on whether the player is using keyboard or controller or if they switch between the two.
     
  6. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,833
    No on both of these.

    #1 It would be a process of checking the assignments in the Controller Map against the Actions you are listing. This would vary depending on how you're listing the Actions because Control Mapper gives you several options on what to list. Assuming you're using an Action Category to list the Actions:

    Code (csharp):
    1. foreach(InputAction action in ReInput.mapping.ActionsInCategory(catId)) {
    2.     if(!controllerMap.ContainsAction(action.id)) {
    3.         Debug.Log(action.name + " is not bound to anything!");
    4.     }
    5. }
    I'd have to see your code to understand why it's failing.

    Swapping conflicting assignments is more complicated than it would first seem. You have to consider that the conflict could be any combination of button / axis assignment including split or full-axis assignments. Couple this with the fact that multiple conflicts can exist and it gets very complicated to make sure you don't end up with another conflict after the swap.
     
  7. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,833
    It's better to use Player.ControllerHelper.AddLastActiveControllerChangedDelegate since you only want to know what the last Controller the Player used. The ReInput method will tell you the last active controller regardless of whether or not it's assigned to a Player.
     
    flashframe likes this.
  8. PsyDev

    PsyDev

    Joined:
    Sep 30, 2015
    Posts:
    31
    Thanks for the reply, sorry I missed it. Looks like I'm not getting email notifications.

    1. Platform is PC.
    2. 1.1.12.2.U2017
    3. Primary input source for Windows is Raw Input.
    4. There is no 'Use Native Keyboard', but Native Keyboard Handling is ticked.
     
  9. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,833
    The rest of my previous message explains the scenario where GetInputDown will not return True on two successive frames if the key is down on both. This only happens when hammering a key repeatedly at very low frame rates. Is this what you're doing?

    I cannot reproduce any problem using your test code except when locking the frame rate very low (5-10 fps) and hammering a key. It will never miss a press in isolation.
     
    Last edited: May 22, 2018
  10. IceBeamGames

    IceBeamGames

    Joined:
    Feb 9, 2014
    Posts:
    116
    A terrible piece of code, but I was just trying to get it working...

    Code (CSharp):
    1.             // Find all of the original controls that use this button assignment
    2.             ElementAssignmentConflictCheck conflictCheck;
    3.             CreateConflictCheck(mapping, assignment, out conflictCheck);
    4.  
    5.             // Loop through all the conflicts found in the current player using this button assignment
    6.             foreach (ElementAssignmentConflictInfo conflict in currentPlayer.controllers.conflictChecking.ElementAssignmentConflicts(conflictCheck))
    7.             {
    8.                 // Contruct an assignment out of the confict and new assignment data
    9.                 ElementAssignment oldAssignment = new ElementAssignment(
    10.                     conflict.controllerType,
    11.                     conflict.elementType,
    12.                     conflict.elementIdentifierId,
    13.                     assignment.axisRange,
    14.                     conflict.keyCode,
    15.                     conflict.modifierKeyFlags,
    16.                     conflict.actionId,
    17.                     assignment.axisContribution,
    18.                     assignment.invert,
    19.                     conflict.elementMapId
    20.                 );
    21.  
    22.                 // Replace the first entry with the old assignment and then break out of the loop
    23.                 conflict.controllerMap.ReplaceOrCreateElementMap(oldAssignment);
    24.  
    25.                 break;
    26.             }
     
  11. IceBeamGames

    IceBeamGames

    Joined:
    Feb 9, 2014
    Posts:
    116
    Here is the control mapper category settings:

    control mapper options.jpg
     
  12. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    396
    Thanks! Will update to that :)
     
  13. PsyDev

    PsyDev

    Joined:
    Sep 30, 2015
    Posts:
    31
    It is true that is does not miss any presses in isolation. I encountered this problem in a button-mashing mechanic, so for sure hammering on a key as fast as possible. It does start dropping intermittent presses when mashing as soon as the frame rate drops below 30fps, and gets progressively worse with lower framerates. So it should not be an issue during release builds, but in our under-development, un-optimized levels running in the editor, the framerate does dip.
     
  14. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,833
    Doing this requires significant changes to the method. I really need to see the code for the entire method to see what you did wrong.

    The following is hackery because this doesn't consider all the changes required to make the UI ask the user if they actually want to do a swap instead of a replacement. This should be split into a separate OnElementAssignmentConflictSwapConfirmed method activated by a new button in the UI.

    EDIT: Code removed because of additional cross-mapping edge cases that were not handled. Working code can be found in new version of Control Mapper when it is released.
     
    Last edited: May 23, 2018
  15. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,833
    Thanks for explaining it. This is just an artifact of the way the Action system works in Rewired. Polling a device directly (UnityEngine.Input.GetKeyDown) isn't the same as an Action-based system so it really can't be directly compared. Rewired could not support returning True for GetButtonDown on successive frames during low frame rates without a sweeping rewrite of the low-level input systems on every platform, the mid-level Controller system, and the high-level Action system, rewriting them all to generate event queues (essentially all the requirements for framerate independent input). I've done this before in the past as an experiment and it just bogs down performance to an unacceptable level, especially on phones/tablets.
     
  16. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,833
    I posted the code to achieve what you want in my previous post. You are using the Action Category to list your Actions, so it will work.

    Code (csharp):
    1. foreach(InputAction action in ReInput.mapping.ActionsInCategory(catId)) {
    2.     if(!controllerMap.ContainsAction(action.id)) {
    3.         Debug.Log(action.name + " is not bound to anything!");
    4.     }
    5. }
     
  17. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,833
  18. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,833
    @IceBeamGames I have modified Control Mapper to make swap an option in the UI. If you want to use the new version before I submit an update (might not be for a while since there's nothing else added yet for the next version), contact me here or PM me.
     
  19. NitromeSteed

    NitromeSteed

    Joined:
    Jul 28, 2017
    Posts:
    15
    That depends on whether you know the Rewired library inside out. For you, all the terminology you've used makes sense because it's a system you made. For me: I search the docs for "gamepad connected" and all I found was stuff about detecting gamepad connection events. Things look very different when you're on the outside of a system looking in.

    Thank you for the solutions - but none of them work.

    It appears we are using an old installation of Rewired, there is no GamepadTemplate class. Rewired.Joystick has no ImplementsTemplate method. - We're using 1.1.12.2.U2017

    Updating Rewired might be catastrophic. We have just submitted the Switch version for Lotcheck. Updating input libraries means we have to spend days testing all of our inputs and connection events.

    If we defer the connection events, then we trigger the joycon applet when building for Switch. Having to toggle this every time we compile is going to lead to silly mistakes.

    Sorry if I seem ignorant because I haven't read the docs thoroughly, but I've been assigned this project after a developer left the company and I'm trying to fix all the bugs they left whilst meeting deadlines.
     
    Last edited: May 23, 2018
  20. NitromeSteed

    NitromeSteed

    Joined:
    Jul 28, 2017
    Posts:
    15
    So this seems to report 0 when I've not got my gamepad not plugged in and 1 when it is plugged in. This is regardless of whether the gamepad started plugged in or not.

    Code (CSharp):
    1. void Update() {
    2. Debug.Log("joysticks:"+m_Player.controllers.joystickCount);
    3. }
    Is there a reason I wouldn't want to use this? I could return true if the joystick count is above zero.

    It seems like a really simple check, but since no one suggested this I assume there is a fundamental problem with it, what is it?
     
  21. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,833
    The issue here is the version of Rewired you are using wasn't designed to categorize Joysticks as anything but Joysticks. The Controller Template system (which is explained in the Controller Maps documentaion) was designed to be a design-time-only system, not a runtime-accessible system. You were looking for a feature that did not exist. Controller Templates explained in the 1.1.12.2 documentation (prior to the addition of the runtime Controller Template system):

    -----------

    Controller Templates (Applies only to "Joysticks"):

    A Controller Template represents a generalized controller layout that matches a number of supported controllers. When you create a map for a Template, any controller that is included in the Template will inherit that map automatically without the need for you to create a map specifically for that controller. For example, Rewired comes with a Dual Analog Gamepad Template. When you create a map for this Dual Analog Gamepad Template, you do not need to create individual maps specifically for any of the gamepads listed on this page because they are all covered by the Dual Analog Gamepad Template. This makes is much quicker to create pre-defined controller maps for a huge variety of controllers. Additionally, as more controllers are added to the Template in the future, the map you've already created will work with these new controllers as well.

    If you have created a map in a Template but still want to make a map for a specific controller that is already part of the Template, just create the map for the specific controller and it will override the map defined in the Template.

    Controller Templates are only intended for developer use. Templates simply provide a shortcut to allow the developer to define mappings for many controllers at once without having to create invidual mappings for every supported device manually. Templates are not available to the end user for remapping purposes. When Controller Maps are loaded, they are converted from the Controller Template map to a native Controller Map for that specific device. The Controller Template no longer has any relationship to the runtime Controller Map that was loaded from it. The end-user cannot modify the developer-defined template mappings. If you were to display a list of element names on the controller for the user to map, it would not be a list of template element names, but rather it would be a list of named elements from that specific device.

    For information about which controllers are compatible with which templates, please see Supported Controllers.

    Dual Analog Gamepad Template:

    The Dual Analog Gamepad Template allows you to make a map which will cover all of the gamepads listed here.

    NOTE: Do not be confused and assume that the Dual Analog Gamepad Template will apply to and work with every gamepad in existence. The Template only applies to and works with recognized gamepads that have controller definitions. There is no possible way to create a system that can automatically recognize and map all gamepads, steering wheels, flight controllers, or any other type of device because the required information to do this simply does not exist in the USB or HID data provided by the device. Only devices that have controller definitions can work with the Template system.

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

    I tried to make it clear that Controller Templates were a mapping-time construct only. There was no such thing as a "Gamepad" device type in Rewired parlance. Joysticks do not have "types" like they do in some systems. The Template system was designed to cross-map from the generalized Template mapping to a device-specific mapping at load time and that is all. What you want to do -- determine if a "Gamepad" is connected -- was not a feature of Rewired until 1.1.13.0 until the run-time Controller Template system was added. After 1.1.13.0, any Joystick may be considered a Gamepad if it implements the IGamepadTemplate Controller Template.

    In 1.1.12.2, the only way you can possibly tell if a Joystick implements the Dual Analog Gamepad Template (as it was called in 1.1.12.2) at runtime is through hacks such as the following:

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections.Generic;
    3.  
    4. namespace Rewired {
    5.  
    6.     public class GamepadHack {
    7.  
    8.         private static System.Guid gamepadGUID = new System.Guid("83b427e4-086f-47f3-bb06-be266abd1ca5");
    9.         private static Rewired.InputManager inputManager;
    10.  
    11.         public static int gamepadCount {
    12.             get {
    13.                 int count = 0;
    14.                 if(!ReInput.isReady) return count;
    15.                 for(int i = 0; i < ReInput.controllers.joystickCount; i++) {
    16.                     if(IsJoystickAGamepad(ReInput.controllers.Joysticks[i])) count++;
    17.                 }
    18.                 return count;
    19.             }
    20.         }
    21.  
    22.         public static bool IsJoystickAGamepad(Joystick joystick) {
    23.             if(joystick == null) return false;
    24.             if(!Initialize()) return false;
    25.  
    26.             var hardwareMap = inputManager.dataFiles.GetHardwareJoystickMap(joystick.hardwareTypeGuid);
    27.             if(hardwareMap == null) return false;
    28.  
    29.             foreach(var guid in hardwareMap.TemplateGuids) {
    30.                 if(guid == joystick.hardwareTypeGuid) return true;
    31.             }
    32.  
    33.             return false;
    34.         }
    35.  
    36.         private static bool Initialize() {
    37.             if(inputManager != null) return true; // already initialized
    38.  
    39.             inputManager = Object.FindObjectOfType<Rewired.InputManager>();
    40.             if(inputManager == null) {
    41.                 Debug.LogError("Rewired Input Manager was not found in the scene.");
    42.                 return false;
    43.             }
    44.             return true;
    45.         }
    46.     }
    47. }
     
    Last edited: May 23, 2018
  22. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,833
    If you want to know how many Joysticks are assigned to the Player you can use that. It won't tell you how many Gamepads are assigned. If you plug in a Racing Wheel or a Flight Stick, it's still going to report 1. You can see this in use in the How To's - Assigning Joysticks to Players.

    If you want to know how many Joysticks are attached to the system, use ReInput.controllers.joystickCount. ReInput.controllers is listed as one of the Important Classes here.
     
    Last edited: May 23, 2018
  23. room710games

    room710games

    Joined:
    Oct 3, 2017
    Posts:
    7
    Hello,

    How do I restore to default a single key (not all of them) when I use InputMapper? I want to do this when player didn't press any button during listening.

    Thanks!
     
  24. emrys90

    emrys90

    Joined:
    Oct 14, 2013
    Posts:
    489
    How would you recommend having consistent mouse input across different pc's? We're trying to limit rotation speed in degrees per second, but so far I've been doing that by just clamping the mouse input. It doesn't work out too well though on pc's with different sensitivity/os settings.
     
  25. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,833
    There is no easy way to do what you want.
    • Everything is based on Controller Maps.
    • Controller Maps are loaded on start or when a Joystick is assigned to a Player based on the settings you have defined for that particular Player in the Rewired Input Manager -> Players page.
    • If bindings have been changed, the developer-defined starting Controller Maps are no longer relevant because now you have to load the bindings from saved XML data.
    • You can clear a Player's Controller Map and load the default from the Rewired Input Manager, but you cannot do this with a single binding from a Controller Map. The same is true for loading saved XML data.
    You'd also run into binding conflict problems trying to do this:
    1. By default, for this Player on this particular joystick, "Fire" is bound to A and "Jump" is bound to B.
    2. User rebinds "Fire" to button B.
    3. User rebinds "Jump" to button A.
    4. User decides to click "Fire" and wait without binding anything.
    5. Your system reloads the default of A for "Fire", now causing both "Fire" and "Jump" to be bound to A.
    6. You would have to do manual conflict checking before restoring your assignment.

    If the player presses nothing during listening, the recommended reaction would be simply to do nothing. Do not clear the binding so whatever it was beforehand is still the same. This is how all the Rewired examples work.

    The only way to do this would be to load an instance of the default Controller Map and manually find the binding you want to restore. This would not work if you want to use the user's last saved configuration from XML for the source. If you wanted to do that, you'd have to create a new Controller Map from the saved XML, find the binding, and then manually restore it. I don't recommend either of these.
     
  26. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,833
    I don't see any possible way you can do this without making mouse input feel awkward. You're trying to negate mouse speed settings from the operating system without even knowing what the current speed is. Any attempts to do this are going to feel like either terrible input lag or inaccuracy.

    The only way I can think of is by treating the mouse as a digital -1 / 0 / +1 value and adding some smoothing. That's exactly what changing Mouse XY Axis Mode to Digital Axis does on the Input Behavior settings. Depending on your use case, you probably aren't going to like the results.
     
    Last edited: May 24, 2018
  27. emrys90

    emrys90

    Joined:
    Oct 14, 2013
    Posts:
    489
    My boss linked me a video where CS:GO seems to have the ability to ignore the OS sensitivity setting.


    Do you know anything about this? It sounds like it would get it pretty close to something that would be acceptable, would it not?
     
  28. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,833
    That requires the system to be polling the device in a way on every OS that ignores the OS settings. Rewired only offers native mouse input on Windows, not OSX or Linux which use Unity's input system for the underlying input source for the mouse. Rewired's Raw Input implementation (Native Mouse Handling must be enabled and Primary Input Source must be Raw Input or Direct Input) uses Raw Input events for the mouse and Windows mouse pointer speed setting is already ignored.

    Inconsistencies in mouse feel across systems can also be attributed to the DPI setting of the mouse independent of the OS setting.
     
    Last edited: May 24, 2018
  29. emrys90

    emrys90

    Joined:
    Oct 14, 2013
    Posts:
    489
    We're currently Windows only. Is this the correct settings?
    upload_2018-5-24_12-7-20.png

    We've had these settings for a while, but I don't think it has been consistent on different machines.
     
  30. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,833
    Yes. As far as I am aware, there's only one way to get mouse events from Raw Input. Rewired uses the only method available to it to do so. The values you see from Rewired are the raw values from Raw Input multiplied by a constant value to make it match Unity's mouse output. Any other modification to the value would come from your Input Behavior settings for the Mouse XY axes.

    Are you using the same mouse on all systems? Are they all set to the same DPI?

    I have tested mouse values by setting Windows mouse sensitivity to 0 and max and compared the values reported by Rewried when moving a set distance across the screen. The results indicate that the values returned by Rewired ignore the mouse pointer speed setting in Windows.
     
  31. emrys90

    emrys90

    Joined:
    Oct 14, 2013
    Posts:
    489
    No, they probably have different mouses. No way every player has the same mouse. I also update it during FixedUpdate and multiply by Time.fixedDeltaTime, is that the correct way to go about it?
     
  32. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,833
    There's no way you can make different unknown mice with different DPI settings all feel the same. Each mouse is sending back different delta values depending on how far you move it and the hardware DPI setting.

    No. You should never multiply delta values by deltaTime. By doing so, you're making the final value change based on the current frame rate. (Though in the case of FixedUpdate, you wouldn't notice it changing since it always returns a fixed value for fixedDeltaTime.) Mouse axes always return delta values. Use Player.GetAxisCoordinateMode to determine the format currently returned by the Action.

    If you are getting input in FixedUpdate, make sure updating Rewired in Fixed Update is checked in the Rewired Input Manager -> Settings or else input values will only be updated every Update.
     
  33. emrys90

    emrys90

    Joined:
    Oct 14, 2013
    Posts:
    489
    I tried setting the Mouse XY Axis Mode to Digital Axis to try it out, and I'm getting values outside of -1 to 1 using rewiredPlayer.GetAxis2D. Am I doing something wrong?
     
  34. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,833
    What version of Rewired are you using?
     
  35. emrys90

    emrys90

    Joined:
    Oct 14, 2013
    Posts:
    489
    1.1.5.3.U5, it's been a while since I've updated.
     
  36. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,833
    Yeah, that's 9 months old. I can't realistically support such an old version of Rewired. So many bugs have been fixed since then. You need to update. You'll likely see the values show -1 to +1 after doing that because all my testing shows that to be the case on the current version.

    See Updating Rewired before updating.

    The only thing that could make it give values outside the -1 to +1 range is Mouse XY Axis Sensitivity, also in the Input Behavior. The option disappears when you change the mouse XY mode to Digital Axis. Change it back, set it to 1, and then set it back to Digital Axis. This setting should be ignored when the mode is Digital Axis.
     
    Last edited: May 24, 2018
  37. emrys90

    emrys90

    Joined:
    Oct 14, 2013
    Posts:
    489
    I just updated, and it's still returning the values outside the -1 to 1 range. The mouse sensitivity is set to 1.

    Also, on the control mapper, nothing seems to happen when I click the invert axis button. This didn't work for me before updating either though.
     
    Last edited: May 24, 2018
  38. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,833
    Have you modified the mouse sensitivity in Control Mapper? Saved XML data overrides your settings in the Rewired Input Manager. Use Debug Information to see the actual real-time values of everything in Rewired.

    Please explain what you mean by nothing seems to happen:
    1. Is the invert button greyed-out?
    2. Does it highlight when clicked?
    3. Are you referring to the final Action values returned and that they're not inverted?
    4. Is this the Mouse X/Y axis you're referring to?
    5. Is Digital Axis still the mode set for the Mouse XY Axis Mode?
     
  39. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,833
    @enrys90 Even with Mouse X/Y sensitivity set to 10, I still don't get values outside of the -1 to +1 range when the Input Behavior's Mouse XY Mode is set to Digital Axis. Therefore, I'm surmising that your Mouse XY Digital Axis mode setting is not being retained because you are using Control Mapper (which uses UserDataStore_PlayerPrefs by default and I didn't know you were using until your last post) and it is loading the saved XML data settings which are changing the Mouse XY Mode back to the default mode (look at the console in the editor -- it should notify you it's loading XML data). You will have to clear your PlayerPrefs to get it to reload the new settings from the Rewired Input Manager instead of the saved XML data. Either that or set it via scripting for testing purposes.

    (See UserDataStore - IMPORTANT: Saved XML data is not updated when you make changes to the Rewired Input Manager for an explanation.)
     
    Last edited: May 24, 2018
  40. emrys90

    emrys90

    Joined:
    Oct 14, 2013
    Posts:
    489
    Clearing player prefs fixed it being outside of range.

    The invert buttons are enabled, and hovering over them changes color. When I click one it appears to have no effect, it doesn't change color to show its toggled on, or anything.
     
  41. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,833
    What version of Unity are you using? This works in all versions I have ever tested including the newest 2018.2.0b5.

    Test the example in Rewired/Extras/ControlMapper/Examples. If the example works, then it's something in your scene.

    Did you modify any of the Control Mapper objects or code?
     
    Last edited: May 25, 2018
  42. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,833
    @emrys90 You are going to have to determine if this is a UI display issue or something else.

    1. Click the invert toggle on some Action.
    2. Open Debug Information and go to Players -> [Player #] -> Controller Maps -> [the Controller in question] -> Axis Maps -> [the Axis map you modified]. Look at the "Invert" value of the binding. Does it change when you toggle it? You can leave the Debug Information inspector open and toggle the invert field over and over and you should see the Invert value changing in the inspector in real-time.
    3. Go to the Scene panel with the game running, click the invert toggle in question and it will be selected in the scene hierarchy.
    4. In the scene hierarchy, open InputGridFieldInvertToggle(Clone) -> Background -> Checkmark.
    5. Look at the Image component in the inspector. What is the color in the Color field (black or white)?

    Nothing I know of could possibly prevent the invert toggle from modifying the binding's invert value short of a script running that changes it back.
     
    Last edited: May 24, 2018
  43. TheBlackBox

    TheBlackBox

    Joined:
    Jan 13, 2014
    Posts:
    33
    Hi,

    I've been working at implementing ReWired into my project - everything was going great until I attempted to add a second player.

    I am hoping to set a player up on KB&M controls whilst the other uses a controller.

    I have adapted the default Unity First Person Character script to work with ReWired but have ran into some issues related to the MouseLook.

    I have movement and other actions working independently for each different input, however the mouse still has some sort of priority over the analogue stick on the controller.

    The controller cannot use the right stick to rotate the view at all, whilst the mouse moves both of the cameras, despite me not assigning the mouse to the secondary player.

    I have attempted to manually assign KB&M as well as the controller via scripting to no avail, as the problem still persists.

    I'm kind of stumped, has this problem been reported before or could I have messed up my setup somehow?
     
  44. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,833
    This is definitely your setup. Rewired can easily work with any combination of controllers, keyboard, mouse, touch controllers, etc. all with multiple Players.

    Rewired will not generate any input whatsoever for a Player for a particular device unless:
    1. That device is assigned to that Player.
    2. Controller Maps for that device are loaded in that Player.

    You can easily see the values coming back from Players for each Action using Debug Information:
    http://guavaman.com/projects/rewired/docs/Troubleshooting.html#debug-information

    You can see in real-time the value for your mouse look Action. You can also see what controllers are assigned to each Player and the Controller Maps for each device with individual bindings.

    Doing this, I'm fairly confident that you'll find the value coming back from your Player without the mouse for the mouse-look Action is 0. That would mean the problem is in your scripts. Your scripts are likely not reading input correctly and/or not using the correct Rewired Player to read input.

    If you cannot figure it out, I will need to see the scripts that are moving your camera in order to tell you what is wrong.

    It definitely sounds like you're either reading input from the same Player for both cameras or you are not using Rewired at all and mouse-look input is still being read from UnityEngine.Input as in the original script.

    You will also need to modify your script to expect input from a joystick Axis which returns an absolute value, not the relative pixel-delta value of a mouse axis. You can't just use the same code for both types of input to move a camera. Read How To's - Handling Joystick and Mouse Axes.
     
  45. RealMTG

    RealMTG

    Joined:
    Jul 27, 2013
    Posts:
    239
    Hello!

    This has probably been asked before, but I don't really feel like sitting through 82 pages.
    Are action element identifier IDs consistent with every controller? Like, is 6 on an Xbox controller (A button) the 6 on a PS4 controller (X button)? I need to show glyphs using that ID and don't have any other controllers than an Xbox controller to test this with and want to make sure the layout is consistent.
     
  46. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    396
    There's a good page in the docs about this

    http://guavaman.com/projects/rewired/docs/HowTos.html#display-glyph-for-action

    You can download a CSV of the current control identifiers too.
     
    Last edited: May 30, 2018
    RealMTG and guavaman like this.
  47. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,833
    No, they are not. They may happen to coincide on those two controllers, but there is no guarantee that to be the case on others. As @flashframe stated, instructions on how to handle controller glyphs is in the docs here.
     
    Last edited: May 30, 2018
    RealMTG likes this.
  48. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,833
    Rewired 1.1.14.4 is now available for registered users. If you'd like to get access to early updates, contact me here.

    Please see Updating Rewired before updating.

    Release Notes:

    1.1.14.4:

    Changes:
    - Control Mapper: Added option to allow assignment swapping on conflicts.
    - Modified Rewired_Editor.dll for new method deprecations in Unity 2018.2.

    Controller Definitions:
    - Unknown, Nintendo Switch: Added mapping in case a controller is not recognized as a valid type. (This should never happen.)
    - Fantec Porsche 911 Turbo S: Changed display name to "Fantec Porsche 911 Wheel", all buttons renamed to "Button 1", "Button 2", etc. due to the fact that this definition applies to multiple Fantec Porsche wheels with different button mappings due to poor identifying information supplied by the devices. Added mappings for shifter.

    Bug Fixes:
    - Fixed compilation error in RewiredStandaloneInputModule.cs in Unity 4.x.
    - Fixed use of deprecated PS4 methods in Unity 2018 branch.
     
  49. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,833
  50. iamarugin

    iamarugin

    Joined:
    Dec 17, 2014
    Posts:
    173
    I see a section in Known Issues (Windows, .NET 4.6 experiemental backend: Application freezes on exit), where you said that this issue was reported to Unity. Could you privude a link to this report? And little note: net 4.6 is no longer experimental in Unity 2018.