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

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    384
    Sorry it's taking a while. It does seem entirely doable and I have most of it done, barring testing. However, it requires some internal changes beyond just the native plugin and I have a few large unrelated changes also pending which all needs to be completed together. Hope to have a beta available in the next few days.
     
    Lars-Steenhoff likes this.
  2. SamFZGames

    SamFZGames

    Joined:
    Mar 2, 2014
    Posts:
    52
    Hello,

    I'm having a problem with InControl when using an Xbox Series X controller on PC. This is happening with all of my games which use InControl, but not with other games I've tried (I haven't tested it on other InControl games but it seems consistent in all of my own games).

    Everything works fine for an unspecified amount of time, and then suddenly all input just... stops. As if the controller has been unplugged. No buttons or directions work, until I stop my game and restart it, at which point it works again.

    This only happens with a Series X pad. Xbox One pads are fine. And it only appears to be in InControl. The controller itself isn't disconnecting (the light stays on), InControl just seems to stop polling it or something, until I restart.
     
  3. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    384
    I've only just received my Series X controller and I haven't had time to test it extensively (been working on a separate large update) but InControl is simply using Microsoft's XInput API for all Xbox controllers and polling it every frame. There's no Series X specific code anywhere. If you're using the older managed XInput module instead of the one in the native input module, maybe try switching to that, but beyond that, I have no idea why the controller would have a problem specifically with InControl, or even what could be done differently. If there is a broader problem with the Series X, that may take a while to be discovered and solved by the community.
     
  4. SamFZGames

    SamFZGames

    Joined:
    Mar 2, 2014
    Posts:
    52
    It's very strange because my Xbox One pads all work perfectly fine, but the Series X pad randomly stops working after a random amount of time. That's whether I have the old XInput enabled or not (Native Input is enabled, yes). And it's only in my games which use InControl, it's not a global thing. The problem doesn't happen with any of my Xbox One or PS4 pads, only the Series X pad. Sometimes it takes a matter of seconds, sometimes up to 10 minutes, but it stops working completely.

    I don't know if this helps but it seems if alt-tab out and then return to the game, I get control back, and sometimes it seems to just come back after a few moments. Again, this *only* happens with the Series X pad, not with any other pads, and the Series X pad is fine in everything else I test it on except my games which use InControl (which is up to date to the latest version). Suspend in Background is disabled. Nothing shows up in the log when it happens.
     
    Last edited: Nov 15, 2020
  5. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    384
    A beta is now up at: http://www.gallantgames.com/downloads

    Some oddities I observed:

    There appears to be no symbols for stick directions, just the stick itself. Also, even though there are technically entries in SF Symbols for dpad directions, they aren't used. So for sticks and dpad directions, I just return the symbol of the stick or dpad itself.

    Some buttons like View, Menu, Share, Options, etc. have no entries in SF Symbols and nothing gets returned, so those are blank until Apple adds them.

    But at least the primary buttons should work.
     
  6. XxPleYxX

    XxPleYxX

    Joined:
    Jul 26, 2011
    Posts:
    41
    Amazing, thank you very much for the support, I will give it a try as soon as I have time.
     
  7. SamFZGames

    SamFZGames

    Joined:
    Mar 2, 2014
    Posts:
    52
    Hello, just dropping in to update on this -

    I just had this happen with an Xbox One controller, in a Unity game not using InControl.

    So it must be a Bluetooth issue of some sort. I apologise, it really looked like it was InControl as it had only happened in those games before (but possibly just comes from me spending more time testing those games as I'm working on them).
     
  8. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    384
    For what it's worth, I have found bluetooth controller connections with both PCs and Macs extremely flaky for years. I don't usually see input permanently stop, but I often encounter stuttering or high (1-2 seconds) latency, and then if I move the controller closer to the computer it'll smooth out for a while. Even at worst I'm only 2-3 ft from the computer, so range shouldn't be an issue, but it is. I suspect the consoles have especially good BT antennas, perhaps directional, to compensate for greater range and the controllers just aren't really designed to be used with PCs, so it's a sub-par experience.

    Personally, I always play wired just to eliminate latency if nothing else.
     
  9. SamFZGames

    SamFZGames

    Joined:
    Mar 2, 2014
    Posts:
    52
    Good call. I'll give wired a shot and see if it still occurs.
     
  10. SamFZGames

    SamFZGames

    Joined:
    Mar 2, 2014
    Posts:
    52
    Hello,

    So I'm really sorry to come back to this, but my message about it being a bluetooth issue must have been a fluke, as today I played both Steam and non-Steam games with a Series X controller all day, including one of my own which used Unity but not InControl, with no issues at all, for hours, and then after hours of playing other games, when I loaded up my game which does use InControl, within 5 minutes of starting the game this issue happened. Totally lost all control over the game until I Alt-Tabbed out and back in again a few times.

    So I do think this is an InControl issue. Sorry for the confusion. To be clear, this problem doesn't happen with an Xbox One pad. Only Series X.
     
  11. XxPleYxX

    XxPleYxX

    Joined:
    Jul 26, 2011
    Posts:
    41
    Hello,

    The glyph system works perfectly, good job! But I come to ask another question, is the InControlNative library compatible with Apple Silicon? Any ETA?

    Thank You.
     
  12. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    384
    I think so. I did build a universal binary for the plugin, so the beta version (1.8.4) and beyond should be compatible, although I don't have any M1 Macs yet so I haven't verified it.
     
  13. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    384
    I should add that this would also require building with a version of Unity that supports Apple Silicon and Apple Silicon must be checked in the plugin inspector. So it might take checking a few boxes here and there for it to work.
     
  14. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    384
    I don't know what to tell you. I'm using Microsoft's XInput API, which is extremely basic and doesn't have any connectivity calls or anything like that and I'm polling it for input constantly. There is nothing specific to this controller that can be implemented. The API is entirely device agnostic. If it's disconnecting, I have no idea why. It could be anything from hardware, to a firmware update required, or something else entirely. It's such a new controller, very little is known at this point.
     
  15. EbonDust

    EbonDust

    Joined:
    Oct 8, 2013
    Posts:
    50
    Hello, I have a question. Is it possible to have normal unity UI block touch stick input, if yes then how?
     
  16. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    384
    Nope.
     
  17. EbonDust

    EbonDust

    Joined:
    Oct 8, 2013
    Posts:
    50
    Ehh, that is unfortunate. I will need to look for a workaround for that or roll something of my own. Thanks for the quick reply.
     
  18. SamFZGames

    SamFZGames

    Joined:
    Mar 2, 2014
    Posts:
    52
    Yeah, very odd. I've just had a dev friend tell me they bought a Series X pad and are having similar issues with their game on their computer, which uses InControl, but not with the demo I sent them that doesn't... Something has to be going on.

    I'm building a new PC soon, I'll let you know if it happens on that one too, and I'll try with my friend's game as well.
     
  19. SamFZGames

    SamFZGames

    Joined:
    Mar 2, 2014
    Posts:
    52
    I have some information on this which may be helpful!

    I loaded up a very basic test I made, and adapted it to use InControl. Sure enough the problem came up. However I noticed in the Debug logs in the console, it seems to get confused about what device(s) are connected.

    It shows two different devices being attached/detached.

    When I first connect the controller it shows two devices connecting. The first one says Name: XInput Controller, Driver Type: XInput. The second one says Name: (empty), Driver Type: DirectInput. If the controller is already connected when I run the game it shows only one (the DirectInput one) being added. But two are shown as disconnecting if I turn the controller off.

    I removed all other Bluetooth controllers listed to make sure it wasn't double-paired or something like that but it still occurs.

    This doesn't occur when I try with an Xbox One pad, only Series X.

    So it seems to me like InControl thinks the Xbox Series X pad is two devices, one XInput and one DirectInput device, and perhaps it tries to switch driver at some point causing the issue?

    Turning off Native Input appears to be a workaround, I haven't tested it for long but the issue hasn't come up when I've had Native Input disabled. But obviously that adds new problems for other controller types. Series X pads don't show up with a name so I don't think I am able to detect a Series X pad and disable Native Input at runtime or anything like that.

    Hopefully this information should help.
     
  20. atrivedi7

    atrivedi7

    Joined:
    Jul 25, 2013
    Posts:
    92
    Has anyone had any issues getting the Series X controller to work on a Series X dev kit? I've built to XBox One using XDK and an XBox One controller worked in that build.

    I've emailed @pbhogan and they said they are unaware of any issues. Just wondering if anyone else might have run into this.

    Thanks in advance!
     
  21. atrivedi7

    atrivedi7

    Joined:
    Jul 25, 2013
    Posts:
    92
    I figured out the solution to my problem. Unity's Event System needs an InputModule of some kind. By default, you can use "StandAloneInputModule". There is an option in the inspector called "Force Module Active". This variable is used in an override method called "IsModuleSupported"

    InControl has, as I understand it, their own implementation of this called "InControlInputModule". It, too, has an option in the inspector called "Force Module Active". However, in their override of "IsModuleSupported", there is a macro section for consoles that return true. GAMECORE is not in that list.


    public override bool IsModuleSupported()
    {
    #if UNITY_WII || UNITY_PS3 || UNITY_PS4 || UNITY_XBOX360 || UNITY_XBOXONE || UNITY_SWITCH
    return true;
    #else
    //rest of function
    }


    For me, it was as simple as turning on that checkbox in the inspector - though it took several hours of build time to figure it out haha

    @pbhogan Should UNITY_GAMECORE be in that list?
     
  22. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    384
    Ah, good catch. Yes, I think it should, and probably also PS5 and Stadia (although I think the latter would match the mouse support check that comes next).
     
  23. Grhyll

    Grhyll

    Joined:
    Oct 15, 2012
    Posts:
    119
    Hi, quick question: is there a reason why there isn't a NativeInputDeviceProfile for PS3 gamepads on Windows? They don't seem to be detected when Native Input is enabled.
     
  24. Grhyll

    Grhyll

    Joined:
    Oct 15, 2012
    Posts:
    119
    Not sure if it's gonna have any effect, but risking a small ping @pbhogan since this is kinda time sensitive for us.
     
  25. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    384
    I'll look into it, but it might take a little while. It's not a high priority controller and, as I recall, (keeping in mind it's been a long time since it's been at all relevant) you need to use a 3rd party driver of some kind to make it work. At which point users could (and probably should) just use x360ce to emulate an XInput controller with it.

    In any event, PS3 controller support should not be a blocking feature for any game. It's not and never was intended for desktop use, unlike the PS4 controller which at least had some measure of Sony support through the PC USB adapter and it being a standard HID device for basic input features.
     
  26. Grhyll

    Grhyll

    Joined:
    Oct 15, 2012
    Posts:
    119
    Hey, thanks for the answer! It's not a blocking issue indeed, it's just that we would have liked to include it in our next patch (which is due very soon) if it was just a matter of forgetting the profile. Since it's more complicated, no worry.
     
  27. Buffles-TE

    Buffles-TE

    Joined:
    Mar 19, 2013
    Posts:
    10
    Saw a post from 2015 posted here mentioning that InControl doesn't do Smoothing for Keyboard buttons similar to getAxis. Don't suppose that has changed since then?
    My controls rely on getAxis and the new Input system doesn't have a proper equivalent for getAxis still.
    Did see another post that said something about Custom Deadzones and Smoothing also in 2015 however I suspect thats more for controllers.
     
  28. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    384
    No, InControl doesn't do smoothing on keyboard or any input. It just gives you the input values. I see smoothing as a behavior or animation implementation rather than an input implementation. And it really shouldn't be different for keyboard or dpad than for analog sticks anyway. If you really want smoothing, just take the input value and run it through Vector2.SmoothDamp() or Vector2.MoveTowards() some such.
     
    Buffles-TE likes this.
  29. Buffles-TE

    Buffles-TE

    Joined:
    Mar 19, 2013
    Posts:
    10
    Fair, Guess I'll be diving into the scripts then. Thanks for the quick response.
     
  30. NMJ_GD

    NMJ_GD

    Joined:
    Dec 28, 2019
    Posts:
    14
    Hi, my company started using InControl version 1.6.16. (this game has been in development several years already). So, I am relatively new and didn't really have anything to do with controllers. So, story short, I have to make PS4 version, but because the one who made the movement is already not working quiet a time, I have to do it. It works perfectly on other devices, even on PC with dualshock it works normally, but it doesn't work on ps4 with or without cable. When I debugged it, in devices it showed unknown device. So it should be the problem, what can you recommend?
     
  31. SamFZGames

    SamFZGames

    Joined:
    Mar 2, 2014
    Posts:
    52
    Aight, I'm dropping in again to annoy you some more. I am sorry if it is frustrating but this is definitely a problem as now I've had a third person who recently got a Series X pad tell me of this issue, not just in my game but in a friend's game as well which uses InControl. If I disable InControl and use the Unity input method and send it to them it works fine, so that's three different people and three different games now. I also tried it on a different PC and had the same problems.

    I think this is beyond the point where we can assume it was my computer and I think since you sell this as an API for all popular controllers this should be addressed and not just pushed aside.

    Key points:
    - This only happens through wireless. It's fine when connected via USB-C.
    - Unity's console shows TWO devices connecting, one XInput one and one DirectInput one. All other controllers only show one device. Perhaps the two APIs are clashing with each other?
    - A quick workaround is to uncheck 'Enable Native Input', but this causes issues with other controllers and rumble features etc.

    I don't mean to frustrate you but I think it's clear this is a real thing at this point, not just bluetooth issues.
     
    Last edited: Jan 3, 2021
  32. binster

    binster

    Joined:
    Oct 16, 2012
    Posts:
    13
    Hi all - got a bit of a long, weird enquiry about InControl and using both analogue sticks and dpad/keyboard button presses for input in menus. Details below!

    I use PlayerActions Left Right Up Down and PlayerTwoAxisAction Move (made from above) for Left Analogue Stick and keyboard WASD - for player movement

    I use PlayerActions PadLeft PadRight etc and PlayerTwoAxisAction PadMove (made from above) for DPad input on console - for item selection in game

    I also make PlayerActions MenuLeft MenuRight etc and PlayerTwoAxisAction MenuMove (made from above) for in-menu control. I assign left stick and the dpad (or WASD if in keyboard mode) to these PlayerActions.

    I was initially using PlayerAction.WasPressed to test for player input.

    Now. The problems arise with the fact that I use up/down and left/right input for menus - for example, a vertical list of menu items that can be selected between with up/down presses, and can be incremeneted/decremented with left/right presses. This is fine using dpad or keyboard input because they're discrete button presses.

    With the analogue stick, PlayerAction.WasPressed for the Actions is called as soon as there's non-zero input. So a slight movement on the stick will predominately call two actions in close proximity (Up and Left, say). Meaning it's practically impossible for a user to change an incrementable menu item without also changing the selected item.

    So I implemented a threshold check - make sure the magnitude of PlayerTwoAxisAction.Value was above a threshold value before considering the action as being 'pressed' and then ignore the input until the magnitude of the PlayerTwoAxisAction.Value was below the threshold again. That works when it comes to stick input.

    But because I wrapped in button presses (eg, Keyboard input) to the same actions, I've hit a wall here - it seems that pressing a key will trigger PlayerAction.WasPressed but WON'T change the PlayerTwoActionAxis.Value to match, whereas analogue sticks will both raise the PlayerTwoActionAxis.Value and trigger PlayerAction.WasPressed.

    So I don't think there is a way to sift out analogue stick movement below a threshold but still be receptive to button presses. I can see there is some deadzone stuff for ActionAxis controls, but the documentation is bereft of detail - I tried setting LowerDeadZone on a PlayerTwoAxisAction and got a message stating that I should set it on the device controls directly as it does nothing there - that doesn't sound good - I don't want to put a deadzone on the left analogue stick while in gameplay, just while in the menus, and I don't want to have to keep setting and re-setting it when changing modes.

    To sum it all up - is it possible to drive a single PlayerTwoAxisAction with both the left-stick and the dpad and use that for menu-movement without the left-stick input being hyper sensitive?
     
  33. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,527
    I think its best to disable analog input when dpad is pressed and enable again when dpad is released

    with dpad I mean dpad/keyboard
     
    binster likes this.
  34. binster

    binster

    Joined:
    Oct 16, 2012
    Posts:
    13
    Thanks for the tip. I ended up going with a dodge of my own which better fit my code, but I suspected this would inevitably be the answer :)
     
  35. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,527
    I'm setting up local multiplayer with two controllers for my game with in-control and playmaker.

    Whats the action that I should use to check for player input on each controller?

    I'm checking what control was pressed on the controller, and after that I assign the device index to the controller that was pressed.

    It working on MAC but on Apple tv it does not seem to work somehow.
    Any idea what I could do ?


    Screenshot 2021-01-12 at 13.44.33.png
     
  36. Grhyll

    Grhyll

    Joined:
    Oct 15, 2012
    Posts:
    119
    Hi!

    One of our player is getting a crash on a Steam build which seems to be related to something inside InControlNative dll. They say they're using an XBox 360 controller, but somehow it may not be an official one, or maybe they just have some other weird device plugged in their computer which causes the issue.

    When the game start, one device is detected, then another one just a bit later, and both have an Unknown device Class and Style, with following values:
    Name: Unknown Device
    Meta: Controller (XBOX 360 For Windows)
    Known: False
    Attached: True
    Active: False
    Supported: True

    A bit later, the game crashes with the following stack trace:
    ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FFE5FDA2365)
    0x00007FFE5FDA2365 (InControlNative) (function-name not available)
    0x00007FFED0F87C24 (KERNEL32) BaseThreadInitThunk
    0x00007FFED224D4D1 (ntdll) RtlUserThreadStart

    We're still trying to gather more info from that player, but I figured I'd just drop this here already since that may be enough for you to find what's wrong? Let me know if you can think of specific relevant info you would need.
    Thanks!
     
  37. Scott-Steffes

    Scott-Steffes

    Joined:
    Dec 31, 2013
    Posts:
    59
    Hey all, this may be an obvious question, but how do you tell what was the last input device that was touched, including the keyboard. From what I can tell InputManager.ActiveDevice only includes controllers and other peripherals, but not the keyboard. Same with InputManager.Devices
    I would have imagined that the keyboard is just another device, but that does not appear to be the case.
     
    Polyfemos likes this.
  38. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    384
    Keyboard and mouse input only works with the bindings API. Devices in InControl currently only represent controllers.

    To see what kind of input an action set (or action) received last, you can use the .LastInputType property on PlayerAction or PlayerActionSet: http://www.gallantgames.com/pages/incontrol-bindings-faq
     
    Scott-Steffes likes this.
  39. LeeLorenzSr

    LeeLorenzSr

    Joined:
    May 3, 2015
    Posts:
    50
    So, my faith in InControl was shaken a bit when I launched my game, Astrokicker, on Steam last week, and immediately had two crashes due to using XInput/Native input module. Disabling Native Input "fixed" the problem, but lost me access to gamepad vibration, which I really want to bring back to my game.
    I tried setting nativeInputEnableXInput to true at runtime, when the user enabled force feedback, but it seems that it doesn't activate the correct managers unless that setting is enabled in the scene already?
    Is there a way to programatically turn this on? I'm kind of operating blind here, because I can't test the failure condition - the two crashes used controllers that we have not been able to identify, so we can't acquire them to test against.

    A side issue involves the Steam Controller. I know, I know... but I'm trying to sell my game on Steam, and their reviewers are kind of picky about this stuff. Any ideas on how to reliably determine if a Steam Controller is unplugged? I wish InControl had a wholistic approach to detecting controller presence, since Steam checks the game's response to unplugged controllers. My (rushed) code works for traditional gamepads, but not for the Steam Controller :|

    UPDATE: Reading the thread above this, it looks like there is an issue with Xbox One Series X controllers? Perhaps that was what was causing my game to crash with XInput enabled? Also, the one user who experienced a crash streamed the game when he was able to finally run it - and his analog stick was stuck in 8 directions. The odd thing here is my game DOES have a mode restricting to 8 directions (Retro mode, I have code to restrict movement, but for that code to be active, other ships would also have been restricted, and they were not), but he was not playing in that mode. It is absolutely the first time I observed this sort of thing, and I chalked it up as an issue with his controller mapping or something.

    Again, I have no idea what controller they were using. I have since put in better logging, but no more crashes since disabling native mode and XInput. I really cannot have players crashing at this stage of my product launch.
     
    Last edited: Feb 2, 2021
  40. lazylukey

    lazylukey

    Joined:
    May 26, 2017
    Posts:
    36
    Hi @pbhogan we've recently been seeing the following exception in our game on the latest version of InControl (v1.8.3 build 9361) and wondered whether you might know why:


    Uploading Crash Report
    Exception: InputManager is not initialized. Call InputManager.Setup() first.
    at InControl.InputManager.UpdateInternal () [0x000b7] in <a9bb021f4d664fd9b3a7d59344f571b7>:0
    at InControl.InputManager.OnLevelWasLoaded () [0x00005] in <a9bb021f4d664fd9b3a7d59344f571b7>:0
    at InControl.InControlManager.OnSceneWasLoaded (UnityEngine.SceneManagement.Scene scene, UnityEngine.SceneManagement.LoadSceneMode loadSceneMode) [0x0000c] in <a9bb021f4d664fd9b3a7d59344f571b7>:0
    at UnityEngine.SceneManagement.SceneManager.Internal_SceneLoaded (UnityEngine.SceneManagement.Scene scene, UnityEngine.SceneManagement.LoadSceneMode mode) [0x0000e] in <e3cc0d511c49480aba0b4b05faed2ad3>:0


    It occurs when the game switches from the menu/lobby scene to the main game scene. Both scenes contain a GameObject with the InControlManager component on it. Both have Don't Destroy On Load checked.

    I am using Unity 2019.4.13f1
     
  41. faolad

    faolad

    Joined:
    Jan 27, 2013
    Posts:
    118
    I keep getting this error on mac build: InControlNative.bundle could not be found or is missing a dependency.

    Edit: Somehow unity fails to copy the InControlNative.bundle into the build (Contents/Frameworks)
     
    Last edited: Feb 9, 2021
  42. faolad

    faolad

    Joined:
    Jan 27, 2013
    Posts:
    118
    A Unity crash occurred with the Xbox One controller plugged in before the game is launched. Frequent crashes also occur during gameplay every time the game loads levels. This only happens with Xbox One controller and only if it’s plugged before the game is launched not after
     
  43. LeeLorenzSr

    LeeLorenzSr

    Joined:
    May 3, 2015
    Posts:
    50
    @pbhogan Any chance we can get some info here? I'd dig into the xinput stuff to figure out why we are suddenly seeing crashes, but I have no idea what controller is being used that is causing this, as the one user of mine who had this happen (while live streaming my game on Twitch, no less!!) won't get back to me.

    I cannot recreate this issue. I have an Xbox One, Xbox 360, and Steam Controller to test with, and testers with Logitech and Nintendo Switch Pro game pad... This problem seems to be with the new "Series X" Xbox One controller (with Share button, I assume?).

    I'd love to help. At the very least, I would like to update my game to bring the force feedback feature back with some confidence that it won't break the game for some of my players. At the very least, can you tell me how I can programmatically enable the native module at runtime? Simply toggling it doesn't seem to properly initialize things.

    I know you are probably swamped with this, but it would at least be nice if you guys could acknowledge the issue and let us know you have a handle on it...
     
    faolad likes this.
  44. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    384
    This is very strange as it should be impossible. It appears from the crash report that InControlManager.OnSceneWasLoaded (the Unity callback) is being called before InControlManager.OnEnable() which should be impossible as the callback is only set after InControl is initialized. The only way I can see this being possible is if you're calling InputManager.ResetInternal() manually somewhere. With Don't Destroy On Load on the menu game object, InControl should never reset until the game exits. If you want to debug this, try to figure out where InputManager.ResetInternal() is being called during the scene switch.

    One thing you could try is modify the script execution order (https://docs.unity3d.com/Manual/class-MonoManager.html) to make InControlManager run as the very first thing.

    Beyond that, can you reproduce this reliably in an otherwise empty project? If so, you can send it to me to look into.
     
  45. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    384
    Please check the Plugin Inspector settings of InControlNative.bundle (click on it in InControl/Plugins/macOS/ in Unity) and check that it is included for the macOS Standalone platform. There are quite a few bugs in Unity's plugin importer, especially when upgrading projects to new Unity versions, that causes things to get unchecked in there.
     
  46. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    384
    I'd need a lot more information to reproduce this. Platform, OS version, Unity version, InControl version, exact Xbox One controller, etc., and does it happen with an otherwise empty project, Standalone? In the Editor? Running in Steam or with Steam running in the background?

    I test frequently on all platforms with Xbox One controllers of all varieties, so this is highly unusual.
     
  47. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    384
    It sounds like there's a couple issues going on here.

    I'll address the Steam controller first. Steam's standard gamepad emulation, as far as I know, does work. Although, it's pretty buggy on Steam's end. All I can rely on is what the system APIs are telling me. If the controller disconnect isn't working, it's literally a bug in Steam. They're the ones sticking hooks into the OS drivers including XInput and doing terrible hacks. InControl just reads the API (it's an extremely straightforward API, to a fault). I've compared my code to Microsoft's example code, SDL and several other projects and libraries out there. Usage is virtually identical. The simple fact is, if the system input API that Steam has its hooks into is telling me that the controller is connected, there is no way to tell that it isn't.

    I've been looking into adding direct Steam Input support via SteamWorks.NET, but that's been extremely challenging. I've engaged with one of the Steam developers, but haven't got much support. Documentation is out of date and wrong. Things just don't work. And worst of all, they require using their action system with absolutely no way of simply reading device inputs directly, which is kind of fundamental to how InControl operates. So it can't work out of the box and would require a bunch of custom things per project. I've had some back and forth and they kind of want to make the process easier to automate, but it doesn't appear they're super motivated to do so. Anyway, I've shelved that for a few months and I'll revisit it.

    As for the Xbox Series X controller—I can't reproduce the crash, try as I might, and yours is the only crash report I have related to this controller (although it sounds like you're not sure?). That makes this pretty hard to do anything about.

    There are two known crashes known at this time, but neither sound like your issue. I'll describe them anyway:

    1. When running under Steam with native input enabled, due to Steam's system hooks, reinitializing XInput/DirectInput seems to cause a crash. What this means for InControl is, it must not reset once the game has started. It should initialize at game launch and shutdown at game exit. Practically speaking, this means all instances of InControlManager need to have Do Not Destroy On Load turned on. InControl will automatically destroy redundant managers that show up in scene loads and only the first one will ever be activated. This is a best practice anyway.

    2. There is a crash that can happen with native input enabled with a particular foot pedal and its driver software. It's not one particular brand... there seems to be a bunch of them generically made in Asia and resold under dozens of names. It looks like this: https://www.amazon.com/gp/product/B00CK1BKZQ and the software has the name "PC Sensor". Interestingly, I can't reproduce it myself, but I've had enough reports that there is definitely an issue with it. It might actually be fixed by InControl 1.8.3 with a potentially related fix for devices that declare an unusually high number of buttons.

    Finally, about programmatically enabling the native module at runtime. There's no elegant solution for this. You cannot toggle it at runtime, especially because it would require reinitializing InControl which is bad in light of crash #1 above, but you could detect a command line switch at launch or have a toggle in settings that requires a restart. Then either have a modified InControlManager script that detects this setting, or have two manager objects and enable one or the other depending on the setting, or set the setting before it gets enabled by another script.
     
    LeeLorenzSr likes this.
  48. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,527
    I want to make a playmaker action to check the currently active controller

    Code (CSharp):
    1. InputManager.OnDeviceAttached += inputDevice => Debug.Log( "Attached: " + inputDevice.Name );
    2.             InputManager.OnDeviceDetached += inputDevice => Debug.Log( "Detached: " + inputDevice.Name );
    3.             InputManager.OnActiveDeviceChanged += inputDevice => Debug.Log( "Active device changed to: " + inputDevice.Name );
    I see this code in Testinput manager, Is there a way to make an action for this?
     
  49. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    384
    I'm not really familiar with PlayMaker, but are you just trying to output the name of it, or are you wanting to hook into the actual change event?

    InputManager.ActiveDevice would always be the current active input device (or the null device if no input has been received yet).
     
  50. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,527
    I want to make a split screen game with two local controllers, so I want the player to press the controller to assign to the player.