Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Rewired - Advanced Input for Unity

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

  1. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,501
    It would really help if you would tell me what version of Unity you're using.

    Doing my own trial and error testing with various 5.x builds, I see it's 5.1.

    Unity broke something again...
     
  2. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    My version is 4.6.1p4. I will try different Unity versions tomorrow, but I would really like to stick with 4.6.1 simply because it is the fastest 4.6 version. Unity 4.6.5 is 25% slower for my game...
    Still, it would be great if you could look into it, maybe it is an easy fix if it is 100% reproducible with 4.6.1p4 for you.
     
  3. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,501
    Thanks for letting me know. I was not aware of any issues in the 4.x branch for this. There are no issues in 5.0.1 or 5.0.2.

    "Easy fix" depends on what they changed that broke it.
     
  4. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,501
    It's a baffling bug dealing with casting, only in Windows Universal mode in the editor. It was an easy workaround -- use as instead of (Type). This should not have caused an error. I'll push an update out later today.
     
    Last edited: Jun 17, 2015
  5. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,501
    @FreebordMAD - I've uploaded 1.0.0.55 with the patch to my site. If you're a registered user, you can download it at the usual place. If not, contact me on the support for on the website or PM me your email address and I'll send you info on how to get the latest build. The UAS should have the update in 5-10 days.
     
    FreebordMAD likes this.
  6. BTables

    BTables

    Joined:
    Jan 18, 2014
    Posts:
    61
    OK, thanks for the info.
     
  7. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,501
    Sorry. I'll keep this in the back of my mind in hopes I can come up with a more expedient solution for you. hopefully sooner than later. (What's your deadline?) Thus far every path leads to much complexity.
     
  8. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    Great! It works now!
    I will not forget to mention you making this hotfix within 24h in my review, which I will write once the integration is finished.
     
    guavaman likes this.
  9. NinjaISV

    NinjaISV

    Joined:
    Dec 29, 2014
    Posts:
    124
    Hey, I'm experiencing a bug and have no idea what it means. Here it is:

    Rewired: An exception occurred while initializing HID device! This device will be non-functional.
    Error querying HID device "\\?\hid#vid_046d&pid_c219#7&30e9e997&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}" at location 35408.
    Exception Message: Object reference not set to an instance of an object
    Stack Trace: at (wrapper unknown) MzUvEypOATMFiEeQaimLAcLWsXT/EflCiUhzSxCUaATzwxYyZivwSdO:ptrToStructure (intptr,object)
    at (wrapper managed-to-native) System.Runtime.InteropServices.Marshal:ptrToStructure (intptr,System.Type)
    at WOKeETSSjfnIQIyrAtQyZHwhfwP.bBHgNLrobYDFQTauFisKdbslMCu (IntPtr , Int16 , Int16 ) [0x00000] in <filename unknown>:0
    at WOKeETSSjfnIQIyrAtQyZHwhfwP..ctor (System.String devicePath, System.String instanceId, System.String description, System.String manufacturer, Int32 hubId, Int32 portId, Boolean isBluetoothDevice, System.String bluetoothDeviceName) [0x00000] in <filename unknown>:0
    UnityEngine.Debug:LogError(Object)
    YWTIvsQTmRsOVpWeBfCUYWlXSFM:QAXUUAcDMIywzkPrIMAaRAvCGxH(Boolean)
    YWTIvsQTmRsOVpWeBfCUYWlXSFM:.ctor(IntPtr, Boolean, Boolean, Boolean, Action`1, Action`1)
    MKFtqvEAmsWizxNzGxAWsTVdJUu:.ctor(UpdateLoopSetting, Boolean, IntPtr, Func`2, Func`1, Boolean, Boolean, Boolean)
    yDTqJxOcfDNSPhsqujXjWzXzNKw:YoiAoyGmnOkQKcVvjgxMEeAGCsnP(ConfigVars, nxhztpZiFtSkHFINVLVzqCDuXaR)
    yDTqJxOcfDNSPhsqujXjWzXzNKw:.ctor(ConfigVars, Func`2, Func`1)
    Rewired.InputManagers.Initializer:Initialize(ConfigVars)
    System.Type:InvokeMember(String, BindingFlags, Binder, Object, Object[])
    qmSVhJBgTqSXuWRMtEZbBXWvHWW:XJlPNDjhCwZDZSpmgjtOKGLZpxx(String, List`1, ConfigVars)
    Rewired.InputManager_Base:InitializePlatform(ConfigVars)
    Rewired.ReInput:mJTjnszhJnWyWtpnmpdWDcJxBRl(Func`2)
    Rewired.ReInput:XJlPNDjhCwZDZSpmgjtOKGLZpxx(InputManager_Base, Func`2, ConfigVars, ControllerDataFiles, UserData)
    Rewired.InputManager_Base:Initialize()
    Rewired.InputManager_Base:Awake()

    Thanks!
     
  10. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,501
    I need more information from you:
    Rewired Version
    Unity Version
    OS Version
    The joystick that is causing this
    When does this occur

    This is a known issue and is extremely, extremely rare. Thus far I haven't found any cause for this. The device in question is returning bad data to Raw Input and cannot be initialized. Rewired simply skips this device and input functions as normal for all other devices. If this is an XInput device, XInput will handle the input and input from the joystick will still function. You didn't mention whether the joystick still worked or not in the game.
     
  11. NinjaISV

    NinjaISV

    Joined:
    Dec 29, 2014
    Posts:
    124
    Thanks for the speedy reply and sorry for the lack of information.

    Rewired version: 1.0.0.54.U5
    Unity version: 5.0.0f4
    Operating system: Windows 8
    Joysticks causing this: Logitech F170, Xbox 360, Logitech extreme 3d pro joystick and every other joystick/gamepad/steering wheel I plug in.
    This occurs as soon as I hit Play and it loads up the scene.
    The only controller that still works after giving me this error is: Xbox 360.

    Also, if Raw Input is the problem, if I use Direct Input instead, will it solve the problem?
    Thanks! And other than this, I'm loving Rewired! Awesome product!
     
    Last edited: Jun 19, 2015
  12. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,501
    Is only one joystick plugged in when this happens?

    I am going to have to work with you directly to determine what about your system configuration is causing this and create special builds to track down the exact cause. Please contact me through the website at http://guavaman.com/rewired#support

    That's not a good solution. You will lose some controller recognition using Direct Input compared to Raw, especially for Bluetooth devices.
     
  13. NinjaISV

    NinjaISV

    Joined:
    Dec 29, 2014
    Posts:
    124
    Okay, will do.
     
  14. NinjaISV

    NinjaISV

    Joined:
    Dec 29, 2014
    Posts:
    124
    Oh, also, I've tried it with one, two and three joysticks plugged in. It still gives me the same error.
     
  15. NinjaISV

    NinjaISV

    Joined:
    Dec 29, 2014
    Posts:
    124
    Also, even though this is completely unrelated, I was wondering if there is a way to get the descriptive name of an action. I've already managed to write a function that gets the element name of an action, but I would like to know if there is also a way to get the descriptive name.
    Thanks!
     
  16. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,501
    It's already exposed as a property in InputAction:
    InputAction.descriptiveName
    http://guavaman.com/projects/rewired/docs/api-reference/html/T_Rewired_InputAction.htm

    In case you're not aware, you can get the InputAction from here:
    http://guavaman.com/projects/rewired/docs/api-reference/html/T_Rewired_ReInput_MappingHelper.htm

    ReInput.mapping.GetAction(actionNameOrId);
     
    Last edited: Jun 19, 2015
  17. NinjaISV

    NinjaISV

    Joined:
    Dec 29, 2014
    Posts:
    124
    Awesome, thanks tons!
     
  18. NinjaISV

    NinjaISV

    Joined:
    Dec 29, 2014
    Posts:
    124
    Also, I don't mean to be a pest, but is there some way I can get the current Negative and Positive buttons for an actions axis? I would like to have a page where the Player can go to see what current buttons are, but I can only access one of the names (The one that's closest to the top of the list) via script by doing this:

    Code (CSharp):
    1.     protected string GetButtonName (string button)
    2.     {
    3.         string name = "";
    4.         ActionElementMap map = InputHandler.input.current.controllers.maps.GetFirstElementMapWithAction(button, true);
    5.         name = map.elementIdentifierName.ToString ();
    6.         return name;
    7.     }
    (The "InputHandler.input.current" is just the active player)

    List.png

    I'm trying to display both S and W (The vertical axis) through code, but am having a really hard time figuring out how to.

    Thanks, sorry for being so annoying!
    :D
     
  19. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,501
    @NinjaISV - Thanks for helping me track down this very rare and hard to reproduce bug!

    Rewired 1.0.0.56 is available for download for registered users now on the website. If you've bought Rewired and want to get early access to the latest downloads, contact me with your email address. This update should be available on the Unity Asset Store in 3-10 days.

    1.0.0.56:

    Bug Fixes:
    - Fixed rare error that caused joysticks to fail to initialize properly in Raw Input in the 64-bit Unity editor and 64-bit builds.
     
  20. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,501
    The issue here is you have more than one ActionElementMap to deal with. Each side of a split axis is a separate mapping. You have to do something like this:

    Code (csharp):
    1. foreach(ActionElementMap map in player.controllers.maps.ElementMapsWithAction("MyAction", false)) {
    2.   Debug.Log(map.elementIdentifierName);
    3. }
    Or if you're only interested in the keyboard:

    Code (csharp):
    1. IList<KeyboardMap> keyboardMaps = player.controllers.maps.GetMaps<KeyboardMap>(0);
    2. for(int i = 0; i < keyboardMaps.Count; i++) {
    3.  
    4.   IList<ActionElementMap> buttonMaps = keyboardMaps[i].ButtonMaps;
    5.   for(int j = 0; j < buttonMaps.Count; j++) {
    6.       if(buttonMaps[j].actionId != ReInput.mapping.GetActionId("MyAction")) continue;
    7.       Debug.Log(buttonMaps[j].elementIdentifierName);
    8.   }
    9.  
    10.   // Or
    11.   foreach(ActionElementMap aem in keyboardMaps[i].ButtonMapsWithAction("MyAction")) {
    12.       Debug.Log(aem.elementIdentifierName);
    13.   }
    14.  
    15.   // You can also do it for AxisMaps or all ElementMaps if this is a Joystick or Mouse
    16. }
     
    Last edited: Jun 19, 2015
    NinjaISV likes this.
  21. NinjaISV

    NinjaISV

    Joined:
    Dec 29, 2014
    Posts:
    124
    Thanks! Just what I was needing!
     
  22. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,501
    NinjaISV likes this.
  23. NinjaISV

    NinjaISV

    Joined:
    Dec 29, 2014
    Posts:
    124
    Hey, one more quick question. I was looking at the Controller remapping example and I really like it. But, I noticed a copyright at the top of it all. So basically, I'm wondering if I am allowed to modify the menu to suit my game, but keep the base mechanics of the remapping script instead of re-writing one myself.
    Thanks!
     
  24. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,501
    Of course! The content is copyrighted, but you're allowed to use it in your games as outlined in the Unity Asset Store EULA: https://unity3d.com/legal/as_terms
     
  25. NinjaISV

    NinjaISV

    Joined:
    Dec 29, 2014
    Posts:
    124
    Awesome! Thanks, you're the best!
     
  26. rxmarccall

    rxmarccall

    Joined:
    Oct 13, 2011
    Posts:
    353
    Sorry in advance if this has been asked somewhere in the past 16 pages of forum posts.

    I was wondering if someone can give me a general outline of how to approach creating a menu that is navigatable by controller using the new uGUI in combination with Rewired. Are there any special considerations or should it all just work?

    I just noticed the new documentation on the site and found the link that has tips in regards to working with unity's new UI. Thanks!

    Here it is: http://guavaman.com/projects/rewired/docs/Integration.html#unity-ui
     
    Last edited: Jun 24, 2015
  27. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,501
    Yes, that's correct. It's not new though. That was added in Rewired 1.0.0.26. Glad you found it.
     
  28. bkw

    bkw

    Joined:
    Sep 20, 2013
    Posts:
    49
    I believe in normal Unity input, Input is updated every update loop, so if one were to check ButtonDown in FixedUpdate, you might miss the event (if frame rate is high), or you'll get the event more than once (if frame rate is low). Is this correct?

    And if so, would I run into similar issues with Rewired if I check ButtonDown in FixedUpdate?
     
  29. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,501
    That's correct and the reason why Rewired has the option to update your input in one or more of Update, FixedUpdate, and OnGUI. If you need to use GetButtonDown in FixedUpdate, enable FixedUpdate in the settings.

    Keep in mind that running the update in more than one update loop does increase CPU usage of Rewired, which is no big deal on a desktop PC but could be an issue on mobile. Most games can get away with just Update.

     
    Last edited: Jun 26, 2015
  30. Karearea

    Karearea

    Joined:
    Sep 3, 2012
    Posts:
    386
    Hi, I've been having trouble with the latest Rewired 1.0.0.56 and Unity 5.1.1f1 on MacOSX builds, using UFPS and the integration pack.

    Performance is fine in the editor, but when built, there's a delay of about a second between inputting on the controller and seeing the effect on screen. This occurs for an external mouse, the touchpad on my Macbook Pro, or any of the Xbox / PS3 controllers I've tried, both button presses and axis inputs. It's tricky to know exactly when it broke, as I develop principally on PC and port the project weekly to ensure it builds.

    I have a repro project with just the UFPS and Rewired assets, plus a simple setup scene- happy to send it over if it would help you.
     
  31. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,501
    Hi,

    There are so many variables to account for when you talking about a whole project. There is little likelihood this has anything to do with Rewired as it's been pretty thoroughly tested on OSX builds, though not with Unity 5.1.1f1 yet. (I will go check myself right now...) The connection between UFPS and Rewired is extremely thin and nothing in this part could cause such a dramatic slowdown either.

    First, the easiest thing to test would be to remove Rewired from the equation. Just remove the Rewired/Integration/UFPS directory. You can easily put it back with the menu item to reinstall the UFPS integration. Test your input in a build. If it's slow, you know 100% it's not Rewired.

    Second, I would check your build logs for a constant hammering of error messages. A huge delay like that screams some kind of issue like that going on.
     
  32. Karearea

    Karearea

    Joined:
    Sep 3, 2012
    Posts:
    386
    Thanks- the input lag is framerate independent, but I hadn't yet excluded the Rewired side of the equation. Running in an otherwise empty scene with the UFPS Hero prefab and just the UFPS input system with the Unity input manager, the lag persists, so it's either UFPS or Unity's input that's at fault. I'll keep digging
     
  33. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,501
    I just tested Rewired on OSX Yosemite w/ Unity 5.1.1f1 and UFPS 1.5 (tested Sky City scene). I don't have any input lag whatsoever with or without UFPS in the equation.

    One thing I did notice though is if you install UFPS after installing Rewired, the Unity input manager settings are overwritten and you get no mouse input. You have to then re-install Rewired through the menu option to get it back.

    Edit: Removed bit about controllers. I didn't see you said you already tested this.

    I'm wondering if there is some other issue specifically with your mac. I would do some testing on a blank scene with Unity's input system.
     
    Last edited: Jun 27, 2015
  34. Karearea

    Karearea

    Joined:
    Sep 3, 2012
    Posts:
    386
    Hi,

    I found the solution in the Editor Log file. I'd moved across the project with 'Virtual Reality Supported' checked true. I don't recall if VR was unsupported on OS X until a forthcoming patch, I'll have a better look at release notes now!

    Thanks for your patience.
     
  35. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,501
    Odd that it would cause that side effect... Because you said it affected gamepads as well, which with Rewired aren't handled by Unity's input system at all.

    Glad you found the solution.
     
    Last edited: Jun 27, 2015
  36. 511

    511

    Joined:
    Nov 18, 2012
    Posts:
    55
    Is it possible to set the mouse position with rewired? It seems that in Unity5 http://docs.unity3d.com/ScriptReference/Cursor-lockState.html is a bit broken. I just need to constrain the mouse to a window properly without writing a software cursor and I don't want to use the winapi myself. Would this be possible with Rewired?
     
  37. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,501
    No. Sorry.
     
  38. rxmarccall

    rxmarccall

    Joined:
    Oct 13, 2011
    Posts:
    353
    I've followed the short guide to getting Unity UI control working with Rewired but I'm not able to change between UI elements with the joystick. Any idea what I'm doing wrong? ( I do have other canvases around in my scene, but I'm using EventSystem.current.SetSelectedGameObject(startingFocusObject); to set focus to the UI Button in the canvas I want to initially control with my joystick.) The object I set initially also is colored as focused visually so that is good.

    Here is what my Rewired Actions looks like for Horizontal:
     
  39. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,501
    There's really not enough information here for me to tell you anything.

    1. Did you disable the StandaloneInputManager on your EventSystem?
    2. Did you assign these Actions to a Joystick Map?
    3. Did you assign that map to a Player?
    4. What Player(s) did you set to drive the input system in RewiredStandaloneInputManager?

    I'm guessing you didn't do #3 because now that I look that's not explicitly listed in the Unity UI setup instructions, but that's a fundamental part of the process of setting up input in Rewired and no input Action will ever return a value unless it's added to a Controller Map and that map assigned to a Player.

    Look at the example I've attached.

    Also, if your joystick/controller is not a recognized controller or if it is but you haven't created a Joystick Map for that controller or template, you won't get any input. If the Joystick Map is not set to be enabled on start in your Player, you also won't get any input.
     

    Attached Files:

    • UI.zip
      File size:
      8.6 KB
      Views:
      398
    Last edited: Jun 28, 2015
  40. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,501
  41. BTables

    BTables

    Joined:
    Jan 18, 2014
    Posts:
    61
    I researched doing it ourselves, I see that it's not a quick fix. Our first release is in a couple of weeks, the sooner the better, but we can make do without it for now.
     
  42. 99thmonkey

    99thmonkey

    Joined:
    Aug 10, 2012
    Posts:
    525
    States it works with UFPS. Do you have a video or documentation that shows how this works with UFPS?
     
  43. WarpBubble

    WarpBubble

    Joined:
    Dec 4, 2013
    Posts:
    33
    Bought this yesterday, today 50% sale! Grrr.

    Good thing I'm really happy with it so far :)
     
  44. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,501
    Thanks for the heads up. I wasn't even aware... It wasn't supposed to be 50% off. I requested 30%. $20 (I get $14, minus taxes) is just too cheap for all the work I put into this and continue to put into it and all the time it can save developers.

    Unity's sale system is strange. You fill out a form but you don't even know if it will ever go on sale. I filled out that form like 6 months ago. There are 365 daily sales per year and tens of thousands of assets on the store, so it's total luck of the draw if you will ever be on sale. I don't think Rewired will ever go on sale again after this one, FYI.
     
    Last edited: Jul 1, 2015
  45. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,501
  46. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,501
    ...
     
    Last edited: Jul 2, 2015
  47. Karearea

    Karearea

    Joined:
    Sep 3, 2012
    Posts:
    386
    Rewired's extremely good value at full price already- one of those must-have assets for anyone developing anything that even might need extra controller integration, or just a bit of input flexibility. Hope you at least get a big sales boost through volume!
     
    guavaman likes this.
  48. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,501
    Thanks ddnharris! :)
     
  49. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,549
    For all of the Flight Simulation and other Simulation controllers support alone I think that is easily worth double the price. Especially for native input support on Windows desktop.
     
    Karearea and guavaman like this.
  50. rpg_gamer

    rpg_gamer

    Joined:
    Nov 28, 2012
    Posts:
    214
    I noticed there were no examples using the new unity UI system, it's all still using onGUI in the included examples. Any docs or examples floating around out there to for use with rewired and the new UI system? Thanks.