Search Unity

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

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

  1. djfrail

    djfrail

    Joined:
    Jan 16, 2014
    Posts:
    124
    Posting this for others who may run into this, and also to see what the author of InControl has to say -

    I was testing a bluetooth game controller (Gamestick) on a newer Kindle Fire and only the left analog stick was working. I modified the GenericAndroidProfile.cs file to the below code (added the bit about Fire Bluetooth) and that made it work:

    Code (CSharp):
    1.  
    2.             JoystickNames = new[] {
    3.                 "Broadcom Bluetooth HID",
    4.                 "Fire Bluetooth HID"
    5.             };
    6.  
    Is this the proper way to do this?
     
  2. djfrail

    djfrail

    Joined:
    Jan 16, 2014
    Posts:
    124
    Question - how do you map the back button on an Android phone or tablet?

    Also - I've read that to detect a press of the back button (the one next to home and menu) on an Android device, you need to check the state of the escape key. But I've noticed that on some of my older test Android devices, this doesn't work:

    if (Input.GetKeyUp(KeyCode.Escape))
    ...do stuff...

    But on newer devices it works fine. What's the proper way to get back button presses?
     
    Last edited: Jun 16, 2015
  3. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    382
    That works. Usually I prefer to create a separate profile for a specific device even if it has the same mappings as something else so it has the correct control names, etc. Also because Amazon is adding heavy modifications to Android and so it may deviate from how things work on other Android devices in the future.
     
  4. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    382
    I'm not sure why that doesn't work on older devices... it is the correct way to detect back button on Android. I'm not aware of any other way to check it. Even on most Android controllers, the way it responds in Unity is via the Escape key instead of an actual joystick button, and is shared across all controllers and the device itself, so often the profiles contain:

    new InputControlMapping {
    Handle = "Back",
    Target = InputControlType.Back,
    Source = EscapeKey
    },
     
  5. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    382
    Are you sure? Unity has never had a major number only define (http://docs.unity3d.com/Manual/PlatformDependentCompilation.html). You have always needed to be specific with UNITY_5_0 || UNITY_5_1 || UNITY_5_2, etc.
     
  6. djfrail

    djfrail

    Joined:
    Jan 16, 2014
    Posts:
    124
    Ah, it was my fault. if (Input.GetKeyUp(KeyCode.Escape)) actually does seem to be working. I wasn't consistently calling it in my code. Sorry for false alarm!
     
  7. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    382
    Oh, cool. Good to know. Wish they would keep their docs up to date. :p
     
  8. username132323232

    username132323232

    Joined:
    Dec 9, 2014
    Posts:
    477
    I need to temporarily remove InControl from my project targeting iOS. When I erase the InControl folder and try to build and run the project, xcode shows a lot of "Semantic Issue" errors.

    How do I properly remove InControl from a project?
     
  9. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    382
    You shouldn't have to do anything more than that. InControl doesn't do anything special on iOS and I've never heard of that error. Chances are it's something to do with Unity generating the Xcode project. You may need to completely delete the iOS build and regenerate it or something like that.

    From a quick google on the subject it sounds like there should be more to the error explaining what it is like "Undeclared identifier ..."
     
  10. username132323232

    username132323232

    Joined:
    Dec 9, 2014
    Posts:
    477
    Deleting the iOS build solved the problem. Thank you so much for the suggestion!
     
  11. farlenkov

    farlenkov

    Joined:
    Mar 28, 2014
    Posts:
    17
    Question: how to implement different sensitivity etc. settings per device?
    For example I have TwoAxisPlayerAction:

    ...
    var Look = CreateTwoAxisPlayerAction( LookLeft, LookRight, LookDown, LookUp );
    LookLeft.AddDefaultBinding( Mouse.NegativeX );
    LookLeft.AddDefaultBinding( InputControlType.RightStickLeft );
    ...
    var Move = CreateTwoAxisPlayerAction( MoveLeft, MoveRight, MoveDown, MoveUp );
    MoveLeft.AddDefaultBinding( Key.A );
    MoveLeft.AddDefaultBinding( InputControlType.LeftStickLeft );
    ...

    I want apply different Sensitivity, Smooth and Acceleration settings for mouse, gamepad and keyboard.
    I thought that I could use PlayerActionSet.LastInputType to detect input source, but if I play with mouse+keyboard it would not be reliable.

    Perhaps it would be useful to have LastInputType property in TwoAxisPlayerAction.
     
  12. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    382
    Hmm. Yes, that seems like something I can add in some fashion. One of the things I'm working on next is the ability to add additional filtering to actions for custom deadzones, smoothing, sensitivity, input curves etc. I'll look at making it possible to do it per BindingSourceType too.
     
  13. Skyboard_Studios

    Skyboard_Studios

    Joined:
    Jul 20, 2013
    Posts:
    51
    Can you confirm that InControl will work on AndroidTV's using the Dpad Controller? This seems to be a major concern for me right as I need to get my game approved by the AndroidTV Review team... They also need a way of confirming that a controller has been unplugged from the game so a Pause Menu is shown to wait until it is replugged in. Please let me know!

    InControl looks sweet and I will be happy to purchase if you can confirm that these issues are taken care of.
     
    Last edited: Jul 7, 2015
  14. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    382
    InControl definitely works with Android TV... I've tested with the ADT-1 and Nexus Player along with the Google Gamepad for Nexus Player (made by Asus) and the remote. The Razer Forge TV and Nvidia Shield along with their respective controllers are also supported.

    Detached controllers can be detected with the InputManager.OnDeviceDetached callback hook.
     
    Skyboard_Studios likes this.
  15. Skyboard_Studios

    Skyboard_Studios

    Joined:
    Jul 20, 2013
    Posts:
    51
    excellent.. I have purchased the plug-in and am currently working on implementing it.

    Thank you for replying back to my request. I have since ordered a Nexus Player with a gamepad for proper testing as using the android emulators are a nightmare. I am hoping I can finally now get my game approved by the AndroidTV review team.

    Update:

    I have been reviewing all the code and examples and I am pleased on how things look. I am now just in the midst of getting some bindings setup (using BindingsExample) as boilerplate... but now I am actually seeing that there is a

    InputManager.ActiveDevice.DPadDown.WasReleased

    getter.. and as I am focusing on AndroidTV Dpad I am thinking all the DPadxxxx methods are the way to go versus tapping into a Up/Down/Left/Right.

    I am trying to get up to speed with how I should be using InControl so please bear with me. :)

    My Nexus Player arrived so I am testing things out with the Gamepad and the Remote Controller and I am finding that the Up/Down Dpad is not firing. using v1.5.8.

    I will continue testing and see what is happening.

    Thanks again.
     
    Last edited: Jul 14, 2015
  16. RChrispy

    RChrispy

    Joined:
    Dec 18, 2013
    Posts:
    71
    Hey here I am again and thanks for your tool ( I think I use an older version 1.5.5 build 5366) But I used my binding for multiplayer now and had a problem with different devices with custom actions. Here is how I fixed this:

    Code (CSharp):
    1. void BindKeyToAction(PlayerAction _Action, InputControlType[] _GamePadInputType)
    2.         {
    3.             //GAMEPADTYPE
    4.             foreach (InputControlType obj in _GamePadInputType)
    5.             {
    6.                 _Action.AddDefaultBinding(obj);
    7.                 //overriding the default device!
    8.                 _Action.Device = InputManager.Devices[playerNum];
    9.             }
    10.         }
    I changed something in your code: ( But I dont think this was intended from your side)
    Code (CSharp):
    1.         InputDevice device;
    2.         internal InputDevice Device
    3.         {
    4.             get
    5.             {
    6.                 if (device == null)
    7.                 {
    8.                     device = Owner.Device;
    9.                     UpdateVisibleBindings();
    10.                 }
    11.  
    12.                 return device;
    13.             }
    14.  
    15.             set
    16.             {
    17.                 if (device != value)
    18.                 {
    19.                     device = value;
    20.                     //MY CHANGE
    21.                     Owner.Device = value;
    22.                     UpdateVisibleBindings();
    23.                 }
    24.             }
    25.         }
    MY PROLEM NOW:
    I can play with different Controllers but the character with playernum = 0; is controller 2.
    And the character with playernum = 1; is controller 1. Why is that my debuglogs give me the correct values back?
    Code (CSharp):
    1. Debug.Log("Action: " + InputManager.Devices[playerNum] + "   SortOrder: " + InputManager.Devices[playerNum].SortOrder + "   Meta: " + InputManager.Devices[playerNum].Meta);
     
  17. RoyalCoder

    RoyalCoder

    Joined:
    Oct 4, 2013
    Posts:
    301
    Hi @pbhogan , I updated to the latest InControl and now I get this error:
    Assets/InControl/Examples/Bindings/PlayerActions.cs(8,22): error CS0101: The namespace `BindingsExample' already contains a definition for `PlayerActions'

    How can I fix this ? thx
     
  18. RChrispy

    RChrispy

    Joined:
    Dec 18, 2013
    Posts:
    71
    Post some Code maybe? ^^ Because you have a double declaration in the same namespace pretty simple compile error. Rename your own declaration. Or maybe you declare your custom playeractions wrong?

    Since you updated I guess you now have the same script twice, and therefore the error. :)
     
  19. RoyalCoder

    RoyalCoder

    Joined:
    Oct 4, 2013
    Posts:
    301
    *Fixed by removing InControl & imported again in my project ;) Thanks !
     
  20. RChrispy

    RChrispy

    Joined:
    Dec 18, 2013
    Posts:
    71
    Glad I could help :)
     
  21. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    382
    Apologies for the delayed response... as usual the forums don't consistently notify me to posts on this thread. :(

    Anyway, I just fired up my Nexus to try to replicate. For me both the controller and the remote works fine, with both Unity 4.6 and Unity 5.1... I just used the TestInputManager scene built for device to confirm. If you can provide any more info on what you're running into exactly, please e-mail me: contact at gallantgames dot com
     
  22. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    382
    Please take a look at the multiplayer examples in the latest update (1.5.8). It shows how to handle this cleanly. Specifically, you should be setting the device on the action set as a whole, not an individual action (note the property is internal, which means it is not for public API use). Also, accessing InputManager.Devices by index is not good as it can contain all kinds of junk including non-functioning devices. You can't just a pick devices 0 to numPlayers. The proper way to get a working device from that pool of devices is detecting a press (using InputManager.ActiveDevice) and then setting up the player with it's action set assigned to that device.
     
  23. RChrispy

    RChrispy

    Joined:
    Dec 18, 2013
    Posts:
    71
    Thanks for your reply. Well the example in 1.5.5 uses an index to assign players with a playernum. So i thought this is the intended way to use the multiplayer. I assigned the divice for each action, since I didnt find a way to assign the divice for an action set ( is there an example)?

    Also I changed some of my code and tried to init the bindings during runtime ist AddDefaultBinding not working during runtime? It's hard to set the multiplayer up on a perfekt clean way for me.

    Cheers :)
     
  24. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    382
    Yes, that was an old example that was encouraging bad behavior so I removed it and added more complex examples.

    The MultiplayerWithBindings example assigns a device for the action set as it creates each player. You just set the Device property on the action set. When it's set to null (which it is by default) it will read from InputManager.ActiveDevice instead.

    AddDefaultBinding does work at runtime. Again, the example uses this too.
     
  25. RChrispy

    RChrispy

    Joined:
    Dec 18, 2013
    Posts:
    71
    Thanks for your answer I updated and now I saw your new aproach. :) Thanks for your support.
    Had to rewrite a lot of code and have still nullreferences when I pull out the USB of my controller. But I am working on it. ;)

    You should try to add an "Asset" aproach within your examples. For your custom actions I think thats the perfekt way to use your system on a most flexible way using the editor! Keep up your work! ;)
     
  26. Tuni

    Tuni

    Joined:
    May 24, 2013
    Posts:
    74
    How does the repeat values of the player actions work? We are working on a few stick (e.g. flick two times left) and buttons gestures (e.g. double press). Are there any InControl features that can help us?
     
  27. silentneedle

    silentneedle

    Joined:
    Mar 14, 2013
    Posts:
    280
    I really love how elegant InControl is. I just have a tiny question.

    What do you would recommend. Adding all actions in one single CharacterActions file, or should I split e.g. chat actions like OpenChatInput in it's own class?
     
    Last edited: Jul 28, 2015
  28. wightwhale

    wightwhale

    Joined:
    Jul 28, 2011
    Posts:
    397
    I'm having trouble with incontrol not working at all when I do a build to PS4. Is the PS4 supported or do I need to find another solution?
     
  29. Obsurveyor

    Obsurveyor

    Joined:
    Nov 22, 2012
    Posts:
    277
    How's this coming along? Just trying to determine if I should do something on my own or wait a couple days.
     
  30. TechiTech

    TechiTech

    Joined:
    Dec 13, 2014
    Posts:
    212
    I'm getting lots of errors with InControl after installing Patch release 5.1.2p2

    Assets/_____ADDONS/InControl/Source/GUI/InControlInputModule.cs(200,41): error CS1501: No overload for method `GetMousePointerEventData' takes `0' arguments

    +35 more errors.. Just letting you know. I'm going to rollback
     
    Last edited: Aug 1, 2015
  31. UnbreakableOne

    UnbreakableOne

    Joined:
    Nov 16, 2013
    Posts:
    168
    I'm using InControl for my local multiplayer and so far I had success with using two controllers and reading from InputManager.Devices[index].

    Problem I'm facing now is that I need to have support for one player switching to Keyboard/Mouse control. If I add keyboard control to AddDefaultBinding of my PlayerInputAction, Keyboard/Mouse would move everyone.

    So I need to have a facility in my game that I can switch from controller to mouse/keyboard on demand. In other words I could decide to play with controller for one player and could switch to Keyboard/Mouse for that specific player.How can I achieve this?
     
  32. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    382
    You'll probably want to get your own in if you need it right away. It's not a high priority item and I want to do some other work first that will somewhat inform how this is implemented.
     
  33. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    382
    There are two properties to control repeating:
    public float FirstRepeatDelay = 0.8f;
    public float RepeatDelay = 0.1f;

    The first determines the delay until repeating starts, and the second the delay between repeats firing. The value and state of a control is not affected by repeating, but on repeats the WasRepeated property will be true.

    There are no gestures built in, so double taps are something you're on your own for currently.
     
  34. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    382
    It's really up to your preference but I typically have a single file per top-level class, so I'd have a file for every different action set my project has.
     
  35. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    382
    It does work on PS4 but only with basic support through Unity Input (so no rumble or LED control) and also only works with the PS4 controller. Several users are developing for PS4 with InControl, so it definitely works, but maybe there is something different in your case. Try building the TestInputManager scene for PS4 and see what kind of information you get. It could be that your devkit is reporting a different name to Unity or something and needs to have the InControl profile updated. Please feel free to e-mail me with what you see in the test scene and we can get into it more.
     
  36. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    382
    Unity patch releases are unsupported as they tend to have some API flux, bugs and other instability issues that are futile to try to work around until a normal point release.

    That said, in this case all you need to do is pass a 0 argument into the offending method call. Apparently Unity decided to add a completely undocumented API change in this patch release.

    In general, however, I'd recommend unless you absolutely NEED something in a patch release (like IL2CPP related fixes) stay far, far away from Unity patch releases. They are just not stable.
     
    TechiTech likes this.
  37. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    382
    I believe I replied to you in an e-mail, but take a look at the multiplayer examples in the newer versions of InControl (you may need to update to get them).

    The basic gist of it is that you create a separate PlayerActionSet instance and just set it up with keyboard bindings for the player you want. There’s no reason different instances need to have the same default bindings. The way to switch on demand is just to have an action set for keyboard bindings and switch it with the one the player is using for controller input when you want. You could even have two separate instances with different keyboard controls (keeping in mind the limitations of keyboard rollover, of course.)
     
  38. BortStudios

    BortStudios

    Joined:
    May 1, 2012
    Posts:
    48
    I'm getting some errors using the latest version of Unity and Windows 10 with the xbox one controller's dpad. I've created a custom actionset with commands that are set to dpad up, left, right, and down. When I press dpad left and right on the controller, it triggers the controls for dpad down and dpad up. Dpad left and dpad right do not trigger with the dpad at all, but instead when I press the right trigger. I do not notice any other problems with the controls, but the inputcontroltype for the dpad seems to be broken
     
  39. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    382
    I'll see if I can get a Windows 10 VM up and replicate the problem. Thank for reporting the issue. :)
     
  40. gskinner

    gskinner

    Joined:
    Aug 28, 2014
    Posts:
    43
    The issue with the Windows10 Profile is to change the DPad mappings from Analog5/Analog6, to Analog6/Analog7.
    Like so:
    DPadLeftMapping( Analog6 ),
    DPadRightMapping( Analog6 ),
    DPadUpMapping2( Analog7 ),
    DPadDownMapping2( Analog7 ),
     
  41. gskinner

    gskinner

    Joined:
    Aug 28, 2014
    Posts:
    43
    I'm hitting an issue with Xbox One controller on OSX. The recommended way to enable the XBone controller on OSX, is to use XOne (http://www.tekrevue.com/tip/xbox-one-controller-mac/).

    Using this utility, the controller reports as "MicrosoftX360Controller", which InControl maps to the Xbox360MacProfile, which contains totally broken mappings. RB = Start, LB = DPadRight , A = LeftStickButton, B = RightStickButton etc.

    [UPDATE] Attached is a modified XboxOneMacProfile.cs, which maps correctly to the XBone Controller using the "XOne" utility:
    https://www.dropbox.com/s/kwern0k8cz5s48p/XboxOneMacProfile.cs?dl=0

    I added "MicrosoftX360Controller" to the supported device names, and fixed all the mappings so they're working properly.
     
    Last edited: Aug 10, 2015
  42. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    382
    This information is incorrect (at least for InControl). Different drivers produce different mappings. The driver I have chosen to support for InControl is https://github.com/d235j/360Controller/releases and the mappings in InControl match up with this driver.

    It supports many other controllers, including Xbox 360, the original Xbox controller and a host of clones.
     
  43. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    382
    It seems that the mappings have changed slightly on Windows 10 compared to Windows 7/8/8.1

    I'll have a fix in the next version for this.
     
  44. dragonstar

    dragonstar

    Joined:
    Sep 27, 2010
    Posts:
    222
    hi i got issues on the update for unity 5.1.3 the console give this errors
    Screen Shot 2015-08-24 at 1.55.32 PM.png
     
  45. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    382
    Unfortunately, this is a bug I reported in the Unity patch releases and was assured would not make it into the final release... and yet, there it is.

    You can fix it by adding a 0 parameter to GetMousePointerEventData() in InControlInputModule.cs, line 207-ish

    I'll have a fix in the next update.
     
  46. dragonstar

    dragonstar

    Joined:
    Sep 27, 2010
    Posts:
    222
    ok thanks i will give try or i wait for the update by way 5.1.3 still full a bug any ways
     
  47. dragonstar

    dragonstar

    Joined:
    Sep 27, 2010
    Posts:
    222
    well i wants to show what was able to make using in control

     
  48. RoyalCoder

    RoyalCoder

    Joined:
    Oct 4, 2013
    Posts:
    301
    Hi @pbhogan , I wonder if it's there a quick solution for mirroring the control interface , like right or left handed !
    Thanks in advance !
     
  49. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    382
    There isn't a one-click solution, but you can set up both sets of controls and just enable one set or the other.