Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Rewired - Advanced Input for Unity

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

  1. FelipeQuevici

    FelipeQuevici

    Joined:
    Jan 8, 2013
    Posts:
    11
    Hello, I have a system that changes the tooltip UI icon whenever the player changes the controller (keyboard to gamepad), however, it only works if the player presses a mapped key on the new controller. If, for example, no action is mapped to Action Bottom Row 1, then the callback added to AddLastActiveControllerChangedDelegate is not called when I press that button, and the tooltip never changes.

    My question is, is there a way to have a callback when ANY input from a new controller has been pressed? (not only mapped ones).

    Thanks!

    Edit: For clarification, booth the keyboard and gamepad are active at the same time, it's just to detect LastActiveController.
     
  2. SonicBloomEric

    SonicBloomEric

    Joined:
    Sep 11, 2014
    Posts:
    897
    Ahh, I see the problem. I had read "Game window" as simply "the Unity Editor window" (i.e. is Unity the focused application or not). Clicking in the Game window specifically does allow those fields to update as expected. Very nice. Apologies for the confusion!


    I think it may be helpful to call this out in the Supported Controllers list explicitly, especially since the marketing is now different between the controllers.


    Makes sense. If the Product Ids change for very small and inconsequential reasons, then mapping everything by name as you do would be far more universally compatible. Good stuff.


    Yup, that did it! Not only does the "Xbox Wireless Controller" work now, but the "Xbox 360 Wired Controller" works as well. Right before I checked the Unity forums for a response, I installed the 360Controller drivers and plugged in my old Xbox 360 Controller, only to find that it also wasn't working with Rewired.

    However, after installing the updated Hardware Maps you provided above, both of the Xbox controllers I'm using work as expected. See:

    upload_2021-4-9_14-14-35.png

    Awesome. Thanks so much for addressing that issue so quickly!


    Before installing your updated Hardware Maps for the Xbox controllers, I was seeing the same issue with the Xbox 360 controller. Your intuition here was also spot-on: I had duplicated the line to control the Camera when replacing Unity Input with Rewired but forgot to erase the original line. For Rewired-recognized controllers, the Rewired input wold overwrite whatever Unity threw in there. If Rewired didn't recognize anything, it would somehow fall back on using the Unity Input version (I emphasized "somehow" because the Rewired defaults [presumably 0] should have overwritten the values from the Input... but they didn't? Not sure... doesn't seem to matter now.

    Update: At this point I'm roughly 99% sure that the issue is that Cinemachine (no integration installed yet) was automatically handling the camera inputs and was using default mappings. The reason the logic I previously described above didn't work was because it wasn't actually ever used. (This whole situation is complicated because I'm integrating with code written by another person so I'm not fully aware of what is and isn't legacy...)

    Again, apologies for the confusion here.
     
    Last edited: Apr 9, 2021
  3. BlankMauser

    BlankMauser

    Joined:
    Dec 10, 2013
    Posts:
    115
    Not sure if you've already considered this, but the GetButtonDown buffer isn't super helpful without combination inputs. For example if I press a button + direction, but then change my direction within the buffer, I will not get the result I originally intended to input.

    I've solved this by making my own buffer system that takes direction and button separately. But this feels like a workaround that could be avoided with some kind of internal queue system in Rewired itself.
     
  4. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,631
    Button Down Buffer does nothing but extend the duration of the Button Down event. It wasn't designed to do what you are doing, making its state dependent upon some other state. Rewired does not allow the user to cancel events.

    What you've implemented is not a feature Rewired was designed to provide. Your system is not a workaround, it's a new feature.
     
    Last edited: Apr 10, 2021
  5. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,631
    If that's the case, then I can only guess both of these problems are caused by a MacOS update, not a firmware update. Because there's no chance there's been a firmware update to the ancient 360 controller.

    However, I can't see how this update could have changed anything with the 360 controller as it should definitely not be identifying itself as an "Xbox Wireless Controller" or using a product id of an Xbox One controller. Indeed, I can see in the image you sent me that the Xbox 360 controller is loading the Xbox 360 Controller definition based on the name its reporting. The definition I updated was the Xbox One definition. There was no update of the 360 definition in the file I sent you, so that update cannot have fixed the 360 controller. Perhaps the addendum at the end applies here and the 360 controller was never broken and it was all just Cinemachine using UnityEngine.Input for input. I wasn't sure if that's what you were saying since the text above also stated the 360 controller started working.
     
    Last edited: Apr 10, 2021
    SonicBloomEric likes this.
  6. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,631
    This is in the documentation:
    https://guavaman.com/projects/rewired/docs/HowTos.html#last-used-controller

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

    If you are trying to do this in a multi-player game, you will have to make your own Last Active Controller per Player detection system, because the ReInput methods apply to all controllers, not just ones assigned to a Player.

    All the functions you need are in the Controller class:
    https://guavaman.com/projects/rewired/docs/api-reference/html/T_Rewired_Controller.htm

    The specific functions depend on exactly how you want to implement it.

    https://guavaman.com/projects/rewir...ml/M_Rewired_Controller_GetLastTimeActive.htm
    https://guavaman.com/projects/rewir...tml/M_Rewired_Controller_GetAnyButtonDown.htm
    etc.
     
    FelipeQuevici likes this.
  7. BlankMauser

    BlankMauser

    Joined:
    Dec 10, 2013
    Posts:
    115
    I understand that, the feature is claimed to help make user input more lenient. The issue is that often times games will not have input simply be just a single button, but rather an action. Forward + Attack is not the same as simply pressing Attack for example.

    However if you had combination actions available for get button down, this would be easily solved.
     
  8. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,631
    Rewired intentionally does not offer mutli-element bindings apart from basic keyboard key combos (which simply follow decades-old conventions of how modifier key and primary key combinations behave):
    https://guavaman.com/projects/rewired/docs/HowTos.html#button-combos

    Making such a generalized system is no simple feat and not something I intended to offer as part of Rewired. The number and type of combined elements, the sequences and timings of element activation, the magnitude and direction of such activation (axes), the devices those elements exist on (Rewired's mapping system is per-device, not cross-device), the rules regarding interactions between the bound elements and other elements that may interrupt, block, or change the result of the action, how to manage mixing axes and buttons and how to manage treating buttons as axes and axes as buttons, how to manage relative vs absolute axes in this mixed state, etc. It also massively complicates control rebinding. "Button combos" does not describe the complexity of such a system. "Gestures" is a much more accurate description. It is left up to the developer to implement such systems if their games require them based on the specific needs of their game.

    This also can quickly go in the direction of interweaving gameplay logic into the input system which, I do not believe is the responsibility of the input system and is something I specifically tried to avoid in the design of Rewired where possible.

    Offering just a basic 2 button simple combo binding with no customization options would do no good because I know from experience that each user will have completely different needs from the next and require more or different features and control over those combos to do what they want in their game. If I imply they can manage this kind of logic using Rewired, it would be opening up a big can of worms. I would not implement the feature without implementing it to its fullest extent as a completely new gesture binding layer, but I am not prepared to do that.
     
    Last edited: Apr 11, 2021
  9. _geo__

    _geo__

    Joined:
    Feb 26, 2014
    Posts:
    163
    Hi there and thanks for making rewired.
    After adding it I noticed my mobile build is now about ~ 10MByte bigger than before. Is this to be expected? Maybe I have been overlooking something.

    Here are some infos:
    * Android, Release Build, il2cpp, URP, arm64 + armv7
    * Unity 2019.4.21f1
    * Rewired 1.1.38.4

    I've only added the RewiredInputManager Script to my main scene. No gui stuff etc. (declined all the popups which ask for extra imports at the start). The only thing I am using from rewired is this code below (I am just getting started with Rewired):

    Code (CSharp):
    1.  
    2. if (Rewired.ReInput.controllers.joystickCount > 0)
    3. {
    4.    if (Rewired.ReInput.time.unscaledTime - Rewired.ReInput.controllers.Joysticks[0].GetLastTimeAnyAxisChanged() <= Time.unscaledDeltaTime)
    5.    {
    6.        return true;
    7.    }
    8. }
    9.  
    I think it may be the hardware maps which take up the space. Is there a way to trim those down for mobile builds?

    Update: just found this in the docs. The ControllerDataFiles seem to be what I need.
    So my questions boil down to:

    A) Is there a built-in way to use platform dependent ControllerDataFiles?

    B) Are the "HardwareMaps" assets auto-referenced somewhere at build time? Because I noticed that even after removing all references to them (trimming "ControllerDataFiles", no refs in any scene or code), the final build still increases by ~10MByte. So either they are not the culprit or I have missed something.

    Would be glad if someone could shed some light on this. Thanks.
     
    Last edited: Apr 12, 2021
  10. SonicBloomEric

    SonicBloomEric

    Joined:
    Sep 11, 2014
    Posts:
    897
    When I initially connected the 360 controller after installing the special macOS driver, it worked the same way as the Xbox Wireless Controller: camera moved but no other input was recognized.

    My current assumption here is that the camera movement was due to Cinemachine and the lack of recognition in Rewired was possibly due to macOS (10.14) not having had a chance to fully proliferate all of the necessary data through its HID system yet (or somesuch). I.e. it may simply be that either enough time passed that the data proliferated correctly through the system or that some cached state wasn't updated and "turning it off and on again" (where 'it' = Unity) was enough to get everything correctly working.

    Total guesses. In the end it doesn't really matter as everything works great now. I'm leaving these comments here in case someone else runs into similar issues down the road.
     
  11. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,631
    No. If Unity handled platform-dependent data better, I would have separated controller definitions into platform-dependent definitions.

    The only place controller definitions are ever referenced is from the ControllerDataFiles scriptable object object, which itself is references in the Rewired Input Manager inspector. This is how Rewired gets all its controller data. Unity objects that are referenced by some GameObject that is included in the scene will be included in the project.
     
  12. _geo__

    _geo__

    Joined:
    Feb 26, 2014
    Posts:
    163
    Thanks for your reply.

    I did some more digging and it turns out the code is contributing more to the file size than the profiles (which strikes me as somewhat odd). Would be interested if that can be reduced. I've now tried some other tools (InControl for example) which allow to disable InputX/native features. This results in only +200 KByte to the final build. Not sure what to make of this but as a mobile dev whose app is about 40 MByte in size, an addtional +5 MByte (per architecture) is hard to justify.

    I think the ReWired API is really nice and very well documented but the file size is killing it for me. A solution I thought of is to make a script which yanks out rewired for mobile builds and only use it for platforms where file size is not as much a concern. But that kind of defeats the purpose of a unified input system. Since rewired is such a prominent asset and used by many I still wonder if there is some missconfiguration in my setup which causes this.

    Anyhow, I now have a working solution.
     
  13. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,631
    I'm sorry but I can't reduce the size of Rewired code base. I fail to understand how adding a few megabytes to a mobile application is an issue these days. Games on mobile can frequently be hundreds of megabytes or gigabytes in size. Even small games like Angry Birds 2 is a 200 MB download. If the size of the library is bigger than you want to include in your download, I suggest you use a different system, because I can't discard code to make it smaller.

    Rewired_Core.dll is 2.29 MB
    Rewired_Android.dll is 19 KB

    Those are the only two libraries that are included in Android builds. iOS builds only include Rewired_Core.dll.
     
  14. _geo__

    _geo__

    Joined:
    Feb 26, 2014
    Posts:
    163
    Thanks again for your reply. I'd argue that file size matters (especially in developing countries). I happen to have done download file size A/B testing for about 100.000 downloads myself (about 3 years ago) and the result was very clear. One MByte less file size increases your conversion rate (Google Play App View to Install) by about 0.7% (+/- 0.2%), depending on the target audience. How relevant this finding is nowadays I don't know, but I assume it's still important. Also, people who have stuffed their phone with What's App files will often delete the "biggest" game first to free up memory. It's always good to not be on the top of this list. Therefore I would argue that it still matters.

    It can be circumvented with asset bundles (i.e. have a slim client and then load the rest on demand or in the background). Sadly I can not postpone downloading a core part like the Input System.

    I understand that attempting to trim the code is an unreasonable attempt with such a full featured asset. Especially since it seems that this is not brought to your attention often (so there is not much demand, which I find odd). As mentioned before, I have a working solution now with another Asset so I am good, just wanted to show that it matters.
     
  15. Jyro-Blade

    Jyro-Blade

    Joined:
    Jun 17, 2013
    Posts:
    5
    Hello,

    So I'm using rewired for a relatively simple system for remapping controls for controllers. The process is relatively straightforward and works great with buttons and d-pad. The game prompts you to input each control in order (left, right, up, down, jump, pause) and waits for an input before proceeding to the next. Then it saves those inputs using the player prefs data saver.

    The problem occurs when using joysticks. The very first time it asks you to run through these inputs, some of the inputs register immediately (as in, you press left and the system recognizes left as an input) but some recognize only upon the joystick returning to center (so you press left, nothing happens, then you let it go back to center and it records the correct input).

    This would be relatively fine, but the problem is that the joystick inputs which map immediately, then map an additional input upon returning to center. Thus the return to center maps as an action to the next input in succession. I'm using a nearly identical chunk of code for reading in each of the inputs so I'm not sure why this is the case. Additionally, once you have run through this once, the next time you do it, each input behaves identically (that being, they all register upon return to center only) and I have no idea why these new remapped inputs track consistently when its the exact same piece of code doing the reading.

    I would appreciate any help or thoughts as to what may cause this initial incongruency between the joystick inputs. Thanks
     
  16. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,631
    Because of how polling works.

    Once polling starts, it records the value of the axis. An absolute change in value of 0.7 from that recorded starting value is required to trigger a value detection. This is done because every single kind of axis must be supported by the polling system, including axes that start with odd zero points or change value in an inverted direction. You must indicate to the user to re-center their sticks before you start polling, as is done in both the Control Remapping 1 example and in Control Mapper. Otherwise, you can use a timer but will have make a guess as to how fast the user will release the stick. If the stick is fully or partially pressed in a direction when polling starts, then released, it will either trigger on release, or it may not be mappable until fully pressed in the opposite direction.
     
  17. Jyro-Blade

    Jyro-Blade

    Joined:
    Jun 17, 2013
    Posts:
    5
    Hey thanks for your response.

    Unfortunately waiting for the user to recenter their joystick wouldn't really resolve this issue. Sometimes the joystick will map when you press in the direction, sometimes it will map upon return to center. So you would still end up with inconsistent times when it was mapped regardless of it you input them one at a time. Yes you could avoid mapping the input to the next item sequentially with a pause but that's more of a workaround instead of addressing the actual issue.

    Once they have all been mapped, they all behave identically. I just want to have everything start at that state instead of requiring running through it once. Is there a good way to compare differences between the default mappings I have generated and the modified playerprefs ones? Or is there perhaps a way to save the playerprefs data to the main prefab settings once I have it mapped after that initial run through?
     
  18. AnatoliiSydorov

    AnatoliiSydorov

    Joined:
    Aug 5, 2018
    Posts:
    3
    @guavaman Hi. Thank you for awesome plugin!
    I have a small problem with InputMapper. Maybe I do something wrong, but I can't remap keyboard with ctrl (left and right both). InputMappedEvent don't execute with ctrl button. Also I tried it in example scene SimpleCombinedKeyboardMouseRemapping and in another project, but problem stay. What should I do to solve this?
     
  19. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,631
    It would solve at least part of the issue. Maybe I didn't explain the situation clearly enough. I know exactly why part of what you are describing is happening because I designed Control Mapper and Control Remapping 1 specifically to get around this problem by requiring the user to press a button when they're ready to map an axis or wait for a visible timer to expire before polling begins.

    The moment you start polling, the axis's current value is recorded at that time. Let's say the user is mapping a stick and in the previous mapping, they moved the stick to the right. Without waiting for the user to re-center the stick before you start polling again, the stick horizontal axis start value is recorded as 1.0. Now you immediately start polling for the next action and the user wants to map that to some other element. They release the stick from fully-right, it re-centers, changing value from 1.0 to 0.0, a change in value of 1.0 which is greater than the 0.7 threshold, it triggers a binding to left stick X-. This isn't what the user wanted.

    This sounds like exactly what you're describing: "This would be relatively fine, but the problem is that the joystick inputs which map immediately, then map an additional input upon returning to center. Thus the return to center maps as an action to the next input in succession."

    The part I do not understand about what you are describing is this:

    "The very first time it asks you to run through these inputs, some of the inputs register immediately (as in, you press left and the system recognizes left as an input) but some recognize only upon the joystick returning to center (so you press left, nothing happens, then you let it go back to center and it records the correct input)."

    Are you saying you can start with the stick centered, THEN start polling for input, then press all the way left and it doesn't register? If that's the case, the only possible cause would be a stick with very bad calibration. Are these RC controllers or something unusual? If the stick reports a max value of -0.5 at fully-left, that would not be sufficient to trigger a binding. The default polling threshold is 0.7. A change in value of 0 to -0.5 wouldn't be enough. If that's the case, the stick needs to be calibrated before binding. You can see this in action using Control Mapper or Control Remapping 1 demo. Either that or you need to lower the threshold value: ReInput.ConfigHelper.defaultAbsoluteAxisPollingDeadZone
     
    Last edited: Apr 15, 2021
  20. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,631
    https://guavaman.com/projects/rewired/docs/InputMapper.html

    2. Configure Options

    Each Input Mapper has an Options object which allows you to configure various settings to fit your needs. These settings should be configured before starting the Input Mapper.

    The API reference for InputMapper.Options:
    https://guavaman.com/projects/rewired/docs/api-reference/html/T_Rewired_InputMapper_Options.htm

    These are the relevant options:

    https://guavaman.com/projects/rewir...er_Options_allowKeyboardKeysWithModifiers.htm

    https://guavaman.com/projects/rewir...Options_allowKeyboardModifierKeyAsPrimary.htm

    It's not clear from your message, but I can only assume you're trying to bind Ctrl itself to an Action and not Ctrl + something else.

    You have left the defaults which allow modifiers to be bound with keys. That means it will allow you to bind Ctrl + F, for example. In order to do so, it must wait for the user to press the primary key after pressing the modifier key. If this option is enabled, modifiers alone cannot be bound by simply pressing the modifier key, otherwise there would be no way to bind modifier + something else. In this scenario, you must hold the modifier key down to bind it by itself. Either that or disable allowKeyboardKeysWithModifiers.
     
  21. AnatoliiSydorov

    AnatoliiSydorov

    Joined:
    Aug 5, 2018
    Posts:
    3
    Yes, you are right. I didn't know that this option allowKeyboardKeysWithModifiers works in such way.
    You really help me. Thanks!
     
  22. auroxi

    auroxi

    Joined:
    Dec 31, 2012
    Posts:
    84
    Hi,

    Say I have an action called "Interact" and I want to know at runtime what the current bound key is for that action, how do I do it?

    Thanks
     
  23. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,631
  24. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,631
    Rewired 1.1.39.0 is available on the Unity Asset Store.

    See Updating Rewired before updating.

    1.1.39.0:

    Changes:
    - Added Unity 2021.x branch.
    - Windows Native, OSX Native: Marginally improved DualShock 4 and DualSense gyro drift in computed orientation.
    - Changed inspector settings on Rewired_DirectInput.dll to explicitly exclude OSX platforms due to new Unity bug in Unity 2020.x including Windows DLLs on MacOS builds.
    - Added changes for new Xbox Wireless Controller firmware on MacOS.
     
  25. Nembroten

    Nembroten

    Joined:
    Nov 28, 2013
    Posts:
    9
    Quick question on use:
    I got 2 actions
    Action 1 : Key W
    Action 2 : Key W + Shift modifier

    when I press W Action 1 is run properly
    when I press W+shift, Action 2 is run properly

    but
    when I hold W
    and then add shift, still Action 1 is run and I expected to switch to Action 2

    I'm missing some setting, or I should just not use modifiers?
     
  26. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,631
    You cannot change the way modifiers work. They work basically as they do in operating systems. If you hold W and then press Shift, you won't get a capital W. If that doesn't work for your game, don't use modifiers.

    https://guavaman.com/projects/rewired/docs/HowTos.html#button-combos
     
  27. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,314
    anyone developed or created a custom control for rewired and SteamVR? I'll already a pretty standard setting and the documentation states you could write a custom controller for it. It would save us days of work if one was already implemented.
     
  28. McGrizzle

    McGrizzle

    Joined:
    Aug 24, 2014
    Posts:
    8
    We just launched a game on Steam using Rewired and there have been reports of controllers not being recognized.
    This has led to at least 1 negative review and refund of the game :-(

    We didn't see these issues in our pretty extensive testing but I can reproduce a similar issue:
    1. start the game from Steam but keep another window focused (on a 2nd monitor) and interact with another app for a few seconds
    2. Alt-Tab back to the game and the controller doesn't respond
    When this happens the log has this all too familiar Unity error followed by a rewired "reconnected" message.

    <RI.Hid> Failed to create device file:
    e7 All pipe instances are busy.

    Joystick reconnected ("Controller (XBOX 360 For Windows)").

    <RI.Hid> Failed to create device file:
    e7 All pipe instances are busy.
    I can unplug-replug in the controller or restart the game as a fix but it's not nice for users to have to do this. I also tried doing AutoAssignJoystick but OnControllerConnected isn't called unless I unplug and replug in the controller.

    We have set the Steam Input Default Configuration to "Generic Gamepad" as recommended which hopefully solves the controller not recognized at all. Also I changed the script execution order so Steam Manager initializes before Rewired.

    Has anyone had this issue and know of a workaround I can do in code?

    We are using Unity 2019.4.23 and Rewired 1.1.38.4.

    Thanks.
     
    Last edited: Apr 18, 2021
  29. McGrizzle

    McGrizzle

    Joined:
    Aug 24, 2014
    Posts:
    8
    I did some more testing and when the controller stops working it's the menu navigation that is broken. In my debug log I can see that the rewired controller is detected and assigned. The default joystick movement and button press doesn't work.
    Pressing UI buttons and navigating menus with a thumb stick is not something I map via rewired actions. I handle things like shoulder buttons to change menu tabs. Not button "Select()". Unity does that by default and in this case stops processing controller input.

    Again this issue only happens when you start the game via Steam and focus on another window (click on menus etc.) for a while. Then alt-tab back to the game.
     
  30. kopanz

    kopanz

    Joined:
    Dec 6, 2016
    Posts:
    13
    Can you please add Logitech G923 to the supported controllers. Button/Axis mapping is same with G29. Only the USB Device ID is different. Is it possible to clone G29 profile and change the device ID without creating it from scratch ? Can we change core settings of Rewired easily ?
     
  31. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,631
    First, the reconnected messages in your log are not from Rewired. Rewired ALWAYS logs information with the prefix [Rewired]. The message you're seeing is from Unity, not Rewired. Rewired never logs anything unless there is a warning or error.

    Steam-configured controllers can only be seen by the application if Steam is configured correctly. This is not optional and this is not specific to Rewired. It will not work unless Steam is configured to expose a gamepad to the application. This is covered in the documentation:

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

    ***IMPORTANT*** Configuring Steam Controller Settings

    Both Steam Controllers and Steam-configured controllers appear to the application based on settings configured both by the developer in the Steamworks backend and by the end user in the Steam client interface.

    You MUST set up default configuration settings for the Steam Controller in the Steamworks backend for your application, otherwise the application may not detect any controllers.

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

    For non-Steam-configured controllers, you must make sure you have a way for users to remap and re-assign controls or you will have more frustrated customers. See Best Practices.

    I'm not clear on what you're saying here.

    "I did some more testing and when the controller stops working it's the menu navigation that is broken"

    Is it the Controller that's not working or the menu navigation? That's a very important difference. Is the Controller producing any input at all?

    Code (csharp):
    1. foreach(Joystick j in ReInput.controllers.Joysticks) {
    2.     if(j.GetAnyButton()) {
    3.         Debug.Log(j.name + " is producing button input");
    4.     }
    5. }
    If the controller is producing input, yet the UI isn't responding, the problem isn't in the Controller or in Rewired, but in the code that is navigating the UI.

    "Unity does that by default and in this case stops processing controller input." If I understand what you're saying here, then you're not using Rewired for UI navigation -- you're using UnityEngine.Input. The Unity Standalone Input Module is a Unity component and uses UnityEngine.Input to get all input. Rewired cannot automatically take over Unity input. Any script that consumes input consumes it from a particular source. The only way Rewired will be used for Unity UI input is if you have set up the Rewired Standalone Input Module to replace the Unity Standalone Input Module and have set it up to process Actions to navigate the UI.
     
    Last edited: Apr 18, 2021
  32. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,631
    https://guavaman.com/projects/rewired/docs/HowTos.html#new-controller-definitions

    If that's true that the only difference is Product and Vendor Id, edit the existing G29 definition and add those Ids to each platform.
     
  33. McGrizzle

    McGrizzle

    Joined:
    Aug 24, 2014
    Posts:
    8
    Hi,

    I verified that Rewired mapped actions work. It seems to be the joystick UI navigation that doesn't work.

    Again, this ONLY happens if you first start the game and have another window focused like a text editor and are interacting with it, then alt-tab back to the game. The joystick stops responding so you can't press any buttons to start the game. The keyboard and mouse work fine.

    Note in our code we never use UnityEngine.Input calls for game actions. We only use Rewired.Player GetButtonDown etc. and all in-game actions are done through rewire.

    The only thing I'm talking about here is the controller thumbstick movement that controls menu button navigation and the submit and cancel buttons. These are the things that stop working with UI.

    upload_2021-4-18_11-36-33.png

    We also have code to prevent deselection so the Unity event system always a selected game object for navigation. And keyboard UI navigation and selection still works.

    For UI navigation we shouldn't have to remap unity button presses or navigation. Unity Standalone Input Module takes care of that. But I think that's the part where the controller gets broken. This seems like Unity and not Rewired.

    If you have any ideas on "resetting" it through code I'd be grateful.

    Thanks.
     

    Attached Files:

  34. McGrizzle

    McGrizzle

    Joined:
    Aug 24, 2014
    Posts:
    8
    UPDATE:
    So it turns out that NOT using rewiredStandaloneInputModule was my problem :oops:
    A quick test on Steam and it seems to fix my issue. Next time I'll RTFM a bit better.

    Thanks for the help guavaman!
     
  35. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,631
    Yep. That's what I was getting at in my previous message:

    If you're not using the Rewired Standalone Input Module, you're not using Rewired for Unity UI navigation.

    Glad you solved it.
     
  36. kopanz

    kopanz

    Joined:
    Dec 6, 2016
    Posts:
    13
    It takes some noticable time to enable/disable a gameobject with ControlMapper items in it. Is it a Unity thing or everytime ControlMapper panel hides/unhides some background functions are called ? Can we shorten the time needed for those state changes ? I'm not calling ControllerMapper.Open or Close, just using GameObject.SetActive().
     
  37. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,631
    The Action list, controller list, bindings list, etc all have to be rebuilt. This isn't optional.

    Use ControlMapper.Open and Close. You will get a flash of canvas scaling artifacts when enabling the GameObject while Control Mapper is already displayed.
     
  38. adamnorton

    adamnorton

    Joined:
    Oct 17, 2012
    Posts:
    37
  39. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,631
    The error is not being caused by Rewired, it's being caused by the code trying to query an Action that was never defined in the Rewired Input Manager. The code is calling a non-existent Action and Rewired is telling you that it doesn't exist.

    Create the Action and map it to something if you need it.
     
  40. Zorkind

    Zorkind

    Joined:
    May 4, 2015
    Posts:
    42
    Hey guavaman....i have a specific situation here that i want your help with.

    I am adding this as a mod to a game, for obvious reasons i can't recompile the entire game, what i do is load everything i need by means of Asset Bundles.

    Have been doing amazing things this way xD

    I setup everything i need for the Rewired to work, but no matter what i do, it wont load the ControllerDataFiles.

    I was wondering, can you provide a way to load AFTER the game has started?

    I understand you load everything at the first moment possible, but is there a way for you to make the Initialization of Rewire manual by means of a method call?

    I can load the ControllerDataFiles from the Asset Bundle, but even if i could set the dataFiles Property in the InputManager class, it is already too late, and i get the message that Rewired could not be loaded, and there's nothing i can do to FORCE it to Retry :(

    Can you help out?

    Thanks o/
     
  41. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,631
    https://guavaman.com/projects/rewired/docs/InputManager.html

    The Rewired Input Manager is a GameObject with MonoBehaviour attached and works like every other MonoBehaviour in Unity. Awake does not run until the GameObject is enabled. Instantiate the GameObject disabled, set the Controller Data Files, then enable the GameObject.
     
  42. Zorkind

    Zorkind

    Joined:
    May 4, 2015
    Posts:
    42
    Ok i will try that then.

    Question, is there any important code in the dataFiles property?

    Since it is get only, i will have to override it with NEW keywork in order to set the datafiles.

    Is that ok?
     
  43. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,631
    That's not going to work. You would not be setting the data files field. You would just be making your own setter which would have no way to actually set the backing field. The only way you're going to be able to do it is through reflection.

    The field is:

    private ControllerDataFiles _controllerDataFiles;
     
  44. Zorkind

    Zorkind

    Joined:
    May 4, 2015
    Posts:
    42
    That field is not in the InputManager_Base class.

    only dataFiles.

    What am i missing?
     
  45. Zorkind

    Zorkind

    Joined:
    May 4, 2015
    Posts:
    42
    Ahhh my bad, i got the field now.

    Forgot to add the flags :p
     
  46. Zorkind

    Zorkind

    Joined:
    May 4, 2015
    Posts:
    42
    Ahhh i got "Rewired: An exception occurred during initialization. Input will not function." now.
     
  47. Zorkind

    Zorkind

    Joined:
    May 4, 2015
    Posts:
    42
    My intuition is telling me that something complex inside the ScriptableObject is making it fail to serialize into the Bundle.

    [ERROR] ControllerDataFiles is missing critical data! The serialized data may have been corrupted. Please see the Known Issues in the documentation for possible causes and solutions.

    I saw a post about this in another thread, Lists and complex structures fail to serialize into Bundles, for some reason Unity stays quiet about this, when you are building the bundles.
     
  48. Zorkind

    Zorkind

    Joined:
    May 4, 2015
    Posts:
    42
    Sorry for posting so much here, i am just trying to understand whats going on.

    I created a small ControllerDataFile with only XBox360 controller, i don't need all the hardware types in the original one.

    Also i checked by writing to the debug the values in the ControllerDataFile, it looks like it is loaded correctly.

    So, something else is wrong here.

    What this method is for? Rewired.ReInput.atCitDwqJJoxOdvZenzpRDMGWUT

    Something in this method is causing that Null Reference but i have no way to determine what it is.
     
  49. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,631
    The function logging the error is this:

    Code (csharp):
    1. private void VerifyDataIntegrity() {
    2.     if(dataIntegrityVerified) return;
    3.  
    4.     if(Utils.ArrayTools.IsNullOrEmpty(hardwareJoystickMaps) ||
    5.         defaultHardwareJoystickMap == null ||
    6.         Utils.ArrayTools.IsNullOrEmpty(joystickTemplates)
    7.         ) {
    8.         Logger.LogError("ControllerDataFiles is missing critical data! The serialized data may have been corrupted. Please see the Known Issues in the documentation for possible causes and solutions.");
    9.     } else {
    10.         dataIntegrityVerified = true;
    11.     }
    12. }
    Its purpose is to detect data corruption that happens a lot with Unity under various scenarios.

    Something is missing from ControllerDataFiles if it's throwing this error. Your Asset Bundle must not contain all the required files. Every single file in Rewired/Internal/Data/Controllers and Rewired/Internal/Data/CustomCalcluation should be included.
     
  50. Zorkind

    Zorkind

    Joined:
    May 4, 2015
    Posts:
    42
    Ohhhh perhaps CustomCalculations then D:

    I will try :p

    Urghhhh i want this to work so bad >_<
     
unityunity