Search Unity

Rewired - Advanced Input for Unity

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

  1. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    You beat me to the punch! I didn't receive an email notification from the UAS this time. I will be uploading 1.0.0.29 now which should be up in a few days hopefully.
     
  2. DaneC020

    DaneC020

    Joined:
    Mar 19, 2010
    Posts:
    191
    I just wanted to say that I have been using rewired and loving it. I rarely leave reviews on threads but the support has been amazing. I ran into a compile issue and guavaman had fixed the issue the next day for me. On top of that he stayed in touch trying to help me with integrating Rewired on the WiiU. His help was tremendously appreciated and his commitment to Rewired alone is a great reason to buy. Thanks for all the help and keep up the amazing work guavaman!

    -Dane
     
    guavaman likes this.
  3. Silly_Rollo

    Silly_Rollo

    Joined:
    Dec 21, 2012
    Posts:
    501
    Getting a weird random crash in the last stable Unity 5 beta with the latest Rewired. No actual crash message the editor just closes right after hitting play about 1/5th the time I start a scene with a Rewired Input Manager in it but otherwise Rewired works fine. In the editor.log I see this message "Unable to initialize primary input source!..." and then "Rewired will fall back to Unity input. Certain features may not be available." and then the editor suddenly closes.

    This message never appears except when it 'crashes' and like I said Rewired works fine otherwise. Any ideas?
     
  4. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Unity 5.x beta releases are not supported. It is not feasible to create a patch for each new beta release. When Unity 5 is officially released, support will be added.

    That said:
    What platform?
    What input source? (If in Windows)
    Is XInput enabled (If in Windows)

    If in Windows try:
    Disabling XInput
    Disabling native mouse support
    Switching from Raw to Direct or vice versa
    Do you have the dependencies listed here installed?

    Setting "Always use Unity Input" will definitely stop the crash if it's happening during native input initialization, but you won't get any of the benefits of native input handling

    It's probably catching an exception while trying to initialize either Direct Input, Raw Input, XInput, or OSX native input and for some reason not just failing gracefully but exiting Unity. Rewired hasn't been tested against the latest beta.
     
  5. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Thanks so much! I appreciate the review!

    It's too bad that WiiU input doesn't work as hoped. At some point I hope to add an input platform to handle its unique input system.
     
  6. tastychickenballs

    tastychickenballs

    Joined:
    Feb 5, 2015
    Posts:
    1
    Hey, this looks like it may be exactly what I'm looking for! Searching through this thread, I was looking for a definitive answer on multiple mouse inputs. Is this now a possibility with rewired? Thanks in advance.
     
  7. guavaman

    guavaman

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

    No, sorry. Rewired supports only one mouse at this time on all platforms. Multiple mice will just all contribute to the same values as will multiple keyboards.
     
  8. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    The question has come up many times in support and here on how to be able to let users just pick up a controller and press "Start" then have that player join as the next available player and with that controller assigned. There have been various ways discussed on how best to do this, but I thought I'd post here another method that I think is better than the other ways I've mentioned.

    This involves basically using a variable Rewired.Player as an input source for your own Player object.

    1. Make your Players (let's say Player 0 – 3) in the editor.
    2. Assign them all joystick maps for the controllers you want to support.
    3. Create a “Start” action and be sure it is assigned in the controller maps you assigned to the Players on some button -- preferably, multiple buttons just to be sure in case a particular controller has no Start button (or “Center 2” as defined in the Dual Analog Gamepad Template.) A safe bet would be to put it on “Center 2” and “Action Bottom Row 1” for the Dual Analog Gamepad Template, and Button 0 on Unknown Controller (if you're defining an Unknown Controller map).
    4. Leave controller auto assignment enabled. Rewired will give each Rewired.Player a controller if available.
    5. Loop through all Rewired.Players and check for player.GetButtonDown(“Start”).
    6. Now in your game code, simply assign whichever Rewired.Player returned TRUE to your game-side player object. Your game-side player object may be Player[0], but the Rewired.Player doesn’t have to be. The user could press a button on the controller assigned to Rewired.Player[3], but you can still then use Rewired.Player[3] as the input source for your game-side Player[0].

    It’s a whole lot less work than trying to loop through maps and such and you get all the benefits of working with named Actions for detecting “Start”. However, if you also support Keyboard and Mouse, at that point you might want to go ahead and load the appropriate keyboard map layouts for your Player[0] into Rewired.Player[3]. This works best if keyboard layouts for the various in-game players will be fixed. IE: Player 1 always uses the WASD set, Player 2 always uses JIKM, etc. (There are ways to make this assignment dynamic too but that's not covered here.)
     
    BTStone likes this.
  9. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    I just noticed they have Rewired 1.0.0.29 in the asset store already.
     
    guavaman likes this.
  10. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Thanks! They're not sending me notification emails anymore it seems...
     
  11. Silly_Rollo

    Silly_Rollo

    Joined:
    Dec 21, 2012
    Posts:
    501
    It's Windows and I have the dependencies installed but disabling XInput and Native Mouse reduced frequency of the crashes to an acceptable level (fairly rare) for now, Thanks!
     
  12. Zeblote

    Zeblote

    Joined:
    Feb 8, 2013
    Posts:
    1,102
    It's been a long time since I asked this and I can't read 400 posts after it, but you've said rewired will move away from keycodes in the future. So... is it now possible to retrieve a localized string of the name of pressed keys? (i.e. ü, ß, etc)
     
  13. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    No, Rewired is still using Unity input to retrieve keyboard input on all platforms. If I implement native keyboard input for any platform, it won't be for many months at least unfortunately. There are a ton of other issues/features in the queue that are higher priority.
     
  14. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422

    Just a suggestion: Could you please make a tutorial out of this and future tips/tricks on your support-website, so people don't have to search here in this topic for this particular solution? :)
     
  15. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Generally if it's a common question, I do add it to the How To's page. This one will be added there as well. Thanks for the suggestion!

    I'm also thinking of adding something to settings and/or a function to do this to make it simpler.
     
    Last edited: Feb 7, 2015
  16. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Okay, that's good. I will definitely be looking into this as U5 gets closer to release. I did identify a possible area where the crash may have occurred after failing to initialize the input source and fixed it. It's likely that it won't just crash anymore, but I will still need to look into why the input source was failing to initialize in U5. I'm working on this issue right now, not in a Unity 5 context, but for a similar crash when the game build is run under sandboxing. The next release should fix that. Also, it will now fallback gracefully to Raw Input if Direct Input and/or XInput is not available due to the lack of dependencies. This will be instead of giving an error and falling back to Unity Input if dependencies are not found.
     
    Last edited: Feb 7, 2015
  17. Sendatsu_Yoshimitsu

    Sendatsu_Yoshimitsu

    Joined:
    May 19, 2014
    Posts:
    691
    I just bought this, and it is an outstanding product, as it's almost immediately solved a lot of problems I've been working around for months. I hope you don't mind a somewhat obscure question: I'm using UFPS for my character and camera control, and following the tutorial for integrating UFPS with Rewired I got the two working together effortlessly. However, I'm a little confused about how the two interact: I still have an active Vp_FPInput script on my player, which listens for input on Update. Does that need to be disabled, to ensure that it and Rewired don't simultaneously trigger and apply the same input twice?

    Related to that, if I wanted to deviate from UFPS's control scheme and, for instance, use 8-direction movement instead of tank controls, where would I actually write that: would I create a new myControls script to interface with Rewired, or would I write it into Vp_FPInput and trust Rewired to use that correctly?
     
  18. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Awesome! So glad to hear that!

    The integration pack just reroutes the source of all input to UFPS to Rewired instead of Unity input. (Anything that goes through vp_Input now goes through Rewired.) All the handling of processing that input happens in UFPS's code. So, no, don't remove the Vp_FPInput script or your input will stop working.

    As long as you get your input from vp_Input, it will be rerouted to Rewired even if you add code to vp_FPInput. Otherwise, if you wanted to drastically change the whole input system, you could just abandon UFPS's input altogether and rewrite your character control script to get input directly from Rewired.
     
  19. Sendatsu_Yoshimitsu

    Sendatsu_Yoshimitsu

    Joined:
    May 19, 2014
    Posts:
    691
    Awesome, thank you for the quick reply! :)
     
    guavaman likes this.
  20. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Rewired 1.0.0.31 is available for download for registered users now on the website. If you've bought Rewired and want to get access to the latest downloads immediately, contact me with your email address. The update should be live on the Asset Store in 3-7 days.

    1.0.0.31:
    Changes:
    - Raw Input will now fall back to Direct Input if it fails to initialize on Windows Standalone platform.
    - Direct Input will now fall back to Raw Input if it fails to initialize on Windows Standalone platform.
    - XInput now falls back to older or newer versions of XInput if XInput 1.3 is not installed. Now works out of the box on Windows Vista, 7, and 8 without additional dependencies. (Note: If XInput 1.3 is not installed, all XInput controllers will be detected as gamepads.)
    - Windows Standalone platform dependencies are now optional.
    - Minor performance improvements.

    Bug Fixes:
    - Fixed Awake warning in RewiredInputManager.cs
    - Fixed crash when failing to initialize native input sources on Windows Standalone platform.
    - Fixed crash when running Windows Standalone build in a sandbox.
    - Fixed Raw Input support for Windows Standalone Platform in Windows XP.
    - Fixed HardwareJoystickMap serialized data null reference exceptions in certain versions of Unity.

    1.0.0.30:
    API Changes:
    - Added ReInput.MappingHelper.GetJoystickMapInstance
    - Added ReInput.MappingHelper.GetKeyboardMapInstance
    - Added ReInput.MappingHelper.GetMouseMapInstance
    - Added ReInput.MappingHelper.GetCustomControllerMapInstance
     
  21. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    If Both Raw Input and Direct Input fail does it fall back to Unity Input?
     
  22. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Yep!

    And if XInput fails, it will fall back to Raw, Direct, or Unity as well.
     
    Last edited: Feb 10, 2015
  23. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Just a small request... If you've bought Rewired and have been using it for a while, I'd really appreciate it you'd write a review or leave a rating on the Unity asset store page. Thanks everyone!
     
  24. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Fuzzy, I would try the latest version 1.0.0.31. There were some changes to the native mouse and Raw Input system that may have solved this. If you don't have access yet, just contact me here and I'll send you the link.
     
  25. Sendatsu_Yoshimitsu

    Sendatsu_Yoshimitsu

    Joined:
    May 19, 2014
    Posts:
    691
    I hope you don't mind a quick question: Is there a simple way to combine multiple inputs into a single event? I have a camera update that I want to run every frame that the player moves the horizontal or vertical axis, but if they move both at once I only want the update to run once. Is there anything like
    Code (csharp):
    1. player.AddInputEventDelegate(OnVerticalUpdate || OnHorizontalUpdate, UpdateLoopType.FixedUpdate);
    ?
     
  26. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    No. That syntax wouldn't compile for one or'ing a method group, and for another the method would get extremely complex to try to allow you to do conditional events. There's no way the event system could tell to fire the vertical to event for one axis and the horizontal event for another axis without a lot more information being sent. (It would probably have to be done with params (arrays) of Action names and callbacks, which would mean garbage collection. And then you'd probably want to specify an operator - and, or, etc...)

    You need to handle that kind of game logic code outside of Rewired. You can do so pretty easily by filtering the result of the event to determine what type it was and for what action it was.

    All the input events methods available are listed here.
     
  27. Sendatsu_Yoshimitsu

    Sendatsu_Yoshimitsu

    Joined:
    May 19, 2014
    Posts:
    691
    Perfect, thank you for the quick and extremely detailed reply! :)
     
  28. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
  29. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    That is a very useful feature that I did not think about much till you posted it. Thanks for the great native input support (raw input and direct input) for Windows standalone platform in Rewired. It is nice to have so much controller freedom with your tool. Keep up the good work.
     
  30. bsterling250DI

    bsterling250DI

    Joined:
    Sep 25, 2014
    Posts:
    78
    Any word on whether or not the Command Line Build issue stated in the Known Issues is being worked on? That has some potential to break our build pipeline.
     
  31. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    No I am not working on that at present as that issue was just discovered literally 3 days ago. Changing that is going to require a fairly big change to the whole platform switching system as it mentions in the docs. Build-time platform switching makes it possible to reduce the size of the builds and memory usage by not including unnecessary libraries for Windows or OSX in Android for example. But Unity's command line build system prevents editor scripts from even running until the build has completed, making it impossible to do platform library switching. Very likely the only solution to this is going to be to just include all platform libraries in all builds, which will waste space, but there's no alternative if command line building is to work because of Unity's limitations.

    I need to evaluate the pros and cons and research other possible solutions before making any changes. I will work on this as soon as I can.
     
    Last edited: Feb 14, 2015
  32. Shiratori

    Shiratori

    Joined:
    Aug 27, 2014
    Posts:
    21
    Hey guavaman! Loving Rewired very much so far!

    I have one question:

    Is it possible to have an input manager in every scene that shares the same setup? i noticed that adding one manager to every scene you are developing doesn't work as you will have to set everyone up individually. For my complete game it wont be an issue since the manager would be added in the menu scene and then carries on to every other level the user loads. But as I'm currently developing multiplayer It would speed up workflow to be able to test each scene without having to go through the menu every time I want to test it. I guess I could just create a testing level and set up the input manager once more for that scene for prototyping. Just wondering if there's a method I'm not aware of for speeding up that process?

    Thanks.
     
  33. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Yes. All you have to do is make a prefab out of it. Whenever you edit your input, edit the prefab instead of the one in the scene and the changes will be available on every level. But you'll have to disable "Don't Destroy On Load" so when you go from level to level you won't be creating multiple Rewired Input Managers. Also, if you're storing any objects from Rewired like Players, you need to get new copies each time because if the Rewired Input Manager is destroyed and then a new one is created, the system is completely cleared and reinitialized and all the old objects now become invalid.

    However, realize there may be controller assignment issues if you do this because everything is reset, including the history of which controllers are assigned to which player. This may be suitable for testing, but probably not for a final game.

    One way you might be able to handle it would be to do something like this:
    1. Create a script that spawns the Rewired Input Manager prefab on Awake if one does not exist in the world already.
    2. Have this script in every scene of your game.
    3. Make sure the script's Script Execution Order is set very, very low to run before all other scripts (but it doesn't have to be lower than Rewired's execution order of -32000.)
    4. Then if you run a test level with no Rewired Input Manager, your script should spawn it before everything else executes.
    5. In your final game, you put the RIM in the main game launcher scene and leave "Don't Destroy on Load" checked.
    6. When your levels load, your script will see there's already a RIM in the scene and not spawn a new one.
     
    Last edited: Feb 17, 2015
  34. Patorama

    Patorama

    Joined:
    Jan 19, 2014
    Posts:
    3
    Has anyone run into an issue where the Unity 'Select' event is triggered every frame when using a gamepad? I have a number of buttons setup in the new 4.6 UI with Select(BaseEventData) triggers on each one. When I select a button using either the mouse or keyboard, the event only triggers on initial selection. However, when I make a selection using the gamepad, the function triggers every frame.

    I'm not sure if this is an issue with Unity's system or the Rewired addOn. If anyone has an suggestions, it would be much appreciated.
     
  35. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    It would be easy enough to determine. Disable RewiredStandaloneInputModule and re-enable StandaloneInputModule and test.

    The RewiredStandaloneInput module is a slightly modified version of Unity's open-source StandaloneInputModule published here. No modifications were made apart from routing the input source to Rewired instead of Unity.
     
  36. Shiratori

    Shiratori

    Joined:
    Aug 27, 2014
    Posts:
    21
    Thanks for the quick reply! Didn't even think about using it as a prefab :p.

    I'll use it for testing purposes, thank you very much!
     
  37. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Rewired 1.0.0.32 is available for download for registered users now on the website. If you've bought Rewired and want to get access to the latest downloads immediately, contact me with your email address. The update should be live on the Asset Store in 3-7 days.

    This is a big release for simulation game developers! I've added controller definitions for 5 more flight control systems and a ship simulator console. See the full list of flight controllers with extended support here.

    1.0.0.32:
    New Controller Definitions:
    - Saitek Pro Flight Yoke System
    - Saitek Pro Flight TPM Panel
    - Saitek Pro Flight Rudder Pedals
    - CH Products Pro Throttle
    - Thrustmaster T.Hotas Flight X
    - VRinsight Ship Console
    - Sony DualShock 2 (alternate profile using My-Power CO., LTD PS2 adapter)

    Changes:
    - Changed RawInput axis detection to include axes in Simulation Controls usage page.
    - Changed RawInput button detection to include buttons in Consumer usage page.
    - Changed OSX Native axis detection to include axes in Simulation Controls usage page.
    - Changed OSX Native button detection to include buttons in Consumer usage page.

    * IMPORTANT * If you've created your own controller definitions, be sure to verify and update the axis and button count values for Raw Input and OSX Native in the Matching Criteria as this update may cause the axis and/or button count to return more elements than before.

    - Changed Raw Input Unknown Controller definition to include added axes.
    - Changed default axis deadzone from 0.25 to 0.1 in Unknown Controller definition.
    - Added L/R triggers, Back, Home, Start, Nvidia Button to Nvidia Shield definition in Raw Input.
    - Added OSX Native definition for Nvidia Shield controller.
    - Added Nvidia Shield Back button mapping in Dual Analog Template.
    - Changed Saitek P880 Shift button mapping to Center 2 in Dual Analog Template.
    - Changed Saitek P990 FPS button mapping to Center 2 in Dual Analog Template.
    - Changed 8bitdo NES30 Raw Input definition to match new axis count.
    - Changed Mad Catz C.T.R.L.R Raw Input definition to match new axis count.
    - Added Native OSX definition for Mad Catz C.T.R.L.R (PC mode).
    - Changed Raw Input HardwareJoystickMap to include other axes outside the fixed set of Direct Input axes and removed Direct Input only axes.
    - Various changes to HardwareJoystickMap data storage structure for Raw Input and Direct Input to accommodate differences.

    Bug Fixes:
    - Fixed L/R triggers in NVidia Shield definition in Direct Input.
    - Fixed Raw Input handling of axes that return signed values in the HID report.
    - Fixed OSX Native handling of axes that return invalid min/max data in the HID report.
    - Fixed incorrect button assignments on Nvidia Shield definition for Raw Input.
     
  38. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Another release today!

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

    1.0.0.33:
    Changes:
    - Added GameStick Controller definitions for Raw Input and Linux.
    - Updated Windows fallback handling to account for announced changes to UnityEngine.Input.GetJoystickNames scheduled for release in Unity 4.6.3p1 to improve hot-plugging in Webplayer and Windows Standalone if not using native input sources.
    - Added filtering to remove devices that return "keyboard" in the name on Linux platform. (Unity input bug reporting keyboards as joysticks.)
    - Changed ControlRemappingDemo1 example to check ReInput.unityJoystickIdentificationRequired and only show the fallback joystick identification dialog box on platforms that require it.
    - Changed FallbackJoystickIdentificationInfo example to check ReInput.unityJoystickIdentificationRequired and only show the fallback joystick identification dialog box on platforms that require it.

    API Changes:
    - Added ReInput.unityJoystickIdentificationRequired. (Note: You can now check this value before requiring users to manually identify their joysticks on fallback platforms. If false, no manual identification is required on that platform and Unity version.)
     
  39. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    Flight Controllers:

    That is certainly a nice list of Flight controllers and makes it great for mixing and matching too. This will be very useful for those who make flight or space simulations. What I see on your list of flight controllers ...

    (A) 2 different Flight yokes (CH Eclipse Yoke and Saitek Pro Flight Yoke Systems)

    (B) 3 different HOTAS systems (CH (Fighterstick and Pro Throttle), Saitek X-55 Rhino and Thrustmaster T.Hotas Flight X)

    (C) 2 different rudder pedals (CH Pro Pedals and Saitek Pro Flight Pedals).

    (D) Multi-Engine (3 options CH Throttle Quadrant) and Saitek X-55 Rhino (split throttle) and for Saitek Pro Flight Yoke System which includes a throttle quadrant ... you might need the additional Saitek throttle quadrant add-one.

    (E) Throttle, Prop, Mixture (for single engine aircraft like Cessna, Piper, etc.) with Saitek TPM.

    WaterCraft Controller

    That ship console looks very interesting I never thought too much about that topic. In my simple search I did find youtube video which shows examples.

     
  40. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    Thanks Guavaman for all of these updates today. It will be interesting to see how much Unity 4.6.3p1 does improve things. But I cannot think of any reason to consider when we have native support already.
     
  41. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    It is a pretty nice selection of flight controllers. I may get access to an X-52 for mapping soon, plus I have an X-45 mapping that @Steve Tack made (thanks!) a while back which I haven't included yet because it's only for Windows and I like to map them for as many platforms as possible. (I may just include it anyway.)

    I thought it would be fun to see the current lineup in pictures:

    flightcontrollers001.jpg

    Definitely a niche product, but quite cool!

    shipconsole.jpg

    The gamepad list would be quite ridiculous looking in photos, wouldn't it? :D

    Keep in mind that these are just the controllers with extended support. Your players should be able to connect up just about any flight controller and be able to use it as long as you've created a control remapping screen for your game. That includes controllers with an insane number of buttons, switches, knobs, dials, etc.
     
    Last edited: Feb 20, 2015
  42. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    True and with native input you get a ton more advantages than just hot-plugging. But for the Webplayer platform, there's no possibility of using native input because of the Unity Webplayer plugin's security model, so Unity's seriously belated fix (5 years after I asked them to do this exact Band-Aid fix they're finally doing) should at least help on that platform... assuming they ever fix the fact that Webplayer does not receive device connect and disconnect notifications from Windows (if that's possible in a browser plugin)... So, no, the fix doesn't really affect Rewired much at all unless you want to just disable native input altogether in Windows.
     
    Last edited: Feb 20, 2015
  43. Karearea

    Karearea

    Joined:
    Sep 3, 2012
    Posts:
    386
    I'd give my gentleman's department to have some sort of bridge between UnityFS and all your hard work mapping those flight controllers....
     
  44. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    :eek: That's a bit drastic, don't you think? Hehe...

    I did get a copy of uFS a while back with integration in mind, but haven't had time to look into that yet. I did briefly look at the system tonight, but I can see the way their input system is designed there's no way for me to do a seamless integration like I did for uFPS without modifying their code or making you change out or add components. I'll look into this more deeply at some point in the next few months.

    If you want a quick and dirty way to make it work and you don't mind changing source code, it looks like it would be pretty simple.

    These are the only files that reference UnityEngine.Input. It's basically a matter of just changing calls to Input.GetAxis, etc. to player.GetAxis, etc.

    CockpitCam.cs
    OrbitCam.cs
    TowerCam.cs
    InputController.cs

    For example, the main file that would need to be changed is InputController.cs:

    InputController.cs Line 85:
    - inputValue = Input.GetAxis( AxisName );
    + inputValue = Rewired.ReInput.GetPlayer(0).GetAxis( AxisName );

    InputController.cs 157:
    - inputValue = Input.GetButton( ButtonName );
    + inputValue = Rewired.ReInput.players.GetPlayer(0).GetButton( ButtonName );

    That would make almost all your input come from Rewired when Source is set to InputManager. You could also add Rewired as another entry to the InputSource enum and add a case to the switch statement, but you'd have to go change the input source on all objects on the plane before this would work. The previous method, you can just leave them all set to InputManager.

    Code (csharp):
    1. case InputSource.Rewired:
    2. {
    3.     if ( "" != AxisName )
    4.     {
    5.     inputValue = Rewired.ReInput.players.GetPlayer(0).GetAxis( AxisName );
    6.     }
    7.     else
    8.     {
    9.         Debug.LogWarning( "InputController - Trying to get input from InputManager with no axis defined." );
    10.     }
    11. }
    12. break;
    Of course you can cache your Player object at the top of the script if you want.
     
    Last edited: Feb 23, 2015
  45. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    Wow! Those Flight Simulation controllers pictures make it so much easier to understand what is included out of the box!

    This is true controller freedom.

    Yes, please include @Steve Tack Saitek X-45 definition even if it is only for Windows. It would be great when you can get the Saitek X-52 to map at some point too.
     
    Last edited: Feb 20, 2015
  46. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    @guavaman and @ddnharris,

    In the UniftyFS forum thread @ddnharris mentioned that he is talking to Chris (developer of UnityFS) who is working on an update. See this (see msg #362) for specifics.

    http://forum.unity3d.com/threads/unityfs-flight-simulation-toolkit.171604/page-8 (msg #362)

    Not sure if Chris is aware of this Rewired 1.0.0.32 update with all of these flight simulation controllers.
     
  47. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    Oh, that's right, I was going to do the Mac mapping for the X-45 wasn't I? I do have a Mac mini that I can fire up.

    X-52 support would be super cool obviously - seems to be the most popular flight stick, or at least one of the most popular.
     
  48. Karearea

    Karearea

    Joined:
    Sep 3, 2012
    Posts:
    386
    Thanks for your help! My wife will be pleased no drastic measures were necessary.

    I'll have a look at the above implementation myself and have a word to Chris, obviously adding Rewired as another input source would be a natural fit.

    Cheers,
    Nick
     
  49. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Hi Steve,

    That would be really awesome if you could!

    I was rearranging the X45 mappings last night a bit to get it more in line with the way I order things and I noticed you only mapped one of the hats as an 8-way hat. When I looked up product info on the X45 I noticed it says it has 2x 8-way hat switches and 1x 4-way hat switch. This is the info I was looking at. Or perhaps the J24C is a different model X45 than you have?

    A few things:
    • The Newegg page mentions 2x 8-ways and 1x 4-way, but you mapped 4 hats total, 1x 8-way and 3x 4-way. Where'd the extra hat come from?
    • Do you know which two hats are supposed to be treated as 8-ways? I can easily add the extra directions for you.
    • On the throttle dials, I like to map them so that when your left thumb is moving from left to right turning the dial while you're gripping the throttle, it moves toward positive. This usually involves an invert on one of those axes (but I don't know which).

    I'll send you my modified X45 map for you to work with after I hear back which two hats should be 8-way and add the element identifiers.

    I also made the Windows fallback Hat 1 8-way as you mapped it as 4-way, probably because of the confusing way you map an 8-way hat from 2 axes returned by Unity. You can see how I did it there. If you do the OSX mappings and you don't understand how the 8-way hat mappings work on fallback or if you get hats in OSX that do very strange things (like having non-0 values at rest after the initial press) I can help explain my system for correcting that. (OSX hats in Unity can be nuts!)

    Additionally, it would be good to check the button, hat, and axis counts and the axis assignments (especially the Sliders) in both Raw Input and Direct Input. Some devices need to have a separate profile created for Raw Input because of minor differences between the two. If there are no differences at all, then it's safe to just leave off the Raw Input mapping as Rewired will use the DI mapping in that case.

    You should do the mapping with the latest 1.0.0.33 since it's possible for it to pick up more axes than before.

    Thanks!
     
    Last edited: Feb 20, 2015
  50. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Okay, will do!

    I will try to reach out to him and see if he's interested in doing an mutual integration. But I may not be able to get to working on it for quite a while.

    I'm sure you are too... ;)
     
    Last edited: Feb 20, 2015