Search Unity

Rewired - Advanced Input for Unity

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

  1. sfjohansson

    sfjohansson

    Joined:
    Mar 12, 2013
    Posts:
    369
    Hi Guys,
    Just added rewired to a project but it seems to stop working randomly and requires a restart of Unity in order to come back to life, any suggestions on how to fix this?

    I had the trial at first but bought the asset store version...using unity on Linux

    Cheers,

    Stefan
     
  2. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    I would wager the cause of the problem is not what you think and that Rewired isn't just no longer working.

    I suggest you go through these links and see if you can discover what is actually changing and why your input is no longer working:

    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#controller-doesnt-work
    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#debug-information
     
  3. seoyeon222222

    seoyeon222222

    Joined:
    Nov 18, 2020
    Posts:
    187
    Thank you for your detailed answer.
    It was very helpful!!!
    I think I understood the concept well. :)
    I see what's wrong.
    I made it again based on advice. As a result, it works as intended

    ----

    I have a another question about joystick scale.
    I'm trying to control the cinemachine with Rewired.
    Rewired CM Bridge has been set up.
    Both mouse and GamePad works normally. Good!

    The problem is the sensitivity of the joystick. (Scale)

    I checked the input value through Debug Information.
    For the Mouse, the value varies widely from -xxx to +xxx.
    For Joystick, the value is clamped in the range of -1 to +1.


    "https://forum.unity.com/posts/7525631/"
    The No.1 way of this answer is the problem I am currently experiencing.
    The Input Behavior joystick axis sensitivity multiply is not a solution for the reasons described in the answer.

    No. 2 answers are also not a solution.
    This is because the sensitivity of the stick should be different depending on the action.


    How do I apply this method if I use a cinemachine bridge?
    upload_2022-7-31_15-51-36.png

    upload_2022-7-31_15-50-50.png
     
  4. SatyPardus

    SatyPardus

    Joined:
    Oct 7, 2016
    Posts:
    7
    Hello!

    We recently switched to Rewired for our input system and encountered a issue today.
    When using a controller, the left and right trigger can't be used at the same time.
    They cancel each other out, resulting in 0 axis and no registered button press.

    This happens with a XBox 360 (wired) controller and an emulated Playstation 4 controller.
    We are currently using Unity 2021.3.2 with XInput disabled.
    Edit: Just found the reason for this on the troubleshot page above. Problem is, when using XInput we for some reason can't get the devices name. It always comes back as "XInput Gamepad", is there a way to read what controller it is with XInput enabled?


    We also tried porting the provided UserDataStore_PlayerPrefs to a Filebased system, instead of PlayerPrefs.
    This worked great, but we noticed that ControllerMap has a static function for loading XML, but not JSON. Is this intended? We had to use a workaround to port the PlayerPrefs version to a Filebased JSON system.


    And the last thing would be, getting the current name of a mapped button, based on the last active controller.
    We came up with a solution for it, but it's quite convoluted.
    Is there any way to easily request the currently bound keys for a controller based on the PlayerID, CategoryID, LayoutID and ActionID?


    Thank you!
     
    Last edited: Jul 31, 2022
  5. kburkhart84

    kburkhart84

    Joined:
    Apr 28, 2012
    Posts:
    910
    I'm no expert...but this seems to be exactly how it works by design. If using XInput devices without XInput(you get the bad shoulder button axes). As far as the names, I'm not sure if XInput exposes the actual names. You are probably going to have to live with this. And if it's me, I certainly prefer the full support of XInput over the names.
     
    guavaman likes this.
  6. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Everything you are describing is known, extensively documented, and caused by limitations of Microsoft's design.

    https://guavaman.com/projects/rewired/docs/ControllerMaps.html#xinput-devices-windows
    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#xbox360-triggers
    https://guavaman.com/projects/rewired/docs/KnownIssues.html#xinput-device-name
    https://guavaman.com/projects/rewired/docs/KnownIssues.html#windows-xinput-devices-use-x360-map
    https://guavaman.com/projects/rewired/docs/KnownIssues.html#more-than-4-xbox-controllers

    I don't remember if there was a reason I left it out or not. I created this function 6-7 years ago when making a hack to UserDataStore_PlayerPrefs. The function to create Controller Map outside the context of a Player was never safe for any other purpose, as Controller Maps are always invalid outside the context of a Player. The only reason it exists is because of the hack I had to implement in UserDataStore_PlayerPrefs at the request of users to attempt to, in some limited way, allow them you add Actions to their input design and have those new Action bindings on their default Controller Maps be reflected in already saved user-defined controller bindings. The function loads the data as a Controller Map, analyzes it, modifies it, then loads it into the Player. It was always a hack, and UserDataStore_PlayerPrefs was never intended to allow for manipulation and modification of the data already saved by the user. A much more robust design would be required to truly be able to manage all the possible requirements of managing saved user data as the input design changes around it. In an ideal design, the saved data would be manipulated directly, not loaded into a temporary Controller Map.

    The documentation covers both of these tasks:

    https://guavaman.com/projects/rewired/docs/HowTos.html#last-used-controller
    https://guavaman.com/projects/rewired/docs/HowTos.html#display-glyph-for-action
     
    Last edited: Jul 31, 2022
  7. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Hover your mouse pointer over the fields in the inspector.

    upload_2022-7-31_15-51-36 copy.png


    Absolute Axis Sensitivity
    The absolute sensitivity multipler. This is only applied to absolute axis sources (joystick axes, keyboard keys, etc.).

    Scale Absolute Axes To Screen
    If enabled, input values from absolute axis sources will be scaled based on the screen resolution. This makes joystick axes behave more consistently with mouse axes at different screen resolutions.

    Why would you want the incoming input value to be scaled differently based on the Action? The scale of input values should be consistent and the result of that input be scaled by the consumer of input (Cinemachine) if needed to adjust speeds of different actions.
     
    seoyeon222222 likes this.
  8. Hi_ImTemmy

    Hi_ImTemmy

    Joined:
    Jul 8, 2015
    Posts:
    174
    Hello there!

    Unity ver: 2021.3.2f1
    Rewired ver: 1.1.42.1.U2021

    I'm having a problem where the speed my camera moves is fine with the mouse, but is a lot slower with a joystick and I need it to go faster.

    In script, I'm using...
    player.GetAxis(<ACTION NAME>)

    ...to get both the vertical and horizontal axis to then move the camera.

    I thought increasing the Joystick Axis Sensitivity would be the ticket, but this doesn't seem to speed up the movement when using the joystick. Is there some other value I should be modifying to make the joystick able to move the camera faster, or is it a case I'll need to add my own sensitivity multiplier in code?

    Here's a little video showing the problem.
     
    Last edited: Jul 31, 2022
  9. seoyeon222222

    seoyeon222222

    Joined:
    Nov 18, 2020
    Posts:
    187

    I think it's a similar question to what I got answered right above.
    "absoluteToRelativeSensitivity"
    I used the cinemachine bridge component
    I wanted to do something similar to the playerMouse component.
    Fortunately, they all had "absoluteToRelativeSensitivity" properties.

    check
    https://guavaman.com/projects/rewir...roller_Axis_absoluteToRelativeSensitivity.htm

    Wouldn't the "absoluteToRelativeSensitivity" value be the solution?
     
  10. Simunek

    Simunek

    Joined:
    Jul 15, 2016
    Posts:
    49
  11. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Make a second binding for that Action. There is nothing more to it. There is no concept of "primary" and "secondary." Control Mapper is simply listing bindings in the order it sees them up to the limit set in the inspector options of number of columns to display.
     
  12. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    See this:
    https://guavaman.com/projects/rewired/docs/HowTos.html#relative-absolute-axes
     
    Hi_ImTemmy likes this.
  13. SatyPardus

    SatyPardus

    Joined:
    Oct 7, 2016
    Posts:
    7
    Thank you very much for the quick answer!
    So as far as I understand from this, using XInput is pretty much a must-do, cause otherwise driver limitations come up?
    If using XInput, any XInput Gamepad will be treated as a XBox 360 Controller as far as I read, does that include the hardeware guid too? Cause the Glyph example has a CSV of controllers with their names and their hardware id.
    Can I still lookup which specific controller it is when using XInput using that hardware id?


    Another question that came up was for the Keyboard.
    I already read in this forum that Rewired does not intend to implement international keyboard layouts.
    https://forum.unity.com/threads/rewired-advanced-input-for-unity.270693/page-164#post-8247489

    But in that post you are showcasing a code snippet of (I assume internal?) code, that would at least open up the possibility for identifying the keyboard layout.
    Is there any way to access that information? So that we could implement international key recognition outself?

    Thanks again!
     
  14. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Yes it does.

    https://guavaman.com/projects/rewired/docs/ControllerMaps.html#xinput-devices-windows

    Special Considerations for XInput gamepads on Windows Standalone, Windows App Store, and Windows 10 Universal:

    On Windows Standalone builds and in the Windows Unity Editor, when Use XInput is enabled, and always on Windows App Store and Windows 10 Universal builds, Rewired uses XInput for all XInput-compatible controllers instead of the chosen primary input source. This has some implications on creating Joystick Maps:

    When using XInput, Rewired has no way of determining the actual controller type because this information is not available through XInput. The only information Rewired has to identify the controller is that it is XInput-compatible. Therefore, all XInput devices are treated as "XBox 360 Controller". This means, with Use XInput enabled, if you plug in a XBox One Controller, Rewired cannot identify that it's an XBox One Controller and load the Joystick Maps you created specifically for the XBox One Controller. Instead, it identifies it simply as an "XInput Gamepad" and loads the Joystick Maps from the XBox 360 Controller maps you've created. This is an inherent limitation in XInput.

    But because Rewired has the Gamepad Template that is compatible with these controllers, it's easiest to just create a Gamepad Template Joystick Map instead and it will work for any XInput device when Use XInput is enabled. This way, you don't have to worry about making separate maps for XBox 360 Controller, XBox One Controller, etc. and everything will just work. This also works cross-platform.

    The glyph documentation is platform agnostic and therefore has to work for any platform and input source, including ones that can tell the difference between Xbox device types. It also has to work if the user has disabled XInput.

    No.

    No. Rewired does not expose any underlying platform-specific low-level information, except when necessary for console platforms to get things like console player ids and such.

    FYI, the contents of a ControllerMap.CreateFromJson function would simply be exactly this:

    Code (csharp):
    1. public static ControllerMap CreateFromJson(ControllerType controllerType, string jsonString) {
    2.             if (string.IsNullOrEmpty(jsonString)) return null;
    3.  
    4.             ControllerMap map;
    5.  
    6.             switch (controllerType) {
    7.                 case ControllerType.Keyboard:
    8.                     map = new KeyboardMap();
    9.                     break;
    10.                 case ControllerType.Mouse:
    11.                     map = new MouseMap();
    12.                     break;
    13.                 case ControllerType.Joystick:
    14.                     map = new JoystickMap();
    15.                     break;
    16.                 case ControllerType.Custom:
    17.                     map = new CustomControllerMap();
    18.                     break;
    19.                 default: throw new NotImplementedException();
    20.             }
    21.  
    22.             try {
    23.                 map.ImportJson(jsonString);
    24.                 return map;
    25.             } catch {
    26.                 return null;
    27.             }
    28.         }
    29.  
     
    Last edited: Aug 1, 2022
  15. sfjohansson

    sfjohansson

    Joined:
    Mar 12, 2013
    Posts:
    369
    Hi, thanks for your quick reply. What I can see is that the input manager debug stops displaying the joystick, and it seems to be very consistent. It only works the first time after launching the editor, you hit play...all good...then stop and the joystick is gone the next time you hit play. The setup is that I have a main scene onto which I load a GUI scene, the input manager is in the main scene, running unity on Linux with an Xbox 360 controller connected wirelessly.
     

    Attached Files:

  16. neur

    neur

    Joined:
    Oct 21, 2017
    Posts:
    1
    There is an issue with the dualsense controller, if you are using the controller's 3,5 jack for audio listening the audio gets muted after initializing rewired with the enhanced device support enabled (if it is disable, the issue it's gone) it only get fixed if you move the windows volume, this happens even after quitting the game in build or exiting play mode in editor, also if you change the light color of the bar.
     
  17. seoyeon222222

    seoyeon222222

    Joined:
    Nov 18, 2020
    Posts:
    187
    Is there a way to give PlayerMouse Cursor Interact Offset?
    here is example (Apex Legend)

    apex1.gif
    when using mouse (keyboard + mouse)
    Interactive with the UI at the correct point in the same way as the OS cursor.

    apex2.gif
    When using GamePad
    The range of interaction recognition is as wide as the offset area from the cursor point focus.

    upload_2022-8-1_21-21-51.png

    How can I do this using Rewired Standalone Input Module and PlayerMouse?
    or Is there any other good way to do this?
     
  18. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    798
    An easy way to do this would be to separate the cursor into

    a) interactive bounds
    b) visuals

    so you have control over the size of the interactive area.
     
  19. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    For completeness I have a few questions.

    (1) What Linux distribution and version are you using? (e.g. Ubuntu 20.04)
    (2) What Unity version are you using?
     
  20. ZurielA

    ZurielA

    Joined:
    Oct 19, 2021
    Posts:
    11
    Can someone clarify the new PS4 PS5 Switch controller support on 1.1.42 If I was using 1.1.41 and had all of these controllers working in Windows, will they fail to work on the new update? Do the plugins for these controllers affect the use in windows? I am not a Switch / Playstation dev and my game is purely on windows, but currently all of these controllers work.. (in windows). will I lose all access to those controllers with the 1.1.42 update? Would I have to register as a PS4/PS5 dev just to use the controllers in windows? Thanks!
     
  21. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    I cannot fix that. Enhanced device support requires initialization of the controller to make it switch into PS mode using low-level HID output report. Sending this report will reset the volume.
     
  22. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    There is a separation of responsibility between the matters related to the UI and Player Mouse / Rewired. Player Mouse does nothing whatsoever except provide a screen position that moves in response to various user input generated by Rewired. That is the end of its responsibility. It is not even responsible for the cursor image itself. It is only responsible for the screen position. What you do with that position is entirely up to you. If you want to move a cursor around using some UI system of your choice you can. And that means you are responsible for anything you want the cursor to do beyond that point, and what you do with that cursor is no longer dependent upon Rewired or any of its code or design. After that point, it's entirely a matter related to using Unity UI and Unity UI's design.

    The first example, it can be easily done by offsetting your cursor UI object in Unity UI. Create a child GameObject underneath the one you are moving with the pixel position output of Player Mouse. Put your cursor image on that child GameObject and offset the RectTransform to align the image's hotspot with the center of the parent transform.

    As for the second example with the large circle that activates the UI element anywhere it intersects the shape, that's again a problem of Unity UI and not Rewired. The Rewired Standalone Input Module is a modified version of the Unity Standalone Input Module and mirrors the capabilities and design of their system. They designed their UI mouse system to utilize a single point screen position and raycasting from that screen position to determine what UI object the cursor is over to then send events to that object on hover enter, hover exit, click, etc. Their system is designed around using a single point for this, not a shape. So what you want to do is not possible without rewriting the Pointer Input Module or by manually doing your own raycasting at various points around the shape to raycast, or by coming up with some entirely new system. Either way, it's a Unity UI design problem and not a function of or an issue with Rewired. As an input system, Rewired's only responsibility is input, not GUI.
     
    Last edited: Aug 2, 2022
  23. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Nothing has changed at all between 1.1.41.5 and 1.1.42.1 with regard to controllers in Windows. Console plugins have no impact whatsoever on support of devices in Windows or any other platform except their own.

    I suggest you investigate what is actually not working with these controllers and why. I very strongly suspect it's caused something else, and not simply the controllers not working anymore because of updating:

    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#controller-doesnt-work
    https://guavaman.com/projects/rewir...l#debug-information-diagnosing-input-problems
     
  24. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Rewired's Linux code has never been tested in the Unity Linux editor, nor is it written in any way specifically for the Unity editor, nor should it have to be. The last time any Linux code was changed was 2017.

    If there is some kind of problem preventing Rewired from detecting devices through UDev simply because the Unity editor was started, stopped, and started again, that would very likely indicate something going on at the Unity/Mono level. The exact same code is being executed each time you press Play. Each time you press Stop, Rewired is deinitialized completely. Rewired should get the same result each time from UDev when it initializes. If a controller no longer shows up, it is not. I don't have an explanation, and I am not at all confident it would be possible for me to discover some kind of workaround to get around whatever is causing this outside Rewired's code.
     
  25. ZurielA

    ZurielA

    Joined:
    Oct 19, 2021
    Posts:
    11
    Thanks for the info! I haven't updated yet because I just wanted to make sure windows was unaffected! but your answer clarified that. thanks!
     
  26. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    I see. I misread your message. I thought you said they stopped working. Thanks for clarifying.
     
  27. seoyeon222222

    seoyeon222222

    Joined:
    Nov 18, 2020
    Posts:
    187
    Question about AddLastActiveControllerChangedDelegate Method

    Keyboard or Mouse -> GamePad is well recognized.
    Switching to the mouse does not seem to be detected as intended.

    for example
    Control using the GamePad
    -> Move the mouse
    -> LastActiveControllerChanged not invoked
    -> Click the mouse
    -> LastActiveControllerChanged invoked

    Isn't mouse movement treated as Active Control?
    No matter what input comes in, I want to receive an event if the input from another device comes in.
    (purpose is to change the image of the cursor or UI, etc)

    Below is the code used
    Is there a better way?
    Did I use anything wrong?

    Code (CSharp):
    1.  
    2. private void OnEnable()
    3. {
    4.     _player.controllers.AddLastActiveControllerChangedDelegate(LastActiveControllerChanged);
    5. }
    6.  
    7. private void OnDisable()
    8. {
    9.     _player.controllers.RemoveLastActiveControllerChangedDelegate(LastActiveControllerChanged);
    10. }
    11.  
    12.  
    13. #region ---- Device Change Callback ----
    14.  
    15.     public UnityAction OnInputDeviceChange2GamePad       = delegate { };
    16.     public UnityAction OnInputDeviceChange2KeyboardMouse = delegate { };
    17.  
    18.     public Controller prevController = null;
    19.     private void LastActiveControllerChanged(Player p, Controller c)
    20.     {
    21.         if (prevController == null)
    22.         {
    23.             // 1. When First Init
    24.             prevController = c;
    25.             if (IsInputTypeGamePad(prevController.type))
    26.                 OnInputDeviceChange2GamePad.Invoke();
    27.             else
    28.                 OnInputDeviceChange2KeyboardMouse.Invoke();
    29.             return;
    30.         }
    31.        
    32.         var prevIsGamePad = IsInputTypeGamePad(prevController.type);
    33.         var lastIsGamePad = IsInputTypeGamePad(c.type);
    34.  
    35.         switch (prevIsGamePad)
    36.         {
    37.             case true when !lastIsGamePad:
    38.                 // 2. GamePad -> KeyboardMouse
    39.                 prevController = c;
    40.                 OnInputDeviceChange2KeyboardMouse.Invoke();
    41.                 break;
    42.             case false when lastIsGamePad:
    43.                 // 3. KeyboardMouse -> GamePad
    44.                 prevController = c;
    45.                 OnInputDeviceChange2GamePad.Invoke();
    46.                 break;
    47.         }
    48.     }
    49.  
    50.     private bool IsInputTypeGamePad(ControllerType t)
    51.     {
    52.         return t is not (ControllerType.Keyboard or ControllerType.Mouse);
    53.     }
    54.     #endregion
    55.  
     
  28. sfjohansson

    sfjohansson

    Joined:
    Mar 12, 2013
    Posts:
    369
    Yes, so I got ubuntu 20.04..as its officially supported and the unity version is 2021.3.4f1.
    Was at a developer meetup the other day and steam was mentioned as the possible culprit..and that seems to actually be the issue.
     
  29. sfjohansson

    sfjohansson

    Joined:
    Mar 12, 2013
    Posts:
    369
    Tested this again after steam was mentioned on a developer meetup, and yes it seems like if steam is running or has been running the device is only detected the first time around.

    I do initialize at least steam before rewired...
     
  30. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Oh. Then the reason this is happening is your Steam configuration.

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

    4. Understand the difference between running your game with Steam running and initialized and without

    When Steam is not initialized, the application may have access to entirely different information about controllers than when Steam has been initialized. This is due to their controller-configuration system. If you get different results when you test your game without Steam running than with it running, this is why.

    Before Steamworks is initialized (or if Steam is not running and you are testing in the Unity Editor):

    • Rewired receives ACTUAL information from the OS input APIs.
    • Rewired sees all devices visible to the system.
    After Steamworks is initialized:

    • Steam hooks the application so calls to OS input APIs are rerouted through Steam.
    • Rewired receives MODIFIED information from the input APIs.
    • Rewired cannot see the true devices connected to the system, only what Steam exposes to it.
    -----------------------

    Once Steam is initialized, it is initialized for the life of the application. That means the Unity editor.

    The first time you pressed Play, Steam had not yet been initialized, so Rewired was able to see the actual OS device information. The second time, Steam had already been initialized and it took over the OS's input APIs.

    Steam is hiding the device because of your configuration settings in Steam.

    https://guavaman.com/projects/rewir...tml#steam-configured-controllers-not-detected

    Steam Configured controllers are not detected

    Windows

      • What controllers appear to Rewired are entirely determined by what Steam allows Rewired to see. Steam hooks the Windows input APIs to change what controllers are visible to the application. This is done so they can support their Steam Controller Configuration, Steam Remote Play, controlling remapping, and other Steam controller emulation features. Steam is blocking Rewired from seeing these controllers.
      • Steam has 4 separate settings that determine how controllers are managed: The Steamworks developer backend settings for controller "configuration" for the application, the default developer-defined Steam Controller profile used by your application, the user client controller "configuration" settings, and the user Steam controller profile setting. These settings determine both what controllers Steam is allowed to “configure” and how those controllers appear to the application. (A "Steam-configured” controller is a controller that Steam has taken control over and has hidden the actual device from the application. It then creates a virtual device so the application can see only that virtual controller. This is how it handles things like button remapping and Steam Remote Play.)
      • All Steam-configured controllers now appear as Steam Controllers to the application and work based on the Steam Controller settings in Steam (developer defaults and/or end-user).
      • By default, with no Steam Controller profile to determine how a Steam Controller or a Steam-configured virtual controllers should behave, it defaults to behaving as a Keyboard + Mouse, and therefore Steam hides the devices from the application.
      • Set the Steam Controller profile to Gamepad to make these Steam Controllers appear as gamepads and your controllers will appear again to Rewired. Alternately, if "configuration" of the controller is disabled in the developer backend settings or the user's client controller configuration, the controllers will appear to Rewired without modification from Steam and Rewired will be able to get input directly from the system.
    Refer to the Steamworks documentation to understand how to configure controllers for your application.

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

    You should be initializing Steam before Rewired so you don't run into problems like this where Rewired ends up getting entirely different input information before or after Steam starts. (This also affects things when you unplug and replug a controller -- try it. Your controller will disappear and not come back because Steam initialized and now is hiding the device.) The advice to initialize Rewired first was changed many years ago when I understood better how Steam works.

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


    It is extremely difficult to have to be Steam support when I did not create Steam and I don't even use it. People are submitting confusing issues with symptoms that make no sense to me all the time that end up being caused by incorrect Steam configuration. What makes it all the more difficult is almost nobody mentions they're using Steam, just the symptoms of Rewired not working for no reason. If you hadn't mentioned it, I probably would never have thought of it, because of all the unknowns with the Unity Linux Editor, having never been tested by me, overshadowed any other theory. I was also not aware that these exact same problems that plague Windows input with Steam are present on Linux. These problems would be far more obvious in the Unity Editor than a build.

     
    Last edited: Aug 2, 2022
  31. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Read the documentation on this:
    https://guavaman.com/projects/rewired/docs/HowTos.html#last-used-controller

    Determining which Controller was last used
    You can determine which Controller or what type of Controller was last used system-wide or by an individual Player. One common use of this technique is to switch on-screen glyphs depending on whether the user is using a mouse/keyboard or a Joystick.

    Use the following methods:

    The ReInput methods will get the last active controller of all controllers regardless of whether or not it is assigned to a Player or any of the elements have been mapped. This is most useful for one-player games.

    The Player.controllers.GetLastActiveController method will get the last active controller used by that Player. Be aware that only mapped elements determine whether a Controller just became active. For example, if you're testing to see if the mouse is the last active controller, if nothing is mapped to the left mouse button and it is clicked, it will not be considered the last active controller in the Player.

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

    You are using the Player version of the event. This works on Actions. Actions only return value if a Controller Map is mapping some element to that Action. Clearly, your Mouse X/Y have no Action mapped to them, or they would be changing the last active controller.

    Use the non-Player version of the event if you want it to trigger when anything on the controller is pressed regardless of whether or not Actions are bound to it.
     
    seoyeon222222 likes this.
  32. SimuSkippy

    SimuSkippy

    Joined:
    Oct 3, 2016
    Posts:
    20
    I can't get mouse button 6 or 7 to work in the control mapper. Only seems to work up to mouse button 5. Is that a limitation of Rewired, or the control mapper, or am I missing a configuration somewhere?
     
  33. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Rewired only supports 7 mouse buttons because UnityEngine.Input only supports 7 mouse buttons and all platforms except Windows Standalone rely on UnityEngine.Input for all mouse input. Windows Standalone has the option of using native mouse support, but the limitation of 7 buttons still applies because the Mouse controller was designed around the limit of 7 buttons.
     
  34. SimuSkippy

    SimuSkippy

    Joined:
    Oct 3, 2016
    Posts:
    20
    Yep...I understand that limitation. But yet, mouse button 6 and mouse button 7 are not being recognized in the control mapper.
     
  35. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Whatever is causing it, it's not Control Mapper. Control Mapper is nothing more than a bunch of function calls to the rest of the Rewired API with a UI thrown in. Detecting button presses is the job of the polling API. The polling API listens to all buttons and axes on the controller in question. Control Mapper doesn't tell it how many buttons to listen for. It always listens to all elements on any device.

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

    Look at the values reported by the mouse controller's buttons live at runtime.

    What platform is this?

    If this is Windows Standalone and Native Mouse Handling is enabled and the last two buttons on the mouse are not showing any activity in Control Mapper, then that means those buttons are not being returned by Raw Input. Disable native input temporarily just to see what UnityEngine.Input is returning and I'll wager it's exactly the same (also uses Raw Input).
     
  36. SimuSkippy

    SimuSkippy

    Joined:
    Oct 3, 2016
    Posts:
    20
    It's Windows Standalone. I disabled native input and it does seem to behave the same.
     
  37. GoldFireStudios

    GoldFireStudios

    Joined:
    Nov 21, 2018
    Posts:
    160
    I know there have been questions about this in years past, but I was wondering if anything had changed on best practices of handling AZERTY, etc keyboards when developing from a US keyboard layout perspective. Is there any way for this to be handled automatically for the player (whether through Rewired or somehow in our own code) or is the only real option to require players to remap the keys through in-game settings? Main reason I'm wondering is it appears that the new Unity input system handles this automatically, but having not used it I'm not sure how accurate that really is.
     
  38. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    There have been no changes to Rewired's keyboard system. It is locked in. The design was based on UnityEngine.Input and even uses the Unity key code system for mapping keys. The whole API would have to be scrapped and redone from the ground up. I would also have to write native keyboard libraries for every platform Unity supports to do this, and attempt to develop some kind of physical-key-location based mapping or keyboard layout map system on each platform.. Every platform except Windows Standalone and Stadia use UnityEngine.Input for keyboard input. I have no plans to redesign Rewired's keyboard input system.

    I don't have any recommendations on how to handle keyboard localization. That's not a topic I have attempted to develop solutions for.
     
    Last edited: Aug 4, 2022
  39. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    It's possible these buttons on the mouse are using some other HID usage than button, or they are beyond index 6.
     
  40. Magnatales

    Magnatales

    Joined:
    Aug 1, 2020
    Posts:
    4
    Hello!

    I tried searching but couldn't find anything related to my issue.

    First of all, rewired is an amazing asset that's it!

    Okay so my question is simple, it is possible to make Rewired work with UI Toolkit? Default UI in Unity is the worst and I kinda wanna do this project with UI Toolkit, but controller is a must (no mouse) and I'm not sure if I can make the navigation work with Rewired.
     
  41. _eternal

    _eternal

    Joined:
    Nov 25, 2014
    Posts:
    304
    How do you obtain the plugin required for the Nintendo Switch?

    When I change my build target to the Switch, I see a popup saying that Rewired requires a special plugin to work on the Switch, and that I should download it from the Nintendo Developer Portal. But it doesn't say where to look in the dev portal, and the stickied thread in the portal's Input subforum tells us to contact you directly. It sounds like there's supposed to be a form to fill out to request the plugin.
     
  42. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Type Rewired in the search box on the Nintendo Developer portal. Register for the plugin on the registration page. I can't provide links or direct instructions because everything on the Nintendo Developer Portal is under NDA.
     
    _eternal likes this.
  43. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    I answered this on the previous page of this forum thread. See this post:
    https://forum.unity.com/threads/rewired-advanced-input-for-unity.270693/page-164#post-8276508
     
  44. sfjohansson

    sfjohansson

    Joined:
    Mar 12, 2013
    Posts:
    369
    Thanks for all the information regarding steam. At least I'm not getting blocked anymore from working as I simply can avoid starting steam when working on controllers/input. I have implemented if not all at least some of the steps, but no luck yet. But it feels like this could become a timesink and I'll let it be for now as the game works on the device.

    Thanks again for your quick responses! :)
     
  45. kopanz

    kopanz

    Joined:
    Dec 6, 2016
    Posts:
    82
    Is there an easy way to merge new actions mappings to old user data ?
    I mean when you add a new action, their mappings come as empty for all controllers.
    I want to fill those with default values.
    It's not possible to ask player to press "Restore Defaults" after connecting each controller they used in a Rewired enabled game before.
    They don't even look at Controller settings :D
    Also a force restore to defaults by scripts at once is even not enough. You have to Restore Defaults for each controller. It's impossible to track such things.
     
  46. guavaman

    guavaman

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

    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.

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

    Rewired does not managed already saved user data. If you want to do that, you have to do it manually yourself based on your needs. UserDataStore_PlayerPrefs already has a hacky system that will attempt to merge new Action mappings onto already saved maps, only put in place because of many user requests, but it's limited and basic and cannot handle many situations. It was never designed to do this task. Once user data is saved, it's outside the control of Rewired. By far the easiest way to handle changing your default input configuration after the fact is to simply clear all saved user data.
     
  47. Zilk

    Zilk

    Joined:
    May 10, 2014
    Posts:
    333
    Is there any way to use L3 and R3 on iOS MFI controllers yet? Seems to be supported in later OS versions but can't get it working in rewired.
     
  48. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
  49. RedVonix

    RedVonix

    Joined:
    Dec 13, 2011
    Posts:
    422
    Howdy! Love Rewired! Got a unique scenario however I'm a bit stuck on... In our game, we have a custom binding screen. It works great - EXCEPT if the player tried to use two kinds of gamepads (which in our setup, they can).

    So let's say the player binds Action to Button Y on am Xbox One gamepad. We want to, internally, also set the binding for a PlayStation 4 gamepad to the similar button (in this case, that would be Triangle).

    So my question is this: When a player binds an Action using InputMapper.Default.Start, and we receive the completion event - how can I then manually bind the Action that they bound to another controller that isn't plugged in, so that when the controller is plugged in it has the saved input value?

    In pseudo code it would be... (And yes this isn't real rewired code...)

    Controller otherController= Rewired.GetController(DualShock4)
    otherController.SetActionInput("Action", "Triangle")

    Thanks in advance!
     
  50. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    What you're trying to do is to save/load bindings based on a Controller Template rather than a specific Controller. That's described here:
    https://guavaman.com/projects/rewir...ving-and-loading-controller-template-mappings
     
    RedVonix likes this.