Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Rewired - Advanced Input for Unity

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

  1. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,578
    The exception is thrown by Play Maker's code which you can see by looking at the 2nd line:

    HutongGames.PlayMaker.Actions.UiOnSelectEvent.OnSelectDelegate (UnityEngine.EventSystems.BaseEventData data) (at Assets/PlayMaker/Actions/UI/EventSystem/UiOnSelectEvent.cs:31)

    They are trying to cast the event to some type that it cannot be cast to.
     
  2. Benji23245

    Benji23245

    Joined:
    May 7, 2020
    Posts:
    208
  3. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,578
  4. aaronflippo

    aaronflippo

    Joined:
    Jun 7, 2012
    Posts:
    43
    Wondering how to handle a specific situation with custom controller mapping. For background, we're using the Controller mapper prefab.

    Here's the situation:
    1. We setup some actions and controller/keyboard maps.
    2. We shipped a version of the game, and have lots of players.
    3. Now we added some *new* actions for cycling through menu tabs.

    What we're seeing is that the default bindings for these new actions aren't properly set to the default buttons/keys as defined in the rewired prefab. Instead, they're falling back to the first item in the controller map. If the user uses the "reset" option on the controller bindings, everything is reset to proper defaults.

    How can we add new individual actions without forcing the entire customized map to reset?
     
  5. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,578
    This scenario is not handled by UserDataStore_PlayerPrefs. It has very basic code to merge new Actions into saved Controller Maps at load time, provided there are no mapping conflicts with the new bindings, but this is very limited functionality.

    From the documentation (see last paragraph):

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

    Limitations:

    UserDataStore_PlayerPrefs is not the be-all, end-all, automatic data storage system. It has limitations. It does not fully automate everything so you can just set it and forget it. It provides an interface for you to save/load data as necessary for the needs of your game. This sometimes requires manual calls to functions to make data save or load at a particular time. Functionality beyond what is described above is up to the user to implement if desired. UserDataStore_PlayerPrefs is a minimum viable product designed for the most common use case needs and was primarily designed for Control Mapper.

    PlayerPrefs itself has significant limitations and negatives, for example, it isn't possible to clear only Rewired's save data from PlayerPrefs without wiping out all other PlayerPrefs data. If this is something you anticipate needing to do for whatever reason, do not use UserDataStore_PlayerPrefs and instead implement your own extension of the UserDataStore class that saves/loads data to whatever storage system you desire so you can have more control over how data is stored and managed.

    If you need to save which Controller Maps are currently assigned to a Player, for example if you've manually loaded an alternate layout at some point and you want that new layout to be loaded the next time you call UserDataStore.Load instead of the default defined in the Rewired Input Manager, you will have to make a new UserDataStore class extension that can handle these special needs. Copy the UserDataStore_PlayerPrefs, change the class name, and make any modifications necessary to what data is saved and loaded.

    IMPORTANT: Saved XML data is not updated when you make changes to the Rewired Input Manager

    UserDataStore does not manage changes between the Rewired Input Manager and data that is already saved to XML. If you make changes to the Rewired Input Manager settings such as adding new controls to a Joystick Map, these new changes will not be preserved when loading saved XML data. The only automated solutions would be to either clear the save data by clearing Player Prefs so that the Rewired Input Manager defaults are used instead or load the default maps in the Player for the any controllers that changed and save those to XML overwriting the existing saved mappings.

    Management of saved user data is up to the developer. If you have special needs beyond the basic use cases, you should extend and replace the UserDataStore_PlayerPrefs component with a new UserDataStore component that meets your specific needs.
     
  6. marcrem

    marcrem

    Joined:
    Oct 13, 2016
    Posts:
    340
    Hi, what do you guys suggest to handle an in-game chat where I want to disable every gameplay input when I'm typing in the chat, and re-enable it after?
     
  7. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,578
    Create a permission system. Your code should be in charge of whether or not input it receives is processed and used. The input system sending input should not be the sole determinant of whether or not user input actually does something in your game.

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

    Rewired’s Purpose and Responsibilities

    It is common for Rewired's Action system to be used in an unintended manner as an integral part of or in place of a separate game state management system. This is not what Rewired was designed for and not how it is intended to be used.

    • Rewired’s sole purpose is to read user input.
    • All “Actions” in Rewired are actually “Input Actions” and should not be used for any other purpose than to get information about the user’s intent. They should not be confused with or used as game states or actions.
    • The Action “Jump” does not designate “Player is jumping,” but rather “The user wants to jump.”
    • The game should implement permission and state management systems that evaluate user input and then change states. After that point, what happens is outside the responsibility of the input system.
     
  8. aaronflippo

    aaronflippo

    Joined:
    Jun 7, 2012
    Posts:
    43
    Ok just to follow up on this:
    I realize that the UserDataStore_PlayerPrefs system isn't meant to be an end-all-be-all solution and that there's a caveat in the documentation that it doesn't properly handle the case where new data is added to the Rewired system after the fact.
    However - UserDataStore_PlayerPrefs has a function called AddDefaultMappingsForNewActions which seems to be designed to handle just this case I mentioned. It just wasn't working properly.

    Upon digging into this a bit more, it looks like the API this function used to create an ElementMap was just silently assigning the wrong element index (0). I made the function work with this modification:

    Code (CSharp):
    1.  private void AddDefaultMappingsForNewActions(ControllerIdentifier controllerIdentifier, ControllerMap controllerMap, List<int> knownActionIds)
    2.     {
    3.         if (controllerMap == null || knownActionIds == null) return;
    4.         if (knownActionIds == null || knownActionIds.Count == 0) return;
    5.  
    6.         // Check for new Actions added to the default mappings that didn't exist when the Controller Map was saved
    7.  
    8.         // Load default map for comparison
    9.         ControllerMap defaultMap = ReInput.mapping.GetControllerMapInstance(controllerIdentifier, controllerMap.categoryId, controllerMap.layoutId);
    10.         if (defaultMap == null) return;
    11.  
    12.         // Find any new Action ids that didn't exist when the Controller Map was saved
    13.         List<int> unknownActionIds = new List<int>();
    14.         foreach (int id in m_allActionIds)
    15.         {
    16.             if (knownActionIds.Contains(id)) continue;
    17.             unknownActionIds.Add(id);
    18.         }
    19.  
    20.         if (unknownActionIds.Count == 0) return; // no new Action ids
    21.  
    22.         // Add all mappings in the default map for previously unknown Action ids
    23.         foreach (ActionElementMap aem in defaultMap.AllMaps)
    24.         {
    25.             if (!unknownActionIds.Contains(aem.actionId)) continue;
    26.  
    27.             // Skip this ActionElementMap if there's a conflict within the loaded map
    28.             if (controllerMap.DoesElementAssignmentConflict(aem)) continue;
    29.  
    30.        
    31.            //joystick version
    32.            if(controllerIdentifier.controllerType == ControllerType.Joystick)
    33.             {
    34.                 controllerMap.CreateElementMap(aem.actionId, aem.axisContribution, aem.elementIdentifierId, aem.elementType, aem.axisRange, aem.invert);
    35.             }
    36.            else
    37.             {
    38.                 controllerMap.CreateElementMap(aem.actionId, aem.axisContribution, aem.keyCode, aem.modifierKeyFlags);              
    39.             }
    40.        
    Hope it helps someone!
     
  9. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,578
    There's no difference in result of the code you posted and the original code.

    Code (csharp):
    1. controllerMap.CreateElementMap(assignment);
    This function results in the folllowing function calls:

    Code (csharp):
    1.  
    2. public bool CreateElementMap(ElementAssignment elementAssignment) {
    3.             if(ReInput._id != _reInputId) { ReInput.CheckInitialized(_reInputId); return false; }
    4.             ActionElementMap result;
    5.             return CreateElementMap(elementAssignment, out result);
    6.         }
    7.  
    8. public bool CreateElementMap(ElementAssignment elementAssignment, out ActionElementMap result) {
    9.             if(ReInput._id != _reInputId) { ReInput.CheckInitialized(_reInputId); result = null; return false; }
    10.             if(_controllerType == ControllerType.Keyboard) {
    11.                 return CreateElementMap(elementAssignment.actionId, elementAssignment.axisContribution, elementAssignment.keyboardKey, elementAssignment.modifierKeyFlags, out result);
    12.             } else if(_controllerType == ControllerType.Joystick || _controllerType == ControllerType.Mouse || _controllerType == ControllerType.Custom) {
    13.                 return CreateElementMap(elementAssignment.actionId, elementAssignment.axisContribution, elementAssignment.elementIdentifierId,
    14.                     TypeConverter.GetControllerElementType(elementAssignment.type), elementAssignment.axisRange, elementAssignment.invert, out result);
    15.             } else throw new System.NotImplementedException();
    16.         }
    You can see that the 2nd function deep simply does exactly what your code change does -- it calls a different overload of the CreateElementMap function based on the controller type passing the exact same values as in your version.

    An ActionElementMap's element index is determined from the Element Identifier Id and Axis Range values. Element index is not stored because it varies by platform and input source per-controller while the Element Identifier Id is constant across all platforms.

    For completeness, here is the constructor to ElementAssignment:

    Code (csharp):
    1. public ElementAssignment(
    2.             ControllerType controllerType,
    3.             ControllerElementType elementType,
    4.             int elementIdentifierId,
    5.             AxisRange axisRange,
    6.             KeyCode keyboardKey,
    7.             ModifierKeyFlags modifierKeyFlags,
    8.             int actionId,
    9.             Pole axisContribution,
    10.             bool invert
    11.         ) {
    12.             this.type = TypeConverter.GetElementAssignmentType(controllerType, elementType, axisRange);
    13.             this.elementIdentifierId = elementIdentifierId;
    14.             this.axisRange = axisRange;
    15.             this.keyboardKey = keyboardKey;
    16.             this.modifierKeyFlags = modifierKeyFlags;
    17.             this.actionId = actionId;
    18.             this.axisContribution = axisContribution;
    19.             this.invert = invert;
    20.             this.elementMapId = -1;
    21.         }
    Edit: I just tested the scenario of adding a new Action and a binding of that Action while loading a saved XML mapping and it works correctly with the existing code. The new binding must not conflict with any other mapping in the saved XML, and the new Action and new binding must have been created at the same time because the list of Action ids is stored in XML in order to be able to compare to the current Action ids to detect a change. If an Action id exists at the time the XML data is saved, even if that Action has not been bound to anything, then later that Action is bound to something and an update is pushed out, that Action is not detectable as a new Action and bindings to that Action that have been created since the XML data was saved will not be created.
     
    Last edited: Aug 7, 2023
  10. Benji23245

    Benji23245

    Joined:
    May 7, 2020
    Posts:
    208
    Hey thanks for answering !

    I can, and would rather, write code, but I'm not sure what to write though.
     
  11. Peeling

    Peeling

    Joined:
    Nov 10, 2013
    Posts:
    435
    Hi! We've successfully used Rewired to support the Logitech G29 steering wheel, both via explicit template support and generic steering wheel support. But one of out players has a G923, and that's not being detected.

    Strictly speaking, it IS being detected as a device, because his joypad is being picked up as Player 2, but it isn't hooking into the actions we've set up.

    I checked the documentation and the G923 isn't listed as supported. Is there anything we can do here to implement support? The player is willing to install beta builds and report back if there's something we can add to log out what Rewired thinks it is.

    Cheers!
     
  12. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,578
    You are going to find there are MANY controllers which are not recognized out of the box. The last wheel I added was probably 5 years ago. Any wheel that has come out since then is not going to be recognized. There are also many, many controllers that can never be recognized. That is why everywhere in the documentation developers are urged to provide a means to map their own controllers. As the documentation states, all controllers without a controller definition will recognized as an Unknown Controller..

    https://guavaman.com/projects/rewired/docs/SupportedControllers.html#controllers-without-definitions

    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.)
     
    Last edited: Aug 8, 2023
  13. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,578
    The link I sent you in my first response tells you what to do with links to further documentation and relevant functions for each step and even includes references the example project that has calibration fully implemented in code and acts as the documentation for this topic.

    https://guavaman.com/projects/rewired/docs/HowTos.html#calibrating-controller-axes

    Calibrating Joystick axes
    The general process of calibrating Joystick axes is as follows:
    1. Get the Joystick.
    2. Get the Calibration Map from the Joystick.
    3. Get the AxisCalibration for the Axis from the Calibration Map.
    4. Set the calibrated values in the AxisCalibration object.
    You can see an example of axis calibration in Rewired/Examples/ControlRemapping1.
     
  14. nekolyst

    nekolyst

    Joined:
    Mar 12, 2018
    Posts:
    23
    Hi! In the rewired standalone input module, I disable "move one element per axis press". But I found that wast too sensitive. When I just quick press button then navigation was move twice. How to avoid this issue?

    Furthermore, Is anyway can reach when I press and hold button, it will navigate to next selectable UI and wait about 0.5 sec. Then start to navigate through other selectable UI quickly?
     
  15. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,578
    The Rewired Standalone Input Module is a modified version of Unity's Input Module. It offers basically the same options the Standalone Input Module offers, with a few additions for Rewired-specific features.

    You will see the exact same settings of Input Actions Per Second and Repeat Delay on Unity's Input Module because the Rewired Standalone Input Module is copy-and-pasted from their code and works in the same way as theirs:
    https://docs.unity3d.com/Packages/com.unity.ugui@1.0/manual/script-StandaloneInputModule.html

    The option "Move One Element Per Axis Press" is new to Rewired and the only additional feature related to customization of how the UI reacts to input. There are no additional options beyond this one feature over the Unity Standalone Input Module.

    https://guavaman.com/projects/rewired/docs/RewiredStandaloneInputModule.html#inspector-options

    The two values to modify to customize this behavior are Input Actions Per Second and Repeat Delay.
     
    nekolyst likes this.
  16. nekolyst

    nekolyst

    Joined:
    Mar 12, 2018
    Posts:
    23
    Thanks! That solve my problem!

    I have another problem here. I want to detect whether user move the mouse. I can find debug information of mouse movement unger the Debug Information/Controllers/Mouse/Axes (4). But how can I acces from code like bool GetMouseHorizontal() and bool GetMouseVertical()? I tried find api under the ReInput.controllers.Mouse but didn't find relative method.
     
  17. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,578
    Mouse is a Controller, which has a list of buttons and axes. ReInput.controllers.Mouse.GetAxis(index) will get the value of the axis at a particular index. The horizontal axis is 0, the vertical axis is 1. The list of elements for the mouse can be found here:
    https://guavaman.com/projects/rewired/docs/HowTos.html#display-glyph-for-action-mouse

    You can also use Mouse.GetLastTimeActive if you only want to know the last time anything returned a non-zero value on the mouse.

    Or if this is to change something based on the last controller used, see this:
    https://guavaman.com/projects/rewired/docs/HowTos.html#last-used-controller
     
    nekolyst likes this.
  18. GrassWhooper

    GrassWhooper

    Joined:
    Mar 25, 2016
    Posts:
    103
    hey small question
    is it possible to figure out the name/type of the of last active controller?
    like, if i want to know, whether the joystick is an xbox one, or a playstation and so on, if that is possible
     
  19. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,578
    Last Active Controller:
    https://guavaman.com/projects/rewired/docs/HowTos.html#last-used-controller

    Controller Name:
    https://guavaman.com/projects/rewired/docs/api-reference/html/P_Rewired_Controller_name.htm

    If you're trying to identify a device type for something other than to display the name string to the user:
    https://guavaman.com/projects/rewired/docs/HowTos.html#identifying-recognized-controllers
     
  20. soniclinkerman

    soniclinkerman

    Joined:
    Feb 20, 2017
    Posts:
    9
    Hello,

    Is it possible to have a UI map and a Gameplay Map category share the same input(I want the UI to be controlled through arrow keys and the gameplay to allow for arrow keys as well) without reassigning the UI map category?

    I set the UI map "User Assignable" to false while leaving the Gameplay map to true. Furthermore, I went to the controller map GO and assigned these specific maps to allow for reassignment.

    By default Gameplay has arrow keys assigned. When I want to remap the gameplay map back to arrow keys, it says it can be reassigned. This makes me believe that it thinks I'm. trying to reassign the UI map for some reason.
    upload_2023-8-12_2-8-57.png
    Here's also a pic of my configuration
    upload_2023-8-12_2-13-19.png
    Keyboard Maps UI
    upload_2023-8-12_2-13-56.png
    Gameplay Maps UI
    upload_2023-8-12_2-14-7.png
     

    Attached Files:

  21. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,578
    soniclinkerman likes this.
  22. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,578
    A note regarding the recent Unity Asset Store sale in which Rewired was included:

    It has come to my attention that Rewired was recently on sale on the Unity Asset Store, being sold for 50% off for the first 7 days of August. I wanted to make it clear that I did not put Rewired on sale. This was a mistake by the Unity Asset Store. I only found out about it because someone at the Asset Store noticed and told me that they had mistakenly put it on sale. They removed it from the sale at my request and the issue has been resolved.

    Whenever I am asked the question about when Rewired will be on sale, I reply that I have no intention of ever putting Rewired on sale again (last time was 2015 or so), and that was and is still true. Rewired is already priced far lower than I consider reasonable for the ridiculous amount of time and effort I have and continue to put into it to developing, maintaining, and supporting it. I believe by letting people know it will likely never be on sale again, they can make their decision based on the value of the software alone and not feel cheated by it going on sale shortly after they bought it. I have always been of the opinion that having constant fire sales devalues products and services, with huge discounts on digital products being the norm these days.

    Rewired is a very support-heavy product. An increase in sales comes with an equal or even greater increase in support, especially because low sale prices tend to attract less experienced users who require more time to support. And supporting one user can be an ongoing process lasting years, spanning multiple games and new platforms. Because of this, the model of selling higher volumes at lower prices has never made any financial sense for this type of product. I learned that lesson very early on with 50% off sales in the first two years and decided then that I wouldn't participate further in the digital sale culture and simply sell it for a fixed price.

    Rewired won't be on sale again in the future unless the base price is greatly increased to compensate. 50% off the regular price of $45 results in a net revenue of $15.75 for the product, plus ongoing updates and support, which translates to a big net loss when time is considered.
     
    Last edited: Aug 12, 2023
    flashframe and Acissathar like this.
  23. marchall_box

    marchall_box

    Joined:
    Mar 28, 2013
    Posts:
    139
    Hello,

    It seems like DualSense Edge is not working. DualSense works perfectly but not the Edge. Is it getting a different hardware guid? I checked the list of guid sheet but DualSense Edge does not exist in the list.

    Does rewired not support DualSense Edge?
     
  24. Benji23245

    Benji23245

    Joined:
    May 7, 2020
    Posts:
    208
    Hey again guavaman,

    Sorry if I sound stupid, but I'm not sure where to find some informations that I need.
    So far I have this code :


    Code (CSharp):
    1.     Joystick joystick = player.controllers.GetController(ControllerType.Joystick, 0) as Joystick;
    2.     CalibrationMap calibrationMap = joystick.calibrationMap;
    3.     AxisCalibration axisCalibration = calibrationMap.GetAxis()
    I assumed the GetController method's id argument should be 0 as I currently only have 1 controller plugged. Is that right ?

    And then in the GetAxis method, what id should I pass for my X360 Left joystick ? And for my Right joystick ?

    Am I doing this right ?

    Thank you
     
  25. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,578
    The only explicitly supported controllers are those in the Supported Controllers list. DualSense Edge is not supported. I never even heard of it until your message.

    If a controller is not recognized, it will be treated as an Unknown Controller which can be supported by user mapping at runtime.
     
    Last edited: Aug 14, 2023
  26. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,578
    Controller id is not an index. See this:
    https://guavaman.com/projects/rewired/docs/BasicUsage.html

    "Id" is NOT an "Index"

    Anywhere the term Id is used in the API is a UNIQUE ID, not an Index, and cannot be used to iterate over items or get the first Joystick.

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

    See how to get a controller:
    https://guavaman.com/projects/rewired/docs/HowTos.html#get-controller

    You can loop through all controllers:
    ReInput.controllers.Controllers
    ReInput.controllers.Joysticks <---- THIS
    ReInput.controllers.CustomControllers

    You can't know this.Element axis index can and does vary by platform and input source in use for the device. While you could look up the axis index for the Element Identifier Id to find this at runtime for the specific controller, I don't recommend that approach. You shouldn't be trying to calibrate a specific controller in code. You don't know what controller the user might be using. You should create a UI where the user can calibrate their own controller no matter what it is. This is what both Control Mapper and the Rewired/Examples/ControlRemapping1 examples show. I suggest you try those examples and see how it is implemented in the UI to understand the process.

    Calibration is very specific to the actual device in use. If a controller has been used a lot and has wear, it may need different calibration than something newer. Hard coding a calibration for an Xbox controller will affect all Xbox controllers and would be an incorrect way to solve this problem. By giving the user a way to calibrate their axes, they should be able to use any controller and have it work properly.
     
    Last edited: Aug 14, 2023
  27. marchall_box

    marchall_box

    Joined:
    Mar 28, 2013
    Posts:
    139
    It's PlayStation Controller - https://direct.playstation.com/en-u...OyhV8vBkWMagQCn7iSsaAoW_EALw_wcB&gclsrc=aw.ds

    Released Jan, 2023, this is pretty similar controller to DualSense but I am not sure why its not working
     
  28. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,578
    Thanks. It isn't recognized because every controller that is explicitly supported must have identifying and mapping information manually added. It clearly does not share the same identifying information with the DualSense, otherwise it would be recognized. Beyond controller recognition, there is also the Enhanced Device Support feature which is runtime drivers I wrote for the DualShock 4 and DualSense. There is no guarantee this driver would work with this new controller and it clearly isn't even being chosen for the device due to differing identifying information.
     
  29. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    483
    Hey guys. Just started using Rewired and have a lot of my controller and keyboard mapped out. The one issue I'm having is "double-tapping". I have a double jump style sequence - when the character hits "Jump" twice in a row, they start flying. Not sure how to map that on the GamePad, or on the Keyboard for that matter.
     
    Last edited: Aug 16, 2023
  30. guidaye

    guidaye

    Joined:
    May 20, 2022
    Posts:
    15
    hi rewired support team, we've encountered the following error report quite frequently and have no idea where to start to fix it:
    [08/16/2023 06:13:17] <Error>: <RI> Failed to get input data:
    The handle is invalid.

    IsLtcEjlmIDOACtiscuUNOzUWwck:ZJplsqLKXbKtKLiTcasEjpkbEfptA(IntPtr, IntPtr, Int32, IntPtr, IntPtr)
    ygqqYrUgbMBMysFMHncMwTRYbZDn:qljSuTwhmOrHdpAaWfqlbGVaWwcS(IntPtr, UInt32, IntPtr, IntPtr)
    ygqqYrUgbMBMysFMHncMwTRYbZDn:imyxgKAChuFlTHFdSJEXxiBAIdSy(IntPtr, UInt32, IntPtr, IntPtr)
    evRETxWWZNOmJLFNoBKvwJQSgyOX:Invoke(IntPtr, UInt32, IntPtr, IntPtr)
    kIdnOEbrisCLHbkCfnbhxfTqmrseb:imyxgKAChuFlTHFdSJEXxiBAIdSy(IntPtr, UInt32, IntPtr, IntPtr)
    evRETxWWZNOmJLFNoBKvwJQSgyOX:Invoke(IntPtr, UInt32, IntPtr, IntPtr)
    JEPbCMfPeoYQPtIYvmdHGMXmVkPb:YFpAHXMrcFujryAefGARVcSwfRRo(IntPtr, UInt32, IntPtr, IntPtr)

    The error is collected from a error report system that was integrated by out client. can you please help up to locate the error and give up any hint on how to solve it.
     
  31. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,578
    First, it is not clear to me whether you're talking about a double-press or simply pressing Jump again at some point while the character is already jumping. In neither case would you map a Rewired Action to the Fly functionality.

    In the latter case, your code would simply check for "Jump" being pressed again while your character is already jumping and then change it to enter the Fly state. The decision to make the character start flying in response to input happens entirely your code and not the responsibility of the input system.

    In the former case, a double press is basically a gesture. You are watching for a specific series of inputs (button down, up, down) that must finish within a specific amount of time. Rewired is not a gesture system. It does not allow you to map Actions to sequences of inputs over time. It provides you the input itself, and if you want to then build a gesture system on top of that, you can. (A fighting game or something.)

    An extremely limited set of helper functions exist to get information for things like double click and timed press, but based on what you're describing, I don't think this would help in your situation:
    https://guavaman.com/projects/rewired/docs/HowTos.html#button-press-types

    Rewired's simplistic double-click handling cannot take into account all the possible scenarios that may be required for even a double-press gesture. For example, it is very common for gestures to be able to be interrupted by some in-game action that takes place or by pressing something else that would cancel it. Gestures also tend to require varying timing across the sequence. None of this is handled by Rewired's simplistic double-click or timed press functionality. Rewired is was not intended to provide gesture mapping capabilities.
     
    jnbbender likes this.
  32. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,578
    <Error>: <RI> Failed to get input data:
    The handle is invalid.

    Is an error from Unity, not Rewired. All Rewired logging is prefixed with the string "Rewired:". Anything that does not start with that string is not a message from Rewired.

    https://guavaman.com/projects/rewired/docs/KnownIssues.html#windows-ri-hid-error

    It is a virtual certainty that this stack trace has nothing to do with Rewired even though Rewired functions are in the stack trace. This is because Rewired has to forward Raw Input events back to Unity so that both input systems can consume input events. This causes Rewired to be in the stack simply because it receives the events first.

    In addition, the obfuscated stack trace isn't any help to me without the exact Rewired version (including Unity branch version) it came from. Regardless, I can see from all the IntPtr's in the function signatures that this is exactly what I thought and is showing the stack trace from the point Rewired receives the Raw Input message from Windows and then forwards it to Unity.
     
    Last edited: Aug 16, 2023
  33. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    483
    Is there a way to modify the sensitivity of each joystick axis independently?
     
  34. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,578
  35. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,578
    Open the Rewired/DevTools/JoystickElementIdentifier scene and press Play. It will display on-screen information for the default primary input source for the platform in question. Take a screenshot of this information and post it here. I'll look at it and see how the controller's identifying information compares to the Dual Sense. If there are other controllers attached, cycle through them with +/-..
     
  36. guidaye

    guidaye

    Joined:
    May 20, 2022
    Posts:
    15
    thanks for your replay and FYI we are working on Unity 2019.4.40f1 with rewired version 1.1.44.0.
    the link you provide reports an error like below:
    • <RI.Hid> Failed to create device file: 2 The system cannot find the file specified.
    which is different from what we have met, but not sure they occur one after another. I searched on the internet, but there is quite few messages related to my error.

    We haven't met this error in our development, I was wondering if this error could cause unity crash or some showstoppers for our game, or it's just an error report without any impact to our game/
     
  37. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,578
    I know the error in my link is not the exact same error text you reported, but the purpose of my sending the link was because of the other information it contains about this being a Unity error and not a Rewired error and that errors like this are common. It is related because both are messages are prefixed with <RI.Hid> which is presumably an internal Unity class related to Raw Input. You would have to contact Unity about this error if you want more information. I have seen and have had reported to me all manner of <RI.Hid> errors over the years. They do not have any impact on Rewired because they are Unity errors. Unity being unable to open a device would mean it wouldn't produce any input, but that would not affect Rewired as long as it is using native input.
     
  38. jmgek

    jmgek

    Joined:
    Dec 9, 2012
    Posts:
    96
    I can't seem to figure out why my ui nav is not working:
    I currently have my rewired input assigned to my canvas with the event system:

    upload_2023-8-17_17-8-34.png

    And I set the `FirstSelected` object in code and it doesn't select the elements in the scene. The Actions are also set with the keyboard and joystick

    upload_2023-8-17_17-9-6.png upload_2023-8-17_17-9-34.png


    1. What am I doing wrong?
    2. How do I handle multiple canvases?
     
  39. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,578
    You posted a picture of the Standalone Input Module which is disabled but the Rewired Standalone Input Module is out of frame. I can't tell anything from this image.

    You don't assign an Event System or Input Module to a Canvas. There should be one Event System in the scene. Input Modules must be on the same GameObject as the EventSystem component. The EventSystem sends UI events to all GameObjects on all Canvases.

    You should have an Event System GameObject somewhere in your scene and generally isn't attached to a Canvas. This game object should not be destroyed when a level is loaded. Either create a Game Object with an Event System and add the Rewired Standalone Input Module to it or create a Rewired Event System from the menu (it will just create a new Game Object with an Event System and a Rewired Standalone Input Module on it). Then configure the Rewired Standalone Input Module.

    Delete all other EventSystems in the scene. Having multiple EventSystems can cause lots of problems such as non-functioning UI input. In the rare case of needing multiple Event Systems, you must use either Unity's Multiplayer Event System or Rewired's Rewired Event System with properly configured settings on each. This is uncommon.

    Once you have set the Event System and Rewired Standalone Input Module configured, ensure a Game Object is selected in the Event System. This is required for keyboard / joystick navigation to work. If it still doesn't work, use Debug Information to debug input values.

    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#debug-information

    Almost all of the information above pertains to how to set up Unity UI and is not specific to Rewired.
     
    Last edited: Aug 18, 2023
  40. guidaye

    guidaye

    Joined:
    May 20, 2022
    Posts:
    15
    Thanks for you explanation, I think we should do something to mute this error report.
     
  41. GrassWhooper

    GrassWhooper

    Joined:
    Mar 25, 2016
    Posts:
    103
    hey, so GetAxisRaw, doesn't appear to be acting as it should? unless i am missing something, and if i am then sorry
    Code (CSharp):
    1.             if (testDirect)
    2.             {
    3.                 Debug.Log(player.GetAxisRaw("Vertical"));
    4.             }
    this is essentially my code, and if you look at the video, you can see that, when i use the controller, if i push up, then i get 0.1 or 0.5 or 0.8 or some float
    but i am using GetAxisRaw which i expected to give me 1 or 0 or -1?
    i feel like i am missing something essential but i thought i'd bring it to light

    unity 2022.3.7f1, windows 11 home, are what i use



    Edit: Note: Keyboard Works Fine, it goes from zero to one, to minus one.

    Edit 2:
    so based on this topic, it appears that Get AxisRaw, simply removes smoothing? and in case of joystick it returns whatever value it is, but in case of keyboard it is 0 or 1?

    Why is Input.GetAxisRaw() not returning whole numbers when using a joystick? - Questions & Answers - Unity Discussions

    well, i guess, even after 7 years of unity, i just learned that xD (if i guessed correctly did i?)
     
    Last edited: Aug 22, 2023
  42. marchall_box

    marchall_box

    Joined:
    Mar 28, 2013
    Posts:
    139
    Hello @guavaman , here is the screenshot you've requested.
    Thank you so much.
     

    Attached Files:

  43. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,578
    GetAxisRaw does not give binary values.

    Unity's GetAxisRaw is not the same as Rewired's GetAxisRaw.

    https://guavaman.com/projects/rewired/docs/api-reference/html/Overload_Rewired_Player_GetAxisRaw.htm

    Gets the raw axis value of an Action. The raw value excludes any digital axis simulation modification by the InputBehavior assigned to this Action. This raw value is modified by dead zone and axis calibration settings in the controller. To get truly raw values, you must get the raw value directly from the Controller element.

    Get AxisRaw will definitely give you floating point values for a joystick axis. A keyboard key will always be 0 or 1 because it is digital.
     
    GrassWhooper likes this.
  44. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,578
    The identifying information is different. While you may be able to just add the identifier and / or the Product Name to the Dual Sense definition on various platforms / input sources, it definitely won't work with Enhanced Device Support (vibration, IMU, etc.). To even test that would require internal code changes. I wouldn't be able to do that without a controller.
     
  45. unity_laJXQ-xENLvAgg

    unity_laJXQ-xENLvAgg

    Joined:
    Apr 1, 2021
    Posts:
    1
    I'm trying to identify specific controllers with Rewired and ran into a small roadblock.

    I'm using
    controller.hardwareTypeGuid
    with supposedly supported hardware, but the GUID it spits back isn't even on the spreadsheet for supported controllers and their GUIDs. The "Joystick reconnected" message doesn't match the controller either. Tested controller is a genuine 8BitDo SN30 NT(?).
    GUID
    ae4830f9-63db-4d4c-90b3-1beb46ecaf49

    Message
    ("Controller (XBOX 360 For Windows)")


    I suspect this is because 8BitDo offers different versions of the SN30 for the SNES Classic and for the original Super Nintendo/Super Famicom... is anybody able to confirm they have a different GUID?

    Edit: the plot thickens. It appears that the GUID above was wrong and the one it outputs is indeed just the xbox 360 GUID
    d74a350e-fe8b-4e9e-bbcd-efff16d34115
    .

    Could this be a driver issue instead?
     
    Last edited: Aug 23, 2023
  46. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,578
    The Joystick Connected message is from Unity, not Rewired.

    The controller is showing up as an XInput device. This is either because of using the XInput connection mode of the controller, a driver/software on your system, or Steam (see this) exposing the device through XInput.

    See these:
    https://guavaman.com/projects/rewired/docs/ControllerMaps.html#xinput-devices-windows
    https://guavaman.com/projects/rewired/docs/KnownIssues.html#xinput-device-name
     
    Last edited: Aug 26, 2023
  47. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,578
    Rewired 1.1.45.2 is available on the Unity Asset Store:

    Release Notes:

    1.1.45.2:

    Changes:
    - Windows Standalone, Raw Input: Raw Input events are no longer forwarded to Unity when application is paused or out of focus.
     
  48. manurocker95

    manurocker95

    Joined:
    Jun 14, 2016
    Posts:
    207
    I know it's been asked some time ago (and stated in the docs) but just to know if it's in the roadmap: Will there be any way to get input from different input values from different mice? Are there any plans to support that? As now they all work as if they were the same
     
  49. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,578
    There are no plans to add that feature.
     
  50. nekolyst

    nekolyst

    Joined:
    Mar 12, 2018
    Posts:
    23
    Hi, How to access the PointerEventData from RewiredEventSystem?
    In my case I want change "pointterPress" to null by script.