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. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    I need more specific information about what's happening to help. Do you have a specific case that I can look at? Also, if I could see or use your controller rebinding screen and test with controllers I have, I may be able to tell you something.

    Rewired's controller remapping polling system already handles axes that constantly return a non-zero value by only registering on an absolute change in axis value over time of > 0.5. (This is absolutely required for flight controllers which can have throttles that sit at +1 in the zero state.) Control Mapper and the ControlRemappingDemo1 example can handle every odd joystick and axis I have thrown at them. How are you doing your polling for rebinding?

    Also, I can't tell from your customer comments -- is this Linux only or every platform?

    What are your chosen input sources for the platforms in question?
     
    Last edited: Jun 1, 2016
  2. vivalavida

    vivalavida

    Joined:
    Feb 26, 2014
    Posts:
    85
    hi @guavaman ,
    Our widows builds on windows 10 act weird when used with an Xbox One controller.

    1. our 'b' button doesn't work,
    2. our left joystick continuously gives a 'leftward' value.

    I've seen some posts about issues with Windows 10, I'm guessing this is related to that.
    Is there something that can be done by me or would I have to wait it out for Microsoft?

    We're using Unity version 5.2.0.
    and Rewired version 1.0.0.67
     
  3. raithza

    raithza

    Joined:
    Dec 14, 2011
    Posts:
    21

    I took a good look at how we did rebinding again and I think our use case is a bit convoluted for me to expect you to support it, but I've found a workaround that solves my issue.
     
  4. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    Please update Rewired. You are using a version 20 releases behind and 10 months old. I can only provide support on the latest version of Rewired.

    Be sure to follow the updating guidelines here.
     
    Last edited: Jun 2, 2016
  5. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    Okay, that's all that's important. Glad you were able to get it working!
     
  6. idavida

    idavida

    Joined:
    Nov 12, 2012
    Posts:
    33
    Its this one yes, and this is actually my problem. There's no way I could get the other trigger if one is currently being held? For me it's too long of a delay waiting for one trigger to be released before the other can be pressed.
     
  7. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    If they are assigned the same Action, they are considered to be contributing sources to one single virtual element -- the Action. When L is held down, the entire state value of your Action = 1. It doesn't matter if R is pressed or release while L is still held, the value will still be 1 because the more massive (abs value) of the contributing values takes precedence. It wouldn't make sense for the Action to return Button Down and/or Button Up while the Action is in a Button Held state.

    To do what you want to do there are only two options:

    1. Use two separate Actions, one for each trigger. This is the most logical and easiest approach.
    2. Manually get the values of the individual axes instead of using the Action system and code a way to determine what a "button down" state is for those axes.

    Alternately, you can change the Input Behavior Button Down Threshold settings to fine tune how far the trigger should be pressed before a button down is triggered.
     
  8. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    Another possibility:

    Check the contributing input sources for the Action assigned to the triggers and evaluate their values manually.
     
  9. cj31387

    cj31387

    Joined:
    May 23, 2012
    Posts:
    143
    Is there a way to allow more than 2 buttons at once? Right now I have left shift as run, wsad as move and strafe but i can only move forward plus run or strafe plus run. I need to be able to have shift + w + d, or shift + w + a etc... But currently only shift + w or shift + d is working at the same time. How do you fix this?
     
  10. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    See this Troubleshooting topic:

    Two or more keyboard keys cannot be pressed at the same time

    "If you find that no input value is returned when two or more keyboard keys are pressed at the same time, you are experiencing a hardware limitation of your particular keyboard called Keyboard Ghosting. This can affect any type of computer that uses a keyboard. This is not an issue with Rewired and there is no possible way to work around this issue in software because no signal is being sent from the keyboard."
     
  11. GoesTo11

    GoesTo11

    Joined:
    Jul 22, 2014
    Posts:
    604
    Are there any plans to have Vive or Oculus Touch controller support for Rewired?
     
  12. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    Not natively at the present time because that requires including native libraries just for those controllers on any platform they're expected to run on and some kind of motion controller and touch abstraction system.

    You can implement support for them yourself using Custom Controllers and the company's SDK.
     
    Last edited: Jun 3, 2016
  13. Rtyper

    Rtyper

    Joined:
    Aug 7, 2010
    Posts:
    452
    Is there any built-in means for binding one action to a short press of a button and another to a long press of the same button? I can do this manually, but it's one of those cases where with keyboard and mouse you'd probably want the action just bound to a different key, whereas on a controller you may need to "double up" like this, and writing control-scheme specific code seems a little hacky when Rewired does such a great job of handling everything else!

    Thanks.
     
  14. cj31387

    cj31387

    Joined:
    May 23, 2012
    Posts:
    143
    It was a problem with my code, my bad :) .
     
    Last edited: Jun 5, 2016
  15. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    No there isn't. Sorry.

    What you are describing would require the ability to bind an Action to a gesture, a gesture being an event triggered when some element value changes over time matching some pre-defined pattern. Rewired does not support this at the present time.

    There are dozens of potential gestures that one could possibly want to handle for every type of controller element (axes especially). Rewired does not provide any binding of Actions to gestures. Action bindings are only to controller elements. That Action can then be queried for axis value, button on, button off, button just pressed, button just released, and button double clicked events. The Action bindings are not bound to gestures but to the button/axis element, and the Action can then be queried for those events listed above.

    Allowing binding Actions to element gestures such as "short press X", "press and hold X", etc. would greatly complicate user control rebinding. It would also complicate the Rewired editor requiring potentially dozens of options per supported gesture type (timings, activation exclusivity, cancellation behaviors, etc.) Because of the vast number of possible variables, these things are better handled in code based on the individual needs of the game in question.

    A gesture recognition and binding system would likely have to be an entirely separate layer on top of Rewired's current system. Gesture recognition and Action binding are not currently planned features.
     
    Last edited: Jun 6, 2016
  16. Rtyper

    Rtyper

    Joined:
    Aug 7, 2010
    Posts:
    452
    OK, fair enough - thanks! Just wanted to make sure before I started trying to implement it manually!
     
  17. fkmclane

    fkmclane

    Joined:
    Jun 6, 2016
    Posts:
    1
    Is using Rewired inside of the Linux editor preview supported? It does not work when I go into play mode. Most notably ReInput.isReady never becomes true and there is nothing in Unity's console log. I'm running 64-bit Gentoo Linux and I'd be happy to provide any information about my system you would like.

    Edit: Also, I'm using the latest Rewired (1.0.0.87) and the latest editor preview (5.3.5f1).
     
  18. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    No seems like the most likely answer. But I will wait for the official answer, but I will be very surprised if it is different. Unity has never released the Linux editor for general use. Until Unity officially supports a Linux release I think it is hard to think of any asset store vendor can be expected to provide support for it.
     
  19. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    @longroadhwy is correct. No, the Linux editor is not supported. I cannot support alpha/beta software because too much can change and break things making the task far too time consuming. However, I see no reason why it wouldn't work if native mode is disabled and is set to use Unity input as the source.
     
  20. Rtyper

    Rtyper

    Joined:
    Aug 7, 2010
    Posts:
    452
    Hi again, this really strange bug has suddenly started happening with no real cause that I can see... I've been using a wireless DualShock 4 for a while with no problems, but now whenever I press play in the editor and have the controller turned on, the game slows to a crawl (< 1FPS) and the console get flooded with the same 3 errors (seemingly from Rewired) over and over:

    This continues until I turn the controller off. The frame-rate may just be a side-effect of all the console output, and input from the controller does seem to be working, but it's basically unusable at the moment. Any ideas?

    Thanks!
     
  21. Arganth

    Arganth

    Joined:
    Jul 31, 2015
    Posts:
    277
    strongly considering getting this asset :)
    (as it works with TPC/behavior designer and inventory pro)

    are there controllers with which it works best? x-box/ps controller/steam controller?

    probably most pc gamer use x-box controllers i guess
    (third person games)


    edit:
    how do you solve "aiming" with the controller in action games?
    lock-on?
    or kind of an aim assist? (anyone knows of an implementation for this or has an idea?)
     
    Last edited: Jun 7, 2016
  22. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    Disable Enhanced Device Support in the Rewired Input manager.

    I'm going to have to change the code to prevent processing the gyro when it returns bad data. I cannot say why it's returning bad data in your case, just that it is.

    The error is from Unity choking on creating Euler angles from an invalid (non-normalized) Quaternion for DS4 orientation.

    The slowdown is certainly caused by log spam. You're getting 3 log entries per frame.
     
    Last edited: Jun 7, 2016
  23. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    Supported Controllers
     
  24. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    This is kind of outside the scope of an input asset like Rewired. A programmer from Insomniac did a good presentation of aim assist techniques that you can watch here: Techniques for Building Aim Assist in Console Shooters (GDC Vault)
     
    guavaman and Arganth like this.
  25. Rtyper

    Rtyper

    Joined:
    Aug 7, 2010
    Posts:
    452
    Alright, makes sense. I'll have to look into why the controller's messing up then. Interestingly, it's only happening over bluetooth - in wired mode it works fine.

    Thanks for all the help!
     
  26. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    Thanks! The more info the better. I will test it thoroughly and add measures to make sure it doesn't throw exceptions.
     
  27. LostPanda

    LostPanda

    Joined:
    Apr 5, 2013
    Posts:
    173
    @guavaman Support htc vive controller it? thanks.
     
  28. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    FAQ: Does Rewired support this controller?

    Usually, this question is asked about exotic controllers such as 3Dconnexion Space Mouse, Arduino, Oculus Touch and Remote, HTC Vive, exotic VR controllers, or some other special-purpose controller that requires its own SDK to use. Rewired does not support such controllers directly. Any use of such controller would require you set up the company's SDK and use a Custom Controller to add support for the device. Even this may not work for all devices.

    Rewired is not a general-purpose, low-level API for working with any and all HID devices.

    See Supported Controllers for more information.
     
  29. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    Make sure you download the Rewired evaluation!

    In my opinion flight controllers work far better than gamepads. It is so nice have a precise flight controller over any game pad. CH FighterStick is one of my personal favorites for a controller.

    Thankfully Rewired handles so many various types of controllers so well. With UFPS (which also has a Rewired integration) I have used gamepads, flight controllers, light guns (i.e arcade guns) and they all work fine. So you definitely can use a great variety of controllers with Rewired. It sure makes it easy to support your own customers since you know that Rewired has outstanding controller support.
     
    Arganth and guavaman like this.
  30. LostPanda

    LostPanda

    Joined:
    Apr 5, 2013
    Posts:
    173
    thanks!
     
  31. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    I've discovered the source of the problem if you're interested. When on Bluetooth, it is possible for the DS4 to send input reports multiple times in a row with the same sensor timestamp. Without knowing that and accounting for it, it was possible to get a value of Inifinity for the deltaTime, which when used to process the gyroscope data yields an invalid quaternion which Unity chokes on. There's nothing wrong with your DS4.
     
  32. Rtyper

    Rtyper

    Joined:
    Aug 7, 2010
    Posts:
    452
    Ah, yeah I see. Good to know I don't have a defective controller then! I can just stick with wired for now - the game's not shipping any time soon. Cheers!
     
  33. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    Rewired 1.0.0.88 has been submitted to the Unity Asset Store. It should be available in 5-10 business days. It is available for download immediately on the Rewired website for registered users. If you would like to register to receive access to early updates, please contact me here.

    Be sure to read the Updating Rewired Documentation before updating.

    New Features:

    Enhanced PS4 platform support! Now all the DS4 features are supported on the PS4 platform including accelerometer, gyro, touchpad, vibration, and light color. Device connect and disconnect events now work properly. In addition, there is an option now to assign joysticks to Players based on the PS4 joystick id so there are no Player/light color mismatches.

    New per-platform options in the Rewired Input Manager settings. Now you can set options for each build platform separately including the ability to disable keyboard input entirely for certain platforms.

    Custom Controllers can now be instantiated via scripting. This makes the system even more flexible, allowing you to create Custom Controllers only when needed. For example, you create a script that detects when the Oculus Touch Remote is attached using their SDK. You can then instantiate your Oculus Touch Remote custom controller and assign that to a Player.

    @OneThree I have added the ability to choose from 3 types of axis sensitivity for axis calibration: Multiplier (current method), Power, and Curve. These must be set in the AxisCalibration and will be saved and loaded with the XML data. There is no editor at present to set these values, nor does Control Mapper support anything but the default Multiplier setting.

    Release Notes:

    1.0.0.88:

    Changes:
    - Added PS4 native platform support
    - Added DualShock 4 definition for PS4 native
    - Added per-platform settings to Rewired Input Manager
    - Added "Disable Keyboard" option to per-platform settings in Rewired Input Manager
    - Custom Controllers can now be created via scripting
    - Added editor log messages in UserDataStore_PlayerPrefs every time data is saved and loaded.
    - Added new axis calibration sensitivity options to change calculation of axis sensitivity using a multiplier, raise to power, or an AnimationCurve.
    - Windows Standalone: Added workaround for Nvidia Shield Controller bugs caused by new firmware causing extreme stalls when receiving input events in Raw Input. Controller can only work with Use XInput enabled and will not cause stalls.

    API Changes:
    - Added ReInput.ConfigHelper.xboxOnePrimaryInputSource property
    - Added ReInput.ConfigHelper.ps4PrimaryInputSource property
    - Added ReInput.ControllerHelper CreateCustomController(int sourceControllerId) method
    - Added ReInput.ControllerHelper CreateCustomController(int sourceControllerId, string tag) method
    - Added ReInput.ControllerHelper GetFirstCustomControllerWithSourceId(int sourceId) method
    - Added ReInput.ControllerHelper GetFirstCustomControllerWithTag(string tag) method
    - Added ReInput.ControllerHelper CustomControllersWithSourceId(int sourceId) method
    - Added ReInput.ControllerHelper CustomControllersWithTag(string tag) method
    - Added AxisSensitivityType enum
    - Added AxisCalibration.sensitivityType property
    - Added AxisCalibration.sensitivityCurve property
    - Added AxisCalibrationData.sensitivityType field
    - Added AxisCalibrationData.sensitivityCurve field
    - Added Platforms.PS4.PS4GamepadExtension class
    - Added Platforms.PS4.PS4GamepadMotorType enum
    - Added Platforms.PS4.LoggedInUser struct

    Modified Controller Definitions:
    - Android: Changed L/R trigger mappings on Nyko Playpad to match across different device revisions.
    - Android: Changed L/R trigger mappings on Nyko Playpad Pro to match across different device revisions.
    - Android: Changed Samsung EI-GP20 definition to match Unity 4.x versions correctly due to mapping changes in various versions of Unity.
    - Android: Changed Xiaomi Wireless Game Controller definition to match Unity 4.x versions correctly due to mapping changes in various versions of Unity.

    Bug Fixes:
    - Windows Standalone: Fixed errors logged by Unity during Quaternion creating when using Dual Shock 4 when connected via Bluetooth with Enhanced Device Support enabled.
    - Windows Standalone: Fixed incorrect Dual Shock 4 Orientation calculation when connected via Bluetooth with Enhanced Device Support enabled.
    - Conflict checking no longer returns True when checking a keyboard element assignment against a blank (invalid) keyboard ActionElementMap.
    - PlayMaker Integration: Fixed infinite loop in certain Actions when using events.
     
    Rtyper likes this.
  34. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
  35. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
  36. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    You're welcome! I'm surprised it came out so fast too. :D
     
  37. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,521
  38. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
  39. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,521
    ok cool i did not catch that, will try it out now
     
  40. electroflame

    electroflame

    Joined:
    May 7, 2014
    Posts:
    177
    I'm curious, is there a built-in way to be able to export actions via an Editor script? Currently I've got a pretty robust system in place to generate constants for a variety of things, and I'd really love to include Rewired in that system (mostly because it's run automatically on rebuilding/compilation, so it'll save a bunch of time).

    I'd imagine that there's probably an internal method somewhere (even calling it via Reflection is fine), so I'm hoping that's it's possible to push me in the right direction. It's also not a problem that I'll need a reference to the Rewired Input Manager, as I only have one and can get a reference to it via a previously-generated constant.

    Is something like this possible, @guavaman?
     
  41. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    How To's - Exporting Actions as constants for use in scripting

    Why would you need to do this via a script? Do you change your input Actions list that often?
     
  42. electroflame

    electroflame

    Joined:
    May 7, 2014
    Posts:
    177
    I actually linked to that same doc area in my original post. :)

    Anyway, during development I'm certainly changing Actions enough that maintaining my own list, or generating one manually, is cumbersome (especially on multiple projects). Ideally, I'd like to be able to get a list of the Actions and generate my own file from that, using my constant-generation framework. Doing so will let me generate the file specifically to my liking (ideally, having a subclass per category so I can do things like RewiredActions.Category1.MyCoolAction).

    It would just be significantly easier if I could add this to my post-compile generation, as then I won't even have to think about it. The aforementioned class layout preferences would just be the icing on the cake.

    Given that this is definitely a very specific request, I wanted to reiterate that I'm totally fine with using Reflection for this, as I fully understand if you don't want this in the public-facing API.

    Hopefully that makes sense.
     
  43. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    D'oh!

    All the data is stored in InputManager.userData which is a public property. All the methods used by the editor script to generate the list are also public and in the UserData class. None of them are documented however.

    Here is the relevant part of the code from the Action exporter:

    Code (csharp):
    1. const string attributeName = "Rewired.Dev.ActionIdFieldInfo";
    2. const string indentIncrement = "    ";
    3. string indent = indentIncrement;
    4. string s = "";
    5.  
    6. s += "/* Rewired Actions\n";
    7. s += "   This list was generated on " + System.DateTime.Now.ToString() + "\n";
    8. s += "   The list applies to only the Rewired Input Manager from which it was generated.\n";
    9. s += "   If you use a different Rewired Input Manager, you will have to generate a new list.\n";
    10. s += "   If you make changes to the Rewired Actions, you will need to regenerate this list.\n";
    11. s += "*/\n\n";
    12. //s += "namespace Rewired {\n";
    13. //s += indent + "using Rewired.Dev;\n\n";
    14. s += "public static class RewiredActions {\n\n";
    15.  
    16. int[] categories = userData.GetActionCategoryIds();
    17.  
    18. for(int i = 0; i < categories.Length; i++) {
    19.   int catId = categories[i];
    20.   InputCategory cat = userData.GetActionCategoryById(catId);
    21.   if(cat == null) continue;
    22.  
    23.   s += indent + "// " + cat.name + "\n"; // write category name
    24.  
    25.   string catFriendlyName = !string.IsNullOrEmpty(cat.descriptiveName) ? SanitizeFriendlyName(cat.descriptiveName) : SanitizeFriendlyName(cat.name);
    26.  
    27.   List<InputAction> list = GetActions(userData.GetSortedActionIdsInCategory(catId));
    28.   foreach(InputAction action in list) {
    29.       string variableName = categorize ? SanitizeVaribleName(cat.name) + "_" + SanitizeVaribleName(action.name) : SanitizeVaribleName(action.name);
    30.       string friendlyName = !string.IsNullOrEmpty(action.descriptiveName) ? SanitizeFriendlyName(action.descriptiveName) : SanitizeFriendlyName(action.name);
    31.       s += indent + "[" + attributeName + "(categoryName = \"" + catFriendlyName + "\", friendlyName = \"" + friendlyName + "\")]\n";
    32.       s += indent + "public const int " + variableName + " = " + action.id + ";\n";
    33.   }
    34.   s += "\n";
    35. }
    36.  
    37. s += "}";
    38.  
    39. // Write to text file
    40. using(System.IO.TextWriter tw = System.IO.File.CreateText(savePath)) {
    41.   tw.Write(s);
    42.   tw.Flush();
    43. }
    44. AssetDatabase.Refresh();
     
  44. electroflame

    electroflame

    Joined:
    May 7, 2014
    Posts:
    177
    Beautiful, thanks! I'll dig into this tomorrow and get things set up. For some reason I was thinking there would be some Editor-specific code/property that I'd need to get -- I didn't realize that userData would be populated correctly in the Editor (d'oh).

    Thanks a bunch!
     
  45. electroflame

    electroflame

    Joined:
    May 7, 2014
    Posts:
    177
    Just wanted to report back that accessing the userData was exactly what I was looking for. Everything's working perfectly now -- thanks for the push in the right direction (and the code sample!).
     
  46. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    Good, glad it works! Thanks for reporting back.
     
  47. resakosix

    resakosix

    Joined:
    Sep 26, 2012
    Posts:
    5
    Hello.

    Just wanted to know if Steam Controller native support is in your roadmap? I got my game working using the xinput simulation but it would be nice to detect the gamepad as steam controller and use it on the editor.

    Thank you
     
  48. FREEZX

    FREEZX

    Joined:
    Apr 2, 2013
    Posts:
    64
    Hello there.
    Just got this asset and i'm really enjoying it. I tried to get the DS4 controller's gyro for some time now and with this asset it works out of the box.
    One minor thing, is there a way for ReWired to not set the color of the light bar when starting it up? I'm using DS4Windows and i have my controller's color already set through that.
     
  49. DMinsky

    DMinsky

    Joined:
    May 20, 2012
    Posts:
    30
    Hi2all,

    There is any easy way to achieve following behaviour with Rewired?

    Get true by player.GetButtonDown() only once for first who called player.GetButtonDown() in this frame.

    My case:
    1. First Submit should set timeScale == 0 and open some window.
    2. In this window i process submit for another action.
    3. So, because of timeScale == 0 i get true from GetButtonDown in 1. then immediately true in 2.
    4. I want to stop receiving true from GetButtonDown after first "usage".
     
  50. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    No there is not. GetButtonDown returns True for the duration of the frame in which it was true. What you are asking here is equivalent to this question in the FAQ:

    FAQ: How do you consume/use an input?

    There is no "consume" or "use" concept in Rewired. You cannot change or override the final Action input values because they are set by the hardware events and then calculated based on combined values of all input sources that contribute to that Action.

    This question is almost always asked due to the desire to use the input system as part of in-game player state/permission management. For example, you should not think of Rewired's Player.GetButtonDown as a flag denoting "game player is now firing". It should be thought of as a signal of the user's intent entirely separate from the game simulation. GetButtonDown("Fire") is equal to "the user wants to fire". Whether or not the game player is allowed to fire at that moment is a game player state management issue and needs to be handled in your game code.

    "User wants to fire" -> If "game player is allowed to fire" -> then "fire".

    Using Rewired or any input system as an integral part of game state or permission management is not a correct usage. This way there is no need for something like consuming input and injecting your game state permission management into the input system.

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

    Setting Timescale is not affecting GetButtonDown in any way. Rewired does not rely on Time.time for anything. Every calculation of Time is based on Time.realtimeSinceStartup.

    What is happening here in your case is you are:

    1. Getting the ButtonDown value for an input at one point during the frame.
    2. Reacting that input value during that same frame and bringing up a window.
    3. Trying to get input again during that same frame in your new window and therefore you get ButtonDown = True still because the ButtonDown state persists for 1 complete frame.

    You will have to do one of the following options:

    1. Instead of reacting directly to player.GetButtonDown to open your window, wrap it with another class or just a variable whose state you can control by setting it to false again after you've "used" it. Both the main screen and the window control should be gathered from this wrapper instead of directly from Player, then you can set the value to false every time it is accessed through a property or a method.

    Code (csharp):
    1. class MyController {
    2.  
    3.     private bool _confirmDown;
    4.     private Rewired.Player player;
    5.  
    6.     public bool confirmDown { // call this to get the down state -- it returns true only once. When checked, it goes false.
    7.         get {
    8.             if(!_confirmDown) return false;
    9.             _confirmDown = false; // once checked, it will return false afterwards
    10.             return true;
    11.         }
    12.  
    13.     void GetInput() { // update this every frame before you need to use input
    14.         _confirmDown = player.GetButtonDown("Confirm");
    15.     }
    16.  
    17.     public MyController(Rewired.Player player) { // set a Rewired.Player in the constructor
    18.         this.player = player;
    19.     }
    20.  
    21. }
    2. Ignore input in your new window for the first frame that it is open.
    3. Instead of opening your window immediately, start the process of opening your window by setting a flag or using a timer, then in the next frame (or when the timer ends), actually open it.
    4. Open your window with a Coroutine and put one yield return in there between the time the input is gathered and the the window is actually opened.
    5. Use GetButtonUp to open your window and GetButtonDown to get input in your window.
    6. Use different Actions to react in the main screen and in the window. If these Actions are on Controller Maps in different categories, you could swap the enabled Controller Maps when the window is opened. For example, two categories -- InGame, Menu. When you open the Window, enable Menu and disable InGame. Map different Actions to open the UI and confirm in the menu. GetButtonDown will work properly in this case because it will not be activated for an Action that was not on an enabled Controller Map when you initially opened the window.
     
    Last edited: Jun 17, 2016
    DMinsky likes this.