Search Unity

Rewired - Advanced Input for Unity

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

  1. s_guy

    s_guy

    Joined:
    Feb 27, 2013
    Posts:
    102
    Hi @guavaman,

    I just bought and started working with this package. Seems really handy and easy to work with.

    Is there a "Rewired way" to treat triggers as buttons? I mean: is there a built-in way to use button style actions for trigger hardware? So, there might be a GetButtonDown result that is only true for one frame after the trigger crosses some axis threshold. End-users or developers could map button actions to triggers and button handling code would "just work".

    I can just manage this myself, but I don't want to reinvent something that you already support.

    EDIT: Separate question: Any assigned input event callback for AddInputEventDelegate fires constantly. This was surprising, due to how the normal C# event subscription pattern works. I can exit early based on the passed data, but seems like the callback should not fire at all if the action didn't occur (if no input changed related to the action) and if the action isn't mapped to anything. Otherwise, this seems to have no advantage over the normal polling paradigm. Am I missing something?
     
    Last edited: Mar 30, 2016
  2. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,969
    player.GetButtonDown
    or subscribe to events for InputActionEventType.ButtonJustPressed

    All Actions can be queried as buttons or axes. Modifying the button threshold is done in the Input Behavior assigned to that Action.

    This is only true if you don't register for a particular event type. There are many overloads you can use to register to receive events for various trigger types. If you use the overload that doesn't specify a trigger type, you are registering to receive events every time input is updated regardless of the event type or Action. This is correct behavior for that overload. See How To's - Getting Input for more information on input events.
     
    Last edited: Mar 30, 2016
  3. s_guy

    s_guy

    Joined:
    Feb 27, 2013
    Posts:
    102
  4. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,969
  5. Xander-Davis

    Xander-Davis

    Joined:
    Apr 23, 2011
    Posts:
    414
    Is anyone having issues with Rewired in 5.4 Beta? Gamepads no longer seem to be working for me, but Mouse and Keyboard are working. Gamepad functionality seems to have broken in an existing project where it used to work and it doesn't seem to work in a new project I just set up to test. Any advice?

    For the project where it used to work, I'm using the MFi iOS controller with a Nimbus on an Apple TV build. For the new project on OS X, I tried with the Nimbus and a PS4 controller (both on OS X via Bluetooth).
     
  6. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,969
    Both OSX and Apple TV broke? I find that hard to believe. I don't support betas, but now I'm going to have to check this. There were no issues in B10 on Windows last I checked.

    OSX and tvOS are completely different platforms. tvOS uses UnityEngine.Input while OSX defaults to my native implementation which uses I/O kit. For tvOS to fail, UnityEngine.Input would have to be failing or returning different string identifiers for the controllers. Or could it be this issue? On OSX, editor, build, or both?

    Whenever something like this happens, you need to do testing to figure out exactly what isn't working. Are no controllers showing up at the low level? Are they not being recognized and therefore not loading the right controller maps? Etc. Some debug logging can go a long way.

    1. Check the low level devices:
    Use Rewired/DevTools/JoystickElementIdentifier on OSX and tvOS to see what joysticks the input source is discovering.

    2. Check Rewired joysticks:
    Code (csharp):
    1. foreach(Joystick j in ReInput.controllers.Joysticks) {
    2.     Debug.Log(j.name + " " + j.hardwareTypeGuid); // if GUID is all 0's it's an Unknown Controller
    3. }
     
    Last edited: Mar 31, 2016
  7. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,969
    @Xander Davis

    I have tested OSX and Windows and haven't found any problems in Unity 5.4.0b12 in the Unity Editor or in builds. I did not re-test tvOS yet, but having not seen any issues at all in OSX with USB or Bluetooth controllers, I'm wondering if this may be a mapping and/or joystick assignment issue with your projects. (That would be the most likely case since both tvOS and OSX aren't working for you, those being different platforms handled entirely differently on an input source level.)

    Use this test code to show which controllers are assigned to which Players and all the controller maps loaded:
    Code (csharp):
    1. // Log information for each Player
    2. foreach(var p in ReInput.players.Players) {
    3.     Debug.Log("PlayerId = " + p.id);
    4.  
    5.     // Log information for each Joystick assigned to this Player
    6.     foreach(var j in p.controllers.Joysticks) {
    7.         Debug.Log("Joystick: " + j.name);
    8.         Debug.Log("Is Recognized: " + (j.hardwareTypeGuid != System.Guid.Empty));
    9.  
    10.         // Log information for each Controller Map for this Joystick
    11.         foreach(var map in p.controllers.maps.GetMaps(j.type, j.id)) {
    12.             Debug.Log("Controller Map: Category = " +
    13.                 ReInput.mapping.GetMapCategory(map.categoryId).name +
    14.                 " Layout = " +
    15.                 ReInput.mapping.GetJoystickLayout(map.layoutId).name
    16.             );
    17.             Debug.Log("enabled = " + map.enabled);
    18.             foreach(var aem in map.GetElementMaps()) {
    19.                 var action = ReInput.mapping.GetAction(aem.actionId);
    20.                 if(action == null) continue; // invalid Action
    21.                 Debug.Log("Action \"" + action.name + "\" is bound to \"" +
    22.                     aem.elementIdentifierName
    23.                 );
    24.             }
    25.         }
    26.     }
    27. }
     
    Last edited: Mar 31, 2016
  8. jesusluvsyooh

    jesusluvsyooh

    Joined:
    Jan 10, 2012
    Posts:
    347
    Any idea what a simple way is to get the A (or other button) working on iOS/mac Nimbus Steelseries?
    All the documentation says its supposed to be "joystick button 14" for 'A' but i can only get the Menu/Pause button and Analogue sticks working.

    Tried Input.GetKeyDown(KeyCode.JoystickButton14) and

    Edit: Adding Unity docs website link http://docs.unity3d.com/Manual/iphone-joystick.html
    JoystickButton0 / joystick button 0 works but no other number >_<
     
    Last edited: Mar 31, 2016
  9. Xander-Davis

    Xander-Davis

    Joined:
    Apr 23, 2011
    Posts:
    414
    @guavaman

    Okay so for the OS X project: doesn't work in the editor or in the build. There, I currently have 'Disable Native Inputs' checked, because otherwise the Nimbus will work from that (in a limited way from the old default Input settings and a Unity First Person Character Controller from Standard Assets: eg-- "Horizontal" and "Vertical" movement). So by disabling it, I'm forcing everything to work through Rewired, which is what I believe I'd want anyway to be sure.

    On the tvOS project, the Nimbus does work in the editor but not on the actual tvOS build running on Apple TV 4. The Siri Remote does work on the build on Apple TV 4, however. I also tried the Nimbus on the iOS build on iPhone 6s Plus and it does not seem to work there either. So I could try adding the manual reference in Xcode to see if that resolves it whenever I get a chance.

    Back in the OS X project, I added the script and got joystick Debug feedback the first time in the editor. However, that was the only time. It has never logged anything more than 'PlayerId = 0' since with each try running the scene in the editor after that. No other changes were made in between tries. Weird... I've attached the log from the first and only time it worked. When I add the DevTools either JoystickElementIdentifier or UnityJoystickElementIdentifier prefabs to my scene, it doesn't display anything at all either.

    Thanks for your help! Hope this can be figured out.
     

    Attached Files:

    Last edited: Mar 31, 2016
  10. Xander-Davis

    Xander-Davis

    Joined:
    Apr 23, 2011
    Posts:
    414
    Update: it appears 'GameController.framework' was already added automatically in Xcode for the tvOS project.

    I've figured out that the Nimbus does work, but only in a certain order of connecting and launching the app. If you launch the game with the Siri Remote and THEN connect the Nimbus, it doesn't work and only the Siri Remote works. Apparently you must quit the app, disconnect the Nimbus, then reconnect it from the dashboard, then launch the app again. If you turn off the controller while in the app, the Siri Remote reverts back to taking control. Whichever is recognized by the app maintains exclusive control until you quit and relaunch in this specific order to change controllers.

    Ideally, both the Gamepad and the Siri Remote would work at any time if both are connected and you can freely change back and forth between them while the app is launched (not being required to quit the app from the multi-task manager). I think that's how Rewired is supposed to work, so this seems like a bug.
     

    Attached Files:

    Last edited: Mar 31, 2016
  11. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,969
    This doesn't sound like a bug. It sounds like this very common oversight:

    "By default, Rewired's Joystick Auto-Assignment system is enabled in the Rewired Input Manager. This ensures that each Player is assigned one joystick when it is attached to the system based on rules set in the Rewired Input Manager - Settings page. You may disable the auto-assignment system if you have special needs that are not covered by its options. See How To's - Assigning Joysticks to Players for information on how to assign Joysticks manually."
     
    Last edited: Mar 31, 2016
  12. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,969
    The Nimbus will not work in OSX if you disable native input. Unity cannot detect the pressure-sensitive buttons, so there is no button support for this controller. Therefore, I did not create a Unity fallback definition for the controller -- why support it if no buttons work? Rewired will therefore treat it as an Unknown Controller, as it does with all unrecognized controllers, will not load a Controller Map for it (unless you've made an Unknown Controller map), and you'll get no input.

    The Supported Controllers page shows the Nimbus does not work on OSX Webplayer (which is Unity Fallback):
    http://guavaman.com/projects/rewired/docs/SupportedControllers.html

    Is this with OSX Native enabled? If the joystick isn't appearing the JoystickElementIdentifier, then it's not showing up to OSX I/O kit. Verify that your joystick is working correctly in something outside Unity. The battery may be low or Bluetooth connection faulty.

    I see from the one time it did work in OSX, you were in Unity Fallback mode. The joystick name was "Unknown Nimbus" -- that's Unity's name for it because it combines Manufacturer string (which is always Unknown on Bluetooth devices) and the Product Name, which is "Nimbus". If you were using Native input on OSX at that time, it would have said "SteelSeries Nimbus" as the controller name.

    Try the JoystickElementIdentifier in Native mode again and see if the joystick shows up. Then switch to Unity mode by disabling native input and run it again. If you see the joystick in Unity mode but not in Native mode, something is wrong. Did you update OSX recently?
     
    Last edited: Mar 31, 2016
  13. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,969
    This thread is for Rewired support and commentary. If you need Unity Input support, please post it in the normal Unity Support forum.

    Controller buttons do not work on MFI controllers in OSX when using UnityEngine.Input except Pause (not pressure-sensitive). They work in iOS, but not OSX. Rewired implements a native library that is able to read these pressure-sensitive buttons in OSX.
     
  14. Xander-Davis

    Xander-Davis

    Joined:
    Apr 23, 2011
    Posts:
    414
    @guavaman

    Ah, that was it-- it needs Native Input. Didn't know the Nimbus doesn't play nice with Unity without it. Ugh. I was mistaken that it was working with the default Standard Asset First Personal Controller set-ups in Native since I renamed 'Horizontal' and 'Vertical' to 'Move' and 'Strafe' in the controller's script where I also included the Rewired code... which confirms that it is indeed working via Rewired now that Native Input is back on.

    Glad we got it figured out!

    Next, is there a Rewired-way to easily convert Mouse Look for the First Person Controller to Axises that can be assigned onto Joystick Maps? For example, Look X mapping to Left Stick X and Look Y mapping to Right Stick Y. Or do I have to start writing new code to convert it manually in the controller script so that it then can finally be assigned via Rewired? Hope it's just a quick switch and not code reconfiguration on the controller...
     
  15. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,969
    There is no automatic way to modify a script to use Rewired as the input source or to intercept calls to UnityEngine.Input and re-route them to Rewired. Unity's scripts are hard-coded to use UnityEngine.Input, so there is no way to make it use Rewired without modifying the source code.

    The First Person Controller gets its input from CrossPlatformInputManager, which gets its input from StandaloneInput when not in mobile mode. StandaloneInput get its input from UnityEngine.Input.

    You could make a new RewredInput class that inherits from VirtualInput like StandaloneInput does by copying the code from StandaloneInput and changing all references to Rewired instead of UnityEngine.Input. You would then have to modify FirstPersonController.cs to use RewiredInput instead of StandaloneInput.
     
  16. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,969
    @Xander Davis

    Well, technically I was wrong. You can do it, but it's pretty hacky... I've attached a UnityPackage that includes a class that exists in the global namespace that will be used in all scripts that call UnityEngine.Input provided they make their calls via "Input" and not the fully-qualified "UnityEngine.Input". This is just a hack that takes advantage of the fact that the compiler gives higher priority to classes in the global namespace compared to those inside a namespace like UnityEngine.

    The cs file must be placed in Plugins/ so it will compile before all other scripts and be available to scripts in Standard Assets.

    All this script does is reroute GetButton and GetAxis calls to Rewired Player 0 so scripts making Input.GetButton or Input.GetAxis calls will use Rewired Player 0 instead of Unity input. All other methods and properties just call back to UnityEngine.Input. If your game is 1-player, it will work. Not so for multi-player.

    Edit: Updated the package to work with Unity 4.3+.
     

    Attached Files:

    Last edited: Mar 31, 2016
  17. Xander-Davis

    Xander-Davis

    Joined:
    Apr 23, 2011
    Posts:
    414
    Interesting-- thanks! I'll check this out when I get a chance. Amazing there isn't a simpler way to get FPS look to just work with joysticks. But I'm just as baffled something like Rewired isn't natively part of Unity (unity being the key word here!) to begin with! Thank you so much for making it and for your support!
     
    guavaman likes this.
  18. Xander-Davis

    Xander-Davis

    Joined:
    Apr 23, 2011
    Posts:
    414
    @guavaman

    I got a chance to test the Mouse X and Mouse Y override. It worked, except using the actual mouse is super sensitive now while using it via Right Stick is slower (closer to what it should be).

    Also upon building, it failed to build to OS X because of this error:
    Assets/Plugins/RewiredUnityEngineInputOverride.cs(395,34): error CS0117: `UnityEngine.Input' does not contain a definition for `IsJoystickPreconfigured'

    Referencing this:

    Code (CSharp):
    1.     public static bool IsJoystickPreconfigured(string joystickName) {
    2. #if UNITY_5 || UNITY_5_3_OR_NEWER
    3.         return UnityEngine.Input.IsJoystickPreconfigured(joystickName);
    4. #else
    5.         throw new NotSupportedException();
    6. #endif
    PS: I'm working now back in Unity 5.3.4p1 to be safe.

    Any advice? Pretty close!
     
  19. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,969
    Change your mouse x/y axis sensitivity to 0.1 to match Unity's default.

    Sensitivity settings are always handled in the Input Behavior in Rewired.
    http://guavaman.com/projects/rewired/docs/InputBehaviors.html

    Code (csharp):
    1. #if UNITY_STANDALONE_LINUX && (UNITY_5 || UNITY_5_3_OR_NEWER)
    2.         return UnityEngine.Input.IsJoystickPreconfigured(joystickName);
    3. #else
    I can't believe Unity hasn't patched this bug yet. That function should be available across all platforms even if it just returns fasle on anything but Linux but it isn't.

    http://docs.unity3d.com/Manual/PlatformDependentCompilation.html
     
    Last edited: Apr 2, 2016
  20. Xander-Davis

    Xander-Davis

    Joined:
    Apr 23, 2011
    Posts:
    414
    Awesome-- that fixed the mouse axis sensitivity. I tried tweaking sensitivity for the Joystick (just to fine tune it) but nothing seemed to change it?

    Any way around that Unity bug then? At least for now?
     
  21. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,969
    The script you are working with is not expecting a -1 to 1 joystick value. It's expecting a mouse delta and probably capping at some speed. Changing joystick sensitivity isn't going to do anything until you get below that cap. This issue is in the script itself how it interprets the incoming data. You would have to change the script to accept either a mouse delta or an absolute axis value if you want it to work "right".

    I already posted the solution. Look at the message above.
     
    Last edited: Apr 3, 2016
  22. Xander-Davis

    Xander-Davis

    Joined:
    Apr 23, 2011
    Posts:
    414
    Can you clarify? I don't see where the solution is-- you just say Unity hasn't patched this bug and then link to Unity docs talking about testing pre-compiled code. What am I missing? :p

    Thanks
     
  23. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,969
    You are missing the code I posted in that message. The original code did not have the check for UNITY_STANDALONE_LINUX that I added to the code in my response.

    I will write out the whole method. Change the method to the following:

    Code (csharp):
    1. public static bool IsJoystickPreconfigured(string joystickName) {
    2. #if UNITY_STANDALONE_LINUX && (UNITY_5 || UNITY_5_3_OR_NEWER)
    3.         return UnityEngine.Input.IsJoystickPreconfigured(joystickName);
    4. #else
    5.         return false;
    6. #endif
    7. }
     
  24. Xander-Davis

    Xander-Davis

    Joined:
    Apr 23, 2011
    Posts:
    414
    Thanks! (Ah I see-- I thought that was the code from my quote)
     
    Last edited: Apr 3, 2016
  25. Xander-Davis

    Xander-Davis

    Joined:
    Apr 23, 2011
    Posts:
    414
    One last thing apparently-- it is successfully building now but ignoring the aspect and resolution settings in PlayerSettings. So do we just force it in the same script? Thanks so much!
     
  26. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,969
    What is ignoring aspect and resolution? These settings would have no effect on the input values Rewired returns for mouse or joysticks.
     
  27. Xander-Davis

    Xander-Davis

    Joined:
    Apr 23, 2011
    Posts:
    414
    Yeah it's weird-- any time I make a build now, the PlayerSettings for Aspect and Resolution don't carry through. It launches it at 1024x576 4:3. If I turn the Launcher dialogue back on, I can select any available resolution, like 1920x1080 16:9 and it works fine then. But it just no longer automatically carries over those settings in PlayerSettings now.

    It also seems to no longer be saving the 'Default Screen Width' and 'Default Screen Height' resolution settings. So even if I change it, later if I check, it's back to 1024x768.

    I agree-- I ran through the code and there's nothing about aspect or resolution. But you mentioned this script overrides things in Unity right? Is it somehow overriding that?

    I tried removing the script and it still does it. Did it somehow change something under-the-hood after importing the package?
     
  28. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,969
    It didn't change anything in Unity. There's nothing magic happening in that script. Here's how it works:

    Some script calls Input.GetButton()

    Adding my script to the project adds a new class called Input with no namespace. Now the compiler sees every call to Input.GetButton as a call to my new script's GetButton instead of UnityEngine.Input.GetButton because my new Input class is in the global namespace and has a higher priority. That's it. It doesn't change Unity in any way, doesn't change any kind of configuration settings, and can't possibly be causing the problem you're having.

    I would check and see if any scripts that are running are overriding the aspect ratio or resolution settings. Rewired certainly isn't doing this.
     
  29. Xander-Davis

    Xander-Davis

    Joined:
    Apr 23, 2011
    Posts:
    414
    Okay-- yeah and now it's remembering it correctly. Weird. Maybe an unrelated bug then. Working now!

    Thanks again! Rewired is the best! It would be awesome if someday there was a directly integrated method that will do this so converting an FPS Mouse Look to Joystick can be done easily in Rewired like this... just maybe somehow not a hack but through a normal way. I really appreciate you making this package available as a workaround in the meantime! Cheers :)
     
  30. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,969
    There is no such thing as a "normal way" of changing the functionality of a script without changing the code. That's not how it works and there's no way to do that. Doing it right means changing the script in question to accept other input sources besides UnityEngine.Input. Without code changes, the only way would be if the script writer had coded it in such a way to allow for external input sources in the first place. I can't make Rewired modify other scripts to do this. The only way for me to do what you want would be for me to provide you with a new FPS controller script that uses Rewired as the input source instead of Unity. In my opinion, that's going too far beyond the responsibility of the input system. I would have to be maintaining different versions of every controller script Unity provides in order to do this. It's not feasible. (It's already difficult enough to maintain the Standalone Input Module branch with all the changes they keep making to it.)

    With a little bit of coding knowledge you can make almost any script out there work with Rewired very easily already.
     
    Last edited: Apr 3, 2016
    Xander-Davis likes this.
  31. Xander-Davis

    Xander-Davis

    Joined:
    Apr 23, 2011
    Posts:
    414
    How would we do the same thing to pass Mouse Left Click to Rewired?

    (For example, you can click on a switch or Press A on a gamepad to activate it - necessary because I'm using Mouse Events in PlayMaker to create Interacts)
     
    Last edited: Apr 4, 2016
  32. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,969
    Use the Rewired PlayMaker Actions instead.

    Anything that calls UnityEngine.Input.GetMouseButton or UnityEngine.Input.GetKey would not get any benefit from being forwarded to Rewired because Rewired uses Actions not keycodes and button ids. The calls to UnityEngine.Input.GetMouseButton or GetKey do not reference Action strings or Action Ids, therefore they have no analogue in Rewired's Action-based system.

    If you're trying to do something that is hard-coded to left click or right click and has no need for the action system or being able to be remapped, you can just use Unity's mouse handling for it. The only platform that has the option for native mouse handling is Windows and it doesn't make any difference with clicks.
     
    Last edited: Apr 4, 2016
  33. Xander-Davis

    Xander-Davis

    Joined:
    Apr 23, 2011
    Posts:
    414
  34. Xander-Davis

    Xander-Davis

    Joined:
    Apr 23, 2011
    Posts:
    414
    So it seems for the example I had in a FPS set-up, there needs to be a Mouse Pick Event in Rewired PlayMaker Actions. The center-locked Mouse Cursor must be over the Switch Object first, for the Button Down condition to be enabled. How would you go about this? Do we need a new action?

    Otherwise it seems I'd have to have the normal Mouse Pick Event change states based on Mouse Over -> New State. In that New State, then have the Rewired Button Down and another Mouse Pick Event for Mouse Off -> Back to the Previous State. Which over-complicates things and is a bit tedious. So if we had a special Rewired Mouse Pick action that had Rewired Button events within it, that would be way more efficient and easier to work with. What do you think?

    EDIT 14:45 EDT: Ah, I figured it out. I took the Mouse Down event off of the Mouse Picker but left on the Mouse Off event. Then just added the Rewired Button Down event and assigned the action to Left Mouse in the Mouse Map. So now both Mouse/Keyboard and Gamepads work for the mouse-over click event on the switch.
     

    Attached Files:

    Last edited: Apr 4, 2016
  35. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,969
    I hadn't seen your edit when I wrote the response. I see you indeed have a reason to use the Player-Action system if you want the controller to activate as if its a mouse button.

    I'm not very familiar with PlayMaker's non-Rewired Actions, so I wouldn't be much help in determining how to use their existing Actions. (I've never worked with Mouse Picker, Mouse On, Mouse Off, etc.) I wrote the PM Actions as a convenience for the user to give you access to most of the Player-Action based API in Rewired from PlayMaker, but not every single method (such as direct access to Controller buttons) is available because 1) They'd almost never be necessary 2) The complete API is absolutely enormous. I did not create direct analogues for any of PlayMakers's Input Actions.
     
    Last edited: Apr 4, 2016
    Xander-Davis likes this.
  36. OneThree

    OneThree

    Joined:
    Oct 28, 2011
    Posts:
    181
    Just wanted to post about an installation problem we ran into. I bought the package the other day, imported it, and got a first pass of input set up in our project.

    But when I submitted the changes through P4, the other members of the team got all sorts of errors when they tried to run the game.

    I investigated, and it turns out that the InputManager.asset file wasn't submitted to P4 when I checked everything in, so all of the buttons and axes added by the Rewired installer were only on my local machine. As soon as I manually submitted the file, it worked fine for everyone.

    My guess is that the installer either doesn't check for version control status (and thus doesn't check the file out before making edits) or doesn't mark the asset dirty (which would mean Unity doesn't detect the change either). Anyway, just wanted to point it out in case there's a way to fix the installer to play nicely with version control.
     
  37. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,969
    Rewired does mark the asset dirty and call save asses. Here's the code:

    Code (csharp):
    1.  // Save changes
    2. if(addedCount > 0 || replacedCount > 0) {
    3.     serializedObject.ApplyModifiedProperties();
    4.     EditorUtility.SetDirty(serializedObject.targetObject);
    5.     AssetDatabase.SaveAssets();
    6.  
    7.     if(addedCount > 0) Logger.Log("Added " + addedCount + " entries to Unity input manager.");
    8.     if(replacedCount > 0) Logger.Log("Updated " + replacedCount + " entries in Unity input manager.");
    9. }
    I know of nothing more I can or should be doing with regard to this. I would assume your source control system would handle file changes.
     
  38. OneThree

    OneThree

    Joined:
    Oct 28, 2011
    Posts:
    181
    I certainly don't know what else should be done, I was just pointing out the experience we had. That said, since the settings file was preserved across editor sessions on my machine it certainly looks like the code you posted above works fine.

    So perhaps there's something additional that you need to do to alert the editor's version control integration that a file has been modified and needs to be checked out?

    Again, I don't know what the solution is, I just wanted to share an issue we ran into.
     
  39. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,969
    Rewired does not explicitly utilize any of Unity's UnityEditor.VersionControl classes or methods. All asset management is handled through UnityEditor.AssetDatabase. If version control needs to be explicitly managed, then none of Rewired's data management will work with version control including saving changes to Rewired Input Manager objects/prefabs which is all handled through Unity's SerializedObject class. As far as I am aware, explicitly managing serialized data in assets through UnityEditor.VersionControl is not required. If it is, then a whole lot of code needs to be changed.
     
  40. angelsm85

    angelsm85

    Joined:
    Oct 27, 2015
    Posts:
    50
    Hi! I'm programming an android game with Unity and I want to implement bluetooth gamepad support. I've followed the quick start tutorial step by step but I cannot get it right. I have an Ipega 2025 gamepad but only works the move horizontal and vertical and I need configure "jump". I'm desperate! Can you help me? What is the script to implement jump in "My Character.cs"?
     
    Last edited: Apr 6, 2016
  41. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,969
    Start here:
    My controller doesn't work
    Joystick control doesn't work

    I have no idea what you're asking. Implementing an Action is your responsibility in the script. All Rewired does it give you the input value and you implement an in-game action based on the result. For example:

    Code (csharp):
    1. if(player.GetButtonDown("Jump")) {
    2.     // Do something -- this is the implementation
    3. }
    As explained in the documentation:

    For input to be returned in a Player from a Joystick, all of the following must be true:
    • The Joystick must be assigned to the Player.
    • The Player must have at least one enabled Joystick Map applicable to that joystick.
    • The Joystick Map must bind at least one joystick element to an Action.
    If you have created a "Jump" Action, and have bound that Action to an element on a Controller Map that will be used for your joystick, and have assigned that Controller Map to your Player, and the joystick has been assigned to that Player (by joystick auto-assignment most often), you can query player.GetButtonDown("Jump") and it will work, assuming you're using a recognized controller. (I do not know if the Ipega 2025 is the same as one of the supported ipega controllers. I have never heard of that model.) In addition, Android can be forced to support unknown gamepads with the option in the Rewired Input Manager.

    I suggest you start over and go through the Quick Start again. I also suggest you read everything under "Concepts." You can also watch this video.
     
    Last edited: Apr 6, 2016
  42. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,969
    Rewired 1.0.0.84 is now available for download for registered users on the website. If you'd like to register to get early access to updates, please contact me here. The update should be available on the Unity Asset Store in 5-10 business days.

    1.0.0.84:

    Changes:
    - Improved accuracy of button down detection when frame rate is extremely low and a button is pressed and released quickly on all platforms. (Note: XInput, being polling-based, still has the potential for button misses at low frame rates.)


    Bug Fixes:
    - OSX Fallback: Fixed bug in Sony Dual Shock 3 controller definition.
    - Float XML data is now read correctly when system's current culture expects commas instead of periods for decimal separator.
     
  43. TheGoodDrive

    TheGoodDrive

    Joined:
    Sep 23, 2015
    Posts:
    9
    Hi,

    Can I set max steering angle (for G27) directly with rewired ? Logitech plugin crash in new project.

    Thks
     
  44. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,969
  45. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,462
    guavaman likes this.
  46. TheGoodDrive

    TheGoodDrive

    Joined:
    Sep 23, 2015
    Posts:
    9
  47. gilley033

    gilley033

    Joined:
    Jul 10, 2012
    Posts:
    769
    Great asset! Five stars for sure.

    One quick question. Is there any built in support for ignoring left mouse button presses when it is over a game object (mostly I'm concerned with uGUI elements)?

    I'm guessing not, and I'll need to check this using eventSystem.IsPointerOverGameObject manually, which isn't a huge deal. The only issue is that the player can remap the left mouse button to different actions, so I'll need to set up a way to account for this (is there any easy way to check if any actions are utilizing the left mouse button?). Again, not a huge deal, but definitely enough work to justify posing this question here before beginning!

    Thanks,
    Kyle Gillen
     
  48. jrDev

    jrDev

    Joined:
    Nov 5, 2008
    Posts:
    1,686
    Hey guava man,

    I am looking into the API for Rewired and would like know if there is a way to get all actions from the Input manager without being in play mode? This is necessary for the in Editor setup I am working on.

    I currently tried this:
    ReInput.mappings.Actions, but it only provides the actions when in play mode.

    EDIT: I found the section in docs about exporting the actions. Is this the only way?

    Thanks,
    jrDev
     
    Last edited: Apr 9, 2016
  49. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,969
    No there is not. Are you talking about changing the result of an Action which is mapped to the mouse left button based on the pointer position? You cannot arbitrarily intercept and modify the values of Actions in any way -- they are calculated based on the combined total of all inputs that are mapped to that Action. If an Action is mapped to a button, it will process and return a result when that button is activated. You are, of course, free to ignore the result of that Action based on any criteria you choose in your own scripts. You cannot, however, modify the input Action value based on outside criteria. (This is similar in concept to this question in the FAQ: How do you consume/use an input?)

    UI control is almost always handled with code that checks for the actual left-click of the mouse not using an Action because an Action will return true when clicked regardless of whether or not the pointer is over anything. All of the Unity UI code including the RewiredStandaloneInputModule checks for the mouse pointer position and mouse left-click, not the result of an Action. It would be an error to map a UI Submit Action to the left mouse button.

    Controller maps are stored in Players. You will have to check all Mouse Maps in all players and determine whether something is mapped.

    How To's - Managing controller maps at runtime

     
    Last edited: Apr 9, 2016
  50. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,969
    You cannot access any of the Rewired API in editor scripts. The reason for this is explained in the Input Manager documentation:

    You can access some of the data in the Rewired Input Manager through the userData property of the InputManager component on the Rewired Input Manager. However, the methods in the UserData class are for internal use, are undocumented, and are subject to change.
     
    Last edited: Apr 9, 2016
unityunity