Search Unity

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

Rewired - Advanced Input for Unity

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

  1. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    So the Third Person Controller Rewired integration was done by Opsive?
     
    Last edited: Oct 4, 2015
  2. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    You can just submit Rewired 1.0.0.70 to the UAS while you work on 1.0.0.71. :)
     
  3. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Yes.

    I may do that.
     
  4. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Update: Xbox One controller does not show up as a joystick device in Ubuntu 12.04 or 14.04. In 15.04 (kernel 3.19.3), attaching the Xbox One controller to the system locks up the system every time. Therefore I can't add support for this controller.
     
  5. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
    I'm using Rewired in another project and I'm implementing D-Pad Up, Down, Right and Left.

    At the moment this is working:
    Code (CSharp):
    1.  
    2.     void GetInput ()
    3.     {
    4.         moveVector.x = player.GetAxis("Move Horizontally");
    5.         moveVector.y = player.GetAxis("Move Vertically");
    6.     }
    7.  
    8.     void ProcessInput ()
    9.     {
    10.         if (moveVector.y >= 0.9f) {
    11.             isChangingCase = true;
    12.             ChangeCaseUp();
    13.         }
    14.         else if (moveVector.y <= -0.9f) {
    15.             isChangingCase = true;
    16.             ChangeCaseDown();
    17.         }
    18.         else if (moveVector.x >= 0.9f) {
    19.             SlideLetterInRight();
    20.             FadeOutGraphic();
    21.         }
    22.         else if (moveVector.x <= -0.9f) {
    23.             SlideLetterInLeft();
    24.             FadeOutGraphic();
    25.         }
    26.     }
    27.  
    But I'd like to use the player.GetButtonUp(?) but I am not sure what the argument would be in this case.

    Would you please provide some documentation regarding this issue?

    Thanks
     
    Last edited: Oct 6, 2015
  6. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    I'm not really sure what you're asking here. Where would you like to use GetButtonUp? GetButtonUp only returns value when a button is just released. In the case of a D-Pad, it would be the moment one of the 4 directions isn't pressed anymore. (This is standard UnityEngine.Input lingo by the way. ButtonDown = the frame the button was pressed. ButtonUp = the frame the button was released. Button = the held state of the button.)

    If you want to use GetButton for your axes, you would use GetButtonDown, not up.

    Code (csharp):
    1. bool up = player.GetButtonDown("Move Vertically");
    2. bool down = player.GetNegativeButtonDown("Move Vertically");
    3. bool right = player.GetButtonDown("Move Horizontally");
    4. bool left = player.GetNegativeButtonDown("Move Horizontally");
    Or GetButton if you want it to return continuously.
     
  7. AlexThunderLotus

    AlexThunderLotus

    Joined:
    Jun 15, 2015
    Posts:
    11
    I see, thank you for trying! It has been mentioned by the user that normally for Unity the mapping seems to be the same as the 360 controller. Is there any way for me to tell Rewired to use the 360 config for the xbone controller on Linux? Here is the thread with more information if you want to glance at it.

    http://steamcommunity.com/app/323580/discussions/0/490121928339605472/

    Again, thanks for trying, it is very appreciated!
     
  8. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    I can't get the identifying information from Linux in order to let Rewired know what's connected because it crashes the entire system immediately upon plugin. If you can get the Xbox One controller to not crash when you plug it in, you can get the mappings for me using the UnityJoystickElementIdentifier tool in the Rewired/DevTools folder. The procedure is shown here in this video:



    I would need the identifying information (the name on Linux) and the element mappings. I can then add them to the existing Xbox One definition.

    My Xbox One controller is the new version with the audio jack. Perhaps this version causes Linux to crash where as the old one doesn't?

    I see from that link that the user is using Mint 17.2. Perhaps I could try that. It doesn't work in Ubuntu 15.04.
     
  9. AlexThunderLotus

    AlexThunderLotus

    Joined:
    Jun 15, 2015
    Posts:
    11
    Alright. I don't have an xbox one controller handy but the video is very informative. Thanks for your help!
     
  10. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    I just installed and tried Mint 17.2 (with all updates). The controller no longer crashes the system, but it does not show up as a device in /dev/input, so it can't be supported. I'm almost certainly convinced now that it's due the fact that I have a gen 2 Xbox One controller. There must be some differences that prevent the 3.17 kernel from recognizing and/or communicating with it.
     
  11. Emre_U

    Emre_U

    Joined:
    Jan 27, 2015
    Posts:
    49
    Control Mapper is sooo awesome! I am the guy who couldn't use the rewired in my pirate game.I had mentioned that in r/unity3d and I remember that you have commented on it.

    But now with your control mapper my chinese gamepad is mapped under 20mins. It should have take like 1 min at most but I have to read the documentation. I couldn't find a way to save the mapped stuff in with control mapper but even seeing which axis is working in calibration was enough for me to map my controller in input manager at last! about saving stuff with control mapper, I remember seeing something about it in docs.

    I am going back to read more about this awesome new feature. Thank you for this great asset!
     
  12. guavaman

    guavaman

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

    Yes, I remember your post. :) You're using one of the infamous "Dragon Rise, Inc." gamepads.

    Control Mapper will save data automatically through the UserDataStore component on the Rewired Input Manager provided you've added one. Rewired comes with a UserDataStore_PlayerPrefs component which will save user mappings to Unity's Player Prefs automatically. Or you can extend UserDataStore to save and load the data to/from any type of data source (DB, binary file, etc.)

    In case you were wondering, these mappings are saved only for the user who makes them and are not stored as part of your distribution. (That would defeat the purpose of user mappings.) This is how Rewired can provide support for those joysticks which are indistinguishable from each other via identifying info such as the whole Dragon Rise series of gamepads. Whatever unknown pad your user owns, he can map anyway and save his mappings.
     
    Last edited: Oct 7, 2015
    Emre_U likes this.
  13. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
  14. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    You cannot remove those lines. They are a required part of the design. Those lines handle full axis assignments whereas the 2 lines below handle split axis assignments. This allows a user to map buttons to axes (like D-Pads) or full axes to axes (Left Stick X) with an invert option.
     
  15. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
    Thanks, but I made myself. :)
    Edit the file ControlMapper.

    http://joxi.ru/wRmzQjNTVg5nrO
     
  16. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Do not create any assignments in the Rewired Input Manager that are assigned to a full axis or they will not show up in the UI. Assign all axes as split axes or you will have trouble.

    In addition, the next time you update Rewired your changes will be overwritten. You will need to copy and change the name of that class for it to work properly.
     
  17. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
    Ok :)
     
  18. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    chiapet1021 likes this.
  19. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    Glad it arrived in the asset store.
     
  20. movra

    movra

    Joined:
    Feb 16, 2013
    Posts:
    566
    I have received a reply from one of the Super Mega Baseball developers. Although they started with open source libraries such as Ogre3D I think they moved on to PhyreEngine for the final game.

     
    Last edited: Oct 10, 2015
  21. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Thanks for the update and the interesting information.
     
  22. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Rewired 1.0.0.71 is now available for download to registered users. If you have purchased Rewired and would like register for early updates, please contact me here. I've submitted the update to the Unity Asset Store, so it should go live in ~7-10 days.

    This is probably the single biggest update to Rewired ever. Finally, Rewired has native joystick support on Linux! All the usual benefits apply like intelligent (and working) hot-plugging, support for > 20 buttons and axes (yes, flight sim controllers work!) I've already mapped the vast majority of gamepads on my list of controllers with extended support and a couple of the flight devices. The remaining devices will be added in future updates, but because Rewired supports run-time user control mapping, these devices should work anyway so long as the user maps them prior to use. As an added bonus, devices that support rumble also work on Linux such as the Xbox 360 controller!

    Apart from the new native Linux support, another important feature to point out is the new "Support Unknown Gamepads" option for Android. If your game only uses gamepads and you want to ensure that most Android gamepads (those that are not already mapped) work out of the box without user mapping, enable this option. Be warned that this option makes support for unknown devices that are not gamepads non-optimal. More information about this option can be found here.

    linux-logo.png

    1.0.0.71:

    Changes:
    - Added native joystick support for Linux Standalone platform
    - Full intelligent hot-plugging support
    - More than 20 buttons and axes per joystick for advanced controllers and HOTAS setups
    - Vibration for XBox 360 controllers (and other compatible controllers)
    - Tested under Ubuntu 12.04 amd64, Ubuntu 14.04 x86/amd64, Ubuntu 15.04 amd64, and Mint 17.2 amd64
    - Works in Unity 4.x and 5.x
    - Added Android: Support Unknown Gamepads option in Rewired Input Manager settings to allow auto-detection of unknown gamepads on Android. (Limitations apply, see documentation for details.)
    - Added additional Behavior Designer tasks
    - Added icon to Behavior Designer tasks
    - Changed display names of Behavior Designer tasks

    New Controller Definitions:
    - SteelSeries Stratus XL (Windows / Android version)
    - Thrustmaster T300 RS (PS3 mode only)
    - Standardized Gamepad

    New Controller Definitions for Linux Standalone (Native):
    - Microsoft XBox 360 Controller (Includes many generic/clones)
    - Sony DualShock 3
    - Sony DualShock 4
    - Logitech F310 (X and D modes)
    - Logitech F710 (X and D modes)
    - Logitech Dual Action
    - Saitek P880
    - Saitek P990
    - Game Elements GGE909 Recoil
    - Nyko AirFlo EX
    - Radio Shack PC Gaming Controller
    - SteelSeries FREE
    - SteelSeries Stratus XL
    - Moga Hero Power
    - Moga Pro Power
    - GameStick Controller
    - Amazon Fire Game Controller
    - Google Nexus Player Gamepad
    - Nvidia Shield Controller (Wired)
    - PS3 Controller (Gasia Wireless Adapter, includes Trust GXT 39)
    - Red Samurai Wireless Android Gamepad
    - Samsung EI-GP20 Smartphone Game Pad
    - 8Bitdo NES30 (Wired)
    - 8Bitdo NES30 (Bluetooth, Mode 1)
    - 8Bitdo NES30 (Bluetooth, Joy Mode)
    - Nyko Playpad
    - ípega Wireless GAMEPAD Controller
    - ípega Multi-Media Bluetooth Controller
    - idroid:con Snakebyte (Mode 1)
    - idroid:con Snakebyte (Mode 2)
    - GameCube Controller (Mayflash 2-port USB adapter)
    - Saitek X52

    API Changes:
    - Added ReInput.GetFirstJoystickTemplateElementIdentifier method
     
    Last edited: Oct 11, 2015
    movra likes this.
  23. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
    Hello!
    I have the following code:
    ax = pl.GetAxis("horizontal");

    How do I know which device is pressed? The controller or the keyboard or mouse ...
     
  24. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551

    Wow! This is amazing to get native input on Linux finally. Cool to get the Saitek X-52 working already. I am looking forward to more Flight controllers and HOTAS systems on Linux. Great job! I just noticed a couple racing wheels (e.g. ThrustMaster T300 RS) are included too.

    That penguin looks very happy in your post. :)

    Keep up the good work!
     
    guavaman likes this.
  25. CaptainMurphy

    CaptainMurphy

    Joined:
    Jul 15, 2014
    Posts:
    746
    Is anyone using Rewired with Mirillis Action! screen recording? I haven't tried it in a while but all of a sudden I lose control input as soon as I start recording now.
     
  26. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Rewired's Player-Action-based input system in controller agnostic. You do not need to know which device is pressed, except in the case of a mouse axis if you're using deltas for mouse axes. In that case, ideally you want to use separate Actions for mouse axes and joystick axes. For example: Look Horizontal (use for keyboard and joystick) and Mouse Look Horizontal (use for mouse). This prevents you from having to try to figure out whether a mouse or joystick/keyboard was being use for that axis.

    If you must know what type of device is being used, check Player.controllers.GetLastActiveController:
    http://guavaman.com/projects/rewire..._ControllerHelper_GetLastActiveController.htm
     
  27. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Mouse, keyboard, joystick, or all? No I haven't ever tried. I can't possibly imagine any reason why it would unless it completely blocks access to standard Windows libraries or captures joysticks in exclusive mode. If that were the case, no game could possibly work with it, nor Unity.

    Another possibility is that it injects its own message window in the process, captures all devices, then forwards the events back to the main window of the parent app. In the case of Rewired, it creates its own message window which is not the parent window of the app. If Mirillis is just piping everything to the main message window, Rewired will never receive any messages at all and there is no possible workaround. The only solution would be to disable all native input in the Rewired Input Manager and use Unity's input system which receives input at the main app window. If the software is designed in this way, it couldn't work with any game that uses a message window for device events.

    XInput does not use windows messaging, so XInput devices (if XInput is enabled and Always Use Unity Input is disabled) would work if the above is true.

    The above could not possibly affect keyboard input as that is just a wrapper around UnityEngine.Input's keyboard handling.
     
    Last edited: Oct 11, 2015
  28. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
    Main Menu.png Scene.png
    After hooking up my scene to the main menu, I am seeing that Rewired Input Manager is mixing the maps altogether.

    At first I got an error saying there can't be more than one Rewired's Input Managers so I unchecked "Don't Destroy On Load" on both Main Menu and Scene and that fixed that warning.

    Again, both Input Managers worked fine when Main Menu is on its own and when Scene works on its own, but when the Scene was loaded from Main Menu things mappings are mixed.

    Main Main is the screenshot with the Event System and Rewired Standalone Input Module.
    Scene is the other screenshot.

    Thanks
     
  29. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    @gegagome What do you mean by "mappings are mixed" ? Are you intentionally using two separate Rewired Input Managers for different input configurations?

    When you destroy a Rewired Input Manager, you completely reset Rewired. Everything is reset and no runtime objects are preserved -- Joysticks, assignments, Players, etc. are all invalidated and re-instantiated when the next Rewired Input Manager is loaded.

    Please see the documentation on how to deal with keeping your Rewired Input Manager in both your final build and when testing scenes: http://guavaman.com/projects/rewired/docs/InputManager.html

    Edit: This is a common enough question that I am going to change the way Rewired works in the 1.0.0.72 update. Now instead of throwing an error when 2 Rewired Input Managers are detected, it will just automatically delete the additional ones found. This way you can just create a prefab out of your Rewired Input Manager and drop it in all your scenes, leave Don't Destroy on Load checked and when you load a level, the additional Rewired Input Manager will just be deleted without causing any issues.
     
    Last edited: Oct 12, 2015
  30. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
    Thanks for the answer.
    Too bad that it's impossible.
    My game - race.
    For keyboard use smoothing in the code.
    For joystick - without smoothing.
    Therefore, I need to know what input device used.
    Use different actions - a bad idea.
     
  31. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    It's not impossible. I told you how you could do it:
    http://guavaman.com/projects/rewire..._ControllerHelper_GetLastActiveController.htm

    Check whether the user is using a joystick or the keyboard with this method and switch your code handling based on that. It's done all the time. Developers use this option to do things like dynamically switch on-screen UI hints based on whether the user is currently using the keyboard/mouse or a joystick.

    >> Use different actions - a bad idea

    It's not a bad idea for all use cases.

    This is the nature of an Action based system which is a combination of all input sources. The other option is to get input directly from controller elements in which case you lose the power of the Action-based system.

    Further, Input Behaviors provide smoothing options for keyboard based input: http://guavaman.com/projects/rewired/docs/InputBehaviors.html
     
    Last edited: Oct 12, 2015
  32. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
    I understand, thank you, this is what I need. :)
     
  33. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
  34. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
  35. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    I was just made aware of a bug in versions 1.0.0.68+ where the Sony Dual Shock 4 on Windows swaps the shoulder buttons and triggers when using the Use Enhanced Device Support option (enabled by default). This will be fixed in 1.0.0.72. Until then, you can replace the SonyDualShock4.asset file in Rewired/Internal/Data/Controllers/Joysticks with the corrected version attached here.
     

    Attached Files:

  36. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Rewired 1.0.0.72 is now available for download to registered users. If you have purchased Rewired and would like register for early updates, please contact me here. I've submitted the update to the Unity Asset Store, so it should go live in ~7-10 days.

    @Diab1O

    I've added new input source tracking for Actions to try to better resolve issues like this. Please see Getting contributing input sources for an Action for information.

    1.0.0.72:

    Changes:
    - Changed handling of multiple Rewired Input Managers in a scene. Now when a level is loaded an an additional Rewired Input Manager is found, it will just be automatically deleted instead of throwing an error. This is to simplify the process and allow each level to have a Rewired Input Manager prefab instance without requiring an instantiator script.
    - Added tracking of the individual input sources that contribute to the combined value of an Action.

    API Changes:
    - Added Player.GetCurrentInputSources methods
    - Added Player.IsCurrentInputSource methods
    - Added InputActionEventData.GetCurrentInputSources methods
    - Added InputActionEventData.IsCurrentInputSource methods

    Bug Fixes:
    - Fixed incorrect mapping of L1/R2 and L2/R2 on Sony DualShock 4 when using Enhanced Device Support in Windows Standalone.

    --------------------------------

    If you are having issues with the Dual Shock 4 controller in Windows, please see this post.
     
  37. MattCarr

    MattCarr

    Joined:
    Jul 5, 2009
    Posts:
    339
    Excellent, thanks. One of the few things left on my list of bugs I wanted to fix before our game is out in Early Access in a few hours ;): http://store.steampowered.com/app/337320
     
    guavaman likes this.
  38. kenlem

    kenlem

    Joined:
    Oct 16, 2008
    Posts:
    1,630
    Hi Guavaman,

    I need a little help implementing touch screen controls.
    I have followed your documentation and think I have everything setup correctly but when I run on an iPhone I don't get touch messages. The app acts like it's getting mouse input and the camera just rotates up and down and left and right.

    I've tried looking at your CustomControllersTouch example but that acts like it's getting mouse events in the editor and not touches when the target is set for iOS. I understand Rewire may not work right in the editor with touches. I tried building that to the device but it crashes so I don't know how that really behaves.

    Code (CSharp):
    1. Requesting Native Resolution
    2. Init: screen size 1334x750
    3. Initializing Metal device caps
    4. Initialize engine version: 5.2.1f1 (44735ea161b3)
    5. 2015-10-13 07:37:17.359 ProductName[1220:283101] *** Assertion failure in -[UnityDefaultViewController supportedInterfaceOrientations], /Users/kennethlemieux/Source Code Control/fo/Unity Project/iOS/Classes/UI/UnityViewControllerBase.mm:103
    6. 2015-10-13 07:37:17.460 ProductName[1220:283101] Uncaught exception: NSInternalInconsistencyException: UnityDefaultViewController should be used only if unity is set to autorotate
    Oddly, I only get this crash in my project if I build with your CustomControllersTouch scene as the first scene. The app works fine if I load any of my scenes first. I really don't need that scene to work but I was hoping it would shed some light on why my code isn't working.

    I have a RewiredEventSystem because I also what to use the Unity GUI (uGUI). If I set the Touch Input Module to Force Module Active = true, my CustomController gets touch events in the editor. If I use the Unity Remote, it works but it doesn't respond to multiple touches. The joystick pad will respond correctly if you use only one finger. If you use another finger and touch somewhere else even outside the collider box for my virtual joystick, the joystick gets the event. It acts like the screen is emulating mouse input.

    Any suggestions?

    Screen Shot 2015-10-13 at 7.16.57 AM.png

    Screen Shot 2015-10-13 at 7.17.21 AM.png

    Screen Shot 2015-10-13 at 7.19.01 AM.png
     
  39. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    @kenlem

    It sounds to me like your issues are primarily with Unity (except for touch input not working).

    There is an option in Unity:
    UnityEngine.Input.simulateMouseWithTouches which you can set to FALSE if you want touches not to return any mouse data. (This is also wraped in Rewired here: http://guavaman.com/projects/rewire...Input_UnityTouch_simulateMouseWithTouches.htm)

    Your app is reacting to mouse movements and translating them into camera movements. This is completely separate from the touch input handling in the example. Unity's iOS implementation returns mouse data as well as touch data when you touch the screen. You should be filtering out mouse input if it's not needed in your code. Using the above flag would disable it globally, but if you want to keep it enabled for other purposes, either use separate Actions for your mouse-related functions and do not check for these when on a mobile platform, or check if the last active controller was a mouse and disregard input from those actions if that's the case. The procedure is described a few posts above this one: http://forum.unity3d.com/threads/rewired-advanced-input-for-unity.270693/page-25#post-2335229

    Additionally, there is a new way to tell what input source was responsible for an Action in 1.0.0.72. Please see Getting contributing input sources for an Action for information.

    Look at the source code of TouchJoystickExample and see that:

    Code (csharp):
    1. if(SystemInfo.deviceType == DeviceType.Handheld) allowMouseControl = false; // disable mouse control on touch devices
    This example checks whether or not the device is Handheld and ignores mouse input if so. There are also other ways to check for this like using the target platform, checking if UnityEngine.Input.mousePresent returns false, and others.

    If you're not getting touch messages, there must be a problem in the setup. It would be important to determine at what point in the pipeline the failure is occurring. If it's at the lowest level, the data returned by ReInput.touch and you're receiving nothing from that in an iOS build, there has to be a deeper problem or setting in Unity. Be sure to check the logs for anything unusual. I suspect the problem is not at that level however. It's probably at the higher level such as your script implementation or your creation and assignment of Custom Controllers and CustomControllerMaps. I would need to see your project to know. Show a screen shot of your Custom Controller itself in the editor, also the Custom Controller Map in the "Default", "Default" cat/layout, also post the code where you feed the data into the Custom Controller.

    If Unity returns touches through UnityEngine.Input.GetTouch, Rewired will return it also. Rewired's touch class is just a convenience wrapper for UnityEngine.Input touch. Unity will not send touch events in the editor except when using Unity Remote as far as I am aware. (I do not know how it handles touchscreen PCs.)

    The error code would indicate Unity is crashing because of something to do with orientation.

    CustomControllerDemo.cs
    Code (csharp):
    1. private void Awake() {
    2.     if(SystemInfo.deviceType == DeviceType.Handheld &&Screen.orientation !=ScreenOrientation.Landscape) { // set screen to landscape mode
    3.     Screen.orientation = ScreenOrientation.Landscape;
    4. }
    5. Initialize();
    6. }
    I can't explain why this would crash because it's a super simple, very common operation, but it would appear that your Player settings in Unity are set to a fixed Portrait orientation. Unity seems to be crashing because this code is trying to change it to Landscape. Change your Player setting to Landscape or Auto and this will probably no longer crash. One would think Unity would handle this at the low level, but apparently not.

    Touch Input Module only affects Unity UI elements and other things specifically designed to rely on it. It won't affect the CustomControllerDemo in any way, nor will it affect what is returned by UnityEngine.touches.

    It is very likely that you enabling ForceModuleActive is simply causing the editor to respond to mouse events to emulate touch. The mouse is not mult-touch capable, so you are not going to get the results you're looking for. As far as I am aware, true touch input events are not available in the Unity editor. You can check this out easily by doing a little testing with UnityEngine.touches and see what's returned.
     
    Last edited: Oct 13, 2015
  40. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
    Yes, in my case dPad's Move Horizontally and Move Vertically do different things?

    How should I handle this situation? "Don't Destroy On Load" is already unchecked.
     
  41. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    You need to explain to me exactly what is happening. I need to know what the problem is in detail before I can help you. Either that or send me your project so I can look at it. I will PM you the email address.

    I need to know what input is not working correctly and how. Is this game input? Unity UI input? Both? Does it affect keyboard and/or mouse or just the joystick D-Pad?

    From what I see in your images, you have a Rewired Standalone Input Module in one of your scenes and not one in the other. If you are destroying the Rewired Standalone Input Module, your UI will be controlled by Unity's Standalone Input Module (if it exists) which uses Unity's Input Manager settings, not Rewired.

    Assuming you're having UI issues (and I'm only guessing), it may be due to the fact that the RewiredStandaloneInputModule gets its list of Players on Awake(). When you destroy the existing input Manager, all those references to Players are invalid now and you would have to re-initialize the RewiredStandaloneInputModule again so it would use the new Rewired Input Manager as its source. (You would have to destroy and reinstantiate the RewiredStandaloneInputModule.) However, if this were the cause, you would get no UI input.
     
    Last edited: Oct 13, 2015
  42. kenlem

    kenlem

    Joined:
    Oct 16, 2008
    Posts:
    1,630
    Thanks for the answer! I have it sorted out now.

    The real problem was that I had Assign Mouse on Start checked. If I uncheck that and build to the device, everything works correctly. :)

    Now I just need to figure out how to set or clear that in code on start up.
     
  43. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    That's yet another way to disable mouse input, but it won't affect input you receive through Unity UI, only Rewired's Player input.

    player.controllers.hasMouse = false;
    http://guavaman.com/projects/rewire..._Rewired_Player_ControllerHelper_hasMouse.htm
     
  44. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392

    Hey there. Thanks for the offer of sending the project. I did some debugging and learned that it was a script that had a UI OnPressed event which somehow was being defaulted as 'Submit' or something like that. Anyway, it is fine and I am happy.

    For future reference though, what are the best practices regarding Rewired Input Manager and multiple screens, with or different input settings?

    Thanks
     
  45. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Glad you got it resolved. So it was a UI input issue. For future reference, this is very important info for me to know when doing support because UI input is handled very differently from game input.

    It depends on your use case. The primary information is outlined here:
    http://guavaman.com/projects/rewired/docs/InputManager.html

    Your issue with dealing with a RewiredStandaloneInputModule is separate and has its own requirements. In 1.0.0.73+ the RewiredStandaloneInputModule will grab its Players and Actions based on whatever Rewired Input Manager is currently found every frame. Prior to 1.0.0.73, the RewiredStandaloneInputModule initialized on Awake with whatever Rewired Input Manager was in the scene at that time, so deleting the Rewired Input Manager but not the RewiredStandaloneInputModule would cause the RewiredStandaloneInputModule to be requesting input from outdated and invalid objects.
     
    Last edited: Oct 14, 2015
  46. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    @gegagome

    A bit of additional info on your question:

    Generally, there's very little reason to use multiple Rewired Input Managers in your project. You can always achieve the same effect of multiple input configurations by using Map Categories (and optionally Layouts). You can dynamically manage what maps are loaded and/or enabled in Players at runtime through scripting. This allows you to have as many separate configurations as you desire and switch among them at will.

    The primary issue with using multiple Rewired Input Managers in your project is the fact that Rewired is completely reset when destroying the old and instantiating a new Rewired Input Manager. The primary issue is that joysticks have to be reassigned to Players, and this may not happen in the same order it happened before. Also, any cached Rewired Players, Controllers, or Maps you have in your scripts will be no longer valid and you have to retrieve them again. Unless you have a very good reason to destroy the Rewired Input Manager, you shouldn't do it unless you're aware of the side effects and are prepared to deal with those.
     
  47. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
    Thanks for clarifying. It makes a lot of sense.

    I plan on using two controllers as a mid-term goal so your later response pretty much settles this issue and will help me avoid confusion in the future.

    Thanks again!

    Love Rewired even more.
     
  48. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Glad to help!
     
  49. AlexThunderLotus

    AlexThunderLotus

    Joined:
    Jun 15, 2015
    Posts:
    11
    Just to report back, I used the xbox 360 config for the xbox one controller on Linux as one user said they were map identically (and old Unity game worked with it). I did it the lazy way by adding the name to the xbox 360 config and so far it appears to be mapped correctly.

    Here is the name of the controller on Linux: Microsoft X-Box One pad
     
  50. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Okay, thanks. I'll add a Linux fallback mapping to the Xbox One definition based on the 360.