Search Unity

Rewired - Advanced Input for Unity

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

  1. ReaperGT

    ReaperGT

    Joined:
    Mar 15, 2017
    Posts:
    1
    Hi, I have two touch pads on my screen, one movement, the second rotation of the camera. One occupies the entire left side of the screen, the second the entire right. On the touch pad to rotate the camera, I use "Activate On Swipe In" so that when you swipe to the buttons, they are not activated, but the camera rotates. But when I start to swipe from the direction of movement towards the touch pad the camera turns. It turns out that they work at the same time. How can I make it so that "Activate On Swipe In" does not work from everything, but only from the selected objects of the interface? or How can I write custom "Activate On Swipe In" functionality?
     
    Last edited: Oct 23, 2021
  2. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Nobody has ever reported anything like this and I cannot even imagine any possible way this could happen based on code. It makes absolutely no sense. There is no connection between scene loading and any code in Control Mapper or Rewired at all.

    Pressing the Restore Defaults button is a synchronous operation. Nothing can inject a delay in this sequence of events. If something were to delay it, the entire game and the Unity editor would freeze because this is run on the main thread. There are no coroutines or anything else that could possibly delay its operation. The call stack goes like this:
    1. OnButtonActivated
    2. OnRestoreDefaults
    3. ShowRestoreDefaultsWindow
    4. OpenModal
    5. OpenWindow
    6. windowManager.OpenWindow
    7. InstantiateWindow
    8. windowManager.Focus(window)
    9. window.TakeInputFocus()
    10. DefocusOtherWindows(window.id)
    The initial event that calls OnButtonActivated is a Unity event called set in the Button's inspector. This calls OnButtonActivated directly using Unity's event system. This is the only possible place I can imagine any kind of delay being introduced. This is not supposed to be delayed, but I cannot control how Unity may implement their event system and if they introduced a bug, that would be very bad. However, I seriously doubt that's the cause.

    Is some other UI element you are creating blocking the visibility of the popup window? Did you reorder the object hierarchy that Control Mapper creates so that the popup windows are underneath the UI itself? Open the demo scenes and try the same thing. They will will work, and if they don't, then I would question whether something in Unity suddenly changed. Something somehow is corrupted in your project or your setup is doing something very differently that is causing this.
     
    Last edited: Oct 23, 2021
    kopanz likes this.
  3. kopanz

    kopanz

    Joined:
    Dec 6, 2016
    Posts:
    82
    All my main menu UI objects are children of the Control Mapper. Otherwise Control Mapper is not showing up. I tried to embed Control Mapper in my game interface. I'm inserting image of the object hierarchy below. MainPageGroup object is part of the Control Mapper. I moved it under my control settings object. There is nothing over Control Mapper controls, but changing the hierarchy might break things.
    controlMapper.JPG

    Thank you for your detailed response.
     
    Last edited: Oct 23, 2021
  4. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    The "Activate On Swipe In" on the Touch Pad does not affect how the Touch Buttons behave. They are separate controls with completely separate logic.

    If you don't want the buttons activating when swiped over, disable "Activate on Swipe In" on the buttons.

    You cannot make "Activate on Swipe In" smart and only activate under certain scenarios based on other controls. The control has no knowledge of any other controls on the canvas. Activate on Swipe In simply toggles whether the touch must be initially pressed over the control or not to capture the touch and activate.

    If you don't want both the Touch Pads to activate when you swipe your finger all the way across the screen, disable "Activate on Swipe In" on both Touch Pads.
     
  5. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    You could easily have broken something by reordering objects in the hierarchy. Something that should be visible over the other windows (the modal window), is probably hidden by something else now. What you see in the hierarchy in edit mode is not nearly all the objects. Control Mapper instantiates a ton of objects at runtime in specific containers within the hierarchy including windows like the one you're saying is not appearing. It's being hidden by something now. This will become apparent when you open the Control Mapper window at runtime and see many more objects, including the Fader object, then if you open a window, you will see it appear below Fader so the window is drawn over everything else.

    You shouldn't be nesting your game's UI into the Control Mapper hierarchy. There's no reason to do that. Control Mapper has its own Canvas. A scene can have as many Canvases as you want. Canvas render order is determined by the order of objects in the scene hierarchy. Canvases lower in the scene hierarchy render last.

    See the FAQ on modifying control mapper:
    "I want to customize more than what's available in the theme settings. How do I do that?"
    https://guavaman.com/projects/rewired/docs/ControlMapper.html#faq
     
    kopanz likes this.
  6. ScottySR

    ScottySR

    Joined:
    Sep 29, 2018
    Posts:
    49
  7. chris_nitrome

    chris_nitrome

    Joined:
    Nov 7, 2018
    Posts:
    9
    Hey there, I'm hitting the same problem and can confirm what other users are saying relating to the 2nd gen Siri Remote. It does seem to be configured wrong.

    When you click on the D-Pad in any direction, you get a Touchpad Click event, not a D-Pad event. (I guess ideally you would only get the Touchpad Click event if you are pressing the center region of the touch area.)

    (edit: I'm using Unity 2020.3.12f1, by the way)
     
    Last edited: Oct 25, 2021
  8. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    You will have to report it to Unity. Rewired is implemented UnityEngine.Input on iOS and tvOS. The bindings used for the specific controller archetypes is taken from Unity's own documentation showing the key mappings. Unity's documentation lists no specific support of the new Siri Remote. I cannot add support for this remote without Unity being able to 1) expose a different identifier for this remote so it can be differentiated from the other remote 2) expose the elements on this remote through UnityEngine.Input buttons and axes. It sounds to me like they have written the code to read the new controller elements and expose those. The only way to support this remote without getting the necessary underlying information from Unity would be to implement a whole native input solution on iOS and tvOS replacing UnityEngine.Input on these platforms.

    https://docs.unity3d.com/Manual/tvOS.html
    https://docs.unity3d.com/Manual/iphone-joystick.html
     
  9. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    The Controller Map is whatever Controller Map you are trying to change bindings on at the moment. Controller Maps exist in the Player.

    https://guavaman.com/projects/rewired/docs/HowTos.html#managing-controller-maps-runtime

    The examples listed in the link I posed above show you how use Input Mapper:

    Creating a controller mapping screen

    Examples:
     
    Last edited: Oct 25, 2021
  10. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Rewired 1.1.41.0 is available on the Unity Asset Store.

    Please see Updating Rewired before updating.

    Release Notes

    1.1.41.0:

    Changes:
    - Windows Standalone, Raw Input, Direct Input w/ Native Mouse/Keyboard Handling: Raw Input messages are now retrieved using GetRawInputBuffer method due to changes to Unity input in Unity 2021.2+ that breaks Rewired's Raw Input message handling due to their use of GetRawInputBuffer to eliminate massive frame rate drop from high refresh rate mice (4000-8000 Hz). Their change to GetRawInputBuffer, which consumes all the Raw Input events when called, makes it impossible for Rewired to continue to share mouse input events with Unity so both Unity's mouse input and Rewired's native mouse input work simultaneously.
    - Implemented Raw Input event forwarding to Unity through new Unity API exposed for this purpose in 2021.2.0. Bonus effect of this change is that Rewired can now be used alongside the new Unity Input System on Windows.

    Bug Fixes:
    - Null reference exception is no longer thrown when certain custom driver functions are called in Start or Awake (ex: DualShock4ControllerExtension.GetGyroscopeValue).
    - Unity Editor: Adding the Nintendo Switch Input Manager component using button on the Rewired Input Manager inspector now sets the GameObject dirty so the object gets saved correctly.
    - When first enabling the only Controller Map that binds a particular Action to the negative pole of an axis while currently holding that axis in a negative state with a value beyond the button activation threshold and querying that Action for its negative button down value will no longer return a down state.
     
    SugoiDev likes this.
  11. joonturbo

    joonturbo

    Joined:
    Jun 24, 2013
    Posts:
    77
    Is there a way to send "Fake" input from a c# script?
    I'd like to write some automated testing and it would be great if I can fire input events from a coroutine and have them be interpreted by Rewired.
    (Couldn't find it in the documentation)
     
  12. joonturbo

    joonturbo

    Joined:
    Jun 24, 2013
    Posts:
    77
    I just figured it out, you can use a Custom controller.
    Code (CSharp):
    1. Player player = ReInput.players.GetPlayer(0); // get the player
    2. var controller = player.controllers.GetControllerWithTag<CustomController>("main");
    3. controller.SetButtonValue("Menu", true);
    You'll need to set some stuff up in the Rewired editor > Players > Starting controller

    Spamming some keywords here so people might find it in the future:
    Faking inputs with Rewired for automated testing
    Sending inputs from c# code to rewired
     
  13. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    Just adding the Rewired documentation link for custom controllers.

    https://guavaman.com/projects/rewired/docs/CustomControllers.html
     
  14. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Yes, you found it. Custom Controllers are the only way to push your own values into the Player-Action system. It's been asked many times in this thread already, so spamming keywords probably won't help. I'll just add it to How To's.

    https://guavaman.com/projects/rewired/docs/HowTos.html#simulating-input
     
    Last edited: Oct 26, 2021
  15. ScottySR

    ScottySR

    Joined:
    Sep 29, 2018
    Posts:
    49
    Just one more step left. Rebinding works now, but I can't get it to load the saved data for some reason. I'm using ReInput.userDataStore.Save(); to save the data and I have "Load Data On Start" enabled in "UserDataStore_PlayerPrefs". I also tried using ReInput.userDataStore.Load();

    Is there anything else that might cause the save data not begin loaded?
     
  16. Lunzren

    Lunzren

    Joined:
    Jun 22, 2021
    Posts:
    7
    Does anyone have a good setup or tips for the touchpad? I have it on the right side of the screen and use it for the camera but when I try to use it the camera jitters up and down.


    I'm using rewired with the ultimate character controller and the latest integration.
     
    Last edited: Oct 26, 2021
  17. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Is the PlayerPrefs key prefix blank in the UserDataStore_PlayerPrefs inspector?

    There's nothing that could cause it to not save. I have never seen any situation where the data wouldn't save or load unless it's on one of the few platforms that do not support PlayerPrefs.

    Is the UserDataStore_PlayerPrefs component on the same GameObject as the Rewired Input Manager component?

    Look at the source code to functions that are being called:
    UserDataStore_PlayerPrefs.Save(); It grabs all the data from all the Players and Controllers and saves that to PlayerPrefs. Add logging here if you want to trace what's happening.

    UserDataStore_PlayerPrefs will load data on Awake. It even logs warnings to the editor console whenever XML data is loaded.

    The only possibility I can think of is the data is being loaded, but then it is immediately being overwritten by something else that's loading the defaults from the Rewired Input Manager. Do you have code calling player.controllers.maps.LoadDefaultMaps?

    Are you using Layout Manager? Did you disable the option "Load from User Data Store"? That would cause it to overwrite the loaded data using defaults.
     
  18. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    The Touch Pad settings you have to use would depend on what format Ultimate Character Controller expects this data to be in (pixel deltas like a mouse, absolute values like a joystick, etc.) The default Touch Pad Mode is delta.

    https://guavaman.com/projects/rewired/docs/TouchControls.html#touch-pad

    It would also depend on how the Custom Controller was set up for the touch controls. Is the Custom Controller axis that is being used for the Touch Pad set to Absolute or Relative (delta)?

    I don't know anything about Ultimate Character Controller or how the integration is setup because I didn't create it and I don't maintain it.
     
  19. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    Now Unity 2021.2 is out of beta. So I tried to update rewired on it and see the result... error

    Unable to update following assemblies:Assets/Rewired/Internal/Libraries/Runtime/UWP/IL2CPP/Rewired_Core.dll (Name = Rewired_Core, Error = 131) (Output: C:\Users\joaqu\AppData\Local\Temp\tmpa54f8c2.tmp)
    [AssemblyUpdater] Failed to resolve type 'System.Int32'
    System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentNullException: Value cannot be null.
    Parameter name: parameterType
    at Mono.Cecil.ParameterReference..ctor (System.String name, Mono.Cecil.TypeReference parameterType) [0x00010] in <a6860a9f6366437387ebdc1f225b7fd4>:0
    at Mono.Cecil.ParameterDefinition..ctor (System.String name, Mono.Cecil.ParameterAttributes attributes, Mono.Cecil.TypeReference parameterType) [0x0000b] in <a6860a9f6366437387ebdc1f225b7fd4>:0
     
  20. idibil

    idibil

    Joined:
    Oct 10, 2015
    Posts:
    24
    Hello guavaman,

    I would like to know if there is any way that the tutorial messages that the player receives with the key to click appear in their language.

    Right now it always appears in English.

    Code (CSharp):
    1.                 if (controller != null)
    2.             {
    3.                 switch (controller.type)
    4.                 {
    5.                     case ControllerType.Joystick:
    6.                         if (Rewiredplayer.controllers.maps.GetFirstElementMapWithAction(ControllerType.Joystick, "Sprint", skipDisabledMaps) != null)
    7.                             tempKey = Rewiredplayer.controllers.maps.GetFirstElementMapWithAction(ControllerType.Joystick, "Sprint", skipDisabledMaps).elementIdentifierName;
    8.                         break;
    9.                     case ControllerType.Keyboard:
    10.                     case ControllerType.Mouse:
    11.                         if (Rewiredplayer.controllers.maps.GetFirstElementMapWithAction(ControllerType.Keyboard, "Sprint", skipDisabledMaps) != null)
    12.                             tempKey = Rewiredplayer.controllers.maps.GetFirstElementMapWithAction(ControllerType.Keyboard, "Sprint", skipDisabledMaps).elementIdentifierName;
    13.                         if (Rewiredplayer.controllers.maps.GetFirstElementMapWithAction(ControllerType.Mouse, "Sprint", skipDisabledMaps) != null && string.IsNullOrEmpty(tempKey) == true)
    14.                             tempKey = Rewiredplayer.controllers.maps.GetFirstElementMapWithAction(ControllerType.Mouse, "Sprint", skipDisabledMaps).elementIdentifierName;
    15.                         break;
    16.                     default:
    17.                         tempKey = Rewiredplayer.controllers.maps.GetFirstElementMapWithAction("Sprint", skipDisabledMaps).elementIdentifierName;
    18.                         break;
    19.                 }
    20.             }
    21.             else
    22.             {
    23.                 tempKey = Rewiredplayer.controllers.maps.GetFirstElementMapWithAction("Sprint", skipDisabledMaps).elementIdentifierName;
    24.  
    25.             }
    26.  
    27.             completeText = "<color=#D94524>" + I2.Loc.ScriptLocalization.SCRIPTS.SpeedAceleration + "</color>\n\n" + "[<color=#8BCB16>" + tempKey.ToString() + "</color>].";
    28.  
    29.             completeText = completeText.ToUpper();
    The idea is that if tempKey leads to a keycode.space, it shows Space (English), Espacio (Spanish) etc...
     
  21. Lunzren

    Lunzren

    Joined:
    Jun 22, 2021
    Posts:
    7
    Yeah, I'm using the default touchpad mode delta. But I've tried them all and Delta is the only one with this jitter issue but it's also the only one that sort of works how I want. The custom controller's axis is set to absolute but I've tried relative and the problem is still there.
     
  22. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    This is a Unity error with their assembly updater. I can't affect anything about how their system works. You'll have to report it to Unity.

    I have tested with Rewired in Unity 2021.2.0b16 and it works. If it displays this error, it causes no issues.
     
  23. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    There is no localization system built into Rewired. You will have translate the items you want to translate and implement a localization system to translate them before they're displayed to the user.

    CSV files of elements for all controllers can be found here:
    https://guavaman.com/projects/rewired/docs/HowTos.html#display-glyph-for-action
     
    Last edited: Oct 27, 2021
  24. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    If the Custom Controller axis is being used for delta values, it should be set to Relative.

    Then the problem would either have to be:
    1) In the code that is consuming the input values to rotate the camera. If this code is multiplying the value by Time.deltaTime, then it is expecting absolute values and multiplying a delta value by Time.deltaTime will result in input response that changes with the frame rate.
    2) In the touch input returned by UnityEngine.Input.GetTouch.
     
    Lunzren likes this.
  25. ScottySR

    ScottySR

    Joined:
    Sep 29, 2018
    Posts:
    49
    Not sure why, but moving a manual call to Load() later in the execution seemed to fix the issue. Someone in the team may have put some code related to this somewhere and doesn't remember anymore that it exists. Have to find that later probably.

    Anyway, I got everything working how I wanted. Thank you for the help!
     
  26. marchall_box

    marchall_box

    Joined:
    Mar 28, 2013
    Posts:
    139
    Hi, does hit support PS5 controller?
    Haptic feedback and adaptive trigger for PC build and Editor?

    (It seems like Input System support PS5 with an additional assets https://github.com/nullkal/UniSense)
     
    Last edited: Oct 28, 2021
  27. idibil

    idibil

    Joined:
    Oct 10, 2015
    Posts:
    24
    Yes, I did this for the complete system, but in the mouse buttons and keyboard where the player can assign any key or button, this can be a hell haha.
     
  28. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
  29. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    ActionElementMap.elementIdentifierName returns a concatenated string of the element name plus modifiers (for keyboard) plus axis pole for split axes. It might be easier to do this concatenation yourself after translating each item individually. Controller Element names are obtained from the Element Identifier which is found in the Controller.Element.elementIdentifier. Pole bindings and modifier keys are found in the Action Element Map properties.
     
  30. _eternal

    _eternal

    Joined:
    Nov 25, 2014
    Posts:
    304
    Hey there. I'm setting up mouse navigation for menus, and I'm running into some trouble with duplicate clicks.

    When I click on a particular button, its onClick event is firing on mouse button down and on mouse button up. The mouse down call is coming from RewiredStandaloneInputModule.cs:830, and it's related to ISubmitHandler, while the mouse up is from RewiredStandaloneInputModule.cs:1091, related to IPointerClickHandle.

    Strangely, this only happens in one particular menu, and only with the Rewired input module.

    Any idea why the onClick event is firing on submit? From looking at the Unity input module, it seems that it should fire on mouseup by default. Indeed, if I remove the Submit action from the Rewired input module, the mouse works correctly by firing events only on buttonup - but then the keyboard doesn't work. Normally the keyboard events get fired on buttondown, and they stop working if I remove the submit action.
     
  31. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    https://guavaman.com/projects/rewired/docs/RewiredStandaloneInputModule.html#troubleshooting

    Problem: Receiving duplicate mouse clicks when clicking on a UI button

    Do not assign UI Submit or Cancel Actions to Mouse Left Button or Mouse Right Button or you will receive double-clicks evey time the mouse button is pressed over a button. The mouse button click on a UI element is based on mouse cursor position and does not use the Action system.
     
    _eternal likes this.
  32. nicbarkeragain

    nicbarkeragain

    Joined:
    Oct 12, 2019
    Posts:
    5
    Hello,
    I'm trying to get rewired working with a switch pro controller - I've created a very minimal project: standard 3D unity project, add rewired, run installer, add rewired input manager to scene. Checking the debug information the controller itself is recognised correctly but I can't see any input recognised for any button or joystick under the "Controllers" section for OSX or windows (all nputs show 0.0000 when pressing buttons and moving sticks), am I doing something obviously stupid? Do I need to do some configuration for things to appear in the device debug?

    Edit: definitely Steam doing something screwy. I have it temporarily working on my mac after opening and quitting steam, will do some more investigation.
     

    Attached Files:

    Last edited: Nov 1, 2021
  33. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    Steam can cause interesting results. Have you looked at this part of the Rewired documentation?

    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#steam
     
  34. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Nintendo Switch Pro Controller cannot be used via USB on desktop platforms:
    https://guavaman.com/projects/rewired/docs/SupportedControllers.html

    When Steam is open on MacOS it takes charge of input. On Windows, you must initialize Steam in your application for it to take over, but that's not the case on MacOS as far as I am aware. When Steam takes over input, it is fully in charge and no settings you change in Rewired will make any difference. Rewired is the consumer, Steam is the producer. If Steam sends no input, the application will get no input.
     
  35. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Rewired 1.1.41.1 is available on the Unity Asset Store.

    Please see Updating Rewired before updating.

    Release Notes:

    1.1.41.1:

    Changes:
    - Added warning to Rewired Input Manager editor to warn users to set Joystick Auto Assignment Max Joysticks Per Player to 100 if a single-player game because of how many developers ignore this setting are left with games that cannot be controlled if a virtual controller or another controller is connected to the system that takes priority other than the one the user is trying to use.

    Bug Fixes:
    - Unity 2021.2+, Windows Standalone, Raw Input, Direct Input w/ Native Mouse/Keyboard Handling: Fixed bug in new Raw Input event forwarding that could cause a multiple of the number of events to be forwarded to Unity if the number of events that were received during a frame exceeded 100. This could occur after execution was resumed from a breakpoint in a debugger due to mouse and keyboard input.
     
    Bartolomeus755 likes this.
  36. justalexi

    justalexi

    Joined:
    Aug 4, 2019
    Posts:
    12
    Hello guavaman,

    First of all, thanks for Rewired, it's been a pleasure to work with it.

    I have keyboard maps for "Default" and "UI" categories (same layout "Player1").
    Default map has "MoveHorizontal" action with keys "A" and "D" for negative and positive axis contributions.
    UI map has "UIHorizontal" action with the same keys.
    I'm using Input Mapper for remapping, and would like to remap simultaneously keys in both maps.

    The question is what is the best way to do so? Remap Default map (for example) with Input Mapper and if successful manually change mapping for the UI map?
     
  37. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    There is no designed way to synchronize remapping the same elements to different Actions on multiple Controller Maps simultaneously.

    I would question why you would even have separate UI and control maps if you want them to always stay synchronized. In that case, I would just get rid of the UI Actions and use the game Actions for controlling the UI. The reason the documentation advises you to have separate maps for UI is so they do not get remapped when changing game mappings, so you can always control the UI with a fixed set of controls. If the user wants to remap UI controls, they would do so separately from game Actions.
     
  38. justalexi

    justalexi

    Joined:
    Aug 4, 2019
    Posts:
    12
    Yes, a separate map for UI protects arrow keys, Return and Esc buttons from remapping. This way the user can't shoot off one's leg completely.

    My game Actions include MoveHorizontal, MoveVertical, Interact, Dash, Pause, Map and I wanted them
    1. to control the UI (so that keys for Interact and Dash Actions would also control UISubmit Action, keys for Pause and Map Actions -> UICancel Action, MoveHorizontal -> UIHorizontal, MoveVertical -> UIHorizontal);
    2. to be remappable.
    The idea was to allow the user to remap, for example, Dash Action, and automatically use the new key for UISubmit Action. Am I overthinking?
     
  39. Lunzren

    Lunzren

    Joined:
    Jun 22, 2021
    Posts:
    7
    I don't anything about coding but where could I find this?
     
  40. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    The requirement that either Interact or Dash be able to function as UISubmit is incompatible with your requirement that when Dash is remapped to a different key, UISubmit be remapped to the matching key. Unless Interact/Dash is one action. Since the RewiredStandaloneInputModule is based on and designed to be very similar to the StandaloneInputModule, only one Action can be assigned for each UI function, so it's not possible to assign two separate Actions (Interact and Dash) to both function as the OnSubmit function. A roundabout way to implement something that would be able to function this way would be to use a Custom Controller, create two buttons, map them both to the UISubmit Action, and then feed in the Action values of Interact and Dash. Note there would be a 1 frame delay in processing because Action values are calculated at the beginning of the frame.

    If there is a fixed 1:1 relationship between two Actions such that they must always remain mapped to the same element, there is no point in having 2 separate Actions. It just complicates things because you have to manually keep the element assignments in sync. Simply assigning Dash to the OnSubmit function works without any synchronization required.

    Protected controls are protected at the Controller Map level defined by the Map Category. The Actions on that map do not have to be part of an equivalent Action category. It is certainly possible to have a UI map category and assign game Actions to that map (Move Horizontal, Jump, etc.) and designate this map as protected.

    The only way to synchronize maps like you want to do is manually through scripting to analyze the bindings(s) of the source Actions and changing the bindings of the target Actions to match.
     
    Last edited: Nov 4, 2021
  41. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    In the Ultimate Character Controller C# script that is consuming the input.
     
  42. kopanz

    kopanz

    Joined:
    Dec 6, 2016
    Posts:
    82
    I want to assign multiple joysticks on a single player. Is it possible ? Control Mapper only allows to assign one.

    I'm a bit confused :)
    There should be a way, as the Thrustmaster has some models with wheel, shifter and pedals as separate devices and you have joystick maps(TH8A Shifter, T3PA Pedals) in Rewired for those devices.
     
    Last edited: Nov 5, 2021
  43. justalexi

    justalexi

    Joined:
    Aug 4, 2019
    Posts:
    12
    Thanks for the explanation! I'm sorry I can not understand the part about Custom Controller fully. I'll need some time to re-read about custom controllers and experiment with them a bit.

    I like your suggestion in the second paragraph (the simpler the better), and I've got an idea how to combine it with both Dash and Interact Actions. I'll post the results soon. Hopefully it will be possible to avoid manual syncronizing.
     
  44. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    The Custom Controller approach is not ideal and not recommended. It's just a possibility.
     
  45. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    https://guavaman.com/projects/rewired/docs/RewiredEditor.html#Settings

    If Joystick Auto-Assignment is enabled, Control Mapper respects what settings you have set there including Max Joysticks Per Player.
     
    kopanz likes this.
  46. kopanz

    kopanz

    Joined:
    Dec 6, 2016
    Posts:
    82
    I'm amazed that you considered every possible use while making this product. Also you have the best customer support in Asset Store :)
     
    guavaman likes this.
  47. justalexi

    justalexi

    Joined:
    Aug 4, 2019
    Posts:
    12
    The results are:
    1. I've modified RewiredStandaloneInputModule: added "dashAsSubmitActionId" and "interactAsSubmitActionId" next to "submitActionId". And added corresponding checks in all places where "submitActionId" was used.
    Then did the same trick with UI Actions for Cancel and Movement.

    2. The immutable arrow keys, Return and Esc buttons stay in the UI Map Category.

    3. Default Map Category contains all game controls including Dash and Interact, and they can be remapped as usual, but now they also pass the same checks as UISubmit Action.

    4. I'm using DoozyUI, and its UIButton, UIToggle, BackButton classes need to include Dash and Interact in their handling of Virtual Buttons.

    Thanks again for the help!
     
  48. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    I strongly suggest you copy the RewiredStandaloneInputModule, rename it, move it out of the Rewired folder, and replace the component on the GameObject with your new component. If you don't, the next time you update, your changes will be overwritten.
     
    justalexi likes this.
  49. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,644
    just updated to 2021.2 and latest rewired version. This line doesn't compile and I commented it out as the whole method is not used according rider. The error is about the Windows namespace not found.

    Code (CSharp):
    1.         public void WindowsStandalone_ForwardRawInput(System.IntPtr rawInputHeaderIndices, System.IntPtr rawInputDataIndices, uint indicesCount, System.IntPtr rawInputData, uint rawInputDataSize) {
    2. #if UNITY_2021_2_OR_NEWER
    3.          //   Rewired.Internal.Windows.Functions.ForwardRawInput(rawInputHeaderIndices, rawInputDataIndices, indicesCount, rawInputData, rawInputDataSize);
    4. #else
    5.             throw new System.NotImplementedException();
    6. #endif
    7.         }
     
  50. justalexi

    justalexi

    Joined:
    Aug 4, 2019
    Posts:
    12
    Yeah, I plan to. Thanks!