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

    yakm

    Joined:
    Sep 12, 2014
    Posts:
    24
    Okay i have the gamepad.dll, where in my project do i place it?, i tried plugins folder and i still get the error The type or namespace name `Gamepad' could not be found. Are you missing a using directive or an assembly reference?
     
  2. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    231
    Put it in Assets/Plugins/XboxOne. Use the plugin inspector (when you click on the gamepad.dll) to make sure it is set to only be activated on Xbox One.
     
  3. muldore

    muldore

    Joined:
    Aug 9, 2015
    Posts:
    2
    We're having some strange problems with triggers in our game that I can't find any mention of in here. We have a multiplayer 2D game in which triggers use abilities for each player. The issue we're having is that, seemingly randomly, pressing a trigger will cause another character to use its ability. Sometimes only the other character reacts, sometimes both characters react, and sometimes the correct character reacts, without any real pattern we've been able to find. Each device is stored per player when a controller presses X in the lobby:

    Code (CSharp):
    1. if (InputManager.ActiveDevice.Action1.WasPressed && !usedControllers.Contains(InputManager.ActiveDevice))
    2.     character.SetDevice(InputManager.ActiveDevice);
    And the action is received in game from the player pressing the trigger:

    Code (CSharp):
    1. if(playerDevice.RightTrigger.WasPressed)
    2.     UseAbility();
    We've used a debugger and have found that when the problem happens, the incorrect controller is sending the action. (ie when player1 hits trigger and player2 uses ability, player2's device hash code is calling it. Likewise when both players use abilities with only one trigger press, the script is called on both players with both controller's hash codes being used)

    We've been doing a lot of testing on this and are coming up blank. This only happens with the triggers, all other buttons function properly. We've also noticed this only happens between two of the same controller (ie two 360 controllers or two XBOne controllers) and have not been able to reproduce it through one 360 and one XBOne. Any ideas on this?
     
  4. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    231
    You've run into a long standing, well known bug in Unity input that they have refused to fix for many years now. Triggers are super unreliable for XInput compatible controllers with Unity. There is any number of bugs related to this from input showing up on the wrong controller, to triggers not working at all or getting stuck, etc.

    The only workaround is to enable XInput support or use native input (in which case you should also enable XInput if you can).

    The drawback with enabling XInput is you have a limit of four XInput controllers, so if you're doing a multiplayer game with more than four players, then you can try only enabling native input with no XInput support, in which case you'll run into the issue of both triggers being on the same axis and cancelling each other out (which is a limitation Microsoft imposes without XInput), but at least input will be more reliable.
     
    kurotatsu likes this.
  5. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    394
    Hi, I'm new with this asset. I'm using this asset with playmaker, how can I make right stick of my controller to act like a mouse?
     
  6. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    231
    I'm afraid I'm not too familiar with using PlayMaker so I can't say exactly. There isn't a single action for doing this, but the basic idea would be to have a Vector2 variable that holds the cursor position and then add the right stick vector multiplied by some scaling to that cursor position every frame. What you then do with that position is up to you... you can't actually move the mouse cursor in Unity, so you'll need to have some kind of sprite at that position or whatever.

    You're probably better off asking the folks in the PlayMaker forums for more specific help with this. InControl's actions are modeled fairly closely to the default Unity input actions, so solutions would be similar.
     
    Crossway likes this.
  7. Frima

    Frima

    Joined:
    Jan 26, 2016
    Posts:
    51
    I just did some profiling on our game and I'm seeing a lot of GC alloc per frame on xbox one. I tested on PC and there's a huge difference. Look at the attached screenshots.

    The PC version doesn't allocate a single byte per frame, perfect!
    The Xbox One version allocate 3.1 kB per frame @ 60 fps.

    This is quite a lot of data and this isn't good. I'll try to investigate a little bit to see if there's anything special.
     

    Attached Files:

  8. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    231
    How strange. That's the first I've heard of that. Unfortunately, I don't have devkit access so I can't profile it myself. Can you do a deeper profile to see where the GC is being created, exactly?

    If you find more information, please e-mail me: http://www.gallantgames.com/contact or, even better, open a ticket here: https://github.com/pbhogan/InControlSupport/issues
     
  9. Frima

    Frima

    Joined:
    Jan 26, 2016
    Posts:
    51
    I can't remote deep profile on xbox one :/ If you know how to do it, please tell me! :)

    https://forum.unity3d.com/threads/is-deep-profiling-available-on-the-xbox-one.435614/
     
    Last edited: Nov 17, 2016
  10. Frima

    Frima

    Joined:
    Jan 26, 2016
    Posts:
    51
    Ok good news, I've found the problem AND fixed it :)

    There's a huge GC allocation party in XboxOneInputDevice.cs in the function float GetAnalogValue( uint analogId ). Each frame, the 8 xbox devices are each getting the values for analog input (AnalogLeftStickX, AnalogLeftStickY, etc..). In that function, a big string is built : "joystick " + JoystickId + " analog " + analogId.

    To fix that, I just create a kind of cache in the constructor. The GC allocation is now 0 byte per frame :) I attached my version to this message.
     

    Attached Files:

  11. sergioem

    sergioem

    Joined:
    Oct 3, 2016
    Posts:
    8
    Hi,

    I am trying to create a build for XboxOne, and I am having the following error:
    Assets/InControl/Source/XboxOne/XboxOneInputDevice.cs(7,7): error CS0246: The type or namespace name `Gamepad' could not be found. Are you missing a using directive or an assembly reference?

    I already have copied the Gamepad.dll into Assets > Plugins > XboxOne however I still get this error. I tried to close/open Unity after copying, tried to switch platform and go back to xbox one, re-imported all. Nothing works!

    You can see in the screenshot attached.

    Can you please advise?

    Thanks.
     

    Attached Files:

  12. Frima

    Frima

    Joined:
    Jan 26, 2016
    Posts:
    51
    From the xbox one native plugin zip file, did you copy all managed dlls located in \Binaries\Managed\Variations\AnyCPU_Release into you project in Assets\Managed\.

    And every dlls from \Binaries\Native\Variations\Durango_Release to Assets\Plugins\XboxOne
     
    sergioem likes this.
  13. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    231
    Sweet, good catch! I'll get it in the next update.
     
  14. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,001
    Hi pbhogan.

    There is a script in Final Ik that I need to make it to work with gamepad (CameraController) but I can't add " using InControl" in this script. why is that?


     

    Attached Files:

    • ee2e.jpg
      ee2e.jpg
      File size:
      18.7 KB
      Views:
      522
  15. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    231
    Are you sure you have InControl in your project? I don't see any reason why that wouldn't work.
     
  16. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,001
    It works on other scripts, I just can't figure out why it just doesn't work with that one :confused:
    I asked Final Ik developer about this too.

    Edit:

    Solved, as Final IK developer mentioned It was because those scripts are under Plugins folder.
     
    Last edited: Nov 28, 2016
  17. kvekos

    kvekos

    Joined:
    May 17, 2016
    Posts:
    60
    Looking at OneAxisInputControl.cs I see a property called WasRepeated.

    There isn't any documentation for this function but the source code suggests that this property is used to do something equivalent to what happens when you press and hold a key on your keyboard: 1. One input is entered. 2. If held for FirstRepeatDelay seconds then another input is entered. 3. For every RepeatDelay seconds while the button is continued to be held another input is entered.

    What I actually wanted was the ability to detect when the player does a double tap of the same direction on a OneAxisInputControl. In my case, I want to know if a player double-tapped the Right or Left Trigger on the controller. Is there a way to get this functionality?
     
  18. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    231
    No, there's no double tap or other "combo" functionality. That's up to you. It's really specific to the game and how exactly it is calculated with timing, sensitivity and how far a stick or trigger needs to move is, again, tweaked specific to a game usually.
     
  19. TCROC

    TCROC

    Joined:
    Aug 15, 2015
    Posts:
    125
    @pbhogan Hey! I just bought your asset and so far it is a huge time saver! I have come across one issue though. Everything works find if I connect the controllers to a windows 10 pc via usb. However, if I connect a ps4 controller to the Windows 10 pc via bluetooth, I get some very strange behavior. The anolog sticks are constantly returning values even though nothing is being used and the triggers act as the left and right analog sticks.

    Edit: Nevermind. Just saw this is already a known issue. Is there a solution planned for the future? If not, are there any workarounds such as a tool that makes the pc recognize the PS4 controller as an Xbox One controller or something?

    I also noticed that a known issue is that the Xbox One controller doesn't work via bluetooth. It worked just fine for me with bluetooth.
     
    Last edited: Jan 2, 2017
  20. MetaMythril

    MetaMythril

    Joined:
    May 5, 2010
    Posts:
    150
    @pbhogan I've been using this for a few months now and it has been fairly straight forward to get running to replace our old input management, but I have one major gripe. The API documentation is bare minimum at best.

    I'm trying to apply a deadzone to the left movement stick so the player doesn't immediately start ducking as soon as a negative Y value input is received but nothing I do seems to have any effect.

    I've tried the following things but because the documentation gives no comments I have no idea which one of these properties should be set or what values the system expects:
    Code (CSharp):
    1.  
    2.         InputManager.ActiveDevice.LeftStick.Down.LowerDeadZone = -0.3f;
    3.         InputManager.ActiveDevice.LeftStick.Down.UpperDeadZone = -1f;
    4.  
    and
    Code (CSharp):
    1.  
    2.         InputManager.ActiveDevice.LeftStickDown.LowerDeadZone = -0.3f;
    3.         InputManager.ActiveDevice.LeftStickDown.UpperDeadZone = -1f;
    4.  
    Bear in mind I've also tried positive values and still no response, so I've ruled that out as well. Also attempting to set deadzones at the PlayerAction just throws back an "obsolete" message so I assume that's a no-go. My "Down" input checks keep firing. I could just check against the stick input values and handle accordingly but it feels like I'm going against the intended design at that point.

    It's vexing to try and use something that should work, but doesn't and the documentation not give you any clue as to where you should even remotely look.
     
  21. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    231
    Unfortunately, you can't set a deadzone on a single direction on an analog stick because it uses a circular deadzone that affects all directions equally. You need to set it on the entire control:
    inputDevice.LeftStick.LowerDeadZone = 0.3f;

    What may be more applicable, however, is on the player action you can set something called a state threshold. This is the minimum value required for the control to be considered "pressed". It doesn't affect the value, however.

    So, for example, you can set:
    playerActions.Down.StateThreshold = 0.3f;
    or, if you're using a PlayerTwoAxisAction:
    playerActions.Move.Down.StateThreshold = 0.3f
    (although, not these are not equivalent... you need to set it on the one you intend on checking)
    Then, depending on which you set, you can check:
    playerActions.Down.IsPressed or playerActions.Move.Down.IsPressed

    In this case, playerActions.Down.Value might have a value of 0.2f but .IsPressed would be false until it crosses 0.3f.

    Failing all of this, if you don't want a deadzone to affect left and right but you also care about the float value of down (not just that it is pressed) then you need to apply your own deadzone to the value separately. There's a utility function in InControl you can use if you like:
    downValue = Utility.ApplyDeadZone( downValue, 0.3f, 1.0f );

    Hopefully that all makes sense. :)
     
  22. MetaMythril

    MetaMythril

    Joined:
    May 5, 2010
    Posts:
    150
    Thanks! This worked great!
    I went with playerActions.Down.StateThreshold

    Now my stick input closely reflects the D-pad functionality so players can pick the option their most comfortable with.

    Thanks again!
     
  23. snugsound

    snugsound

    Joined:
    Mar 9, 2014
    Posts:
    12
    Hey Patrick, quick question for you: what is the "correct" way to poll the Menu and View buttons on an Xbox One Controller? I would have thought it would be something like:
    Code (CSharp):
    1. InputManager.ActiveDevice.GetControl(InputControlType.Menu).WasPressed
    But no dice on this.

    EDIT: the above works, but only if XInput is disabled. Is this a bug?

    Thanks!
     
    kurotatsu likes this.
  24. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    231
    It's not a bug. Unfortunately, XInput has no idea what controller it is dealing with (it could be anything XInput compatible) and literally Windows doesn't tell the XInput API anything about it, not so much as a name. As such, I go with the official API mappings which are Start and Back (https://msdn.microsoft.com/en-us/library/windows/desktop/hh405052(v=vs.85).aspx) which, of course, lines up with the Xbox 360 controller.

    So, essentially, when dealing with XInput devices, check InputControlType.Start and InputControlType.Back
     
  25. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    231
    Sorry for the slow reply on this. By the time I got round to testing I found my PCs onboard bluetooth stack had somehow imploded and I couldn't get it to work again for the life of me... so I had to order a USB dongle to test everything with. :p

    Anyway, here's the skinny on PS4 controllers:

    When connected over USB and Bluetooth, Unity can't tell them apart and the mappings differ, so I had to pick one to go with. I chose USB as it's more reliable. Bluetooth tends to have some latency and skipping in it and occasionally disconnects.

    It does, however, work just fine with the DualShock 4 wireless adapter (https://www.amazon.com/DualShock-4-USB-Wireless-Adaptor/dp/B01KWLKKQU). In fact, it's much more reliable than regular bluetooth. The only limitation is only one controller can be connected at a time with it.

    The other thing to know is that with the native module enabled, the PS4 controller works in all configurations as InControl can tell whether it's connected over USB or bluetooth.

    The regular Xbox One controller and Elite controller do not work wirelessly unless you're using the Xbox One wireless adapter (https://www.amazon.com/Microsoft-Xbox-Wireless-Adapter-Windows/dp/B00ZB7W4QU) which is only Windows 10 compatible. The newer white Xbox One S controller has bluetooth capability and thus is able to work wirelessly. I think the new color ones coming are probably also this newer model.

    The known issues page is out of date on these issues. The Xbox One wireless adapter and the PS4 wireless adapter were released some time after I wrote that. I'm going to go update it right now actually...
     
    kurotatsu likes this.
  26. Alloc

    Alloc

    Joined:
    Jun 5, 2013
    Posts:
    231
    Minor correction here: Using the XB1 controller wirelessly on W7 myself ;)
    I actually can't remember what exactly I did to get it working ... But I think it was just Windows Update getting the drivers for me.
     
    kurotatsu likes this.
  27. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    231
    Oh, good to know! Boy, it's hard to keep it all straight with all the weird driver changes MS has been pushing out. :confused: Glad they're making stuff work more generally though.
     
    kurotatsu likes this.
  28. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,494
    How do I add a default binding of Shift + Right Mouse Button? It would be nice if this is possible:

    Code (CSharp):
    1. attackSource.AddDefaultBinding(Key.Shift, Mouse.RightButton);
    UPDATE: Also an even weirder request: is it possible to bind to a simultaneous Left + Right Mouse Button press?

    The reason I'm asking is my game has 3 attack buttons. In the gamepad this is easy, but for keyboard + mouse controls, I want to add defaults that can work even for users that only have a two-button mouse. I need something that acts as a 3rd button for a 2-button mouse. That's why I want to bind to either Shift + Right Mouse Button or simultaneous Left + Right Mouse Button, or both if possible.
     
    Last edited: Jan 21, 2017
  29. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    231
    Neither of these is currently possible, but I have an experimental ComboBindingSource you can try that should solve at least your first, if not both requests. Please contact me by e-mail (http://www.gallantgames.com/contact) if you would like the code for it.

    I'll also add that supporting a two button mouse is probably not something you need concern yourself with. I haven't seen one of those in over 10 years. I doubt you're going to run into someone (especially a gamer) with one.
     
    kurotatsu likes this.
  30. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,494
    Cool, thank you! I'll send you an email.
     
  31. WarpZone

    WarpZone

    Joined:
    Oct 29, 2007
    Posts:
    320
    I looked through the docs and couldn't find a definitive list of all the keyboard keys. Letters and numbers are obvious, but what about weirder cases like the numpad?
     
  32. WarpZone

    WarpZone

    Joined:
    Oct 29, 2007
    Posts:
    320
    Also I have a problem. I want players to be able to use a thumbstick, a D-pad, WASD, or the arrow keys to move the player around. So naturally I do something like this:

    Code (CSharp):
    1. Move = CreateTwoAxisPlayerAction( Left, Right, Down, Up );
    2.  
    3. .....
    4.  
    5. playerActions.Left.AddDefaultBinding( Key.LeftArrow );
    6. playerActions.Left.AddDefaultBinding( Key.A );    
    7.  
    8. playerActions.Left.AddDefaultBinding( InputControlType.LeftStickLeft );
    9. playerActions.Left.AddDefaultBinding( InputControlType.DPadLeft );
    10.  
    11. .....
    12.  
    13.       cachedPlayerGameObject.transform.Translate(
    14.          (playerActions.Right * 4 * Time.deltaTime)-(playerActions.Left * 4 * Time.deltaTime),
    15.          (playerActions.Up * 4 * Time.deltaTime)-(playerActions.Down * 4 * Time.deltaTime) ,
    16.          0,
    17.          Space.World );
    18.  
    But when I do it this way, for some reason the diagonal movements are processed differently! On D-pad and analogue stick (tested using the same xbox controller,) the diagonals are processed like a race car driving diagonally. But on keyboard, they just add the two motions together, resulting in an unrealistic manhattan-like movement. I don't even know how to describe it. But you know how in a 2D shoot 'em up, you can move left, and suddenly start going up left, and your left speed doesn't reduce at all? It's like that. Like you're hovering or gliding.

    I'm fine with using one movement paradigm or the other, but they have to all work the same way. As-is, players on keyboard would have an unfair advantage, and even in single-player it just looks unprofessional.

    Why have TwoAxisPlayerActions at all if you can't USE them the same way with all inputs?
     
  33. Pawl

    Pawl

    Joined:
    Jun 23, 2013
    Posts:
    110
    Hey Patrick, we're huge fans of InControl! Just updated from 1.6.3 to the latest 1.6.10 and just wanted to let you know that we get a few minor compiler warnings, using Visual Studio 2015:

    Not a big deal, just figured you should know =)

     
  34. frolicOne

    frolicOne

    Joined:
    Apr 21, 2015
    Posts:
    4
    Hey All,

    I am new to InControl, and have this situation with UI navigation on some menu screens.
    The requirement is to support keyboard and gamepad nav. I originally made everything to use Unity UI event system, which has nice out of the box UI navigation using 4 actions: H-Axis, V-Axis, submit and cancel.

    However, when I started using InControl and placed the InControlInputModule script in the event system, I lost all keyboard functionality. So before I start writing my own script - did anyone ever used InControl for UI navigation?
    What is the common practice for that?
    Do you have scripts or snippets you can share?
     
    kurotatsu likes this.
  35. wightwhale

    wightwhale

    Joined:
    Jul 28, 2011
    Posts:
    390
    I'm having a problem when a player rapidly presses a button the WasReleased flag isn't updated in time. So it behaves normally when a player presses fast, but if a player presses super fast the was released code doesn't fire. I'm not fully sure why this happens but very fast button presses certainly changes how the code behaves. Alternatively I don't quite understand the WasRepeated works, it doesn't seem to need to have the user release the button at all it gets hit when a user holds the button.
     
  36. santacrs

    santacrs

    Joined:
    Jan 11, 2017
    Posts:
    4
    https://docs.unity3d.com/Manual/OculusControllers.html
    According to this page Oculus Touch controllers are active Input.GetJoystickNames() should give a string with the names. However, I'm getting a blank string even though the controls are functional and present when I run my Unity code. Is this a bug?
     
  37. malyKuba

    malyKuba

    Joined:
    Jan 30, 2013
    Posts:
    5
    Hi there. First of all, I love your asset, but I encountered with a problem when I quit my built app. (It is not happening in Editor!) See below.
    I did some debugging and it seems that property IsSetup is set to false in function OnApplicationQuit but (and that's strange) update is still running and it caused this error. Any idea how to bypass this trouble? Thanks for your respond in advance,

    Jakub.

     
  38. friuns3

    friuns3

    Joined:
    Oct 30, 2009
    Posts:
    279
  39. shtirlitz406

    shtirlitz406

    Joined:
    Feb 28, 2017
    Posts:
    2
    Hi. A am have a problem.
    in PlayerActionSet 2 action: fire (bindings to: LeftMouseButton) and ability(bindings to: InputControlType.Action1).
    when i am click to LeftMouseButton works playerActions.fire.WasReleased and playerActions.ability.WasReleased.
    :(
    How i can fix that?(Do to work one action playerActions.fire.WasReleased)
     
  40. shtirlitz406

    shtirlitz406

    Joined:
    Feb 28, 2017
    Posts:
    2
    i am fix this. This bug becose i using CustomInputDeviceProfile
     
  41. v2-Ton-Studios

    v2-Ton-Studios

    Joined:
    Jul 18, 2012
    Posts:
    183
    I've been using InControl for a while and love it -- recommending it to any devs I talk to about input.

    After upgrading to Unity 5.6 I'm experiencing intermittent occurrences of missed input.

    For a consistent repro:

    Using Xbox One controller on Mac OS Sierra.
    Unity 5.6
    VSCode + Unity Debugger / C# / mono

    - Turn on debugging
    - Set a breakpoint in VSCode which will be hit based on input, example in Jump code.
    - Press Jump e.g. A
    - Hit breakpoint
    - Disable breakpoint, and resume play
    - Press Jump e.g. A

    Result: Jump / A is not captured, nor is AnyButton. The Update() loop which checks for input does get executed.

    Expected: Jump / A is captured.

    Workaround: Enabling 'Native Input (Mac / Windows only)

    Is this a known issue? I'll happily assume it's a bit of a corner case :), but I've had it repro when not returning from hitting a breakpoint... it just happens sometimes when first playing a scene -- worrisome as missed input just isn't okay in any game.
     
  42. Vadya_Rus

    Vadya_Rus

    Joined:
    Oct 23, 2013
    Posts:
    8
    Hey everyone,

    I'm trying to get the Nintendo Switch Joy-Cons to work with InControl and have managed to get a profile going for the controller. The issue I'm having is that since both controllers have the name "Wireless Gamepad", both controllers end up getting the same profile. On the other hand, within Windows 10's Device Manager the left and right joy-cons are coming up as Joy-Con (L) and Joy-Con (R).

    Would anyone have a clue on how make it so that the controllers can be differentiated between each other?

    EDIT: I've figured it out. In order to differentiate between the two controllers, the profiles needed to inherit from NativeInputDeviceProfile. Now I've got it working perfectly.
     
    Last edited: May 5, 2017
    napky33 likes this.
  43. AdminBag

    AdminBag

    Joined:
    Sep 19, 2016
    Posts:
    8
    Hi All, thank you so much for this amazing plugin!
    I am working on the XboxOne version and I stumbled into the GamePad.dll problem.
    I have already put the Gamepad.dll in the XboxOne folder but unity keeps giving me the same error:

    "The type or namespace name `Gamepad' could not be found. Are you missing an assembly reference?"

    I tried also the solution of @Frima :


     
  44. bagelbaker

    bagelbaker

    Joined:
    Jun 5, 2017
    Posts:
    31
    Hi!

    Any suggestions on how to handle default bindings depending on keyboard layout?
    For exemple, on QWERTY keyboard layouts, we would bind WADS and on AZERTY layouts we would bind ZQDS.
    Our current solution is to use GetKeyboardLayoutName() from user32.dll and check the codes for the keyboard layout. It works well but it relies on user32.dll and only works on Windows.
    I was wondering if there was another solution.

    Cheers!
     
  45. RemDust

    RemDust

    Joined:
    Aug 28, 2015
    Posts:
    273
    Hi there !
    I'm enjoying InControl so far but I'm having a hard time setting up my Sticks controller.
    I'm checking LeftStickX value (superior or not to zero) and apply velocity to my rigid body2D but sometimes when I release the stick "too hard" my character is ending up turning back in the opposite direction.

    How can I prevent this from happening ?

    Also, when I push my stick "down" there is always an "x component" to the vector2 that I'm creating by pushing down and the character is moving, again, what can i do to avoid this behavior ?
    Sorry for being such a noob, and thanks for any help you'll be able to provide !
     
    Last edited: Jun 11, 2017
  46. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    231
    Working with a few other users we've figure out a bit more information on setting up for Xbox One. Here are the full instructions:

    If you're getting a compilation error about the type or namespace 'Gamepad' being missing, you need to install the Xbox One native plugin which can be found in the Unity Xbox Forums:
    > Build Downloads (Sticky Topic)
    > Latest Builds
    > Unity's Xbox One Native Plugins
    Gamepad.dll can be found in Binaries\Native\Variations\Durango_Release
    GamepadImport.dll can be found in Binaries\Managed\Variations\AnyCPU_Release
    Put both in Assets/Plugins/XboxOne.
    Use Unity's Plugin Inspector (when you click on the plugin files in the Unity editor) to make sure Gamepad.dll is set to only be activated on Xbox One and that GamepadImport.dll is enabled for all platforms, or at least for the Unity editor on the platform you're developing.
     
  47. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    231
    Not that I'm aware of, unfortunately. Unity doesn't seem to make any information about keyboard layout available. I suspect your best bet may be to add default bindings for the majority case (QWERTY) and then allow rebinding in your UI for those who have other layouts whether regional, or custom/ergonomic keyboards.
     
  48. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    231
    The first issue is probably due to the sensitivity of your controller that when the stick springs back it briefly fires a small value in the opposite direction. You could try ignoring absolute values under a certain amount on that axis.
    var x = inputDevice.LeftStickX;
    if (Mathf.Abs(x) < 0.2f) x = 0;
    This may not always feel right, so you may need to do something that when the value has been above a certain value in one direction then it will not allow values in the other direction under a small amount for a brief period of time. A bit complex to implement, but input is often more complex to implement to get that perfect feel.

    The second issue is just the reality that it is nearly impossible to hold the stick perfectly downwards. There's going to be some small value on the second axis. Again, ignoring values under a certain threshold on this other axis may be what you want to do.

    This is an internal method, but you may find it useful so I'll mention it. There is an undocumented method in the Utility class:
    public static Vector2 ApplySeparateDeadZone( float x, float y, float lowerDeadZone, float upperDeadZone );
    This method applies the kind of dead zone that typically applies to DPads where it seems to snap slightly to 8 directions. Pass in something like 0.2f on the lowerDeadZone and 1.0f on the upperDeadZone.
     
  49. bagelbaker

    bagelbaker

    Joined:
    Jun 5, 2017
    Posts:
    31
    Does InControl have native support for Nintendo Switch platform? We used InControl for a project on PC/PS4/XboxOne and it works great. About to port to Switch and wondering if it'll work.
     
  50. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    231
    Not yet. Work to add support is underway, but we're still waiting on development hardware so there is no ETA on it yet.

    That said, if your needs are fairly simple (i.e. not multiplayer) search for InControl on the Nintendo Switch Developer forums (under Unity, Controllers and Input) and you'll find another user has posted a basic InControl module that worked for them.
     
unityunity