Search Unity

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,625
    The PS4 platform has the option "Assign Joysticks by PS4 Joy Id":
    https://guavaman.com/projects/rewired/docs/RewiredEditor.html#Settings

    "If this option is enabled, joysticks will be assigned to Rewired Players based on the PS4 joystick id assigned by the system. This option ensures that the PS4 joystick id will match to the Rewired Player when auto-assigned. This option overrides some other joystick auto-assignment settings. More than one joystick will be assigned to a Player if multiple joysticks are found for that PS4 player id."

    All special platforms have system ids exposed through the relevant Controller Extension for that controller. You can see the PS4's here:
    https://guavaman.com/projects/rewir...Rewired_Platforms_PS4_PS4GamepadExtension.htm
     
  2. CHOO5D

    CHOO5D

    Joined:
    Dec 24, 2016
    Posts:
    55
    "If your game is 1-Player: Set Max Joysticks Per Player to 100 so all controllers attached to the system may be used by the player."

    So for single player games, I will need to set the max joysticks to 100? is that what you mean?
    Not sure if 1-Player is referring to single or multiplayer and it's weird that single player game needs to have many controllers being detected.. maybe i need more information, thanks.
     
  3. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    If your game is not a multi-player game, set it to a high number like 100. If you leave it at 1 and the user has more than one controller attached to the system (or if there are virtual devices appearing to the system), then only one controller will work. If you set it to 100, all controllers attached to the system will contribute input and the user can pick any of them up and use them.
     
    CHOO5D likes this.
  4. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    In addition to what @guavaman said there are several types of single player games where you have multiple usb controllers hooked up concurrently and used. Also there are times when customers have multiple products from different manufactures for these types of games. This is not an exclusive list but just to give you an idea.

    Car Racing games. (racing wheel, shifter and pedals = 3 usb devices)

    https://www.thrustmaster.com/en_US/products/categories/racing-wheels&tid=505

    Flight Simulation type games (flight stick or yoke, throttle and then rudder pedals = 3 usb devices)

    https://www.thrustmaster.com/en_US/products/t16000m-fcs-flight-pack

    Farm Simulator ( Heavy equipment wheel, Gas and brake pedal set , and Side panel control deck = 3 usb devices)


    https://www.logitechg.com/en-us/products/farm/farm-simulator-game-bundle.945-000063.html
     
    guavaman likes this.
  5. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    Good points!
     
  6. Hugbot

    Hugbot

    Joined:
    Jul 10, 2013
    Posts:
    10
    Hey @guavaman

    I'm not sure the appropriate channel to reach out regarding some confusion on my end about the `Rewired` library. It seems absolutely wonderful!

    Can you speculate or provide an answer/explanation on an issue I'm encountering with `GetButtonDown` value input being raised?

    I have a Player called `Player One` who assigned the playerId of `0`

    Player One has a `KeyboardMap` that is set up to use the `WADS` keys that are mapped to four actions
    • Move Up
    • Move Down
    • Move Left
    • Move Right
    Screen Shot 0003-10-11 at 6.50.46 PM.png
    Screen Shot 0003-10-11 at 6.51.22 PM.png

    Screen Shot 0003-10-11 at 6.51.37 PM.png
    I want to build this as an event wrapper so that I can hook into the `ButtonDown(ActionName)` method so I can fire off events when that occurs.

    I wrote the code below

    Code (CSharp):
    1. void Update() {
    2.     PerformMovement();
    3. }
    4.  
    5. private void PerformMovement() {
    6.     bool isMoveLeftPressed = player.GetButton(moveLeftKeyName);
    7.     bool isMoveRightPressed = player.GetButtonDown(moveRightKeyName);
    8.  
    9.     float moveLeftValue = player.GetAxis(moveLeftKeyName);
    10.     float moveRightValue = player.GetAxis(moveRightKeyName);
    11.  
    12.     if (isMoveLeftPressed == true || isMoveRightPressed == true) {
    13.         Debug.Log("----------");
    14.         Debug.Log("isMoveLeftPressed: " + isMoveLeftPressed);
    15.         Debug.Log("moveLeftValue: " + moveLeftValue);
    16.         Debug.Log("isMoveRightPressed: " + isMoveRightPressed);
    17.         Debug.Log("moveRightValue: " + moveRightValue);
    18.     }
    19. }
    I believe it's It's fairly straightforward.

    My issue is that when I used this configuration the `isMoveLeftPressed` is never True. Ever.

    HOWEVER, the action itself does show the value as going to -1 when held down.

    Screen Shot 0003-10-11 at 6.52.12 PM.png

    Screen Shot 0003-10-11 at 6.52.24 PM.png

    Why is the `player.GetButton(moveLeftKeyName);` never returning true if its action is working? Am I misunderstanding something about how these function or raised?
     
  7. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    Read this:
    https://guavaman.com/projects/rewired/docs/HowTos.html#button-press-types

    Negative Buttons:

    Each of the methods above also has a corresponding Negative Button method which is named the same except with NegativeButton in place of Button. These serve to allow you to use axes as buttons and will trigger when the negative side of the axis is activated while the standard Button version will trigger only when the positive side of the axis is activated. However, it is usually easier to just map each pole of the axis to a seperate Action (split axis) so that each Action can just be queried with GetButton.

    If you want all GetButton calls to return True when either the positive or negative side of the axis is activated, enable the option "Activate Action Buttons on Negative Values" in the Rewired Editor.

    Also read this:
    https://guavaman.com/projects/rewired/docs/HowTos.html#get-input

    Rewired already provides an event interface if you choose to use it.
     
  8. Kazeon

    Kazeon

    Joined:
    May 22, 2017
    Posts:
    41
    Thank you very much!

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

    I'm encountering a problem started yesterday and it still persists until now: all the sudden my joystick doesn't work at all on my PC. I know it's most likely not related to Rewired at all, but you have the most experience around here so probably you can help.

    When I plugged my joystick (no matter to which USB slot), the unity always prints "<RI.Hid> Failed to get preparsed data: The operation completed successfully." error in the console. And the joystick simply doesn't work (not detected by rewired). I googled and they say it's because my joystick is not recognized as common gamepad, but it's an Xbox One controller, it worked before, and it also works on other PCs. Do you know how to fix this?

    I will keep searching and edit this post when I've found the solution. Thanks in advance!

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

    UPDATE #1:

    Found out that other joysticks also do not work. They work on other PCs tho.
     
    Last edited: Oct 13, 2021
  9. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    There is something in the Rewired documentation here on that type of error message.

    https://guavaman.com/projects/rewired/docs/KnownIssues.html#windows-ri-hid-error

    It sounds like you have PC hardware problems or a usb driver problem if all usb controllers are failing. Have you recently performed an OS updates?

    What windows version are you running? (e.g. Windows 10 build 20H2)
     
    guavaman likes this.
  10. aaronm64

    aaronm64

    Joined:
    Nov 24, 2018
    Posts:
    17
    Hello!
    Will Rewired be able to work with OpenXR?

    We currently use Rewired, but we are upgrading to OpenXR and the OpenXR package seems to require the New Input System, which Rewired reports is incompatible.

    Re: https://docs.unity3d.com/Packages/com.unity.xr.openxr@1.2/manual/index.html => Upgrading a Project to use OpenXR => 3. Update your input code.

    Do you have any recommendations for us? Thank you!
     
    Last edited: Oct 13, 2021
  11. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    This is what I see in the Rewired documentation with regards to VR.

    https://guavaman.com/projects/rewired/docs/FAQ.html#does-rewired-support-vr-controllers
     
    guavaman likes this.
  12. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    Steam can cause all sorts of issues with joysticks if not configured correctly:
    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#steam

    Remove any 3rd party drivers / mapping tools like DS4Win.
     
  13. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    Rewired is not a VR input system. It requires too much work to maintain all these 3rd party SDKs and frameworks across platforms as they constantly evolve. I do not have the bandwidth to support VR with all the other platforms, devices, software distribution systems, Unity versions, etc, I support.

    Rewired may or may not work correctly with the new input system enabled depending on the specific platform and input sources in use.

    The only way to make Rewired work with something like this is to Implement your own Open XR wrapper using Custom Controllers.
     
  14. StageClearStudios

    StageClearStudios

    Joined:
    Jan 30, 2018
    Posts:
    40
    Hey @guavaman !

    Is there a way to disable some buttons/keys for remapping? For example the pause button on a controller or the escape key on a keyboard. Have been searching for a while, but haven't found anything. Thanks!
     
  15. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    I need more context. How have you implemented remapping?

    1. Control Mapper: No, unless there is already an Action mapped to that element that is protected from reassignment: https://guavaman.com/projects/rewired/docs/HowTos.html#conflict-checking

    2. Custom system using Input Mapper: See #7:
    https://guavaman.com/projects/rewired/docs/InputMapper.html
     
  16. HazukiDD

    HazukiDD

    Joined:
    Oct 8, 2019
    Posts:
    4
    Howdy @guavaman !
    Not sure this was the best place to ask for support or whatnot but I'm struggling to find out how to iterate through the the "Mouse Maps->Elements"
    Now following the code used in ControlRemappingDemo1.cs
    To loop through the keyboard maps I have:
    Code (CSharp):
    1.         foreach (InputMapCategory category in ReInput.mapping.UserAssignableMapCategories)
    2.         {
    3.             selectedMapCategoryId = category.id;
    4.             selectedMap = selectedPlayer.controllers.maps.GetFirstMapInCategory(ControllerType.Keyboard, 0, category.id);
    5.         }
    Code (CSharp):
    1.         InputMapCategory mapCategory = ReInput.mapping.GetMapCategory(selectedMapCategoryId); // get the selected map category
    2.         if (mapCategory == null) return;
    3.         InputCategory actionCategory = ReInput.mapping.GetActionCategory(mapCategory.name); // get the action category with the same name
    4.         if (actionCategory == null) return; // no action category exists with the same name
    5.  
    6.         foreach (InputAction action in ReInput.mapping.ActionsInCategory(actionCategory.id))
    7.         {
    8.             string name = action.descriptiveName != string.Empty ? action.descriptiveName : action.name;
    9.             Debug.Log("selectedMap:AllMaps:" + selectedMap:AllMaps);
    10.                foreach (ActionElementMap elementMap in selectedMap.AllMaps)
    11.                 {
    12.                     if (elementMap.actionId != action.id) continue;
    13.  
    14.                     //ActionElementMap elementMap
    15.                     Debug.Log("ActionElementMap elementMap:" + elementMap);
    16.  
    Appologies that the code block for some reason looks awfully structured using the code button here, so
    Debug.Log("selectedMap:AllMaps:" + selectedMap:AllMaps)
    will return all 13 (0-12) of the elements that are in:
    Rewired Editor->Keyboard Maps->Element: (Category is : 0 : Default *, Layout: 0 : Default *) I can then assign these to specific buttons to show what keys are currently mapped. Great stuff now using the same code but replacing
    selectedMap = selectedPlayer.controllers.maps.GetFirstMapInCategory(ControllerType.Keyboard, 0, category.id);
    with the ControllerType.Mouse so:
    selectedMap = selectedPlayer.controllers.maps.GetFirstMapInCategory(ControllerType.Mouse, 0, category.id);


    Now running this exact same code but with the new controller type as mouse
    Debug.Log("selectedMap:AllMaps:" + selectedMap:AllMaps)
    now only ever returns 1 map
    which is the first element from Rewired Editor->Mouse Maps->Element: (Category is : 0 : Default *, Layout: 0 : Default *) so what do I do here? no matter what I've tried I'm only still ever returned 1 map, I can't see why this would make a difference code wise vs the keyboards map currently stuck on this so your help would be greatly appreciated!
     
  17. XCO

    XCO

    Joined:
    Nov 17, 2012
    Posts:
    380
    Do you know if this supports the PS5 ?
     
    futurlab_peterh likes this.
  18. marchall_box

    marchall_box

    Joined:
    Mar 28, 2013
    Posts:
    139
    I recently updated Unity version for my project from 2019 LTS to 2020 LTS.
    I got this warning and re-installed the Rewired but the warning does not go away.
    upload_2021-10-17_2-28-28.png
    How do I manually re-download the rewired??
     
  19. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    From the Rewired documentation you can try these and see if that helps.

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

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

    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#wrong-rewired-version-installed
     
    guavaman likes this.
  20. Smack332

    Smack332

    Joined:
    Nov 5, 2018
    Posts:
    9
    I'm using Rewired in a new project with several custom controllers, and it's helping tremendously. However, the project also depends on a lot of UI customization, which I planned on using Doozy 4.0 for. However, Doozy depends on the new Input Manager, which Rewired does not support. I tried enabling both the new and old input handling, and so far it seems to work. However, I'm worried that something might break down the road, since Rewired specifies that you only should enable the old system.

    Can anyone shed some light on what might happen with both enabled?
     
  21. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    395
    I talked to Doozy's developer and he seems willing to better separate the hard-dependency on the new input system.
    No ETA or anything, but just something to keep in mind.

    I also emailed Rewired's support about this, and there are no plans to support Unity's new Input system, and using both is unsupported (might not work on some platforms).
     
    Smack332 likes this.
  22. Smack332

    Smack332

    Joined:
    Nov 5, 2018
    Posts:
    9
    Thank you for the info. So it may be safe to assume that as long as it works on my target platform now with both enabled, it will continue to do so later as well?
     
  23. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    395
    It might break with a future Input System or Unity update, or even OS update.
    Since it is not vetted, there's really no way we can know for sure.
    If your only attachment to the new Input System is Doozy, you might be able to just keep developing as normal, and when the Doozy dev releases the update with the proper separation, you can remove the dependency to the Input System.
     
  24. gearedgeek

    gearedgeek

    Joined:
    Jun 19, 2015
    Posts:
    236
    Unity 2019.4.31f1 with Corgi Engine 7.3.1

    Getting this error when installing the integration with Corgi.
    Code (CSharp):
    1. Assets\Rewired\Integration\CorgiEngine\Scripts\RewiredInventoryInputManager.cs(64,21): error CS0103: The name 'InventoryOpen' does not exist in the current context
    2. Assets\Rewired\Integration\CorgiEngine\Scripts\RewiredInventoryInputManager.cs(74,38): error CS0103: The name 'InventoryOpen' does not exist in the current context
    3. Assets\Rewired\Integration\CorgiEngine\Scripts\RewiredInventoryInputManager.cs(128,17): error CS0103: The name 'InventoryOpen' does not exist in the current context
    4.  
     
  25. utkarshdwivedi3997

    utkarshdwivedi3997

    Joined:
    Aug 11, 2017
    Posts:
    25
    Hey @guavaman! I had based our control mapping code pretty much 1 to 1 on the Simple Combined Keyboard Mouse Remapping example provided with the Unity Rewired assets. This system worked perfectly until we upgraded from Rewired 1.1.30.0 to v1.1.39.3.U2019.

    We have 6 Rewired players that all need to get the same exact remappings. The way we do this is to GetPlayer(0), get the maps from this player that need to be remapped, show those elements in the UI and then let the player remap those controls. Once the player is done remapping that specific map, we apply the map to the remaining 5 players by clearing their ElementMaps and then copying over the ActionElementMaps from the ControllerMap for player 0 that was used for the remapping. Here's the basic flow of this:
    1. Load saved XML maps into Player 0 using AddMapsFromXml(), if there are any saved maps.
    2. ControllerMap sourceMap = GetPlayer(0).GetMap(...)
    3. Apply sourceMap to players 1 through 5 (this is part of the loading saved maps process)
    4. Player remaps sourceMap, and the remapping shows the identifiers correctly in the UI before and after being remapped
    5. Apply sourceMap to Players 1 through 5
    6. Save sourceMap into XML
    As I mentioned, this was working perfectly until the upgrade and there seems to be a small issue now - Players 1 through 5 seem to still get the rebindings and work properly, however Player 0's bindings seem to not change at all. This does not make sense to me because Player 0's map is the one that is actually remapped (sourceMap) and then copied over to the other players. It seems that even though sourceMap is updating correctly, it is not updating Player 0's map. As a workaround I tried to copy over the sourceMap to Player 0 as well, but that seems to be completely clearing Player 0's maps without adding the ActionElementMaps.

    Another issue that happens is at the start when saved maps are loaded. Even though the sourceMaps work after being copied to Players 1 through 5, the next time the game launches and the sourceMap XML is loaded and copied over from Player 0, Players 1 through 5 have the default maps. Player 0's maps are empty. This, also, started happening after the upgrade.

    I've gone through the changelist because I did upgrade through a lot of versions of Rewired, but it doesn't seem like anything in the notes might have caused this change. I'm still investigating the cause of this, but I wonder if this could be a bug introduced in one of the updates or not.
     
  26. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    That is a big risk to take that especially when it says that is not supported in the documentation.

    https://guavaman.com/projects/rewired/docs/KnownIssues.html#not-compatible-unity-new-input-system

    Also I can think of nightmare cases where it works fine on your machine and it only fails on a few of your customers' machines in the field. With thousands of customers it would a problem if it keeps failing on only a few hundred of them. That would sure cost you a large amount of time and your customers. Also since it is not a supported by Rewired (as stated in the documentation) you cannot ask for support either.
     
    Smack332 likes this.
  27. AlCaTrAzzGames

    AlCaTrAzzGames

    Joined:
    May 17, 2017
    Posts:
    25
    hi all, just wondering if there was support with rewired for either

    a. the 2nd gen siri remote for tvOS (GCDirectionalController)
    b. glyph support for controller remapping, as added in iOS/tvOS 14.5 and 15
     
  28. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    guavaman likes this.
  29. gearedgeek

    gearedgeek

    Joined:
    Jun 19, 2015
    Posts:
    236
    I have also noticed there are a few missing scripts in the Mesa1 demo scene in the rewired integration folder.
     
  30. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    In the Rewired docs it discusses some of the limitations in the Requirements section ...

    https://guavaman.com/projects/rewired/docs/Integration.html#CorgiEngine
     
  31. gearedgeek

    gearedgeek

    Joined:
    Jun 19, 2015
    Posts:
    236
  32. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    Nothing has changed with XML loading between those versions.

    Since I don't have your implementation, I can't really say anything with certainty.

    If you were using any of the Rewired remapping examples, it is not possible for Player 0's controller maps to be rebound and not stick in the Player. The exact Controller Map object you are editing when rebinding is the exact object the Player uses for input. There are no temporary objects. So I can only assume there is some code that is clearing or overwriting the maps. This also would be the case for this:

    Log the XML that is being loaded into the Player from wherever you are loading it. Verify what you think is being loaded actually is being loaded. Verify what is loaded in the Player using Debug Information.
    • How have you implemented saving / loading of XML? Are you using User DataStorePlayerPrefs or some custom implementation?
    • When / how are you loading data?
    • Are you using any other Controller Map management systems like Layout Manager?
    • Are you ever calling player.controllers.maps.LoadDefaultMaps or something similar?
     
  33. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    There is nothing that would prevent it from showing the ActionElementMaps in the Mouse if they exist and match the criteria. Did you try using Debug Information to see exactly what Controller Maps and Action Element Maps are loaded in your Player? https://guavaman.com/projects/rewired/docs/Troubleshooting.html#debug-information

    My suspicion is you have saved XML data being loaded and therefore what is loaded in the Player is not what you're seeing in the Rewired Input Manager:

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

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
  35. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#wrong-rewired-version-installed

    Error: The version of Rewired installed was not designed for Unity X. Please install Rewired for Unity X.
    The error indicates you have installed a version of Rewired incompatible with the version of Unity you are using. You must install the correct version of Rewired from the Unity Asset Store.

    The Unity Asset Store will automatically download the correct branch for the version of Unity you are using when downloading an asset. However, it does have bugs. If you have downloaded Rewired in a newer or older major version of the Unity editor, that version of the file will be cached in the Asset Store download location. The exact same download location is used for all versions of Unity from 5.0 onward, so when you switch to a different major version of Unity, the Unity Asset Store installer will install a copy of Rewired which was downloaded for a different version of Unity. The only solution is to delete the cached download and re-download it in Unity editor. See the Unity Manual for location of the Asset Store files.

    The download locations as the time of this writing are as follows:

    Windows:
    C:\Users\(your user name)\AppData\Roaming\Unity\Asset Store
    C:\Users\(your user name)\AppData\Roaming\Unity\Asset Store-5.x

    MacOS:
    ~/Library/Unity/Asset Store
    ~/Library/Unity/Asset Store-5.x

    Linux:
    home/.local/share/unity3d/Asset Store-5.x

    These locations are subject to change at any time due to changes by Unity. Always See the Unity Manual for the most recent information about the location of the Asset Store files.
     
  36. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    Until now, there has been no way to even have the new Input System enabled on Windows and have both Rewired's native input and the new Input System's keyboard and mouse input function simultaneously. Due to a breaking change by Unity in 2021.2 beta that caused Rewired's native mouse input to stop working (https://forum.unity.com/threads/windows-mouse-raw-input-mouse-handling-broken-in-rewired.1172786/), changes had to be made to Unity to get around hard Windows limitations with the Raw Input API. A new function was added to Unity that would allow Rewired to forward Raw Input events to Unity, thereby making it work not only with Unity 2021.2 beta, but also with the new Input System. So going forward, it should be possible to use Rewired with the new Input System enabled on Windows, though Rewired will not make use of the new Input System in any way and the setting must be set to "Both" so it can have access to the legacy UnityEngine.Input.
     
    Smack332 and SugoiDev like this.
  37. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    Then the developer has made breaking changes and the integration will not work anymore without code changes.

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

    >> Corgi Engine v4.0 (No future version compatibility is guaranteed.)

    The last time I updated the integration was 1.1.31.0 which was released 2/24/2020. I believe it was on v6 at that time.

    I can't support multiple versions of an asset as they change over time. Assets do not have preprocessor #if's like Unity to be able to branch code like #if CORGI_ENGINE_V4_OR_GREATER do this, etc.
     
    gearedgeek likes this.
  38. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    Rewired uses UnityEngine.Input for all input on tvOS and iOS:
    https://guavaman.com/projects/rewired/docs/Overview.html#tested-platforms

    GCDirectionalController is a native API and Rewired does not implement it. Unity may, but if it does, it exposes everything through the same old UnityEngine.Input system. I see nothing about support for new features of the remote in Unity's tvOS input documentation. Does it even have any different features? I would expect it would already work as the standard remote, but I can't say for sure because I don't have one and I haven't tested it.
     
  39. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    Just downloaded Corgi Engine 7.3.1 and see the same errors.

    He changed "InventoryOpen" to "InventoryIsOpen." Change 3 lines of code and it will compile.
     
    haywirephoenix and gearedgeek like this.
  40. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    395
    That's neat!
    I guess the only thing "missing" for me is having Rewired working with domain reloads disabled so we can enter playmode fast.
    I was actually thinking about this today and have a question. What's Rewired's entry point? If I can call into it manually when entering playmode, it could just work
    This is something I've done for other stuff, including my own. I can pay the price for my code to re-initialize (less than 1 second), I just don't want to pay the price for Unity's code to re-initialize (often in the 10 seconds ballpark).
     
  41. thiskidcalledtom

    thiskidcalledtom

    Joined:
    Nov 9, 2017
    Posts:
    35
    Hello! When navigating UI on a gamepad (using the gamepad template) I've notived the UI navigation is very sensitive, i can skip items in UI very easily, I've configured both d-pad and left analogue stick to navigate UI, and UI is controlled in its own action map. Is there a way to lower the navigation sensitivity for UI? Thank you!
     
  42. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    797
    Check the input actions per second / repeat delay in the standalone input module

    https://guavaman.com/projects/rewired/docs/RewiredStandaloneInputModule.html
     
    guavaman likes this.
  43. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    Rewired's entry points are Unity's main entry points for code:
    MonoBehaviour.Awake
    MonoBehaviour.Update
    MonoBehaviour.FixedUpdate
    MonoBehaviour.OnGUI

    It can't work on a custom update because Rewired has to work with Unity UI, which is based on Update and Rewired's API is not thread safe. I've had people ask for the ability to manually execute the entry and update before, so they could run the input update on a different thread. It has a bunch of unforeseen consequences. Rewired also has to run its Awake before any other script that might call any of its functions in Awake, so it has a script execution order of the lowest possible value.

    You could already achieve this as it is now though. Just instantiate or enable the Rewired Input Manager GameObject after entering Play mode manually. Disable the GameObject manually when you exit.

    The problem is, when the script domain is not reloaded, static fields are not cleared. Rewired's public static events and fields in ReInput are all reset by Rewired when it initializes, but if there are any other static fields anywhere else in the code that possibly depend on a value being null on start, they will not be cleared and it will not work, but possibly only on the 2nd you enter Play Mode.

    Example:
    Code (csharp):
    1. private static object _someValue;
    2.  
    3. public static object someValue { get { return _someValue ?? (_someValue = CreateSomeValue()); } }
    If the object created on the first use of the someValue property is dependent upon being created by the current running instance of Rewired, it will fail. Rewired tracks its own internal session id (a static value) that is incremented every time Rewired initializes in a play session. Any object created by one Rewired session is invalid once that session ends. If a new session starts and something attempts to use that object from the previous session, an exception will be thrown. This is done to prevent the user from storing Player, Controller, ControllerMap, etc. objects in their scripts, then disabling the Rewired Input Manager, deinitializing Rewired, then re-enabling it, starting a new session.

    This will also cause major problems with using the System.AppDomain.CurrentDomain.DomainUnload event. There is one static class in Rewired on Windows that does exactly this. This would no longer function and may lead to crashing in the editor if domain reloading is disabled and Play mode is entered twice.

    The only way to be sure this would work is for me scour the entire code base (and all plugins and optional packages) for statics and rework anything that may depend on a null starting value, or even possible a false bool or 0 int value at start. And also to rewrite anything that depends on the app domain being unloaded or reloaded. In short, I have to explicitly support this feature. I don't believe there are any short cuts that will "just work".

    Edit:
    I just tried disabling domain reload and I'm not seeing any issues doing basic testing in Windows. I'm actually surprised. Have you tried using it with domain reloading disabled?
     
    Last edited: Oct 21, 2021
    SugoiDev likes this.
  44. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    Look at the inspector settings of the Rewired Standalone Input Module.

    https://guavaman.com/projects/rewired/docs/RewiredStandaloneInputModule.html#inspector-options
    • Input Actions Per Second Number of selection changes allowed per second when a movement button/axis is held in a direction.
    • Repeat Delay Delay in seconds before vertical/horizontal movement starts repeating continouously when a movement direction is held.

    These speed settings are taken straight from Unity's Standalone Input Module, so their documentation applies:

    https://docs.unity3d.com/Packages/com.unity.ugui@1.0/manual/script-StandaloneInputModule.html
     
  45. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    395
    It's a shame this is always the case when Unity finally gets something right.
    I myself don't fully support disabling both domain and scene reloads on my stuff. Mostly because of edge cases.

    Well, I've been using it on Windows for a long time already. I always thought it was supported and only decided to confirm with you on that last email I sent hahaha
    I don't use anything that can be considered "advanced", and also don't think I use any integrations, so my use-case is not super representative.
    But I can say I had disabled domain reloads to enter playmode ever since it was alpha and Rewired's been working somehow. The gain in productivity is just massive. It's my favorite feature ever since I started using Unity on v3.

    Granted, I'm a programmer, so I change a lot more code than data, and my domain reloads somewhat frequently compared to a pure designer.
    Disabling scene reload does cause issues, though, both with my code and Rewired's.


    Edit: Thanks for the super detailed answer!
     
  46. AlCaTrAzzGames

    AlCaTrAzzGames

    Joined:
    May 17, 2017
    Posts:
    25
    the new remote has a DPad in addition to the old swipe/touch based controls and submit/back buttons. the old controls work, but the new DPad doesnt unfortunatly (looks like a limitation from unity, they dont support it with either input system
     
  47. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    Unity already has D-Pad support on the older remotes. Does this not work on the new one?

    https://docs.unity3d.com/Manual/tvOS.html

    "Swipe to the edge of the remote Generates directional pad (D-pad) up/down/left/right button presses. For a list of mappings, see documentation on iOS Game Controller support."

    They're even exposed as buttons 4, 5, 6, 7.

    https://docs.unity3d.com/ScriptReference/tvOS.Remote-reportAbsoluteDpadValues.html

    Rewired maps these buttons to the D-Pad on the Controller.
     
  48. ScottySR

    ScottySR

    Joined:
    Sep 29, 2018
    Posts:
    48
    How do I remap controls in Rewired? I managed to get ControllerPollingInfo of the pressed button, but I can't figure out how to remap the an action with that button.
     
  49. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
  50. kopanz

    kopanz

    Joined:
    Dec 6, 2016
    Posts:
    82
    Hi,

    When I click on the Restore Defaults button in Control Mapper, it doesn't show the Restore Defaults prompt panel until i switch the game scene. Prompt panel is opening in the newly opened scene, and im able to complete restore process there. I'm not able to cancel restore process or click to other buttons in the control mapper after clicking on the Restore Defaults button. I'm assuming this is a problem so many people had encountered. What could be wrong ? I switched to RewiredEventSystem and RewiredStandaloneInputModule but it didn't make a change.