Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. 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. mbhagat

    mbhagat

    Joined:
    Dec 15, 2013
    Posts:
    49
     
  2. Slaktus

    Slaktus

    Joined:
    Dec 5, 2012
    Posts:
    58
    Hey, thanks for the prompt response.

    Found a workaround: Turns out that the bug only triggers when I connect controllers via the USB hub in my monitor. If I connect them directly to the motherboard's USB connectors, everything works as it should.
     
  3. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,608
    Do not give me attitude. If you think that's going to get you somewhere with me and that somehow that's going to make more helpful and you get better support, you're wrong. In fact, it will have exactly the opposite effect. I have no problem at all refusing support to people who disrespect me or push me around. You are not entitled to support. I give support voluntarily. There is no contract that states I owe you unlimited free support when you buy my product.

    I sent you that link because that is the single most important tool in the entire system for debugging problems. Even I have to use that tool to debug these problems. If you read the link, you would see there is a complete step by step checklist that walks you through the entire input stack of Controllers, Controller Maps, Players, Input Behaviors, and Actions.

    And for your information, all of your pictures in both posts are broken and do not display.

    a.png
    b.png


    Your explanations of the problem you are having is very poor. I do not even understand what your problem is. This is literally all the information I have:

    ...

    1st post:
    "We are facing issue of visibility of controller in live game.
    Many users have started reporting controls are not visible on their android devices.
    How to find out what is causing issue for certain android devices ?
    Rewired version used in game is 1.1.38.4"

    ...

    2nd post:
    "But many users are reporting they are facing issue because mobile touch pad is not visible at all."

    ...

    Those two bold lines are is literally the only information I have. I did not correctly understand what you meant by "Controls are not visible." Are you talking about Controllers not appearing to the system? As far as I knew, you were talking about Controllers, as in physical controllers. Only when you mention a touch pad in the second post... So now I have to infer from this that you're talking about on-screen Touch Controls. If you had stated this in your first question, I would have had more clue as to what you were talking about.

    Rewired isn't responsible for making Touch Controls visible or not. That's up to you. The Touch Controls are simply Unity UI objects. All of your Canvas settings, Canvas Scaler, other UI component involved, anchors, positions on the UI, etc., determine where/how they render. Rewired isn't in charge of this functionality. When you set up the Touch Controls, you also set up the Canvas, Canvas Scaler, and placed the objects in the scene, anchored them to some location on the canvas, etc. None of that is Rewired's responsibility. Rewired's responsibility is reading the touch and piping that into an Action. Display of these objects depends entirely on your scripts to enable or disable the GameObject and position them in the UI Canvas. You are going to have to debug all your code regarding the creation, enabling, and positioning of these GameObjects.

    All I can do is make wild guesses because I do not have your code. Did you implement some code that says "Hide the touch controls when a Joystick is connected?" There are Android devices out there that ALWAYS have a Joystick connected and exposed through UnityEngine.Input.GetJoystickNames. If your code does that, then the Touch Controls will never be visible on these devices because they have some driver that causes a joystick to appear when there is no physical joystick attached. Again, none of this is Rewired's responsibility, so if that's causing it, it is in your code.
     
    Last edited: Jun 23, 2021
  4. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,608
    There's no reason that a hub should change the information Rewired sees from a HID device. I can only guess the hub is broken.
     
  5. mbhagat

    mbhagat

    Joined:
    Dec 15, 2013
    Posts:
    49
    If it is live game and your customer facing problem then only you can understand
    Attitude ?
    Its you or me over acting and using attacking language ?
    Images were not uploaded from drive link so I posted again so you are still saying you can not see them ?

    You say that support is not your duty so please write it as first line on your asset and see how many sales are there after such line.

    You are over reacting and I never faced such issue with any kit maker or developer.
    My frustration is there because game is live and daily lots of 1 star are coming because of touch control visibility.
    Frustrated and not satisfied with your support.
    If you can not give support just proceed for refund and I will buy some other controller.
     
    Last edited: Jun 23, 2021
  6. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,608
    There isn't a single sentence where I used "attacking language." I did not attack you in any way. I am simply stating facts.

    I responded to your first post. If the response didn't solve your problem or pertain to your question or you could tell I misunderstood your question, you can explain that and explain your question again. It is never helpful to push someone you're asking to help you.

    I see the 3 images in the 3rd post now. They're just showing 3-word reviews with no more information about the problem. I have no context about your game and know nothing about it. These images wouldn't have helped me understand the problem any better, because I don't know anything about the game. I assumed the images would contain some screen shots of the game showing a problem you were having or some kind of screen shots of configuration settings.

    I bend over backwards every day to provide support to thousands of customers. I spend many, many hours supporting them individually and have done so for the last 7 years. I spent the entire day yesterday from morning to midnight on one single support issue for a customer. All anyone needs to do to understand how much time and effort I put into support is to look at this thread with over 7,300 posts. That said, this service is completely voluntary. I reserve the right to refuse service to anyone for any reason, just like any other business. I don't take to being pushed or insinuations of being lazy in providing support.

    I understand that. I also have to deal with customer issues in live games every single day across all platforms. Everyone has fires they have to put out.

    First, try explaining your problem clearly.
    Second, if you don't get the response you need, explain why it didn't resolve your issue and clarify the problem without insinuations or accusations.

    I've already told you everything I know about how to find the source of the problem. I told you where the problem is not -- Rewired is not controlling the visibility of these controls. I told you about permanent joysticks on Android. I told you that Rewired isn't what controls visibility of controls -- your scripts are. These are the things you need to find the cause and come up with a solution. There's no way I can solve this problem myself because I don't have anywhere near the information you do about your project.
     
    Last edited: Jun 23, 2021
  7. mbhagat

    mbhagat

    Joined:
    Dec 15, 2013
    Posts:
    49
    I am writing again in simplest form I can write to give you idea.
    I am using your controller plugin with UFE 2.3.
    I have five-six Android devices with me and touch pad appears fine in all and working. So after testing in all devices I have uploaded new version to play store. Game is 2 years old and daily 7k around downloads are there.
    After new version is released lots of complains start coming.
    "Touch pad is not visible."
    "Controls are not visible."
    I write same in my explanation .
    Touch pad is not displaying in some devices. What could be the reason ?
     
  8. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,608
    You shouldn't be using oldMap to set most of these values. You're setting the Element Type, Axis Range, and other properties by simply copying them from the old map. These should be set based on ControllerPollingInfo or information obtained from the input field itself as shown in all the examples.
     
  9. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,608
    Thanks for the detailed explanation. It is very helpful.

    >> I am using your controller plugin with UFE 2.3.

    This is critical information that I needed to know and completely changes the picture.

    This optional integration does indeed contain a script that has an option to hide touch controls based on whether a joystick is connected or not. This option is visible in the inspector of the Rewired UFE Input Manager. (Hide Touch Controls When Joysticks Connected) This is almost certainly what's causing the problem. At the time this was written, the "permanent joystick" issue on Android was not known, so the method used to show or hide the touch controls is flawed on Android. You could disable this inspector option and make the touch controls always visible, or you could come up with another way to determine whether to show the touch controls or not.

    This "easy" way to know whether or not to display the controls is flawed and won't work because of this Android bug/issue. In terms of the integration, I will have to think of a different way to approach this (watch for a joystick button press instead of the presence of a joystick to hide the controls?), but for now, the fastest solution would be to disable the option, make the controls always visible, then write a script that enables/disables the Touch Controls game object based on your criteria for when they should be shown / hidden.

    One potential approach would be:
    Make touch controls to appear by default and when the user touches anywhere on the screen.
    Make touch controls to disappear when the user presses a button or moves a stick on a physical controller.

    Rewired doesn't monitor the entire screen for touch, so you would have to use UnityEngine.Input.GetTouches to detect when the screen has been touched.

    As for controllers, the easiest way would probably be to monitor Controller.GetLastTimeActive on all controllers assigned to Player 0 and compare that timestamp to the time of the last touch detected. The most recent of the two would determine whether to show or hide the touch controls.

    I will look into either removing this inspector option or changing the way it works, but for now, the best solution will be for you to either write the script to handle enabling/disabling, or just make them always visible.
     
  10. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,608
    Try replacing the RewiredUFEInputManager.cs file with the attached in Rewired\Integration\UniversalFightingEngine2\Scripts.

    This makes changes to the script to constantly monitor touch input anywhere on the screen and input from all controllers assigned to Player 0. If a controller button press is detected, the touch controls will be hidden. If a touch is detected on the screen, the touch controls will be shown. Using a button press to detect the presence of a joystick is the safest option I can think of because I do not know if these phantom joysticks on Android are returning any non-zero axis values. If they do, then switching on either axis or button value to determine if the user wants to use the joystick would be dangerous, so it just uses button presses to determine this instead for safety.

    If you updated Unity, it's very likely the older version of Unity did not expose these phantom joysticks, but the new version does.
     

    Attached Files:

    Last edited: Jun 23, 2021
  11. mbhagat

    mbhagat

    Joined:
    Dec 15, 2013
    Posts:
    49
    Let me try and update you for the same.
    Thank You !
     
  12. n00b_013

    n00b_013

    Joined:
    Dec 20, 2020
    Posts:
    14

    Thank you very much for the quick response.. I have looked into your guides a lot and still am unable to get it working..

    For your info: I'm using the Edy's Vehicle Physics Pro as car engine.. Uncommenting lines 22 to 26 makes my car move forward, backward and steering. So I tried to replicate this using the Rewired add-on and matching the code on it..

    As can be seen in the console, both horizontal and vertical inputs are being received, but when using the player.GetAxis:

    Code (CSharp):
    1.  
    2.         float horizontalInput = player.GetAxis("Horizontal") * gamepadInput;
    3.         Debug.Log("Steering: " + horizontalInput);
    4.  
    5.         float verticalInput = player.GetAxis("Vertical") * gamepadInput;
    6.         Debug.Log("Acceleration: " + verticalInput);
    It's not moving the car/steering wheels.

    Code (CSharp):
    1.        
    2. float horizontalInput = Input.GetAxis("Horizontal") * gamepadInput;
    3. Debug.Log("Steering: " + horizontalInput);
    4.  
    5. float verticalInput = Input.GetAxis("Vertical") * gamepadInput;
    6. Debug.Log("Acceleration: " + verticalInput);
    7.  
    When using the basic input from Unity, it is driving.. But i want to use the features of Rewired, to be able to connect more input devices.. Can you assist before I buy this add-on.

    Anyone has experience getting Rewired to work with Edy's VPP ?
     

    Attached Files:

    • VPP.JPG
      VPP.JPG
      File size:
      141.4 KB
      Views:
      299
  13. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,608
    Please post the entire script.

    What value is logged by Debug.Log for Steering and Acceleration when you use Rewired?

    Did you attempt to debug this using Debug Information?:
    https://guavaman.com/projects/rewir...l#debug-information-diagnosing-input-problems

    Go through that checklist and answer each of the questions.
     
  14. Blitz54

    Blitz54

    Joined:
    Dec 20, 2020
    Posts:
    20
    Hello! I just installed Rewired with the latest 2021 Unity. However, I'm a Bolt user, and I can't seem to get the Input Event nodes to appear when using 2021 Visual Scripting. I can add everything to the Visual Scripting nodes and types like in the Documentation on the Rewired site, but nothing seems to work.

    Sorry if this has been brought up before, I searched for a while but not many people seem to use visual scripting. But I am a dumby, and require it for now.
     
  15. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,608
    The Rewired Bolt Integration package was not designed for nor tested with Unity Visual Scripting. I do not know if it works, but I would strongly suspect it doesn't as its unlikely they haven't made any major code changes since the transition from Bolt to Visual Scripting.

    https://guavaman.com/projects/rewired/docs/Integration.html#Bolt

    Requirements:
    • Bolt 1.4.0f11. (No future version compatibility is guaranteed due to frequent breaking changes in Bolt.)
    I suggest you use the polling actions instead of events.
     
  16. little_box

    little_box

    Joined:
    Aug 22, 2017
    Posts:
    28
    Hi. guavaman.
    I have a problem. My rewired joystick map and keyboard map settings are as follows.
    https://imgur.com/a/TydXtxh
    https://imgur.com/a/xNPnQTm
    When I press J key in the editor, the 'select' action is triggered. If I build to OSX, it executes fine. But if I build to PC, I press J key and then no action is triggered, I have to press space key to trigger the select action. Is there something wrong with my setting?
     
  17. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,608
    Keyboard maps are handled exactly the same on all platforms. The same keyboard maps are generated for Windows and Mac from the same Rewired Input Manager data.

    You probably have outdated saved mapping data that is being loaded in the build:
    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#works-in-editor-not-in-build

    As always, use Debug Information to see exactly what's happening at runtime:
    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#debug-information
     
  18. little_box

    little_box

    Joined:
    Aug 22, 2017
    Posts:
    28
    The problem was fixed. It is due to outdated saved mapping data. I use PlayerPrefs.deleteAll to solved this problem.
     
  19. Blitz54

    Blitz54

    Joined:
    Dec 20, 2020
    Posts:
    20
    Thanks for the quick response. The 2021 visual scripting is a little buggy in general for me anyway, so for now I'll just use 2020 with Bolt and Rewired. I did try importing Bolt into 2021 which worked, but still couldn't get the events to show up.

    Thanks! My favourite part of any project is getting Rewired set up.
     
  20. KarlKarl2000

    KarlKarl2000

    Joined:
    Jan 25, 2016
    Posts:
    606
    Hi @guavaman
    Is it possible to release the input of the controller via script? In certain instances I'd like to force release the player's input, even if they are holding down a button \ axis.

    Similar to Unity's Input.ResetInputAxes
    https://docs.unity3d.com/ScriptReference/Input.ResetInputAxes.html
    https://answers.unity.com/questions/1373613/resetinputaxes-not-resetting-axes-only-buttons.html

    I wasn't able to find much on Google, just this from the Rewired API references, but this sounds like something else. :eek:
    https://guavaman.com/projects/rewired/docs/api-reference/html/M_Rewired_ReInput_Reset.htm

    Thanks for your continued support on this great application!
     
  21. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,608
    Did you install the Bolt integration? If it didn't work anymore due to some kind of breaking change in the Bolt code, I would expect to see some kind of compiler error.
     
    Last edited: Jul 1, 2021
  22. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,608
    No. Action values cannot be set by anything but Controllers and Custom Controllers. Action values are calculated from the total of all Controller elements contributing input to the Action.

    Being able to clear Action or controller values would cause problems with event-based input APIs. (You clear it, some axis like a lever on a flight controller previously returning 1 in its position now returns 0, no new events are ever received until the user manually moves it. One of many examples, and one that does affect Unity when using that function. Same goes for always-on buttons like switches and dials.)

    See this related topic:.
    https://guavaman.com/projects/rewired/docs/FAQ.html#consume-input
     
    Last edited: Jul 1, 2021
  23. KarlKarl2000

    KarlKarl2000

    Joined:
    Jan 25, 2016
    Posts:
    606
    Oh I see. I'll have to look for an alternative solution then. Thanks for the clarification. :)
     
  24. Barliesque

    Barliesque

    Joined:
    Jan 12, 2014
    Posts:
    128
    I'm looking to map to the pinky lever of a Thrustmaster HOTAS Warthog Joystick. The list of options in the joystick map doesn't include that. Or maybe it was added to a newer version of Rewired than is in this project? (v1.1.30.0.U2019)
     
  25. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,608
    The button is included in the definition and has been since it was created.

    123213213.png

    32434234.png
     
  26. Barliesque

    Barliesque

    Joined:
    Jan 12, 2014
    Posts:
    128
    Ah ha! Sorry, it's been a while since I last used Rewired. Apparently I'd forgotten how things work and should've consulted the documentation first. I think I've worked it now. Thanks!
     
  27. sSuite

    sSuite

    Joined:
    Sep 28, 2014
    Posts:
    17
    Hello! Are there any plans to support the "adaptive" force feedback on the Dualsense controller triggers? Or is that already doable somewhere that I haven't found?
     
  28. CurryKitten

    CurryKitten

    Joined:
    Dec 22, 2016
    Posts:
    36
    I've just released my game on Android (and iOS) and a few users have noticed an issue with Android coming up with the device uinput-fpc which is apparently the fingerprint scanner that decides to identify itself as a joystick to the OS.

    I had gone with the idea of showing touch controls when there's no joystick and not when a joystick is connected, but obviously, this breaks it. Android being Android, no doubt there are a few more weird and wonderful devices that do similar things. I'm putting an update in to allow the user to always have an option to use touch controls (and the code removes the joystick from the user for this case)

    Whilst I'm sure you have no desire to try and override the OS when it tells rewired "this is a joystick" it would be nice to have something akin to a "black list" of controllers we don't want recognised as controllers. I had similar issues for some windows users when other devices were seen as joysticks (but this was just a case of letting the user pick from a list of all their joysticks, and so easy to ignore the false one.

    Or perhaps there's a better way that already exists that will let us ignore a joystick based on it's name or something like that?
     
  29. bzkarcade

    bzkarcade

    Joined:
    Oct 5, 2017
    Posts:
    21
    How can I assign map to the keyboard?

    I have two categories of maps (Default and UI) I can assign them correctly when using a Joystic. Going from the gameplay to the pause menu and vice versa totally correct with the Joystic. But when using the keyboard to have the same behavior, it only works to pause the game, since the pause action is apparently active. but when I want to use the resume button from the pause menu, it doesn't work.

    I feel that I need something similar to these lines, but I specify for the keyboard:

    player.controllers.maps.SetMapsEnabled(true, "UI");
    player.controllers.maps.SetMapsEnabled(false, "Default");
     
  30. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,608
    No. If the PS 5 platform eventually gets support, it will support it, but there are no plans to support it on any other platform.
     
  31. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,608
    The reason this is happening is that Rewired is dependent upon UnityEngine.Input for all input on Android. Unity is exposing it so Rewired sees it.

    Rewired does not have any kind of framework for low-level platform-specific device blacklisting. (Every input API on each platform has different kinds of information available about the controller to identify it. A blacklist would have to be input source / platform specific, using whatever information is available on that specific API. I avoid exposing platform-specific information in the Rewired API wherever possible.) The prescribed solution for this kind of problem is to always give your users a way to assign and unassign controllers from Players.

    Regarding touch control display, I just had to deal with this same kind of issue a few messages up in the thread for showing/hiding touch controls in the UFE2 integration. See this post for my solution:
    https://forum.unity.com/threads/rewired-advanced-input-for-unity.270693/page-148#post-7265608
     
    Last edited: Jul 12, 2021
  32. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,608
    I'm totally lost as to what you are trying to do and what problem you are having. Please explain more clearly exactly what you are doing and what is not working. The first question of yours "How can I assign map to the keyboard" does not make sens to me with the rest of the information in your question. If the Keyboard Map was not assigned to the Player, then no Actions on that Keyboard Map will return non-zero input. Enabling controller maps that are not assigned first will not do anything. Assigning Keyboard Maps to Players is the same process as assigning Joystick Maps to Players in the Rewired Input Manager.

    If input is not working under some scenario using the keyboard, follow the troubleshooting documentation to find out why:
    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#keyboard-problems

    Use Debug Information to view exactly what Keyboard Maps are enabled in the Player at runtime and what bindings exist on those keyboard maps:
    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#debug-information

    A Controller Map must exist in a Player, bind the Action to an element, and be enabled in order for it to contribute to input.
     
    Last edited: Jul 12, 2021
  33. bzkarcade

    bzkarcade

    Joined:
    Oct 5, 2017
    Posts:
    21
    I have a 1 player setup, assigning 100 joystick to player0
    cap_200.JPG

    I have only two categories, default and UI

    cap_201.JPG

    The problem is only the keyboard, when I use the joystick the expected behavior works well, because I change the map to use through the code.
    The expected behavior is to press pause button -> pause logic -> show ui -> change input map to UI -> press UIResume or UICancel -> hide ui -> unpause logic -> change input map to Default

    But when I use the keyboard, the Default map is invoked.

    cap_202.JPG
    The problem is here

    upload_2021-7-12_10-25-55.png

    The keyboard only knows the default map at the start of the execution, how can I assign the ui map to the keyboard?

    the code I use is this:

    Code (CSharp):
    1.     public static void ChangeAllInputToDefault()
    2.     {
    3.         Player player = null;
    4.         for (int i = 0; ReInput.isReady && i < ReInput.players.allPlayerCount; i++)
    5.         {
    6.             player = ReInput.players.Players[i];
    7.  
    8.             player.controllers.maps.SetMapsEnabled(false, "UI");
    9.             player.controllers.maps.SetMapsEnabled(true, "Default");          
    10.         }
    11.     }
    12.  
    13.     public static void ChangeAllInputToUI()
    14.     {
    15.         Player player = null;
    16.         for (int i = 0; ReInput.isReady && i < ReInput.players.allPlayerCount; i++)
    17.         {
    18.             player = ReInput.players.Players[i];
    19.  
    20.             player.controllers.maps.SetMapsEnabled(true, "UI");
    21.             player.controllers.maps.SetMapsEnabled(false, "Default");
    22.         }
    23.     }
    Thanks for your time
     
  34. VR_Junkie

    VR_Junkie

    Joined:
    Nov 26, 2016
    Posts:
    77
    Can this system be used for VR games? In order to create cross platform functionality with PC
     
  35. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,608
    Thanks for the detailed explanation.

    Assign it to the Player's starting Keyboard Maps just like you did for the Joystick in the Rewired Input Manager. See Step 17:
    https://guavaman.com/projects/rewired/docs/QuickStart.html



    If you have done this and the UI Controller Map isn't showing up, then it's because you're loading out of date saved XML data. You would see a warning about loading XML data in the console. This would only happen if you are using UserDataStore_PlayerPrefs. This is a very frequently overlooked issue:
    https://guavaman.com/projects/rewired/docs/UserDataStore.html#saved-xml-not-synced

    I suggest you use Layout Manager and Map Enabler instead of managing Controller Map enabled state yourself. This is discussed in this topic under "Managed":

    https://guavaman.com/projects/rewired/docs/HowTos.html#enabling-disabling-controller-maps
     
  36. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,608
  37. Hysparions

    Hysparions

    Joined:
    Jan 7, 2019
    Posts:
    29
    Hello Guavaman ! :) First thanks for the amazing work here on rewired and your complete Doc !
    I tried to find the solution for my problem, but after one hour searching I'll be glad if you could help me :)

    I had some jitter occuring on my camera only when rotating using player.GetAxis() in Update() with my mouse (I try to move it constantly)

    I logged the output of get Axis and when moving the mouse I noticed inconsistency between values, For example it does

    14
    14
    15
    0 <--- Input Miss ?
    14
    15
    15
    32 <--- Double Input?
    15
    15

    My game is really cartoonish so the slightest jump in input creates visible artefacts. I would like to know if I could do something for this, or if it comes from the bluetooth mouse frequency... Otherwise I'll try to Smooth Values based on last frames

    Have a nice evening :)
     
  38. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,608
    What you're describing is simply the nature of mouse deltas. These values are coming from Windows.

    The mouse does not return the same number of pixels moved every frame. You can't move your hand at a perfectly consistent rate. And your game's frame rate is never going to be perfectly consistent. And mouse hardware has a polling rate which isn't going to be the same as or perfectly aligned to your frame rate.

    Windows delivers mouse delta values at the start of the frame for everything that happened in the previous frame. This is the value reported. If a value of 0 is reported, Windows did not return a delta that frame for whatever reason.

    If you want perfectly smooth mouse input, you're going to have to smooth it out over time which will introduce latency.
     
    Hysparions likes this.
  39. guavaman

    guavaman

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

    1.1.39.3:

    Changes:
    - WebGL builds work again after changes to compiler in Unity 2020.2.0 to that caused builds to throw an error on launch.
    - Updated UFE2 integration to change auto show/hide of touch controls to toggle based on a screen touch and a controller press instead of toggling based on the presence of a controller due to problems with phantom joysticks that appear on some Android devices.
    - Control Mapper: Focus is now reset when calling Reset while windows are open.

    Bug Fixes:
    - ControllerMap.hardwareGuid is now correctly set for MouseMap, KeyboardMap, and CustomControllerMap.
     
  40. _eternal

    _eternal

    Joined:
    Nov 25, 2014
    Posts:
    303
    Hey,

    I'm getting some Rewired errors when I try to create a build, even though the game boots correctly in the editor. Unity 2020.3.13f1 and Rewired 1.1.39.3

    Code (CSharp):
    1. Field 'System.Collections.Generic.List`1<Rewired.Components.PlayerMouse> Rewired.Integration.UnityUI.RewiredStandaloneInputModule::playerMice' from 'C:\gamedev\unity\monospaced-lovers\Library\ScriptAssemblies\Assembly-CSharp.dll', exception Failed to resolve Rewired.Components.PlayerMouse
    2. UnityEditor.BuildPlayerWindow:BuildPlayerAndRun ()
    3.  
    4. Field 'System.Collections.Generic.List`1<Rewired.Components.PlayerMouse> Rewired.Integration.UnityUI.RewiredStandaloneInputModule/PlayerSetting::playerMice' from 'C:\gamedev\unity\monospaced-lovers\Library\ScriptAssemblies\Assembly-CSharp.dll', exception Failed to resolve Rewired.Components.PlayerMouse
    5. UnityEditor.BuildPlayerWindow:BuildPlayerAndRun ()
    6.  
    Those two errors repeat twice when I try to create a build, so that's 4 error messages in total.

    For what it's worth, my game doesn't actually use mouse input. In my Rewired Standalone Input Module, I tried toggling "Allow Mouse Input" off and on, and I tried adding/removing the empty player mouse in the playerMice list, but it made no difference.

    Here's the whole Event System game object: https://imgur.com/a/cy0C9IL

    Again, to be clear, everything is working in the editor. It only fails when I try to create a build.
     
  41. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,608
    That error does not make sense. Disabling mouse settings wouldn't have any effect on this kind of error.

    Rewired.Components.PlayerMouse is a MonoBehaviour-based component in Rewired_Core.dll. I have never seen a "failed to resolve" exception before. I can only guess that it is thrown by Unity when a class which is referenced in a script somehow does not exist. How would it even compile if that's the case? The class does exist. It is contained in Rewired_Core.dll. The class is no different than any other class that inherits from MonoBehaviour.

    Is Rewired_Core.dll excluded from the build target?
    Are you using ASMDEF files?

    I am at a total loss. Even if I wanted to to cause this kind of error, there's no way I could do it. This has something to do with Unity'scataloging of classes in assemblies during compilation, which is outside my control. All I can guess is there is something corrupted in your project. Try deleting Unity temporary cache folders (il2cpp caches, etc.) Try building to a different location and not over an existing build. Try starting a new project and build a test scene (Rewired/Examples/PlayerMouseUnityUI). If you have scripts that execute code on a build using build pipeline callbacks, remove them and see what happens.
     
    Last edited: Jul 16, 2021
    _eternal likes this.
  42. _eternal

    _eternal

    Joined:
    Nov 25, 2014
    Posts:
    303
    All right, thanks for the explanation. I'll try following up with Unity and see what they say.

    I haven't been able to reproduce this in an empty project with the PlayerMouseUnityUI scene, so it looks like something in my project is causing Rewired to throw those errors, rather than something in Rewired causing the build to get corrupted.
     
  43. CurryKitten

    CurryKitten

    Joined:
    Dec 22, 2016
    Posts:
    36
    Are there any differences between how Rewired works for a regular Intel based Mac and an M1 Mac? Apologies if this has been asked before, but "M1" fails the search term as it's too short.

    I've just found that a very problematic joystick that I think someone defined the HID info as a mouse and went crazy at previous versions of macOS works fine on Big Sur (macOS 11) but a few guys on M1 macs (also running macOS 11) are telling me it's not working for them. I've not got my hands on an M1 based mac so I've no idea how the compatibility is supposed to work - it could well just be this troublesome joystick, but wanted to check if there was anything different I needed to know about on M1 and Rewired?
     
  44. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,608
    Rewired is not written for M1 or Intel. Rewired OSX is 100% managed code. All calls out to native libraries (I/O Kit) are done through P/Invoke and are architecture-agnostic. There is not a single bit of M1 or Intel-specific code in Rewired. Any behavior differences between M1 and Intel systems is entirely due to differences as reported by the exact same calls to I/O Kit. In addition, Rewired on Mac uses UnityEngine.Input for all keyboard and mouse input. Joysticks are handled by I/O kit if Native is the primary input source.

    Yes, there are a lot of general idiosyncrasies and issues with M1 macs and controllers. This is pretty widely known. Apple still has work to do in this area. (Intel even used controller issues as a bullet point in one of their "Intel is better than M1 Mac" marketing presentations.)
     
    Ryuuguu likes this.
  45. thiskidcalledtom

    thiskidcalledtom

    Joined:
    Nov 9, 2017
    Posts:
    35
    Hello! I have just updated my unity version to 2020.3.3f1 LTS. i have a warning in the console telling me to update rewired but i cannot find it in my package manager at all, Do i have to manually update it from the website or something?

    and when i update, Will it keep all my keybindings I've done, or will i have to redo them all?
     
  46. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,608
    Package Manager is managed by Unity and the Asset Store. Unity is completely in charge of how the package manager works. I don't even know anything about it except what I have discovered through trial and error using it.

    As I have no input on how the Unity Asset Store distributes the asset, this is a total guess. I am going to guess you installed Rewired long ago in an old version of Unity using the old Asset Store website interface in the Unity editor. They have since moved all asset store functionality into the Package Manager. Because you never installed it from the Package Manager, the Package Manager has no idea Rewired was ever installed into the project. Again, I don't even know how the package manager works internally, so this is just an educated guess.

    Delete Rewired and reinstall it from the Package Manager.

    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#clean-reinstall

    Follow the guidelines there and you will not lose data. The only way you can lose data is if you actually save a scene or a prefab while Rewired is no longer installed.

    Rewired is stored in Unity serialized data in GameObjects like everything else you create in Unity:

    https://guavaman.com/projects/rewired/docs/FAQ.html#where-is-data-saved

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

    If Rewired is not listed in your Asset Store assets in the Package Manager, contact Unity about it before you delete Rewired. That's directly connected to your store purchases and I have no ability to do anything regarding the Asset Store.
     
    thiskidcalledtom likes this.
  47. CHOO5D

    CHOO5D

    Joined:
    Dec 24, 2016
    Posts:
    55
    I made a action called 'Interact' which I mapped 2 different keys for the action ('E' & 'Enter'). Only the 'E' works so I am guessing that the action only allows 1 key to be mapped to it?
     
  48. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,608
    No that is not correct. An Action may be mapped to any number of elements on any number of Controllers.

    Debug Information is the single most powerful tool to figure out why "it doesn't work." Use it. It allows you to visualize every single Rewired object in the system at runtime including Controller Maps and bindings.

    "Enter" and "Keypad Enter" are two different keys.

    Finally: https://guavaman.com/projects/rewired/docs/UserDataStore.html#saved-xml-not-synced

    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.

    IMPORTANT:

    During development, you may run into a situation where your controls don't seem to make sense. This may happen when you make some runtime control changes, save them, and then proceed to change your mappings in the Rewired Input Manager. Because UserDataStore_PlayerPrefs is configured to save controller data on disconnect and load controller data on start and controller connect, the loaded settings will override new changes you make to the default mappings in the Rewired Input Manager.

    During development, it may be useful to disable or remove the UserDataStore_PlayerPrefs component. If you've already saved controller settings and want to remove them, you can use the Clear All Player Prefs button in the Debug Options foldout on the UserDataStore_PlayerPrefs inspector. WARNING: This will clear ALL PlayerPrefs data for the current project. This is due to the limitation that there is no way to look up what keys exist in PlayerPrefs.
     
  49. sk1zZ

    sk1zZ

    Joined:
    Mar 30, 2015
    Posts:
    9
    Hi!
    I have a little problem with remapping controls for PC. I want to assign keyboard or mouse button to an action but InputMapper.Context constructor receive only one kind of controller map (Keyboard or Mouse).
    Is it possible to listen input from 2 different maps, or there is some workaround for this kind of remapping?
     
  50. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,608
    No, it is not possible to listen for input on two controllers at the same time using a single input mapper.

    See this example:
    https://guavaman.com/projects/rewired/docs/Examples.html#simple-combined-keyboard-mouse-remapping
     
    sk1zZ likes this.