Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Rewired - Advanced Input for Unity

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

  1. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    Is there something obvious that might make the mouse and keyboard stop working on a system after a scene change?
    It's a messy one. First off, I can't see the problem as it works fine for me in editor and standalone windows build.
    I have a tester that has this problem where the mouse and keyboard do not work in the game scenes. They actually work fine in the menus though. They only just noticed this in the last week because they had just been using controllers (xbox one and oculus touch) which still work fine for them in the game scene.

    It actually seems like it did work very briefly back in July last year but that info is not really proving to be of any help in tracking down the problem. Back then it was Unity 5.4.0f3 and now 5.5.0p1 but they also have a build on Unity 5.4.0f3 which is the first one that does not work.
    I can't really tell if Rewired version was changed in that time, but it may have been. I was using version .99 which I have only just today updated to the latest in this project. I'm not sure when .99 was released though. Waiting to hear back from them on the latest build currently.

    Their keyboard is a Logitech G19s.

    Update:
    Just thought to add that the by using Input.anyKeyDown I can see keys are being pressed but the normal Input.GetButton does not seem to be returning values for the keys.

    Update2:
    I just heard back and it does not work with the latest Rewired 112 either on their machine.
     
    Last edited: Feb 21, 2017
  2. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    1. Have the user send you the log file and see if anything shows up.
    2. The most likely cause would be loading XML save data which is overwriting your default keyboard maps with blank values. See this for information.
    3. Scene change (assuming Application.LoadLevel) issues would depend on exactly how your're managing your Rewired Input Manager(s). Read this page for very important information on how to manage Rewired Input Managers on different scenes. However, problems with this would likely be visible on your machine as well.
    4. Is your "Menu Scene" actually using Rewired or could you be using the StandaloneInputModule (non-Rewired version) so the user is controlling the scene with Unity instead?
    5. Do you have a way for your users to remap controls? Control Mapper or similar. This would immediately show whether this is a mapping problem or something more low-level (unlikely).
     
  3. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Do you mean Input.GetKeyDown(KeyCode) doesn't return values? Input.GetButton will only work with Axes set up in the Unity Input Manager.

    You can do the same basic tests using Rewired.ReInput.controllers.Keyboard to get value of keys directly. However, it's unlikely this is the issue.
     
  4. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    I have some logs from them already and there is there is no loading XML saved data shown in there.

    I am using just one Rewired Input Manager for the entire game. So this one is active very first scene, menu and then game scenes. All have Don't destroy on load enabled. They are all based on one prefab which and known to be the one used in the game scenes as I have been recently adding Oculus touch which propagated to the all scenes correctly.

    Menu is using Rewired. Just checked again to be sure by adding a new element to the UI section and it worked as expected in the menu.

    Yes, I do have ControlMapper implemented. Are you saying this may show some kind of miss mapping. I have been getting them to mash every key on the keyboard but joy from that.

    This is what I meant above. I added this to see if I could see any keys being pressed. It shows them pressing keys.
    if (Input.anyKeyDown) Debug.Log("Input was " + Input.inputString);

    But this leftHold = Input.GetButton("Left"); does not seem to get a value assigned on their machine for example.

    I notice the message: "Rewired: Currently overriding Unity input." after leaving the menu screens but not sure it related. The guy told me he could see the mouse during the loading screens which last for anything up to ~20 seconds as there may be dialogue sounds playing. He said the mouse disappears when the reaching the actual game scene. I need to get him to specifically test this though with a key press. He may just be seeing the mouse cursor but not a working one. Need to check.
     
  5. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255

    Did you perhaps mean is it using rewired on their machine. Eg. If the keyboard and mouse did not work on rewired on their machine at all, is there a fallback that might be happening on their machine?
     
  6. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Rewired does not log saving and loading XML data in a build, only the editor. Because you are using Control Mapper, it is guaranteed that you are saving and loading XML data.

    The most important thing to see in the log file would be an exception being thrown. All Rewired logged entries will start with Rewired:

    No, it would show whether or not they can bind key presses to existing maps. If they can't do that but they can bind joystick buttons, something is very wrong.

    This is what I meant above. I added this to see if I could see any keys being pressed. It shows them pressing keys.
    if (Input.anyKeyDown) Debug.Log("Input was " + Input.inputString);

    If you want to test raw key presses, use Input.GetKey(KeyCode.LeftArrow) or whatever key you're interested in.

    That means you have Unity Input Override installed and enabled. This is only logged in the editor and not builds.

    Having this installed would affect the result of Input.GetButton calls because it's getting input from the Player (the whole purpose of Unity Input Override). Input.GetKey calls are not affected and are passed through to Unity unmodified.

    Rewired cannot modify the mouse cursor in any way. It does not include any native code to control the hardware cursor on any platform. It doesn't make any calls to the Unity functions to hide/enable/disable the hardware cursor either.
     
    Last edited: Feb 21, 2017
  7. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    There is no fallback. I was asking whether or not you were sure that the Menu Scene was using the RewiredStandaloneInputModule instead of the StandaloneInputModule. It's a pretty common user error, but it's not the case here apparently. If it were the case, it would lead me to suspect certain causes, but it's not.
     
  8. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    The attached script contains a game version of the Rewired Input Manager Debug Information code. Put this on a game object and it will allow you to look through all the same debug information in a build. You will be able to see all the Keyboard Maps on the Player and what key is bound to what Action. You can see whether the Mouse is assigned to the Player, what the maps for that are, the current values of key presses live in the Controller and after being processed into the Action.
     

    Attached Files:

  9. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    Thanks. I will throw it in and send a build to the guy.
     
  10. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    I have managed to see what the problem area is thanks to that DebugInformation.cs.
    Thanks again.
     
  11. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Great! What did it turn out to be?
     
  12. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    Me.....

    I was in effect disabling all Default maps when someone selected InvertY from a menu and I enabled the InvertY map. I should have been disabling only the default map for the joystick. InvertY does not exist for the Keyboard and Mouse maps. I never use InvertY and I guess only tested that it worked when I put it in, so I never really saw the problem.

    I am now only disabling the default map for Joystick when I enable InvertY.
     
  13. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Ahh, I see. That's one of those cases where the symptoms are so far off from the apparent cause that it would be impossible to track down without debugging. Thanks for the explanation and glad it's resolved.
     
  14. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    Certainly felt like some weird machine specific thing. Happy it was just me doing something silly.
     
  15. gearedgeek

    gearedgeek

    Joined:
    Jun 19, 2015
    Posts:
    236
    I'm having a issue with the Input. I have Unity Input component but I no longer have the Rewired Input component.

    I started a fresh project and imported Rewired. I did the default installation and where to add the Rewired Input component to my player but I only get the Standalone Input Module.
     
    Last edited: Feb 24, 2017
  16. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    More information is needed:

    (1) What version of Unity are you using? Is it 32-bit or 64-bit?
    (2) What operating system are you using? and is 32-bit or 64-bit).
    (3) What version of Rewired are you using?

    (4) The Rewired documentation has this section for trouble shooting.

    http://guavaman.com/projects/rewired/docs/Troubleshooting.html

    (5) Did you try opening any of the Rewired examples and see if they work as expected?

    (6) There is a Rewired Standalone Input Module which is not the same as Standalone Input Module. See the documentation here for details.

    http://guavaman.com/projects/rewired/docs/RewiredStandaloneInputModule.html
     
  17. noanoa

    noanoa

    Joined:
    Apr 17, 2014
    Posts:
    225
    Hello, when I looked at Unity's InputManager(via Project Setting), I have 570 axes(like Joy1Button0, Joy2Button0,,,,Joy10Button0).
    Wouldn't it affect performance if all the axes are checked every frame? (Especially, when my game only uses 1 joystick).
     
  18. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    All axes are never checked every frame. Those axes are only used if you are using Unity input as the input source, have disabled native input, or are on a platform that uses Unity input such as iOS or Android. Even on those platforms, the axes are only checked for joysticks that are connected.
     
    noanoa likes this.
  19. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    The Rewired Standalone Input Module is installed automatically if you are using Unity version 4.6 or greater. Any version of Unity before 4.6 does not have the Rewired Standalone Input Module. The module is only installed after you confirm to accept installation.

    The Rewired Standalone Input Module is located in Rewired/Integration/UnityUI.
    It can be added by adding that component to an Event System object or by creating a Rewired Event System using the menu item Game Object -> Create Other -> Rewired -> UI -> Rewired Event System.
     
  20. gearedgeek

    gearedgeek

    Joined:
    Jun 19, 2015
    Posts:
    236
    I'm currently using Windows 10 (64 bit), Unity 5.5.0f3 (64 bit), Rewired 1.0.0.112.

    I believe before I updated Rewired that there was a Rewired Input component. I would remove the Unity Input component and added the Rewired Input. Now after the update I don't have the same Rewired component.

    Did that component change in the update or did I not install Rewired correctly?
     
  21. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    I don't understand what you mean by a "Unity Input component" or a "Rewired Input" component. The only such component like that that exists for Rewired is the RewiredStandaloneInputModule and that's only if you're using Rewired to control Unity's UI. It's not a part of basic Rewired usage.

    If you are talking about the Rewired Input Manager GameObject, that's something you have to create in the scene that contains all the input settings. There is no equivalent Unity object because Unity's input system is built into the engine.

    Please see the documentation for information on how to set up an use Rewired. If you don't remember the basic first steps like how to create a Rewired Input Manager, go through the Quick Start.

    As for updating Rewired, there's a documentation page on updating that tells you how.
     
  22. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    I re-read your first post. Rewired does not come with any components that you attach to a player object for controlling it. That you would have to make yourself. Rewired provides the input management, but not the input implementation.
     
  23. gearedgeek

    gearedgeek

    Joined:
    Jun 19, 2015
    Posts:
    236
    Thank you for the info. I had a major brain fart. It was my mistake and nothing with Rewired.

    I'm using Third Person Controller by Opsive and I forgot to import their integration kit for Rewired to work with TPC. The Rewired Input component comes from the TPC integration kit from Opsive.

    Sorry for the trouble.
     
  24. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    I see. Thanks for the explanation and glad it works now.
     
  25. toto2003

    toto2003

    Joined:
    Sep 22, 2010
    Posts:
    528
    hi guavaman ,i own a 8bitdo fc30 pro , it work fine on pc, but when i use it as bluetooth joypad it didnt map correctly, i got only 2 button that work, the mapping look exactly the same as the pc one so it shouldn t be the issue. any idea?
    cheers
     
  26. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    1. What platform are you trying to use it as a Bluetooth Joypad on?
    2. What version of Rewired are you using?
    3. Are you using the Dual Analog Gamepad Template or are you mapping each separately?
    4. What firmware do you have installed?
    5. Are you using Control Mapper or the UserDataStore_PlayerPrefs component?
    You must have the correct firmware for the gamepad to work properly. The last checked firmware was 1.68.
    http://guavaman.com/projects/rewired/docs/SupportedControllers.html

    8Bitdo NES30 Pro / FC30 Pro
    (Wired. Requires firmware 1.68+)

    8Bitdo NES30 Pro / FC30 Pro
    (Bluetooth, Mode 1)

    Open the Rewired/Extras/ControlMapper/Examples/ControlMapperDemo/ControlMapperDemo scene, run it, and see what happens when you try to map the device. Post anything odd such as elements not working or elements appearing with different names than they should.
     
  27. toto2003

    toto2003

    Joined:
    Sep 22, 2010
    Posts:
    528
    hi, thanks to get back to me so quickly, so i just upgrade the firmware to the latest, it work fine on windows 10 testing with wire on pc, but when i build for android using bluetooth it s where i get the mapping issue, i did a screenshot so u can see that it work fine, and showing you the mapping. but i will investigate further as i m still new to this.
    screenshot2.png screenshot.png
     
  28. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Several things:

    1. What version of rewired are you using?
    2. There's no advantage to creating individual Controller Maps for these gamepads. Use the Dual Analog Gamepad Template and your game will support all the gamepads Rewired has extended support for out of the box with no user configuration required.
    3. You are editing a prefab instance of the Rewired Input Manager as I can see from the yellow warning at the top. Only do this if you fully understand the implications and how Prefabs work.

    The information about you having problems on Android is very important information. I will re-test on Android with the latest firmware and see what I can find out.
     
    toto2003 likes this.
  29. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    I have updated to the latest 1.71 firmware and have no issues on Android. It doesn't look like there's a problem with the device definition.

    What mode are you connecting your controller in? The only supported modes are wired and Mode 1 Bluetooth. What you describe about only 2 buttons working sounds to me like you're connecting in Mode 2, which is keyboard mode. If you have a Keyboard Map mapping those keys assigned to your Player, you will get keyboard input from the keys when pressed. Clear your pairing and connect via Mode 1 by holding the power button for 3 seconds, then pairing to Android.
     
  30. toto2003

    toto2003

    Joined:
    Sep 22, 2010
    Posts:
    528
    ok i ll try to use the dual analog gamepad template, will let u know tomorrow how s thing went. i use the latest version of rewire from the store. and i use rewire with a racing kit. there only two button that work for me , so i m pretty sure that the bluetooth is active and communicate fine with the phone. thanks for looking tho.
    cheers
     
  31. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    The Dual Analog Gamepad Template won't fix this problem, but it's just way more convenient than making maps for each controller. I believe it's likely the connection mode causing the problem.
     
  32. toto2003

    toto2003

    Joined:
    Sep 22, 2010
    Posts:
    528
    i m on mode 1. but i ll try to redo this with a clean project
     
  33. toto2003

    toto2003

    Joined:
    Sep 22, 2010
    Posts:
    528
    i use racing game starting kit to be exact if that help.
     
  34. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Thanks. This shouldn't make any difference.

    Are there any other controllers attached? How many Max Joysticks Per Player do you have it set to in the Rewired Input Manager Settings under Joystick Auto-Assignment?

    Please download the attached CS file and put the object on a GameObject in a scene and build to Android. This will let you see all the same information you can see in the Rewired Input Manager Debug Information inspector. You can look at the Controllers themselves to see if the buttons/axes are responding when you press elements on the controller. If that looks correct, the next step would be to check the Actions in the Player. If those do not respond, check the Joystick Maps in the Player for that joystick and see what everything is mapped to.
     

    Attached Files:

  35. TommiH

    TommiH

    Joined:
    Jan 14, 2008
    Posts:
    253
    Hello guavaman,

    I'm a bit confused about the action categories. I created a new one under Default and added some actions to it, but I can't seem to find any way to add those actions to my keyboard maps. The Category listing under Keyboard Maps don't show my category.

    Edit: Sorry, I do seem to be able to set the category of each input, and was confused between "action categories" and "map categories".
     
    guavaman likes this.
  36. toto2003

    toto2003

    Joined:
    Sep 22, 2010
    Posts:
    528
    ok, only one player, set it to auto assignement, so far the bluetooth control respond to the debug mode that you provide, all the buttons and axis work as expected, but didnt work on my android device even tho everything work fine on the editor.
    i suspect there some input issue with the racing toolkit that need to be updated, so i try in a freshly new project, import rewired open an exemple scene, work fine, import racing kit , import the rewire provided in the kit and it turn out that i already got some error, so i ll contact the owner of that kit. thanks
    screen3.png
     
  37. toto2003

    toto2003

    Joined:
    Sep 22, 2010
    Posts:
    528
    ok find my issue with bluetooth, the kit has auto assign controller it detect if it s desktop or mobile, if i force it to desktop then it work, mobile input pop the UI button panel and make it controllable with unity UI. i believe rewire should also work with ui but i didn't dig enough into that matter, but right now i m happy it finally work :)
     
  38. devotid

    devotid

    Joined:
    Nov 14, 2011
    Posts:
    445
    @guavaman The amount of Service and Help that you provide is AMAZING.

    THANK YOU.
     
    guavaman likes this.
  39. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    The exception you are getting is due to incorrect installation of Rewired or another package overwriting the Unity Input Manager. See this Troubleshooting topic:http://guavaman.com/projects/rewire...tml#exception-input-manager-entries-not-setup

    The DebugInformation.cs file was for you to use and build on Android to see exactly what is happening on that platform. There are many important differences between Android and Windows/Mac that testing things in the editor will not be able to tell you anything about what's happening on Android. Please build it on Android and see what you can find. (Edit: Oh, nevermind, you already resolved it! Great!)

    The debug info is already available in the editor on the Rewired Input Manager inspector, so this CS file is only useful for testing in builds.
     
  40. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Okay great! Thanks for letting me know! I'm glad it's fixed. As for the UI, you'll need to make sure you're using the Rewired Standalone Input Module for that to be controlled by Rewired.
     
  41. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    You're welcome and thank you for the appreciation! It's warmly welcome.
     
  42. toto2003

    toto2003

    Joined:
    Sep 22, 2010
    Posts:
    528
    hi guavanam, so i follow the doc about the ui, so now i can selected through my joystick all the buttons, but how should switch between different map?gameplay and pause panel by exemple, i already define these, i guess i need to do that switch when i want to pause and display my pause panel, but i don t know what is that specific fonction for doing that and do rewire could detect if the user use a bluetooth controler or not on the build?
    thanks
     
  43. toto2003

    toto2003

    Joined:
    Sep 22, 2010
    Posts:
    528
    ok i think i find it , but it wasn t easy to find it, i had to go through the 56 pages of that thread and it wasn t so clear on the doc, so i m going to try that when i pause my game
    player.controllers.maps.SetMapsEnabled(state, categoryName) , but i m prettty sure i m going to face some issue knowing me :p
     
  44. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    The information you want is in the documentation. The How To's page contains over 40 different topics on common things developers want to do with Rewired. Enabling/disabling controller maps is here: http://guavaman.com/projects/rewired/docs/HowTos.html#enabling-disabling-controller-maps

    It is also described and linked on the main Controller Maps documentation page which is part of the required documentation reading under Concepts in order to know how to use Rewired.
     
    toto2003 likes this.
  45. toto2003

    toto2003

    Joined:
    Sep 22, 2010
    Posts:
    528
    yes i just saw it, it s just that there was so many to read and get the right info at the right place wasn t so simple to me, don t get me wrong, i think your doc is well detail, and it could be nice for lot of dev, but i m the kind of person who like to rush and want to make thing work quickly. and again thanks for your support.
    any hint you could forward me for detecting if there bluetooth joystick plug in?
     
  46. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Rewired does not give any information about whether a device is Bluetooth or not. Not all platforms even support Bluetooth, XBox One for example.

    What is it that you really need to know about the controller? Whether it's wireless or not? What would you be using this information for? There may be other ways of doing what you want to do.
     
  47. toto2003

    toto2003

    Joined:
    Sep 22, 2010
    Posts:
    528
    well if i know there a bluetooth joystick pluged, i can hide my mobile UI button panel, etc. i m targeting mobile plateform to be more specific.
     
  48. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Then you don't really need to know if a Bluetooth controller is attached, just any controller.

    Code (csharp):
    1. if(ReInput.controllers.joystickCount > 0) HideUI();
    More relevant information from the docs:
    How To's - Receiving Joystick connect and disconnect events
     
    toto2003 likes this.
  49. DMeville

    DMeville

    Joined:
    May 5, 2013
    Posts:
    418
    Hey @guavaman

    Quick question for you, does the Steam Controller work with Rewired on OSX? I have a player who can't get their Steam Controller working, and I wasn't sure if it should actually work! I glanced over the website but only find mention of Windows and Linux specifically. They're saying PS4 controller works fine in game, Steam Controller can't even be detected at all when testing for any buttonpress in the remapping screen. They say that the Steam Controller works fine in Big Picture and CS:GO on OSX.

    Should this be working, or is the Steam Controller not supported on OSX?
     
  50. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Steam Controller is untested on OSX. It's very likely that it requires SDL2 as the input source, which means losing Rewired's native controller support and features. Since I haven't sat down and figured out how they implemented the Steam Controller on OSX, I can't say for sure, but that's my best guess.

    Otherwise, if they make it show up through I/O Kit as a HID device, then probably all that's missing is the mappings. If you use Control Mapper or similar and that is the case, they would be able to map it.