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. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,697
    I am wanting to control the x axis of a transforms rotation via the Trigger.

    My issue is that the trigger, which can collect a "Raw Value", when it is pressed, so from 0-1, does not do so at Release... which makes sense, except that "Release", is any negative pressure....

    So, "Release", is not defined by zero pressure on the trigger, but by any negative amount.

    At that point, I lose the "Raw Value" collection.

    I have contacted the author, but he hasn't gotten back to me yet. Any tips?

    Thanks
     
  2. FM-Productions

    FM-Productions

    Joined:
    May 1, 2017
    Posts:
    72
    Hi,
    just a quick question:
    I'm using Unity 2018 b10 and InControl is working fine when I run my game in Editor mode.
    In a standalone build however, it seems that InControl does not recognize my controller. I have also set up PlayerActions with keyboard inputs and those are working fine in the Standalone build. I have an wireless XBox 360 controller.
    Do you have any idea what the issue could be?
     
    kingbreedicus likes this.
  3. illogikaStudios

    illogikaStudios

    Joined:
    Nov 19, 2008
    Posts:
    66
    Hi there !
    We are experiencing an issue with the xbox one controller on PC. It looks like the name of the device is exactly the same when connecting a xbox 360 or xbox one controller (XInput controller), so I'm not able to detect a difference. I would like to have this option because I would like to update correctly all the prompts inside the game.
    I've seen a variable called DeviceStyle, but it remains "XboxOne" no matter what controller I connect.

    Thanks !

    Edit: it looks like if I disable XInput option, I have the correct device name.
    Do you know what this option enable? Allowing the rumble? Less issues on windows?
     
  4. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,697
    Hi there,
    So very urgent matter.

    I set up my game to run with inControl and it works perfectly, within the editor, however, I just built out to Mac OSX and when I Button A Release, the game crashes.

    My system is this.....

    Action: Button A Release. Subscribed Generic Manager see this. Now Subscribed Generic Manager has potentially sub subscribers. The error happens somewhere along here. All subscriptions are checked in that if subscription is null, no event fired.

    Error is not isolated to one sub manager type, so I think it is higher up... I can not test or debug log from the build to Mac OSX, so, I am wondering what it might be.

    If you have any ideas, please let me know. I have a major deadline with in hours and if it can be solved I have to remove inControl
     
  5. fredericoraiss

    fredericoraiss

    Joined:
    Aug 13, 2013
    Posts:
    18
    Hi, how are you?
    I'm having a problem with using gamepad for android. It's just recognizing ps4 gamepad, but I need it to recognize generic controls on android. In the case within unity it recognizes control.
     
  6. RemDust

    RemDust

    Joined:
    Aug 28, 2015
    Posts:
    432
    Hi guys !
    Do you know if there is an "easy way" to disable every input for a specific device ?
    (in order to prevent player number "X" to do any action for a certain time)

    Of course I could set a flag "canControl" but I have many behaviors and I'm not sure I want them to check for this bool every frame :/
     
  7. dearamy

    dearamy

    Joined:
    Mar 17, 2015
    Posts:
    68
    Got an error when import the InControl.package. I'm using Unity2018.1.3f1.

    Assets/InControl/Source/Utility/Utility.cs(377,42): error CS1070: The type `Microsoft.Win32.Registry' has been forwarded to an assembly that is not referenced. Consider adding a reference to assembly `Microsoft.Win32.Registry, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
     
  8. RendCycle

    RendCycle

    Joined:
    Apr 24, 2016
    Posts:
    330
  9. Alloc

    Alloc

    Joined:
    Jun 5, 2013
    Posts:
    241
    Yes, as a normal XInput controller. No special features though (like the gyro), just what e.g. a XB1 pad has.
     
    RendCycle likes this.
  10. IcenEdel

    IcenEdel

    Joined:
    Jun 18, 2017
    Posts:
    4
    Is there a way to make a KeyBinding act like the regular Input.GetAxis() Unity has?

    For example:

    //Press W to go forward
    playerActions.Forward.AddDefaultBinding(Key.W);

    //in some other script
    float xVal = playerActions.Forward.Value;

    //prints 1
    Debug.Log(xVal);

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

    xVal returns a straight 1, but I would like it to act like Input.GetAxis("Vertical"), where the value has smoothing/ramp-up applied
     
  11. Zed001

    Zed001

    Joined:
    Sep 13, 2012
    Posts:
    6
    Is there any way to have a certain control be set in the inspector? Like, either a dropdown list of actions (Action1-4, Bumpers, Start Button, etc.) or a string that just says the name of the action to check for in an IF statement.

    Google didn't help much so I guess I'll ask here, although I feel like I'm just going about it the complete wrong way.

    Thanks.
     
  12. Spookytooth3D

    Spookytooth3D

    Joined:
    Oct 31, 2013
    Posts:
    73
    This may not 100%, as I basically stripped down my controller script. It has all of the basic control names, and essentially you can just fill in the blanks within the IF statements. It works great with PS4 Controller, and the GameVice Controller. I'm sure it would not be too difficult to figure out other controllers. I also believe there's a way to echo the available controller values, but I forget how I did that before. Hope this helps! - Mike

    Code (CSharp):
    1.  
    2. using System;
    3. using System.Collections;
    4. using System.Collections.Generic;
    5. using UnityEngine;
    6. using InControl;
    7.  
    8.  
    9. public class NewMonoBehavior : MonoBehaviour {
    10.  
    11.   // Update is called once per frame
    12.  void Update () {
    13.        var inputDevice = InputManager.ActiveDevice;
    14.  
    15.  
    16.      //Controller buttons
    17.  
    18.       if (inputDevice.Command.WasReleased) {
    19.          // Button “Menu”
    20.        }
    21.  
    22.      if (inputDevice.Action1.WasReleased) {
    23.          //Button "A";
    24.       }
    25.  
    26.      if (inputDevice.Action2.WasReleased)
    27.       {
    28.           //Button ”B”;
    29.       }
    30.  
    31.      if (inputDevice.Action3.WasReleased) {
    32.          //Button “X”
    33.        }
    34.  
    35.      if (inputDevice.Action4.WasReleased) {
    36.          //Button “Y”
    37.        }
    38.  
    39.  
    40.        //bumpers
    41.  
    42.      if (inputDevice.LeftBumper.IsPressed) {
    43.             //"LeftBumper";
    44.         }
    45.  
    46.      if (inputDevice.RightBumper.IsPressed) {
    47.            //"RightBumper";
    48.        }
    49.  
    50.  
    51.         //Triggers
    52.      if (inputDevice.RightTrigger.WasReleased) {
    53.             //Right Trigger    
    54.         }
    55.  
    56.      if (inputDevice.LeftTrigger.WasReleased) {
    57.          //Left Trigger
    58.      }
    59.  
    60.  
    61.         //Joysticks
    62.         if (inputDevice.LeftStick.IsPressed) {
    63.          //"Left Stick Button";
    64.          float myLeftStickValX = inputDevice.LeftStickX.Value;
    65.           float myLeftStickValY = inputDevice.LeftStickY.Value;
    66.       }
    67.  
    68.  
    69.         if (inputDevice.RightStickButton.IsPressed) {
    70.             //“Right Stick Button";
    71.             float myRightStickValX = inputDevice.RightStickX.Value;
    72.             float myRightStickValY = inputDevice.RightStickY.Value;
    73.            
    74.        }
    75.  
    76.      if (inputDevice.RightStickRight.IsPressed) {
    77.            //“Right Stick Right";
    78.      }
    79.  
    80.      if (inputDevice.RightStickLeft.IsPressed) {
    81.             //Right Stick Left";
    82.        }
    83.  
    84.      if (inputDevice.RightStickUp.IsPressed) {
    85.           //“Right Stick Up";
    86.         }
    87.  
    88.      if (inputDevice.RightStickDown.IsPressed) {
    89.             //“Right Stick Down";
    90.       }
    91.  
    92.      //DPad
    93.      if (inputDevice.DPadDown.WasReleased) {
    94.             //"DPad Down”;
    95.      }
    96.       if (inputDevice.DPadUp.WasReleased) {
    97.           //"DPad Up”;
    98.        }
    99.       if (inputDevice.DPadLeft.WasReleased) {
    100.             //"DPad Left";
    101.          
    102.        }
    103.       if (inputDevice.DPadRight.WasReleased) {
    104.            
    105.            //"DPad Right";
    106.         }
    107.  
    108.  }  
    109. }
    110.  
    111. 


     
  13. dl290485

    dl290485

    Joined:
    Feb 4, 2018
    Posts:
    160
    Can anyone help me with Xbox 360 vibration using Playmaker?
     
  14. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    384
    The simplest is to add a field of type InputControlType (which is an enum) and then you can call inputDevice.GetControl( controlType ) to query that particular control.

    There is an inputDevice.GetControl() call that takes a string (the string form of the enum entry) but that would be really slow as it has to use Enum.Parse under the hood. You're better off parsing it yourself and then passing in the enum if you really want to use a string.
     
  15. dl290485

    dl290485

    Joined:
    Feb 4, 2018
    Posts:
    160
    *WOOSH*
    Right over my head.

    I don't understand a single part of this information :)

    Thanks though. I'll paste this reply over in the Playmaker forum and see if someone can tell me what to do specifically for Playmaker to do what you said.
     
  16. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    384
    That reply was to @Zed001, not regarding your question. :)

    You're better off asking about it in the Playmaker forum though. I don't use Playmaker so I'm not really familiar with it and InControl is very much a code asset for programmers. Maybe someone in the Playmaker community has put together a Playmaker action or command or whatever it's called to send the vibration command.
     
  17. dl290485

    dl290485

    Joined:
    Feb 4, 2018
    Posts:
    160
    Oops. I was in a hurry. Embarrassing.

    Yeah I figured this is a coder's asset, but I thought I'd start by asking here if by chance someone uses Playmaker and knows what to do.

    The problem with going straight to Playmaker forum is that people will probably be like; "In Whatsit? Control? What's that? Oh it does controller functions huh? Have you asked them what to do?"

    So is there anything you can tell me that I can take to them? Is there a manual for doing vibration with InControl, so I can at least say I want to do that? (which means people who don't know your asset can potentially still help)

    Oh and I did come across a plugin (what ever they call it) for Playmaker, but it only adds 4 actions in total which are only for get axis and get button down/up (which I am actually using, along with just the added items in the Input list).
     
  18. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,527
    If you know the function for the controller vibrate in c# it pretty easy to make it into a playmaker action, look for a custom action template at the the playmaker website and just paste the c# function inside it.
     
  19. dl290485

    dl290485

    Joined:
    Feb 4, 2018
    Posts:
    160
    Ok yep, that's essentially what I'm asking for help locating now.

    Can someone please direct me to where the function in c# is for vibrate.
     
  20. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    384
    Look for the Vibrate and StopVibration methods on InputDevice: http://www.gallantgames.com/incontrol-api/html/class_in_control_1_1_input_device.html

    It's basically:
    void Vibrate( float leftMotor, float rightMotor )
    void Vibrate( float intensity ) // which just calls Vibrate( intensity, intensity );
    void StopVibration()
     
    dl290485 likes this.
  21. dadamsj1

    dadamsj1

    Joined:
    Jul 25, 2017
    Posts:
    42
    @pbhogan Just started using your plugin! So far I'm very impressed.

    I am having trouble using the InputModuleAdapter that you have posted on your website here. For some reason, when the adapter is enabled, I don't get any response from the UI even when a button is highlighted (except from mouse). I cannot figure out what is going wrong since it seems to be basically plug-and-play.

    Everything works fine when the adapter is disabled though.

    Am I missing something?
     
  22. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    384
    Hard to say without taking a look at your exact setup. The one gotcha that can happen with action sets is that when one is instantiated (new InputModuleActions() in this example), it binds to the input manager at that exact moment. If InControl goes through a reset or initialization after that, the action set will end up being detached from the input manager. So you either need to make sure InControl initialization comes first in the script initialization order or use the InputManager.OnSetup event hook to ensure things happen after InControl initializes. If you absolutely need to instantiate an action set early, it can be manually attached or detached with InputManager.AttachPlayerActionSet() and InputManager.DetachPlayerActionSet()

    You're welcome to e-mail me a minimal project reproducing the problem if you're stuck and I'll take a look: http://www.gallantgames.com/contact
     
  23. dadamsj1

    dadamsj1

    Joined:
    Jul 25, 2017
    Posts:
    42
    Thank you! The problem was that the adapter was initializing before InControlManager was in the scene.
     
  24. RendCycle

    RendCycle

    Joined:
    Apr 24, 2016
    Posts:
    330
    I'm doing some research on which Input Manager to use and I came across an article that mentions InControl is only suitable for games that uses a single gamepad. Is that true and if not, does the use of multiple gamepads already been solved/fixed (i.e. Disconnecting any gamepad disconnects ALL gamepads.)? Here is another article (quite old) I found which explains a possible solution for using less than 8 controllers for local multiplayer.
     
    Last edited: Sep 4, 2018
  25. protopop

    protopop

    Joined:
    May 19, 2009
    Posts:
    1,561
    InControl has been great - its even been straightforward to add in new gamepad profiles successfully when players asked for it, and its worked on IOS, Android, and AppleTV too! so thank you.

    My users with Pixel XL 2 and Android Pie the game says it's detecting a gamepad even when none is connected (false gamepad detection). This disables the touch controls in my setup.

    I googled it and its a problem with several games. ex: https://forum.xda-developers.com/pixel-2-xl/help/android-pie-false-gamepad-detection-t3829524 , https://www.reddit.com/r/GooglePixel/comments/98nbls/p2xl_detecting_a_gamepad/

    Do you think this is something that can be fixed from inside InControl, or maybe its the android/hardware combo? Has anyone heard of this before?

    I am thinking to add a button to manually disable incontrol - is it as simple as just disabling the incontrol gameobject in the scene? or is there a better was that i can call from a script.
     
  26. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    384
    The tldr; is that InControl does (and has for a couple years) had a native input module that gets around this problem using direct access to native OS input and doesn't disconnect all controllers when one disconnects since it can properly hook into OS level events. Native input is only supported on Windows and Mac and can be enabled in the settings.

    But if the native input module is not enabled (and I really do recommend everyone use the native module whenever possible) then InControl has to default to using Unity Input under the hood. The problem with Unity Input is (and I've complained to Unity at length about this) the only identifiers it gives you is the names in the Input.GetJoystickNames list. If you connect four identical controllers—a fairly common scenario—then you'll get four identical names in the list and the order of the list is undefined (regardless of the player lights on the controller, for example). So when a controller disconnects, one of those identical names in the list disappears. Unity gives no indication of which one of the four it was. That makes it impossible to tell which specific device in the list disconnected and the only reasonable response InControl has is to trigger a disconnect for them all, and then reattach new devices for those still in the list. A multiplayer game should still be able to handle this by showing a controller selection UI on any disconnect (similar to what Nintendo Switch games do, for example) allowing players to "activate" controllers by pressing some controls and reassigning players. I think that's a pretty good UX design strategy even if specific device disconnects can be detected anyway.

    In any event, the native input plugin gets far more information about each device from the OS including attach/detach events and, when available, a unique hardware serial number which is used to reassign a reconnected controller to the same device object it had before it was disconnected.
     
    RendCycle likes this.
  27. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    384
    I don't think there's anything InControl can really do about this. False gamepad detection is always a potential. I've even seen a case where a webcam reported itself as a controller. Go figure. So either you need to have a setting, as you mentioned, and you can call InputManager.Enabled = false; to disable InControl, or disabling the gameobject should work too. But I think perhaps a better approach is to only hide touch controls when input is detected from a controller (so phantom controllers would have no effect) and then have touch controls show again if the screen is touched.

    If you're using InControl's touch controls, I think there's a setting for enable on touch on the Touch Manager.
     
    protopop likes this.
  28. protopop

    protopop

    Joined:
    May 19, 2009
    Posts:
    1,561
    Another very thoughtful and useful response - thanks so much for the help:)
     
  29. joaobsneto

    joaobsneto

    Joined:
    Dec 10, 2009
    Posts:
    152
    I'm having an issue playing the game with 2 Xbox One controllers pluged with the same wireless adapter. They are recognized like different devices, but the triggers are some kind shared. If player 1 press Left Trigger, only player 1 will receive the event, but meanwhile Player 2 press the Left Trigger also, both players will receive the same event. It leads to very strange behaviors. I solved the problem changing the Triggers for the Bumpers, but if my player want to map the input to trigger, it would break the game.
     
  30. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    384
    This is due to a bug in Unity input which InControl uses by default. Please enable native input (and XInput) support to circumvent this issue.
     
    joaobsneto likes this.
  31. RendCycle

    RendCycle

    Joined:
    Apr 24, 2016
    Posts:
    330
    Thanks for the explanation! If I am only targeting Windows and Mac OS, how do you enable InControl to use the Native Input Module? Is it enabled by default?

    Has this issue already been posted to Unity as a feature request / bug to fix so people can vote on it? I found one here but not sure if this is what is needed... or if this will actually make a difference. But at least something has been publicly posted where people can find it and maybe take an action even if its a small step at the beginning. :p
     
    Last edited: Sep 8, 2018
  32. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    384
    If you click on the InControl Manager gameobject you'll see an option to check in the inspector to enable native input.

    It's been put to Unity by many people many times in many places, voted on, argued about, etc. ad nauseum. We've even gotten some Unity engineers try to fix it but give up due to complexity or fear of breaking what's there already. Basically, their approach for the last couple years is it'll be fixed by their new input system when it eventually comes out so they don't want to get into it. Unfortunately, they're also probably less motivated to fix it in the current system since solutions like InControl and Rewired exist that can circumvent it.
     
  33. RendCycle

    RendCycle

    Joined:
    Apr 24, 2016
    Posts:
    330
    Haha I understand. :D Good thing there is InControl and Rewired! I hope Unity acquires one or both of your products, combine the best parts, and make it an integral part of the system. I will try InControl soon. Many thanks for the information sir! :)
     
  34. sdtr443w

    sdtr443w

    Joined:
    Nov 29, 2014
    Posts:
    23
    I'm wondering if there's some way to unite keyboard and mouse control with InControl when I'm using its event system with Unity's GUI components.I can describe my problem using a list of buttons. Let's say I have five buttons in a vertical group. I can highlight any of them with a mouse in any order by hovering over them with the cursor. I can also highlight them with the keyboard but I have to use the up and down action keys.

    If I highlight one with the mouse, I can still use the arrow keys to highlight others simultaneously. So I have two buttons highlighted.

    I came up with a hack so that the current button stops being highlighted if either the mouse enters the domain of another button, or the user presses a key (OnPointerEnter; OnSelect). However, a keyboard-based action will pick up at the next button from where it was previously instead of where the mouse was if that was the most recently selected button.

    It's like the mouse and the keyboard have their own even systems or something. Is there some grand setting to basically bind these as one UI controlling device?
     
  35. PazziCZ

    PazziCZ

    Joined:
    Mar 17, 2014
    Posts:
    1
    Hi, is there some way to make input that combines Keyboard and Mouse? I know there is KeyCombo struct but this is only for Keyboard keys.

    I want to make 3 inputs:
    1. Mouse Scroll wheel -> block rotation
    ...AddDefaultBinding(Mouse.PositiveScrollWheel);

    2. Keyboard Shift -> run
    ...AddDefaultBinding(Key.LeftShift);

    3. Combination Shift + Scroll wheel -> zoom in/out
    ??? ...AddDefaultBinding(new KeyCombo(Key.LeftShift, Mouse.PositiveScrollWheel));


    I know how to make 1st and 2nd inputs but don`t know how to make 3rd input possible. Any help please?
     
  36. rrh

    rrh

    Joined:
    Jul 12, 2012
    Posts:
    331
    I notice when starting a game the joystick isn't immediately active. It takes about 10 seconds before it starts responding to the joystick input.

    I understand it might be beyond what InControl can change to make it faster than 10 seconds, (maybe it's the operating system adding the delay) but is there some kind of event I can listen for so I can show a "Joystick Detected" message?

    EDIT: Okay, so after some testing, the delay shows up if I enable the "Enable XInput Support" checkbox contained within the "Enable Native Input" section. It delay does not show up if I enable the above "Enable XInput Support" checkbox that's above "Enable Native Input."

    What's the difference between enabling it inside of Enable Native Input or above Enable Native Input?
     
    Last edited: Oct 8, 2018
  37. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,533
    Will this plugin be supporting the new unity input system that is out in package preview now?
     
  38. rrh

    rrh

    Joined:
    Jul 12, 2012
    Posts:
    331
    So I'm trying to work out some default binding for controllers.

    So I've been using for example .AddDefaultBinding(InputControlType.Action1) but then when I display the bindings it shows up as Action1. Rather than A for an XBox controller and Cross for a Playstation controller, etc.

    When the player sets the bindings themselves, it shows up as A or Cross or whatever according to what controller they're using. But for convenience I want defaults for common controllers, rather than make the player go through each button one at a time. But if it displays "Action1" instead of what's really on the button that could be confusing for them.

    It looks like when they manually set them it goes through AddBinding which is passed a BindingSource, instead of AddDefaultBinding which only accepts an InputControlType. But I can't just create a new BindingSource because it's an abstract class. I can create a DeviceBindingSource but don't know how to assign it a particular device.

    It looks like the buttons are named in ButtonMappings on various extensions of UnityInputDeviceProfile. I can get a list of current devices from InputManager.Devices but the InputDevice class doesn't appear to have a profile attached to it so I don't know how I would access the ButtonMappings for the given device.

    EDIT: Okay, a small step forward, if I loop through the InputManager.Devices, device.Action1.Handle will show the name that corresponds with the action1 button. So I can theoretically access the info I want through there, now I just need to work out how to do it in a reasonably organized manner.

    But let me know if there's a simpler way to handle this.
     
    Last edited: Nov 25, 2018
  39. prakash7titus

    prakash7titus

    Joined:
    May 29, 2015
    Posts:
    9
    How do i move the cursor with right stick of ps4 controller ?
     
  40. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    384
    The one separate from native input uses XInput together with the default Unity input module. This existed before native input, so it's really just there for legacy support.

    The one inside native input allows the native input module itself (the native plugin) to use XInput internally. While I think it's almost always the right choice to enable it, there are certain drawbacks, specifically: XInput supports a maximum for 4 controllers, and the XInput API does not allow for identifying the specific controller hardware, so, for example, it's impossible to tell the difference between an Xbox 360 controller and an Xbox One controller, or any other XInput compatible controller -- it's just an "XInput Controller". On the plus side it tends to have broader compatibility and supports haptic feedback.
     
  41. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    384
    Yes, the plan is to do so, although probably not until the first release or the preview becomes substantially more complete. Last I checked it was still pretty rudimentary.

    My understanding is the first phase with basic functionality of the new input system is planned to release in Unity 2019.1 or 2019.2 with further features (and probably console support) being added over time.

    I'll probably also be adding keyboard and mouse support to the native plugin at some point so that, at least on desktop systems, Unity input could be completely ignored if necessary.
     
    joaobsneto likes this.
  42. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    384
    You would need some kind of plugin that allows for moving the system mouse cursor (InControl does not) or you need to implement a virtual mouse cursor yourself, assigning mouse input to it if detected and otherwise moving it with the right stick—probably with some acceleration and maybe snapping built in.
     
  43. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    384
    The reason it shows up as Action1 is because it doesn't yet know what device is being used. The moment there's an active device, it'll switch names appropriately. The binding is the same (for example, InputControlType.Action1) but its label is dependent on the device, so you don't need to add multiple bindings. Keep in mind, there may be no controller attached, or there could be other non-responsive devices in the device list. Or the user could switch controllers mid-game. That's why it adapts to which controller is actually being used.

    Ideally, you'd have the user using the controller sometime before they get to your bindings menu. But if not, the worst that could happen is they see different labels. If the generic labels really bother you, do some string comparisons and make it show A, B, X, Y instead of Action1, Action2, or what have you.
     
  44. rrh

    rrh

    Joined:
    Jul 12, 2012
    Posts:
    331
    Okay, so if I use the keyboard to go to the controller menu, it shows Action1 etc. But if I push the joystick before I go to the controller menu, the conversion shows up, like you said. So, not as bad as I thought before, but still I can't guarantee someone will use their controller if it hasn't been bound yet.

    Even if I use the keyboard only, the controller still shows up in InputManager.Devices. If the length of InputManager.Devices is 1, then it's a safe bet that's the device they'll be using.

    Also, if I'm loading the controls that were saved last time, maybe I should save what profile was used then and guess that's what we're using this time.

    Is there something I can do to make a device active? Like
    if (InputManager.ActiveDevice == null && InputManager.Devices.Count == 1)
    InputManager.Devices[0].RequestActivation();

    That seems like it's what I'd want, but it doesn't seem to do what I want.
     
  45. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    384
    Almost. This should work:

    if (InputManager.ActiveDevice == InputDevice.Null && InputManager.Devices.Count == 1)
    {
    InputManager.Devices[0].RequestActivation();
    }

    InputManager.ActiveDevice is actually never null, rather it is assigned a special instance of InputDevice that always produces no input, so InputManager.ActiveDevice can always be used safely without a null check.
     
  46. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,533
    Also getting this error...

    Assets/InControl/Source/Utility/Utility.cs(455,30): error CS1070: The type `Microsoft.Win32.Registry' has been forwarded to an assembly that is not referenced. Consider adding a reference to assembly `Microsoft.Win32.Registry, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

    Assets/InControl/Source/Utility/Utility.cs(455,39): error CS0023: The `.' operator cannot be applied to operand of type `Microsoft.Win32.Registry'


    Can you fix it, using api compatibility .net standard 2.0
     
  47. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    384
    I can't. It seems to be pretty specific to the Unity 2018.3 beta, maybe a bug where they don’t include the correct Microsoft assembly reference. In any event, the fix is to switch Api Compatibility Level to .NET 4.x which is what it is supposed to be.

    For others who might not know how to do this, it's done by going to build settings > player settings and under Other Settings > Configuration switching the Api Compatibility Level to .NET 4.x (and Scripting Runtime Version to .NET 4.x Equivalent, which should be the default).
     
    Willbkool_FPCS likes this.
  48. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,533
    What if I really need to use api 2.0 due to another asset? Can something be done as it is just that one method in your plugin that is causing the problems.

    Also this is using 2018.2.f17 so its not 208.3 related
     
  49. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    384
    Then you need to switch to the .NET 3.5 scripting runtime version.

    And get on the other asset to upgrade their compatibility because it won't be long before 2.0 compatibility goes away, or at least fades into obscurity and lack of support from Unity. 4.x is a superset so it's weird the other asset isn't compatible, or at least should be very easily made compatible.

    The bottom line is I can't make the 4.x runtime and 2.0 api work together. It's some kind of missing assembly reference or forwarding incompatibility that Unity isn't dealing with when it generates the solution/project files and InControl needs to use that method.
     
  50. hododoho

    hododoho

    Joined:
    Oct 9, 2017
    Posts:
    12
    Been loving InControl so far!

    Quick question though. Is there an easily supported way to map button combinations, either through a Binding or some other method? For example, I currently have a PlayerAction Fire bound to a single button. Currently I have a way to toggle controls so that pressing B+A triggers Fire instead, but essentially I have to throw out the existing binding and instead use an if statement to check that both buttons are pressed at once.

    Ideally I was imagining something as simple as Fire.AddBinding(Action1, Action2), where you might be able to supply multiple inputs at once to represent an action. Might you have any suggestions for mapping these sorts of multi-button actions, even if it doesn't necessarily use the binding system?
     
    RemDust likes this.