Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

InControl - input and cross platform controller support for Unity, made easy!

Discussion in 'Assets and Asset Store' started by pbhogan, Jul 18, 2014.

  1. snugsound

    snugsound

    Joined:
    Mar 9, 2014
    Posts:
    12
    Thanks for confirming / I think I'm having deja vu here :)
     
  2. legacyblade

    legacyblade

    Joined:
    May 14, 2015
    Posts:
    1
    Hey all,

    For some reason, InControl won't respond to input. I have an InControl Input Manager in the scene and a script with the following Update Method.

    Code (CSharp):
    1. if (InControl.InputManager.ActiveDevice.AnyButtonIsPressed)
    2.             Debug.Log("A button was pressed.");
    I'm sure the Update method is being called. But no matter what I do, it won't acknowledge any button presses. (I've tried multiple controllers and starting a new project). I've tried both Unity 2019.1.0f1 and 2019.2.0b9.

    InControl has been my go-to for every unity project for years now, and it's always just worked in the past. So any help would be appreciated. :)
     
  3. RobbyZ

    RobbyZ

    Joined:
    Apr 17, 2015
    Posts:
    18
    FYI, there's something weird going on with 32bit builds + il2cpp + InControl.

    I was getting some weird errors like these when running an il2cpp build:

    And I discovered that at least in Unity 2018.4.2f1 you can't run a 32bit .net 3.5 build, even on low stripping. I tried toggling .net 4, and that kind of worked -- but only if I didn't build via BuildPipeline script but used the editor build panel (it generated identical builds except the GameAssembly was about half the size and caused those errors again).

    Anyway, I was able to get a consistent repro of this issue on a new project with the TestInputManager example scene, set to IL2CPP + 32bit + .net 3.5 on InControl 1.7.3b9338 and Unity 2018.4.2f1. I suspect it's something going on with Unity IL2CPP as opposed to InControl.

    I saw there's a newer Unity build with some IL2CPP fixes, not sure if that will resolve but I'm unable to upgrade currently due to an external version dependency. So for now I'm using 64bit build and things seem to be working, although I would have preferred to stick with 32bit as there's still about ~1% of the market on 32bit OS.

    Finally, if you do want to use high stripping, it is possible by using a link.xml file. Just place it in your InControl folder. Here is the version I am using so far on my project (I am not using the InControl specific assemblies currently, so if you are, you'd have to update the Assembly tag)

    Code (CSharp):
    1. <linker>
    2.    <assembly fullname="Assembly-CSharp">
    3.        <namespace fullname="InControl" preserve="all" />
    4.        <namespace fullname="InControl.NativeProfile" preserve="all" />
    5.    </assembly>
    6. </linker>
     
  4. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    220
    That's weird. Have you tried any of the examples or the TestInputManager scene just as a sanity check? If those work then it's just something not set up correctly. Otherwise, e-mail me with some more system information and we can go from there.
     
  5. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    220
    Good to know. IL2CPP is definitely a bit broken when it comes to things Unity considers deprecated, such as 32-bit and .NET 3.5. I've had a bit of back and forth with them on IL2CPP and the native plugin where there just seems to be some incompatibilities they're not dealing with. I wouldn't hold out hope for a fix... their approach tends to be to drop support rather than spend effort to fix bugs in deprecated things. They're definitely pushing people towards .NET 4.x now.
     
  6. snugsound

    snugsound

    Joined:
    Mar 9, 2014
    Posts:
    12
    Hey Patrick, would it be possible to add an option to have touch controls use unscaled delta time? I use them in my pause menu, and they do work, but because of the reliance on delta time they don't behave the same (they remain "idle" colour when touched, virtual stick doesn't snap back to center, etc.).

    I've patched this for now but not really ideal.
     
  7. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    220
    That seems like something that can be added. It should probably even do that all the time as I don't know why they would ever need scaled delta time. Can you e-mail me with what exactly you patched?
     
  8. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    931
    Hi, i have a question ( or request ).

    Can we use some information from the controller in order to save settings for that specific controller !?

    Like i saw somewhere in the code that you can get the serial number of the device. Could this be get currently per device and be used as a save file name or is there already any other way of doing that ? I wen through the documentation in the website but did not find anything regarding that !

    Thanks !
     
  9. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    220
    Info
    Eh... this is somewhat nuanced.

    When using the Unity input module, no... there is no hardware specific unique identifier ever. Unity just doesn't expose it. You have the device name, however, so if you wanted to you could have settings per device type (e.g. all Xbox 360 controllers), but not per individual piece of hardware.

    When using the native input module, unique hardware information is often (but not always) available. Specifically, this would be the combination of hardware vendor ID, product ID and serial number. None of these are required to be provided by manufacturers. The serial number is not a globally unique number by itself... just presumably unique to the product line. Even the combination of all three is not necessarily unique... it's conceivable that, say, a cheap knock-off xbox controller uses Microsoft's vendor and product IDs to be appear like the real thing and since the serial number is whatever they want, there could be a duplicate. It would just be extremely unlikely to occur, especially that one user would own two controllers that happen to have the same hardware info.

    And then there's one more exception, which is if XInput is enabled (something I generally recommend) then there is also no hardware specific identifier for compatible controllers, and, in fact, not even a hardware type available. It's just an "XInput-compatible controller" according to Microsoft's API, with no further information about what exactly it is.

    So it boils down to: I don't think it's a reliable feature you can offer. It would probably be better to offer saving multiple controller configurations in your UI and let the user select one other than the default if they want. It's not a stretch that the configuration needs to be changed manually if they plug in a different controller. And maybe you could have it automatically select one if, and only if, a vendor ID, product ID and serial number is available.

    All that said, if you are using native input and want to get at this information, try cast the input device to NativeInputDevice and, if successful, it will have an Info property of type NativeDeviceInfo which contains:
    public string serialNumber;
    public UInt16 vendorID;
    public UInt16 productID;
     
  10. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    931
    Hi, thanks for the great input. It's all much clearer to me now. I will consider you suggestions and comment. Thanks !
     
  11. fwalkerCirca

    fwalkerCirca

    Joined:
    Apr 10, 2017
    Posts:
    57
    Hi I am new to InControl and I have a quick question.
    What is the difference with the behavior of Touch Stick and Touch Swipe controllers? Other than the drawing of the controls, I am not seeing a difference in the values received from them. I would have expected the Swipe to do to 0 once the user stops moving the swipe. What am I missing?
     
  12. napky33

    napky33

    Joined:
    Sep 2, 2018
    Posts:
    2
    Hey man, would you mind sharing the Joy-con profile?
     
  13. napky33

    napky33

    Joined:
    Sep 2, 2018
    Posts:
    2
  14. RainbowWhale

    RainbowWhale

    Joined:
    Feb 25, 2018
    Posts:
    37
    Hello! Great plugin! But I have a little problem..
    If I use InControlInputModule in EventSystem, keyboard input in dosn't work in UI. How to solve this problem?
     
  15. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    220
    You'll need to create action sets with keyboard bindings and then set them on the input module. There's an example with explanation here: http://www.gallantgames.com/pages/incontrol-new-unity-gui
     
  16. RainbowWhale

    RainbowWhale

    Joined:
    Feb 25, 2018
    Posts:
    37
    But I did it. My Player is controlled by keyboard and gamepad, everything works fine. But the UI is controlled only from the gamepad.
     
  17. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    220
    Did you assign the player actions to the input module? This part in the example code linked previously:

    var inputModule = GetComponent<InControlInputModule>();
    if (inputModule != null)
    {
    inputModule.SubmitAction = actions.Submit;
    inputModule.CancelAction = actions.Cancel;
    inputModule.MoveAction = actions.Move;
    }

    If not, it's going to default to only using the active device for controller-only input.
     
  18. RainbowWhale

    RainbowWhale

    Joined:
    Feb 25, 2018
    Posts:
    37
    Ok, thanks for the answers. I figured out the problem, I made a small mistake myself .. Thanks for the plugin! Did not have to waste time on a routine
     
  19. hododoho

    hododoho

    Joined:
    Oct 9, 2017
    Posts:
    12
    Hiya, quick question. Does InControl support controllers on mobile devices via bluetooth or usb on the go connections? Android? iOS? Thanks in advance!
     
  20. hododoho

    hododoho

    Joined:
    Oct 9, 2017
    Posts:
    12
    From my initial testing it seems like PS4 isn't working on Android 9, but XBox One is.
     
  21. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    931
    Hi,

    1. i would like to detect whenever any input using a controller is detected. I found an option to detect if any button is pressed but don't know how to deal with analog sticks.

    2. This code gets now updated every frame. It was working yesterday. Something that could call that every frame ?

    Code (CSharp):
    1. if (InControl.InputManager.ActiveDevice.AnyButtonWasPressed)
    2. {
    3.      Debug.Log("This is called every frame");
    4. }
    EDIT : the issue 2 got fixed. The controller i am using has some Clear button. Pressing it just fixed it ! However any info on the first point is appreciated !

    Any help on these !?
     
    Last edited: Sep 7, 2019
    Lars-Steenhoff likes this.
  22. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    931
    Hi,

    i just purchased an XBox One controller, but got Unity crash every time i exit play mode...
    I am not sure why is that if it is Window, Unity or InControl...

    I am using latest Windows 10 update, latest InControl and Unity 2019.2.3f1

    Any help on how to catch and fix this problem is highly appreciated !

    Thanks !
     
    Last edited: Sep 9, 2019
  23. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    2,273
  24. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    931
  25. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    931
    Hi @pbhogan , please could get in touch to help find the reason of why it's th

    It also crashes with 2019.2.4f1 and InControl !
    In empty project without InControl added it does not crash !
    The crashing problem went away. I think i just switch the controller to USB3.0 port and that might have fixed it. Not sure!

    However i have a question. I can't seem to find how to use these profiles ! Is it any way to auto detect that the controller is an XBox One and preset bindings ? How is this done ?

    The video about profiles has some option that it's currently not available in the InControl manager and i don't see any info about that in the docs !
     
  26. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    931
    Hi @pbhogan , is there a chance you find a little time to little on something !

    I can't understand what is the way of detecting and pre set initial bindings for XBox One controller.
    I am seeing this "XboxOneInputDevice" script but i can't find any information on how to use this.
    What is this script for and should i use it if an XBox controller is detected ot you are using it for some internal stuff ?
    Not finding any information on how to deal with known model controllers !

    Thanks !
     
  27. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    2,273
    @Vagabond_ I recommend e-mailing because the forums don't always give notifications.
     
    Vagabond_ likes this.
  28. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    931
    Thanks for suggestion. I will try to contact by email as well !
     
  29. hododoho

    hododoho

    Joined:
    Oct 9, 2017
    Posts:
    12
    Running into an issue I'm sure you've seen many times before, but I can't get to the bottom of it. I've set up a PlayerActionSet and set up the left stick with a TwoAxisPlayerAction using AddDefaultBindings. Now I'm running into a situation where if I instantiate this action set at the same time as I set its device, everything works fine, but if I instantiate this action set really early on in the application, then later set the actionSet.Device property, I end up in a weird situation.

    I can see that InputManager.ActiveDevice == actionSet.Device, yet InputManager.ActiveDevice.LeftStick is getting values, but the actionSet.MainStick is not seeing any data or values. Any thoughts on what potential causes might be? I don't suppose it's possible to instantiate actionSets too early and somehow their default bindings never kick in?

    I assume this the standard way to instantiate things?

    Edit: Just found out that myActionSet.ActiveDevice != InputManager.ActiveDevice. Seems suspicious. What might be causing that?

    Code (CSharp):
    1.     public CharacterActionSet()
    2.     {
    3.         MainStickUp = CreatePlayerAction("Main Stick Up");
    4.         MainStickDown = CreatePlayerAction("Main Stick Down");
    5.         MainStickLeft = CreatePlayerAction("Main Stick Left");
    6.         MainStickRight = CreatePlayerAction("Main Stick Right");
    7.         MainStick = CreateTwoAxisPlayerAction(MainStickLeft, MainStickRight, MainStickDown, MainStickUp);
    8.     }
    Code (CSharp):
    1.     public static CharacterActionSet InstantiateWithGamepadDefaults()
    2.     {
    3.         CharacterActionSet characterActions = new CharacterActionSet();
    4.  
    5.         characterActions.MainStickUp.AddDefaultBinding(InputControlType.LeftStickUp);
    6.         characterActions.MainStickDown.AddDefaultBinding(InputControlType.LeftStickDown);
    7.         characterActions.MainStickLeft.AddDefaultBinding(InputControlType.LeftStickLeft);
    8.         characterActions.MainStickRight.AddDefaultBinding(InputControlType.LeftStickRight);
    9.  
    10.         return characterActions;
    11.     }
     
    Last edited: Sep 10, 2019
  30. hododoho

    hododoho

    Joined:
    Oct 9, 2017
    Posts:
    12
    Is there a way to make touch areas layered in some way? For example, I'd like to have a Touch Stick on the right side of the screen, but have the active area overlap some existing Touch Buttons. If a button is touched, I'd like it to not activate the touch stick.
     
  31. hododoho

    hododoho

    Joined:
    Oct 9, 2017
    Posts:
    12
    Not sure if you intended this to ever be used this way, but just FYI I added a method to TouchStickControl to directly get its value to use programatically with the "Target" option set to "None". Maybe it's worth considering integrating something like this for all the touch controls?

    Code (CSharp):
    1.         public Vector2 GetValue()
    2.         {
    3.             return DeadZone.Circular(value.x, value.y, lowerDeadZone, upperDeadZone);
    4.         }
    Edit: Maybe it's also worth considering giving touch controls their own lifecycle statuses too, like WasPressed, WasReleased, and all that? This is mostly for the use case where I'm using touch controls that aren't bound to a target.
     
    Last edited: Sep 11, 2019
    Lars-Steenhoff likes this.
  32. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    931
    I see it is hard to get support by developer, but anybody else knows hot to get keyboard detected as InputDevice type too, in order to be able to differentiate the type of the input device !?

    Thanks !
     
    Last edited: Sep 12, 2019
  33. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    931
    In case i spawn InControl manager from script which of course should be removed when exit play mode, the editor crashes every time. Seems related to cleaning up some stuff in the background, because when i have the manager added to a scene without spawning it, it does not crash the editor on exit play mode. This is only happening with XBox One controller ! May be it's Unity related but i am not sure ! Just sharing if anybody else got this issue !
     
  34. OfficialCoatsee

    OfficialCoatsee

    Joined:
    Mar 4, 2014
    Posts:
    1
    Hey, I am trying to build a little test. It all works as expected in the editor, however as soon as I try to build for iOS, I get this error: The type or namespace name 'InControl' could not be found (are you missing a using directive or an assembly reference?)

    Can anyone shed some light as to what I am not doing correctly?

    Edit: Nevermind, silly me. Moved the plugin folder from inside the InControl asset folder, to the root Assets folder, along with the InControl.amsdef file, and now it's working fine :)
     
    Last edited: Sep 13, 2019
  35. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    723
    Hi @pbhogan we're evaluating InControl right now and wile we really like it, it seems we've come across an issue. Apparently the rebind function for mouse button is broken in 2019.1.5f1 on Windows 10 (even in the Bindings example scene). It's not possible to assign a mouse click after clicking on the "+" button. The line still says "Fire (Listening) = 0" and stays stuck this way, not reacting to any mouse click.

    Furthermore we've also met a problem with clicking on a custom button to assign a keyboard key; since the system listens for input from the last used device (in this case the mouse, because of the button click) it isn't capable of catching a keyboard key press (unless we're doing something wrong)...

    Would you be able to help us with these please?
     
  36. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    220
    The first issue is because listening for mouse presses is not enabled by default. You'll need to enable them in the listen options. In the example, in PlayerActions.cs look for, and uncomment, the line:
    playerActions.ListenOptions.IncludeMouseButtons = true;

    I must have commented it out while testing something a while back and forgot to uncomment it.

    As for the second issue, I don't fully understand and maybe you could e-mail me (a much better way to get in touch! http://www.gallantgames.com/contact) with some details. If what you're saying is the act of clicking the button is triggering the listen and then immediately accepting the mouse click as a binding, then you'll either want to trigger listening on mouse up or disable listening for a mouse click (by setting the listen options). It's worth looking through the BindingListenOptions class as there are a variety of options to tweak and callback hooks if you need to deal with more complex situations.
     
  37. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    220
    For legacy reasons, keyboard and mouse are not considered "devices" in InControl in the same way as controllers. They only give input and work with the bindings API. So they won't appear in the devices list or ever be the active device, for example.

    For the bindings system, there are a variety of properties for getting information about the last binding source that gave input to the binding. Both on PlayerAction and PlayerActionSet there is a LastInputType property that you can check to see if it was a keyboard binding. There is also a OnLastInputTypeChanged callback you could use if you need to be notified to update UI for example. You can also use the LastDeviceStyle properties to learn what kind of controller gave input (for example Xbox, PlayStation, Nintendo, etc.)
     
    Lars-Steenhoff likes this.
  38. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    931
    Cheers Patrick, thanks for the feedback on support requests. I actually managed to get InControl really well integrated. I am still learning the API so any tip is welcome as is helps to speed up development !
     
    Lars-Steenhoff likes this.
  39. oldcloud

    oldcloud

    Joined:
    Apr 15, 2019
    Posts:
    4
    How to set Key Combo ?
     
  40. massiveminiteam

    massiveminiteam

    Joined:
    Aug 28, 2018
    Posts:
    36
    InControl is not detecting the Switch Pro Controller on Windows with the enabled native input module. We are using the latest InControl version from the Asset Store. Did anyone of you had the same problem and knows how to fix this?

    Edit: InControl detects the device but we don't get any input. LastInputTick is always 0.
     
    Last edited: Oct 18, 2019
  41. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,448
    What's the situation with the new unity input system and incontrol will this be getting an update for that?
     
  42. Grhyll

    Grhyll

    Joined:
    Oct 15, 2012
    Posts:
    89
    Hi!

    I was wondering if supporting vibrations for PS4 pads on Windows is something that have good chances to be there quite soon, or if it's still just a possibility for some day in a distant future? (For what it's worth I believe Rewired does it out of the box, though I'm not 100% sure.)