Search Unity

Rewired - Advanced Input for Unity

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

  1. indieDoroid

    indieDoroid

    Joined:
    Jan 25, 2016
    Posts:
    171
    @guavaman

    Hope you can help. I'm getting errors while building with il2cpp.

    Are these related to Rewired by chance? I created a new project to test and only added rewired. Prior to installing Rewired from the Asset store, I was able to build an il2cpp build.

    I'm on Unity 2018.4.5f1

    d:\deleteunityporj\temp\stagingarea\data\il2cppoutput\bulk_rewired_core_5.cpp(29809) : fatal error C1001: An internal error has occurred in the compiler.

    Thanks for the help.

    Failed running C:\Program Files\Unity\Hub\Editor\2018.4.5f1\Editor\Data\il2cpp/build/il2cpp.exe --convert-to-cpp --emit-null-checks --enable-array-bounds-check --dotnetprofile="unityaot" --compile-cpp --libil2cpp-static --platform="WindowsDesktop" --architecture="x64" --configuration="ReleasePlus" --outputpath="D:\DeleteUnityPorj\Temp/StagingArea/Data\Native\GameAssembly.dll" --cachedirectory="D:\DeleteUnityPorj\Assets\..\Library/il2cpp_cache" --map-file-parser="C:\Program Files\Unity\Hub\Editor\2018.4.5f1\Editor\Data\Tools\MapFileParser\MapFileParser.exe" --directory="D:\DeleteUnityPorj\Temp\StagingArea\Data\Managed" --generatedcppdir="D:\DeleteUnityPorj\Temp\StagingArea\Data\il2cppOutput"
    stdout:
    Building GameAssembly.dll with MsvcDesktopToolChain
    Msvc Install Version: 15.0
    Msvc Install SDK Directory: C:\Windows Kits\10
    Msvc Linker Path: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\link.exe
    Msvc Compiler Path: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\cl.exe
    Output directory: D:\DeleteUnityPorj\Temp\StagingArea\Data\Native
    Cache directory: D:\DeleteUnityPorj\Library\il2cpp_cache
    ObjectFiles: 646 of which compiled: 199
    Time Compile: 9006 milliseconds Bulk_mscorlib_11.cpp
    Time Compile: 8946 milliseconds Bulk_mscorlib_9.cpp
    Time Compile: 8856 milliseconds Bulk_Rewired_Core_8.cpp
    Time Compile: 8680 milliseconds Bulk_Rewired_Core_20.cpp
    Time Compile: 8532 milliseconds Bulk_Rewired_Core_6.cpp
    Time Compile: 8459 milliseconds Bulk_System.Xml_7.cpp
    Time Compile: 7810 milliseconds Bulk_System_0.cpp
    Time Compile: 7106 milliseconds Bulk_System.Xml_5.cpp
    Time Compile: 5384 milliseconds Bulk_Generics_6.cpp
    Time Compile: 4847 milliseconds Il2CppTypeDefinitions.cpp
    Total compilation time: 68646 milliseconds.
    il2cpp.exe didn't catch exception: Unity.IL2CPP.Building.BuilderFailedException: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\link.exe /out:"D:\DeleteUnityPorj\Library\il2cpp_cache\linkresult_CB2C57AC6C465BB10A2673A2D57153BF\GameAssembly.dll" /DEBUG /INCREMENTAL:NO /LARGEADDRESSAWARE /NXCOMPAT /DYNAMICBASE /NOLOGO /TLBID:1 /OPT:REF /OPT:ICF /LTCG /HIGHENTROPYVA /DLL /NODEFAULTLIB:uuid.lib "kernel32.lib" "user32.lib" "advapi32.lib" "ole32.lib" "oleaut32.lib" "Shell32.lib" "Crypt32.lib" "psapi.lib" "version.lib" "MsWSock.lib" "ws2_32.lib" "Iphlpapi.lib" /LIBPATH:"C:\Windows Kits\10\Lib\10.0.18362.0\um\x64" /LIBPATH:"C:\Windows Kits\10\Lib\10.0.18362.0\ucrt\x64" /LIBPATH:"C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\lib\um\x64" /LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\lib\x64" /SUBSYSTEM:WINDOWS @"C:\Users\PC\AppData\Local\Temp\tmpAC8F.tmp"
    Creating library D:\DeleteUnityPorj\Library\il2cpp_cache\linkresult_CB2C57AC6C465BB10A2673A2D57153BF\GameAssembly.lib and object D:\DeleteUnityPorj\Library\il2cpp_cache\linkresult_CB2C57AC6C465BB10A2673A2D57153BF\GameAssembly.exp
    Generating code
    d:\deleteunityporj\temp\stagingarea\data\il2cppoutput\bulk_rewired_core_5.cpp(29809) : fatal error C1001: An internal error has occurred in the compiler.
    (compiler file 'd:\agent\_work\2\s\src\vctools\compiler\utc\src\p2\main.c', line 187)
    To work around this problem, try simplifying or changing the program near the locations listed above.
    Please choose the Technical Support command on the Visual C++
    Help menu, or open the Technical Support help file for more information
    d:\deleteunityporj\temp\stagingarea\data\il2cppoutput\bulk_rewired_core_5.cpp(29809) : fatal error C1001: An internal error has occurred in the compiler.
    (compiler file 'd:\agent\_work\2\s\src\vctools\compiler\utc\src\common\error.c', line 835)
    To work around this problem, try simplifying or changing the program near the locations listed above.
    Please choose the Technical Support command on the Visual C++
    Help menu, or open the Technical Support help file for more information
    LINK : fatal error LNK1257: code generation failed
    at Unity.IL2CPP.Building.CppProgramBuilder.PostprocessObjectFiles(HashSet`1 objectFiles, CppToolChainContext toolChainContext)
    at Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics)
    at il2cpp.Program.DoRun(String[] args)
    at il2cpp.Program.Run(String[] args)
    at il2cpp.Program.Main(String[] args)
    stderr:
    Unhandled Exception: Unity.IL2CPP.Building.BuilderFailedException: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\link.exe /out:"D:\DeleteUnityPorj\Library\il2cpp_cache\linkresult_CB2C57AC6C465BB10A2673A2D57153BF\GameAssembly.dll" /DEBUG /INCREMENTAL:NO /LARGEADDRESSAWARE /NXCOMPAT /DYNAMICBASE /NOLOGO /TLBID:1 /OPT:REF /OPT:ICF /LTCG /HIGHENTROPYVA /DLL /NODEFAULTLIB:uuid.lib "kernel32.lib" "user32.lib" "advapi32.lib" "ole32.lib" "oleaut32.lib" "Shell32.lib" "Crypt32.lib" "psapi.lib" "version.lib" "MsWSock.lib" "ws2_32.lib" "Iphlpapi.lib" /LIBPATH:"C:\Windows Kits\10\Lib\10.0.18362.0\um\x64" /LIBPATH:"C:\Windows Kits\10\Lib\10.0.18362.0\ucrt\x64" /LIBPATH:"C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\lib\um\x64" /LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\lib\x64" /SUBSYSTEM:WINDOWS @"C:\Users\PC\AppData\Local\Temp\tmpAC8F.tmp"
    Creating library D:\DeleteUnityPorj\Library\il2cpp_cache\linkresult_CB2C57AC6C465BB10A2673A2D57153BF\GameAssembly.lib and object D:\DeleteUnityPorj\Library\il2cpp_cache\linkresult_CB2C57AC6C465BB10A2673A2D57153BF\GameAssembly.exp
    Generating code
    d:\deleteunityporj\temp\stagingarea\data\il2cppoutput\bulk_rewired_core_5.cpp(29809) : fatal error C1001: An internal error has occurred in the compiler.
    (compiler file 'd:\agent\_work\2\s\src\vctools\compiler\utc\src\p2\main.c', line 187)
    To work around this problem, try simplifying or changing the program near the locations listed above.
    Please choose the Technical Support command on the Visual C++
    Help menu, or open the Technical Support help file for more information
    d:\deleteunityporj\temp\stagingarea\data\il2cppoutput\bulk_rewired_core_5.cpp(29809) : fatal error C1001: An internal error has occurred in the compiler.
    (compiler file 'd:\agent\_work\2\s\src\vctools\compiler\utc\src\common\error.c', line 835)
    To work around this problem, try simplifying or changing the program near the locations listed above.
    Please choose the Technical Support command on the Visual C++
    Help menu, or open the Technical Support help file for more information
    LINK : fatal error LNK1257: code generation failed
    at Unity.IL2CPP.Building.CppProgramBuilder.PostprocessObjectFiles(HashSet`1 objectFiles, CppToolChainContext toolChainContext)
    at Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics)
    at il2cpp.Program.DoRun(String[] args)
    at il2cpp.Program.Run(String[] args)
    at il2cpp.Program.Main(String[] args)
    UnityEngine.Debug:LogError(Object)
    UnityEditorInternal.Runner:RunProgram(Program, String, String, String, CompilerOutputParserBase) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:128)
    UnityEditorInternal.Runner:RunManagedProgram(String, String, String, CompilerOutputParserBase, Action`1) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:73)
    UnityEditorInternal.IL2CPPBuilder:RunIl2CppWithArguments(List`1, Action`1, String) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:368)
    UnityEditorInternal.IL2CPPBuilder:ConvertPlayerDlltoCpp(String, String, String, Boolean) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:349)
    UnityEditorInternal.IL2CPPBuilder:Run() (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:211)
    UnityEditorInternal.IL2CPPUtils:RunIl2Cpp(String, IIl2CppPlatformProvider, Action`1, RuntimeClassRegistry) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:42)
    DesktopStandalonePostProcessor:SetupStagingArea(BuildPostProcessArgs, HashSet`1) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/DesktopStandalonePostProcessor.cs:245)
    DesktopStandalonePostProcessor:postProcess(BuildPostProcessArgs) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/DesktopStandalonePostProcessor.cs:46)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)
     

    Attached Files:

  2. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,445
    What version of Rewired are you using? The latest version on the asset store is 1.1.27.2
     
  3. indieDoroid

    indieDoroid

    Joined:
    Jan 25, 2016
    Posts:
    171
    yea thats the one I believe. Mine says

    1.1.27.2.U2018
     
  4. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,769
    @indieDoroid This is reproducible in Unity 2018. You will not be able to build to IL2CPP with 1.1.27.2 for Unity 2018. (Tested, Rewired 2019 works.) This is a Microsoft compiler error revealed by the random obfuscation in Rewired as processed by IL2CPP, then compiled. The only way that this will work is for me to build it again, manually test an IL2CPP build, and make a new update.

    It is incredibly frustrating that these compilers have these kinds of bugs. What works in .Net does not work when processed by IL2CPP into C++ code. This is very similar to an issue with Android NDK 13b that causes me to have to test every single release on Unity 2017, Unity 2018, and Unity 2019 IL2CPP builds (6 times, trial and release) making the update process a very long and arduous task. Now I'm going to have to do the same thing for all versions on Windows IL2CPP because clearly there's a possibility of hitting this obscure Microsoft compiler bug (which incidentally is not the same bug as the Android bug so there's a chance the Microsoft compiler may succeed and the Android fail or vice versa). My already long update release times are going to skyrocket because of this. :mad:
     
    Last edited: Aug 2, 2019
  5. indieDoroid

    indieDoroid

    Joined:
    Jan 25, 2016
    Posts:
    171
    Hmmm so maybe the best option is to update to Unity 2019 if Microsoft won't be able to address the compiler error eh?

    It's good to know at least we have one valid solution!

    I can only imagine the frustration of dealing with other dev's tools to work. Thanks for your efforts!
     
  6. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,769
    Only if you need to build today. If you can wait, I will make a new 2018 build and upload it today. This is an issue of randomness. A new build won't have the problem, and I will verify by doing an Il2CPP test build on Windows before I upload it. This isn't a problem in Unity 2018. It's a problem with the specific build. If you contact me privately with your email address, I can give you access to download it without having to wait for the Unity Asset Store to approve the submission.
     
    Last edited: Aug 2, 2019
  7. utkarshdwivedi3997

    utkarshdwivedi3997

    Joined:
    Aug 11, 2017
    Posts:
    17
    Okay, thanks!

    Just figured out that the problem is with my configuration. I tried to use my RewiredInputManager in the SimpleCombinedKeyboardMouseRemapping scene, and the InputMapped event doesn't fire, but it does with the InputManager that's included in the scene.

    I've narrowed down the problem to the mouse not being assigned to any player in my
    RewiredInputManager 
    (the
    Assign Mouse on Start
    box is unchecked on all my players). But I also have the
    Assign Keyboard on Start
    box unchecked on all players, yet there is no problem with keyboard polling. Also, the System player does have both the
    Assign Mouse on Start
    and
    Assign Keyboard on Start
    turned on by default and they can't be changed. My assumption was that since the System player has the mouse and keyboard, I would have no problem polling for inputs, but this seems to only be true for the keyboard.

    If this is intended behaviour, I can make a workaround and assign the mouse to one of the non-system players while I'm polling for input, and then un-assign it until I need to use it again. If it's not the intended behaviour, do you have any advice on this?

    Also, I'm using
    Code (CSharp):
    1. ReInput.mapping.GetKeyboardMapInstance(category, layout);
    and
    Code (CSharp):
    1. ReInput.mapping.GetMouseMapInstance(category, layout);
    to get the mouse and keyboard layouts, instead of getting them through a specific player
    Code (CSharp):
    1. player.controllers.maps.GetMap(controllerType, 0, category, layout);
    , but changing it to get the maps through a specific player doesn't affect the issues I'm having.
     
  8. indieDoroid

    indieDoroid

    Joined:
    Jan 25, 2016
    Posts:
    171
    Not a big rush, I can wait a few days for the submission approval process. Thanks for the help!:cool:
     
  9. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,769
    Controller polling is a Player-based operation handled by the Player.ControllerHelper.PollingHelper class. It is designed to only poll the Controllers that are assigned to the Player. If it is polling the Keyboard when it is not assigned to the Player, that is a bug. I am looking at the code and do not see how that would be possible. There is a check on every Controller polling function that checks whether the controller is assigned to the Player and it will simply return a ControllerPollingInfo.Fail if not. Is it possible you are assigning the Keyboard to your Players through scripting? Use Debug Information to see whether the Keyboard is assigned to your Player at runtime:
    http://guavaman.com/projects/rewired/docs/Troubleshooting.html#debug-information

    Don't try to assign the same Controller Map instance to multiple Players. This will not work. Controller Maps store information about the owning Player when assigned to the Player.
     
  10. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,769
    Unity has acknowledged it and added it to the bug tracker:
    https://issuetracker.unity3d.com/product/unity/issues/guid/1173748

    The issue is not currently live yet, so the link goes nowhere.
     
  11. Gooren

    Gooren

    Joined:
    Nov 20, 2015
    Posts:
    104
    I just encountered a weird bug. I have implemented a virtual cursor, as seen in the examples scene "PlayerMouseUnityUI".
    At first glance, everything seems to work just fine! I can control it with a mouse, I can control it with a controller, with a keyboard, just amazing!
    But... sometimes when I click an UI element, some other element reacts instead OR as well.

    To better see what is happening, I selected the RewiredEventSystem object and watched the "Selected:" field in the bottom preview section of the inspector. And I noticed that when I hover the virtual cursor over any UI elements, they quite often do not match with the EventSystem selected field.

    The event system thinks the cursor is somewhere else or what not. The weirdest thing is that the Selected field doesn't event match the hardware cursor. And it also lists UI elements that are in inactive and therefore hidden!

    Have you ever seen this happen?

    EDIT: The hidden UI elements are not hidden because they are inactive, but because their Canvas element is disabled. Not inactive, just disabled.

    EDIT2: After playing a bit more with it, I think there are two problems.:
    - There is the HW cursor, the virtual cursor AND then the EventSystem sees a third cursor that it uses for determining the selected game object from hover :D
    - The EventSystem also takes UI objects from disabled canvases into account when determining selected game object from hover.
     
    Last edited: Aug 3, 2019
  12. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,769
    Never. No reports anything like this have ever been reported.

    1. Unity version.
    2. Rewired version.
    3. Platform you are testing on.

    The EventSystem does not track the cursor. The cursor is handled in the PointerInputModule which is the base class of the StandaloneInputModule. In Rewired's version, the RewiredPointerInputModule is the base class of the RewiredStandaloneInputModule and manages tracking multiple cursor positions where the Unity version only tracks 1.

    It sounds to me like you have multiple cursors, one without graphics. Show me your entire RewiredStandaloneInputModule configuration, if adding PlayerMouse to the RewiredStandaloneInputModule via code, show me the code. If you have 2 PlayerMouse being controlled and only one visible, this could easily happen.

    Do you somehow have 2 input modules on the EventSystem?

    Try the Rewired examples. If they work right, you know you're doing something wrong and the issue is not in Rewired.
     
    Last edited: Aug 3, 2019
  13. Gooren

    Gooren

    Joined:
    Nov 20, 2015
    Posts:
    104
    Thanks for quick reply.
    Someone please sound the re*ard alert bell. I found out that I had the axis actions (both horizontal and vertical) set for directional UI navigation as well as for virtual cursor movement :D My fault...

    Plus there was and unfortunately still is the issue with the input module selecting Selectables that are in a disabled canvas. I will have to figure out what to do about that.
     
  14. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,769
    I cannot reproduce this either. What do you mean by "disabled canvas"? Are you referring to the GameObject being disabled or the Canvas Component being disabled or something entirely different? The PointerInputModule definitely will not select any GameObject that is disabled. They are not even raycast against by the GraphicRaycaster. If the GameObject is disabled and therefore not visible in the Game view port, it will definitely not be selected when a pointer is clicked over where it used to be. Something completely different has to be happening.

    If you select the object before you disable the canvas or the GameObject, it will not be automatically deselected by the EventSystem. This is how the EventSystem works and not controlled by Rewired.

    If you have Buttons with manual navigation set up (explicitly setting which Selectables are used for each direction of movement) and press a navigation direction, I would expect that it would still select the designated Selectable regardless of whether it is enabled or disabled, but I'm not certain. This is Unity's Selectable component and not controlled by Rewired.
     
  15. Gooren

    Gooren

    Joined:
    Nov 20, 2015
    Posts:
    104
    I don't think Rewired is to blame.

    I had automatic navigation on all my Selectables.
    When user opens a menu in our game, all other GUI is hidden. I do this by disabling all other canvases (literally disabling the canvas components only) in the scene. But then, when I tried navigating with keyboard arrows or controller hats, it sometimes selected Selectables that were currently hidden by being in a disabled canvas component.
    I fixed it by switching to manual navigation on my Selectables. A bit annoying, but it leads to superior results in our case anyway. And it fixes the problem at the same time. So... problem solved :)

    I hope this discussion helps others in the future who might stumble upon these problems.

    Anyway, sorry for taking your time.

    Important footnote - also interesting for other readers I think - Rewired is amazing! I first tried the new input system by Unity. The latest version, like two weeks ago. It is still ridden with bugs (understandable, it is in preview, but one might think 0.9.0 version might lead to at least the most basic stuff working on major controllers...)
    Rewired documentation is great, maybe a bit overwhelming at first, since Rewired is obviously the most advanced input system on the market at the moment. But that is the way I like it. I need a tool that is powerful enough to help me achieve anything input related. Our game supports multiple input methods and it is a breeze to configure with Rewired. I have no idea what I would do without it! Reasonable default bindings on widely spread controllers would be virtually impossible to achieve.
     
  16. utkarshdwivedi3997

    utkarshdwivedi3997

    Joined:
    Aug 11, 2017
    Posts:
    17
    I just looked at the debug information, only the system player has the keyboard, and if the polling also checks for the controller being assigned to a system player, then it should work for my mouse as well (since the mouse is also assigned to the system player). The mouse doesn't work unless assigned to a non-system player.
     
  17. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,769
    There's no code difference whatsoever between the System Player and other Players. I have just tested the Simple Control Remapping example changing the Player from 0 to the System Player and everything works as expected including mouse binding. Therefore, the problem has to be in your code.

    Polling only checks the Player you tell it to. Polling is not a global operation. This is in the code. If you are not explicitly telling it to poll the System Player, it's not going to do that. Polling is a Player-based operation. All polling happens through the player.controllers.polling which is a helper object owned by the Player itself. When you tell Input Mapper to start polling, you provide Input Mapper with a Controller Map in which to store the bindings. This Controller Map contains an owner Player Id. This Player Id in the Controller Map is used to determine which Player owns this Controller Map and which Player to poll for input. If you are loading a Controller Map instance from the Rewired Input Manager and using that to poll, it has no Player Id assigned because it doesn't belong to any Player. This will not work. Player Id is only assigned to the Controller Map when you assign it to a Player, not when it is freshly loaded orphaned instance. The Controller Map cannot belong to multiple Players, so you cannot assign the same instance to more than one Player and have it work. The moment you assign it to another Player, the owner information will be baked in and the other Player that also has the Controller Map will be holding an invalid Controller Map assigned to another Player.
     
    Last edited: Aug 5, 2019
  18. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,769
    I see. The Selectable navigation (as opposed to mouse click selection) is handled in Unity's Selectable code. It doesn't rely on the input module for anything but the navigation messages (move left, cancel, etc.). At that point, it's out of the hands of the input module.

    I would be that if you disabled the GameObject instead of the Canvas component it would work. You could also add a Canvas Group and use the interactable property to disable the child Selectables which would definitely work, but shouldn't be necessary.

    Thanks! I appreciate it and I'm glad Rewired has worked well for you. You might think about copying and pasting that into a review on the Asset Store. :D
     
  19. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,769
  20. utkarshdwivedi3997

    utkarshdwivedi3997

    Joined:
    Aug 11, 2017
    Posts:
    17
    Ah, understood. That explains my issues. I've fixed that by loading a player's map instead of using an instance.

    Thanks so much for helping out on this! And I agree with everybody else, Rewired has been such a life saver!
     
    guavaman likes this.
  21. Gooren

    Gooren

    Joined:
    Nov 20, 2015
    Posts:
    104
    Mission accomplished :)
     
    guavaman likes this.
  22. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,769
    Thanks!
     
  23. YoyoMario

    YoyoMario

    Joined:
    Apr 8, 2013
    Posts:
    11
    Hello @guavaman
    I'm having issues with android builds,
    on my Taranis X7Q it seems to read wrong inputs for my analogs, for instance my right Y analog doesn't get a reading at all (it's read by right bumper for some reason), also on android it doesn't take input from xbox or ps3 controllers, could I get some assitance? I think I may have setup some stuff wrong but I don't know what to change.

    On PC everything works perfectly fine.

    Cheers!
     
  24. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,769
    1) What version of Rewired.
    2) What version of Unity.

    http://guavaman.com/projects/rewired/docs/SupportedControllers.html
    • PS3 controller is not supported.
    • Original Xbox One controller is not supported.
    • Xbox One S controller is only supported via bluetooth connection.

    >> on my Taranis X7Q it seems to read wrong inputs for my analogs

    Disable "Support Unknown Gamepads":
    http://guavaman.com/projects/rewired/docs/SupportedControllers.html#android

    Give your users a control remapping screen:
    http://guavaman.com/projects/rewired/docs/HowTos.html#controller-mapping-screen

    Use Debug Information to debug issues:
    http://guavaman.com/projects/rewired/docs/Troubleshooting.html#debug-information
    http://guavaman.com/projects/rewire...l#debug-information-diagnosing-input-problems
     
  25. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,769
    Apparently the bug does not occur with the same version of Rewired using the latest version of VS 2019, but does in an earlier version of 2019, so this bug was fixed by MS at some point between then. That doesn't help anything because I have to support old VS versions so it looks I have to make Windows Standalone IL2CPP test builds before every release now too.
     
  26. YoyoMario

    YoyoMario

    Joined:
    Apr 8, 2013
    Posts:
    11
    @guavaman Thanks for super fast response!
    I did what you said, but it didn't help... I recorded a video for you, it's easier to show than to write that out, so if you have time, I try to go over what works as normal, and I try to explain what happens on android. If you need video from android I can record that one aswell tomorrow.

    Again awesome asset, allows me to read 100% range of my real pilot controller instead of 50% as Unity default input.
     
  27. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,769
    Thanks for the video. What your video shows me is that you are not understanding Rewired's system and how it is intended to be used.

    In your video you show that you are not using Rewired's entire Player-Action system at all. You haven't created Players, Controller Maps, or anything. So what you're using Rewired for is simply to get raw Controller data. Rewired is primarily an Action-based input system. This uses Controller Maps to to bind a controllers elements to Actions. Rewired also standardizes mappings for recognized controllers across platforms and input sources through the use of a controller definition system. The entire purpose of these two systems is to eliminate the virtually insurmountable problem of accessing controller element indices directly which is exactly what you're trying to do.

    No two platforms (or even different input APIs on the same platform) are guaranteed to give you a list of a controller's elements in the same order. Even worse, no two input API's are even guaranteed to give you the same TYPE of elements. (Triggers may be buttons in some APIs, -1 to 1 axes on other APIs, or even splitting a single axis on other APIs.) Number of buttons can even change.

    Your underlying problem here is you are expecting to see these axis indices remain consistent across Windows Standalone + Raw Input and Android. This is just not going to happen.

    If you were using Rewired in the way intended, your user would map his controller's elements in-game to a list of Actions, so any controller, recognized or not could be supported. It doesn't matter if element indices differ on different platforms because the user would just map them as needed on the platform they're on. Example:
    http://guavaman.com/projects/rewired/docs/ControlMapper.html

    For recognized controllers, you can define developer-defined default Action mappings which work across platforms. The only reason this works is the huge number of controller definitions included with Rewired that standardized this mess of indices across over a dozen platforms. These definitions were all manually created, mostly by me, with the devices in-hand. To make default mappings "just work" out of the box across platforms, there's just no other way.

    The second problem: Why aren't some controller elements working on Android?

    Rewired is giving you exactly what it's seeing from UnityEngine.Input. Android uses UnityEngine.Input for the underlying input source on Android as shown in the documentation here:
    http://guavaman.com/projects/rewired/docs/Overview.html#tested-platforms

    UnityEngine.Input itself gets the information from Android's gamepad API which in turns does its own mapping.

    In short: If these axes don't appear, they can't be supported. The only way these axes would be able to be supported is through accessing them natively through Android's native HID API.
     
    Last edited: Aug 7, 2019
  28. tcz8

    tcz8

    Joined:
    Aug 20, 2015
    Posts:
    211
    So... I keep checking for ReInput.isReady at the top of Update() and everything is fine until I recompile at runtime at which point ReInput.isReady stays false forever.

    Any ideas?
     
  29. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,769
  30. andiPossess

    andiPossess

    Joined:
    Dec 2, 2017
    Posts:
    4
    So, I'm trying to use IGamepadTemplate directly for various reasons, and it works fine on PC and Xbox One, but when deploying to PS4, I run into an issue where the Dual Shock 4 doesn't implement IGamepadTemplate. That is, ImplementsTemplate<IGamepadTemplate> returns false, so I can't use the gamepad template directly with it.

    Do you know anything about this? Anything that can help, please, thanks.

    EDIT: Controller.name is reporting as "Controller 1". I notice that the SonyDualShock4 settings show up as "Gamepad [0-9]+" or ".*controller.*" as a fallback. Could that be related?
     
    Last edited: Aug 8, 2019
  31. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,769
    No. The DS4 would definitely implement the IGamepadTemplate in an unmodified Rewired installation. Based on what you state below, it sounds like you have modified various things in the Controller/Template definitions and/or Controller Data Files which is almost certainly where the problem lies.

    These are not the Rewired default settings. You must have modified them. The official controller definition for Sony DualShock 4 on PS4 has one product name matching criteria: Controller [0-9]+. Gamepad [0-9]+ is old and was changed in 1.1.27.0. It never had a ".*controller.*" as a fallback.

    Rewired version?
     
  32. andiPossess

    andiPossess

    Joined:
    Dec 2, 2017
    Posts:
    4
    Thanks for looking into it. Looks like Controller [0-9]+ did end up fixing it.

    Anyway, as far as I know, I haven't changed the values in the templates or the controller definitions (except to fix this one issue). I appear to be on version 1.1.27.1.U2018, and opening up the package gives me the Gamepad[0-9]+ version of the DualShock 4 input definition.
     
  33. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,769
    Update to Rewired 1.1.27.3. Your problem has nothing to do with the Gamepad Template. The controllers were simply not being recognized because of the bug fixed in 1.1.27.2. (Same controller definition issue.)

    1.1.27.3:

    - Rebuild due to Windows Standalone IL2CPP issues in Unity 2018 branch.

    1.1.27.2:

    Controller Definitions:
    - Added D-Pad buttons to Apple TV Siri Remote definition.

    Bug Fixes:
    - Fixed gamepads not working on PS4 platform due to change in 1.1.27.0.
    - Unity 2018.3+ (new prefab workflow): Changes are no longer lost after importing data from json or compacting ids from the Rewired Editor -> Tools menu when in "prefab edit mode" and then exiting "prefab edit mode."
     
    andiPossess and Bartolomeus755 like this.
  34. andiPossess

    andiPossess

    Joined:
    Dec 2, 2017
    Posts:
    4
    Thanks! That covers my use-case.

    I did notice something else though. The Center 1 button for the gamepad template (aliased as Back) appears to be mapped to the Share button on DualShock 4, which is a reserved system button on the PS4. Most games I've run into used the touchpad button as the Back button equivalent.

    Just wondering about the reasoning behind this decision, as it means we can't use the gamepad template as-is for PS4 builds without supplementing it with the touchpad button mapping. In my case I just ended up changing the mapping of Center 1 on the template to the touchpad button.
     
  35. tcz8

    tcz8

    Joined:
    Aug 20, 2015
    Posts:
    211
    Unfortunatly I'm not sure this applies, my editor is set to "Recompile And Continue Playing" but thank you for reminding me of the known issues page! (Which I completely :eek: overlooked :confused: when checking the troubleshooting section)

    In case you ask, my script order is as follow:
    • Rewired.InputManager -32000
    • Rewired.Initializer -31999
    • Rewired.Internal.OnGUIHelper is -31990

    And this is the first thing running in Update()
    Code (CSharp):
    1.  
    2. if (ReInput.isReady) {
    3.     if (player == null) {
    4.         player = ReInput.players.GetPlayer(playerId);
    5.         return;
    6.     }
    7. } else {
    8.     return;
    9. }
    BTW I am not running the latess version but I would rather not upgrade it at this time unless your'e sure it's related.

    Thanks for you're help.
     
    Last edited: Aug 9, 2019
  36. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,769
    Templates cannot handle everything. The Touchpad button is not mapped on the DualShock 4 in the gamepad template because it ran out of elements. I would tell you to use the Dual Shock 4 specific Controller Map, but you're obviously using templates in your code for something. (FYI, Controller Templates were never designed for code use and added MUCH later in Rewired's life due to people constantly asking about using them at runtime. They were designed as a mapping template and nothing else and the design of these template definitions were made for that purpose.)

    The Dual Shock 4 definition was made long before Rewired even supported the PS4 platform. The template mappings were designed to match the layout of similar controllers not specifically for the PS4 platform.
     
  37. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,769
    Without some kind of stack trace, there's nothing I can tell you. There is literally nothing you can possibly do to change the behavior of Rewired's resuming from compile. It relies on that one variable in Unity to determine when it resumes.

    I can't possibly know whether updating it would change anything since I don't know what version of Rewired you're using. If it's more than a few months old, you should update it.
     
  38. Gooren

    Gooren

    Joined:
    Nov 20, 2015
    Posts:
    104
    Hi, I just encountered a minor NullReferenceException while calling RewiredPointerInputModule.GetLastPointerEventData method. The 'data' variable can be NULL.

    I was calling to it like this 'GetLastPointerEventData(0, 0, pointerId, false, PointerEventType.Touch);'. It only happens on first call, not after.

    Unity: 2018.4.4f1
    Rewired: 1.1.27.2U2018

    . upload_2019-8-9_16-4-4.png
     
  39. Gooren

    Gooren

    Joined:
    Nov 20, 2015
    Posts:
    104
    You might also be interested in the new 2018.4.6f1 changes and fixes, there are a few input related entries there.
     
  40. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,769
    #1) RewiredPointerInputModule.GetLastPointerEventData is a protected method. You can't possibly call this unless you are modifying or replacing RewiredStandaloneInputModule. If you're doing this, you must be an expert at C#. I do not provide support on how to modify classes that come with Rewired that are not meant to be modified.

    #2) Your error is self-explanatory. No pointer event data has ever been created, therefore the object doesn't exist. The code you posted even shows you how the object is created when it doesn't exist by that method:

    Code (csharp):
    1. Dictionary<int, PlayerPointerEventData> byMouseIndexDict = pointerDataByIndex[pointerIndex];
    2.             if(!byMouseIndexDict.TryGetValue(pointerTypeId, out data) && create) {
    3.                 data = CreatePointerEventData(playerId, pointerIndex, pointerTypeId, pointerEventType); // create the event data
    4.                 byMouseIndexDict.Add(pointerTypeId, data);
    5.                 return true;
    6.             }
    #3) GetLastPointerEventData is never even called in Rewired code.
     
  41. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,769
    The only thing I see that is relevant to Rewired is this:
    macOS: Fixed an issue where GCController might return incorrect values when used in a native plugin. (1145433, 1152870)

    I have been getting asked by everyone lately when Rewired will support GCController framework on MacOS. This was never even possible. A couple of years ago, I tried making both a C# library and a C++ library in XCode. Neither could ever detect any controllers no matter what I tried. It sounds like other people started wanting to do this and now they found whatever was causing it. In the past, it would NEVER return a value other than 0 controllers. At some point it sounds like it was changed and started working IF you unfocused and refocused the game window. Now it looks like they fixed that.
     
    Gooren likes this.
  42. Gooren

    Gooren

    Joined:
    Nov 20, 2015
    Posts:
    104
    C# is my main source of income, professionally, for the last 8 years. So I feel confident when making a derived class from 'RewiredStandaloneInputModule' to make something like "GetUIObjectUnderPointer" even possible.

    I had the same thing in a StandaloneInputModule derived class before. After moving our existing project to Rewired, I had to change it to derive from the RewiredStandaloneInputModule instead. Now it sometimes throws an exception that is completely unnecessary (when calling the 'GetLastPointerEventData' method). The thing is - the code I posted screenshot of, the code from the RewiredStandaloneInputModule class - has an unnecessarily unhandled state.
    The method can be called with the 'create' parameter set to false. If it does not find the data and 'create' is false, it proceeds to access the 'mouseSource' property of the 'data' object. If that is null, then it is not handled, throws an exception and voila. Unpleasant and unnecessary exception is born. I think you can just add a null check for accessing the 'mouseSource' and 'touchSource' properties and all will be perfectly well.

    Besides that, I was able to move all Input customizations from the native Unity implementation to Rewired with breeze. Everything works perfectly, no issues whatsoever. I really like Rewired and I keep recommending it to other developers on every possible occasion. It keeps saving me lots of time, while also making it possible to achieve a superb controller support and general input "refactor" in our game.
     
  43. tcz8

    tcz8

    Joined:
    Aug 20, 2015
    Posts:
    211
    Allright, I did the update and wihtout any other changes everything works now.

    Thank you for your help.
     
  44. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,769
    I understood that the code is from the RewiredPointerInputModule. I see what you're saying about the create boolean. This code path never happens when called by the RewiredStandaloneInputModule and I did not expect users to make changes to the RewiredStandaloneInputModule and call methods that are unused in the RewiredPointerInputModule. I really should have removed the entire GetLastPointerEvent function entirely because it is not used. Thanks for the bug report.

    Code (csharp):
    1. // Get or create the pointer event data
    2.  
    3.             Dictionary<int, PlayerPointerEventData> byMouseIndexDict = pointerDataByIndex[pointerIndex];
    4.             if(!byMouseIndexDict.TryGetValue(pointerTypeId, out data)) {
    5.                 if (!create) return false;
    6.                 data = CreatePointerEventData(playerId, pointerIndex, pointerTypeId, pointerEventType); // create the event data
    7.                 byMouseIndexDict.Add(pointerTypeId, data);
    8.                 return true;
    9.             }
    10.  
    11.             // Update the input sources
    12.             data.mouseSource = pointerEventType == PointerEventType.Mouse ? GetMouseInputSource(playerId, pointerIndex) : null;
    13.             data.touchSource = pointerEventType == PointerEventType.Touch ? GetTouchInputSource(playerId, pointerIndex) : null;
    14.  
    15.             return false;
     
    Gooren likes this.
  45. Gooren

    Gooren

    Joined:
    Nov 20, 2015
    Posts:
    104
    Anyway thanks for not removing it :D The fact Rewired Input Module offers equivalent of said native input module method just saved my butt big time. I have no idea how would I obtain specific UI component that mouse pointer currently hovers over otherwise.
    And thanks for this fix :)
     
  46. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,769
    You're not the first one to want this information. I recall seeing some popular asset use reflection to get this from the PointerInputModule and therefore break with the RewiredPointerInputModule because the method signature changed. Unity should add a property to the EventSystem or the input module to get this data. I could expose a property on the RewiredPointerInputModule, but it's complicated because it can track more than one pointer. I suppose making a public method to get the GameObject underneath a pointer id would be fine.
     
    Gooren likes this.
  47. Gooren

    Gooren

    Joined:
    Nov 20, 2015
    Posts:
    104
    Hi, it's me again :) Just a few quick questions - the force feedback support table mentions Linux. Does this mean Android is supported out of the box as well? Since it's a Linux based OS?
    Also, can we expect force feedback support for iOS and tvOS in the future?
    Thanks
     
    Last edited: Aug 12, 2019
  48. ModLunar

    ModLunar

    Joined:
    Oct 16, 2016
    Posts:
    87
    @guavaman Wow, am I late to the party! Just stopping by to say... you made this morning Christmas for me.

    This is one of the happiest days of my Unity life since February 2015. I can finally build the games of my dreams without dealing with "controller unsupported" issues, and excessive input logic all over my codebase. This is on-par with how happy I was with the Nested Prefab support + improved Prefab Workflows from Unity 2018.3. Once I finalize getting the mappings for my game setup now with the trial version, expect another download! ;)
     
  49. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,769
    No. Android, iOS, and tvOS are UnityEngine.Input dependent platforms. not native. Controller vibration support isn't possible without me making a native library for the platform.

    See this:
    https://guavaman.com/projects/rewired/docs/Overview.html#tested-platforms
     
    Gooren likes this.
  50. Gooren

    Gooren

    Joined:
    Nov 20, 2015
    Posts:
    104