Search Unity

[Released] cInput 2 - Unitys custom inputmanager got improved !

Discussion in 'Assets and Asset Store' started by Roidz99, Apr 4, 2012.

  1. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    What do you get when you Debug.Log(Keys.Xbox1DPadLeft) ?
     
  2. Doghelmer

    Doghelmer

    Joined:
    Aug 30, 2014
    Posts:
    120
    I get:
    Joy1 Axis 6-
     
  3. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    Is this with the latest release of cInput? Or was that too broken so you reverted to the old one? And are you using an Xbox 360 gamepad now? Or an Xbox One gamepad?
     
  4. Doghelmer

    Doghelmer

    Joined:
    Aug 30, 2014
    Posts:
    120
    Ack, so sorry about that, yes I had reverted last night and I completely forgot about it.

    Xbox One controller support is working perfectly with 1 controller plugged in.

    When I have an Xbox One controller and Xbox 360 controller plugged in, the issue I was having with RT and LT not working is present.
     
  5. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    OK. That explains it. The previous version doesn't distinguish between Xbox 360 gamepads and Xbox One gamepads.

    D-Pad Left on 360 is Axis 6-, which is what the Right Trigger maps to on Xbox One gamepads. Once I get the IndexOutOfBoundsError fix uploaded, you should see that problem go away.

    RT and LT don't work for either controller? Or just the Xbox One controller? Or just the Xbox 360 controller?

    I only experience problems with Xbox 360 triggers if multiple 360 gamepads are connected. Having an Xbox One controller connected (or not) doesn't seem to affect anything for me. And my Xbox One triggers are working just fine. That said, I did notice that when rebinding controls at runtime, the Xbox One triggers got mapped to axes 3- and 6- instead of 9+ and 10+. But I already have a fix for that as well which will be included in the next release.

    Sorry for my confusion, but before I release these fixes I want to make sure I understand the trigger problem you're experiencing so I can fix it, if possible.
     
  6. Doghelmer

    Doghelmer

    Joined:
    Aug 30, 2014
    Posts:
    120
    They don't work for either controller. Except if I press LT or RT on both controllers at the same time, in which case they both fire.
     
  7. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    And this is using cInput 2.8.7?

    Can you please show me some code of your setup, as well as the code that is trying to read the value of the inputs?
     
  8. Doghelmer

    Doghelmer

    Joined:
    Aug 30, 2014
    Posts:
    120
    This happened with 2.8.8 as well.

    I can reproduce the issue using the following code

    void Start () {
    cInput.Clear();
    cInput.SetKey("TriggerRight", Keys.Xbox1TriggerRight);
    StartCoroutine(test());
    }

    // I stuck this in just in case something was getting set after my Start() function
    IEnumerator test() {
    yield return new WaitForSeconds(3);
    cInput.Clear();
    cInput.SetKey("TriggerRight", Keys.Xbox1TriggerRight);
    }

    void Update () {
    if (cInput.GetButtonDown("TriggerRight")) {
    Debug.Log("PRESSED");
    }
    }
     
  9. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    Weird. Using that code, I can't reproduce the issue. But something is definitely acting up on my end because the Coroutine never finishes waiting the 3 seconds.

    Code (csharp):
    1.  
    2.     IEnumerator test() {
    3.         Debug.Log("Coroutine started!");
    4.         yield return new WaitForSeconds(3);
    5.         Debug.Log("Coroutine finished waiting");
    6.         cInput.Clear();
    7.         cInput.SetKey("TriggerRight", Keys.Xbox1TriggerRight);
    8.     }
    Using the above code, I see "Coroutine started!" but I never see "Coroutine finished waiting"

    Maybe it's time for a system reboot. (For both of us?)
     
  10. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    OK now I'm really puzzled. I rebooted and I'm seeing the same behavior you described where I have to press both triggers at once, but the coroutine still won't finish.
     
  11. Doghelmer

    Doghelmer

    Joined:
    Aug 30, 2014
    Posts:
    120
    No idea about the coroutine, but I guess it's good you're able to repro it now.
     
  12. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    Found out that Time.timeScale was somehow set to 0.

    Exon in the Unity IRC channel informed me about Edit -> Project Settings -> Time which for some reason was configured such that Timescale was 0.

    Now to try to figure out this trigger issue. :)
     
  13. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    OK that didn't take long. This is related to the other trigger problems that have been plaguing Unity for years, described in more detail here:
    Basically, it looks like Unity is only detecting input on Axis 3 on one gamepad, while reading input on axes 9 and 10 on another gamepad, but thinking they are the same gamepad (but only when triggers are pressed on both at the same time?).

    And it seems to be the luck of the draw as to whether or not you experience this issue. I usually keep two Xbox 360 gamepads connected and an Xbox One gamepad. This causes my 360 gamepad triggers to only work on axis 3, but my Xbox One gamepad works just fine and doesn't interfere with the 360 gamepads. Even after I disconnected one of my 360 gamepads things were still working fine until I rebooted my machine with just one of each connected.

    I'll be looking into the possibility of fixing these trigger issues, but I'm not sure how long it will take me to come up with a solution, and the current release of cInput is essentially broken, so I'm going to put out a bugfix release ASAP and then work toward a solution to the trigger issues for a later date.

    Thanks for all your help in bringing these issues to my attention and helping me reproduce them.
     
  14. Doghelmer

    Doghelmer

    Joined:
    Aug 30, 2014
    Posts:
    120
    No worries. I'm just surprised stuff like this exists in Unity and next to no one actually bothers to test thoroughly and call it out. I'm pretty positive I'm not the only one out there releasing a two-player controller-based game, but given some of the issues I've had it kinda feels like I am. Another example: Last time I tested, it wasn't possible to use a Steam controller with an Xbox 360 controller. Wrote up a bug for that one, but it's still active.
     
  15. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    Hi folks,

    An update to cInput has been accepted on the Asset Store. Whether you bought cInput from the Asset Store or on our website, the update should be available immediately.

    cInput changelog:

    v2.8.9

    • Fixed IndexOutOfRangeException introduced in 2.8.8. (Thanks Doghelmer)
    • Xbox One gamepad triggers now try to map to axes 9 and 10 when scanning for inputs.
     
  16. slcrubes

    slcrubes

    Joined:
    Sep 4, 2015
    Posts:
    11
    Thanks for a great resource. I have one question...I can't seem to get the Question Mark key to work at all. I'm sure I'm doing something wrong, but I can't figure it out. I'm trying to map pressing the question mark key to the Help screen in my game. The action of "Help" is matched to the Primary key of "Question", but it never works.

    If I simply change the Primary key to a different key, such as any letter like I or P, it works fine. I've tried it with Slash (the key below Question mark), and it works fine. I've tried Slash with a Primary modifier of Left/Right Shift, but that doesn't seem to work either.

    I've also taken other mappings that I know are working well, and changing those to Question instead, and they no longer work.

    I've used this resource for many, many different key mappings, and it has always worked great. I'm just wondering if there's something special about the Question mark key that I don't know.

    This is using Unity 5.3.3f1 on two different Mac OS X machines (one running 10.10, the other 10.11), both have the same issue. Thanks!!
     
  17. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    There is nothing inherently special about the Question mark key that should prevent it from being mapped by cInput. That said, the way cInput works, you would need to actually use the [Left/Right] Shift+Slash to activate it.

    In my tests, this is working as it should in Unity 5.3.3f1 on Windows 10.
    cInput Question Mark Test.png
    Are you by chance using a non-standard (non-US QWERTY) keyboard where the Question mark and the (forward) Slash are on different keys?

    Also don't forget that before you can create a new input with a modifier key, you have to define the modifiers using AddModifier(). Please refer to our reference manual's "using modifier keys" section for further information, if needed.
     
  18. slcrubes

    slcrubes

    Joined:
    Sep 4, 2015
    Posts:
    11
    Yep, as expected, I forgot to define the modifiers beforehand. Thanks for pointing that out.
     
  19. wood333

    wood333

    Joined:
    May 9, 2015
    Posts:
    851
    I was able to get cInput working with Motion Control 2. I took the MC2 provided input manager and stripped out the incorrect namespace line, and then stripped out all code not referencing strings. There are still a couple issues with the controller function, but cInput is passing on the key/button information to the controller, as intended.

    I would pursue the integration further, except that we are starting to use another controller, the Third Person Controller Template (TPCT). When I get back to cInput, I will let you know how cInput and TPCT integrate, easy or hard.

    Incidentally, the designer of Motion Controller sells a separate input product. His is well designed, but it does not have a HUD feature like cInput. It is wonderful that you provide the HUD for users to easily change keys. It's a professional feature that we are delighted to have in our project.
     
  20. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    I'm glad to hear you got it (mostly) working. Thanks for the kind words. They're much appreciated. :)
     
  21. V4nKw15h

    V4nKw15h

    Joined:
    Dec 16, 2011
    Posts:
    47
    Hey Deozaan, Can you check your deadzone settings for flight sticks.

    Last week I added joystick support simply by updating cInput2. I'd previously been using a very old outdated version before joysticks were implemented. Everything has been great. Nobody had any problem getting their joysticks working, but I've got one player today complaining about the deadzone being too large on a HOTAS stick.

    There is no code in my game that alters the deadzone via cInput. Printing out cInput's deadzone setttings using GetAxisDeadzone all return 0.001. The default. Yet this player is getting a bigger deadzone on his stick than in all other games.

    He made a video to show his hotas config utility running at the same time as my game NeonXSZ and Descent.

    We can see he's moving his stick (via his config utility) , and it's registering movement instantly in Descent, but in my game, using cInput2, it's not registering until he's moving his stick about 20%.

    We've confirmed he's got every deadzone setting set to zero both on HOTAS and Windows, yet cInput appears to still have a deadzone.

    I've also tested using an Xbox Controller, and there is no deadzone. It works as expected. It seems to be just with flight sticks. He also confirms he's getting the deadzone effect on every axis. I'm at a loss as to why this is happening so I thought I'd try and eliminate any issue in the current version of cIput with you.
     
  22. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    This actually sounds about right. cInput is a wrapper around Unity's Input Manager, which means that we take the input that Unity gives us and do stuff with it. As such, we tried to keep all the Input Manager values at their defaults and just build on top of it. We did it this way because we didn't want to interfere with anything else that might be using the default Input Manager to get its values. So with that in mind, it may be helpful to know that Unity's default deadzone for axes seems to be 0.19 (i.e. 19%).

    This generally works fine for gamepads such as the Xbox controllers, which tend to require fairly large deadzones. But for flight sticks you may need more sensitivity than that. The solution is fairly simple: Go into Unity's Input Manager settings (Edit -> Project Setttings -> Input) and adjust the deadzone on the joystick axes to something smaller.
     
  23. V4nKw15h

    V4nKw15h

    Joined:
    Dec 16, 2011
    Posts:
    47
    Thanks for the quick response. I just came back here to tell you not to worry, and that I'd solved it. Yes, I found the same thing you suggested it would be. The joystick deadzones in Unity are set to 0.19. Sorry to bother you but good job on the super fast response.
     
  24. DMCH

    DMCH

    Joined:
    Nov 6, 2012
    Posts:
    88
    Hi Deozaan. Finding cInput really good to use, great job with it. Have encountered a small problem, I was hoping you might be able to help me figure out. I seem unable to map the space or enter key. Everything else works fine. Using CInput 2.8.9, Unity 5.3.3f1, and on windows 8.1. Have included code I'm using below. Thanks!

    Code (CSharp):
    1.     /* Changes the key of the clicked on button
    2.      */
    3.     public void ChangeKey(int keyPositionIn)
    4.     {
    5.         Debug.Log("GameOptionsScript.ChangeKey. Method called. Position is: " + keyPositionIn);
    6.         cInput.ChangeKey(keyPositionIn);
    7.  
    8.         // Update checks for keypress, then updates binding
    9.         isCheckingForKeyInput = true;
    10.  
    11.         // Update the text for the key button, shows ...
    12.         UpdateSpecificKey(keyPositionIn);
    13.     }
    14.  
    15.     /* Updates a specific key
    16.      */
    17.     public void UpdateSpecificKey(int keyPosIn)
    18.     {
    19.         keyBindingTextList[keyPosIn].text = cInput.GetText(keyPosIn, 1);
    20.     }
    21.  
    22.  
    23. // Update Loop
    24.     void Update()
    25.     {
    26.         if(isCheckingForKeyInput)
    27.         {
    28.             if(cInput.anyKey)
    29.             {
    30.                 Debug.Log("GameOptionsScript.Update. A key has been pressed.");
    31.                 UpdateKeyBindingText();
    32.                 isCheckingForKeyInput = false;
    33.             }
    34.         }
    35.     }
     
  25. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    From what I can tell from your code, it looks like you've made your own keybind UI which when clicked will rebind inputs using cInput. My guess is that space and enter are configured as the "accept" key in the UI input settings, so using them to map the keys immediately presses the selected UI buttons again, which starts the process over again, making it look like nothing happened.

    Try adding a small delay between when a key is bound before the UI accepts input again.
     
  26. DMCH

    DMCH

    Joined:
    Nov 6, 2012
    Posts:
    88
    That did the trick! Don't need the keyboard to effect UI, so just removed space and enter as accept keys. Thanks for the help!
     
    Deozaan likes this.
  27. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,467
    Hey guys... I just purchased this asset after hearing how great it is... and wanting to use it with UFE... I am using the X360 controller with Unity and I am getting a console ping that Joystick button 0 is not a valid input... what I would like to know is how to get this properly configured for the input manager for the X360 controller... I am using the Input Manager that comes with UFE but I am at a dead end... perhaps someone can explain what I am missing
    Thanks
     
  28. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    Hello,

    cInput provides an installation script that will set up your Input Manager with everything you need to get cInput working. Some of our most recent updates to cInput have attempted to improve compatibility with Xbox 360/One controllers. It sounds like the folks at UFE haven't kept up to date with cInput's configuration.

    So if you're going to use UFE's input manager settings, and they don't provide a cInput-compatible InputManager file like they claim they do, you should contact them about it and ask them to make sure they remain up to date with cInput.

    Either that or you could manually add the missing inputs yourself to the Input Manager, but you may have to re-configure it each time you update UFE or start another project, so the best solution is to get the folks at UFE to fix it on their end.
     
    KRGraphics likes this.
  29. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,467
    I will have to do that. I replaced the inputs in the manager with mapping that I found from the official microsoft site... and I am will test this with cInput. I've already set up the inputs in UFE and gonna try to make it work. The only thing missing is the triggers... :(
     
  30. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    Xbox triggers are an annoying case in Unity. Sometimes they work, sometimes they don't. Sometimes they both map to the same axis, sometimes they map to separate axes. It's a headache, and this is a problem with Unity itself. In other words, this problem is not limited just to cInput. For example, here's a post about the trigger bug from the developer of InControl.

    The most reliable way I've found to get triggers to work properly--though it's still no guarantee--is to have only one Xbox controller connected to your computer.
     
    Last edited: Jun 20, 2016
  31. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,467
    And right now I do :)... I'm making a fighting game and using the bumpers feel unnatural to me... and I also made a copy of my button mapping in case of an update
     
  32. stevenc33

    stevenc33

    Joined:
    Apr 20, 2016
    Posts:
    18
    Anyone else having problems with cInput for UFPS?

    I'm using the latest version of UFPS 1.6.1 and am getting the Message: "Couldn't find an axis match for Horizontal. Is it possible you typed it wrong?" I have the correct InputManager.asset in my ProjectSettings folder and it has Horizontal defined.

    EDIT: It was my oversight. Problem is resolved. Thank you.
     
    Last edited: Jul 21, 2016
    PNUMIA-Rob likes this.
  33. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    We've responded to your email and have received your confirmation that the problem is now resolved. :)
     
  34. yumianhuli1

    yumianhuli1

    Joined:
    Mar 14, 2015
    Posts:
    92
    Hello,I need joystick 20,21,22... but unity joystick just support between 0 -19, can i use your package for joystick 20,21,22......?
     
  35. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    No, sorry. cInput uses Unity's Input Manager to do its magic, so a general rule of thumb is that if you can't see an input using Unity's Input Manager, cInput won't be able to either.
     
  36. yumianhuli1

    yumianhuli1

    Joined:
    Mar 14, 2015
    Posts:
    92
    Thank you Dear Deozaan, I tried the DXinput,but failured.I heard u3d no longer support for DXinput,so how can i get 20,21,22...button values?
     
  37. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    I'm not sure. This isn't something that cInput supports. Maybe try XInput?
     
  38. yumianhuli1

    yumianhuli1

    Joined:
    Mar 14, 2015
    Posts:
    92
    Does XInput support joystick/Wheel?
     
  39. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    I believe so but I can't provide any support for XInput. I'm not very familiar with it.

    Good luck!
     
  40. yumianhuli1

    yumianhuli1

    Joined:
    Mar 14, 2015
    Posts:
    92
    thank U!
     
  41. TechDeveloper

    TechDeveloper

    Joined:
    Sep 5, 2016
    Posts:
    75
    Hello I keep getting this error msg in the console. Using Unity 5.4.1

    INTERNAL_get_color is not allowed to be called from a MonoBehaviour constructor (or instance field initializer), call it in Awake or Start instead. Called from MonoBehaviour 'cGUI' on game object 'cObject'.
    See "Script Serialization" page in the Unity Manual for further details.
    UnityEngine.GUI:get_color()
    cGUI:.cctor()
    UnityEngine.GameObject:AddComponent()
    cInput:_cInputInit() (at Assets/Plugins/cMonkeys/cInput/Scripts/cInput.cs:312)
    cInput:SetKey(String, String, String, String, String) (at Assets/Plugins/cMonkeys/cInput/Scripts/cInput.cs:465)
    cInput:SetKey(String, String) (at Assets/Plugins/cMonkeys/cInput/Scripts/cInput.cs:433)
    GameManager:Start() (at Assets/_SCRIPTS/GameManager.cs:195)
     
  42. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    This is a known issue that started occurring in Unity 5.4.x. The fix will be in our next release.

    If you have cInput Pro with source code access (which it appears you do), you can apply the fix yourself without having to wait for the update by editing cGUI.cs:
    Code (csharp):
    1. // change line ~69 from this:
    2. private static Color _bgColor = GUI.color;
    3. // to this:
    4. private static Color _bgColor;
    5.  
    6. // and add this somewhere in the script:
    7. private void Awake() {
    8.     _bgColor = GUI.color;
    9. }
     
    TechDeveloper likes this.
  43. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    Hi folks,

    An update to cInput has been accepted on the Asset Store. Whether you bought cInput from the Asset Store or on our website, the update should be available immediately.

    cInput changelog:

    v2.9.0

    • Corrected/added Keys class entries for Xbox One's View and Menu buttons.
    • Fixed error in Unity 5.4 about making an API call from the constructor. (Thanks Steven)
     
    TanselAltinel likes this.
  44. Studio_Akiba

    Studio_Akiba

    Joined:
    Mar 3, 2014
    Posts:
    1,421
    @Deozaan I have been trying to rebuild the controls in my project to work with cInput for the last 2 days (I know, I should have planned it from the start), but we are having a lot of trouble with a few things:

    1) We seem unable to use the Left joystick's left/right axis on the Xbox One controller, the axis just constantly receive a 0, nothing changes when moving the stick, but up and down work fine, we have tried using both the Keys Xbox method and manual Joy1... methods and nothing.

    2) While building our UI system to display the required key for certain actions, we tried to use a function using cInput.GetText but this appears to be causing massive issues, mainly being that the function doesn't seem to work.

    We are using this in our control script:
    Code (CSharp):
    1. cInput.SetKey("Interact", Keys.Mouse0, Keys.Xbox1X);
    And in the same script we have this function:
    Code (CSharp):
    1. public static string GetKeys(string keyDescription, int key)
    2. {
    3.         return cInput.GetText(keyDescription, key);
    4. }

    Which is called in another script like so:
    Code (CSharp):
    1. //Get primary control
    2. string key1 = AdvancedControls.GetKeys(keyControl, 1);
    3. //Get secondary control
    4. string key2 = AdvancedControls.GetKeys(keyControl, 2);

    But we receive the following error each time, which points to an issue in your script somewhere:
    Code (CSharp):
    1. IndexOutOfRangeException: Array index is out of range.
    2. cInput.GetText (Int32 index, Int32 input) (at Assets/cMonkeys/cInput/Scripts/cInput.cs:1200)
    3. cInput.GetText (System.String action, Int32 input) (at Assets/cMonkeys/cInput/Scripts/cInput.cs:1161)
    4. AdvancedControls.GetKeys (System.String keyDescription, Int32 key) (at Assets/Scripts/Character/AdvancedControls.cs:58)
    5. GetControlsForUI.GenerateControls (System.String keyControl) (at Assets/Scripts/UI/GetControlsForUI.cs:19)
    6. GetControlsForUI.Start () (at Assets/Scripts/UI/GetControlsForUI.cs:12)
    Have we simply done something wrong in calling this function, or is this a deprecated function?

    We are in need of accessing these controls as we have a setup like so:
    Code (CSharp):
    1. switch (key1)
    2.         {
    3.             case "Xbox1X":
    4.                 {
    5.                     key1Text = "XB_X";
    6.                     break;
    7.                 }
    8.             case "Xbox1B":
    9.                 {
    10.                     key1Text = "XB_B";
    11.                     break;
    12.                 }
    13.             case "Mouse0":
    14.                 {
    15.                     key1Text = "PC_/LMB";
    16.                     break;
    17.                 }
    18.             case "Mouse1":
    19.                 {
    20.                     key1Text = "PC_/RMB";
    21.                     break;
    22.                 }
    23.             case "Mouse2":
    24.                 {
    25.                     key1Text = "PC_/MMB";
    26.                     break;
    27.                 }
    28.             case "NONE":
    29.                 {
    30.                     key1Text = "C_NONE";
    31.                     break;
    32.                 }
    33.         }
    Which allows us to translate the controls from the GetText function into the icon calls for our UI setup.

    I am hoping we have just done something rather simple wrong, but I am not skilled enough to pull apart everything in unfamiliar code and work out what is wrong :|

    Any ideas?
     
  45. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    @Labyrith-Studios:

    For the horizontal axis on the Xbox One controller, I can't think of any reason why that should be happening. The most probable possibility that I can think of is that somehow your configuration is not set up properly to read input from that axis.

    Does the horizontal axis on the left stick return any values when using Unity's input system? If so, it should work with cInput assuming you've set up your inputs properly. If this continues to be a problem, I would be interested to know if you can reproduce it in a fresh project, and if so, can you send me that fresh project so I can take a look?

    As for GetText not working, my best guess is that the UI is trying to call GetText before cInput has been properly initialized and set up. If that's the case, then cInput doesn't know about the inputs before you're trying to get information about them, which would result in an out of range exception. Handling this error more elegantly is definitely something we need to fix on our end, so that it returns a string saying something like "invalid input" or similar instead of causing an error that breaks everything. But you can still fix the root cause behind the error (assuming my guess is correct) by initializing and setting up cInput in a "preloader" scene or by waiting a frame (or a few frames) after cInput is initialized to make sure it has loaded its settings properly before trying to access it.

    It's also possible that the UI/GetText issue is causing an error which is preventing other scripts from running/finishing properly, which may be the cause of the Xbox One horizontal axis issue.

    I hope this helps.
     
  46. Studio_Akiba

    Studio_Akiba

    Joined:
    Mar 3, 2014
    Posts:
    1,421
    Still haven't gotten to the bottom of the joystick issue, but the GetText error stopped for a while and I dismissed it as gremlins, until I duplicated the object the script was on, making the GetText instanced with a multiple.

    Now, the original works, but the other objects produce errors on GetText and don't receive anything.

    For example, I have the script on 3 objects now, the original gives no errors, but the other 2 produce a single error (same that I posted earlier), so I get the same error twice in this case.

    Any ideas on how I can create that delay? Do you have any code examples that would allow me to do this on a Start function?
     
  47. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    Sorry if my responses are delayed. Gmail is aggressively sending a lot of legitimate email (such as notifications about replies to this thread) to my spam folder lately.

    If I understand you correctly, your UI script(s) are trying to GetText in their Start functions? Adding a delay is pretty simple in Start since you can use Start as a coroutine:

    Code (csharp):
    1. IEnumerator Start() {
    2.     // do all your important stuff here that doesn't rely on cInput
    3.     // ...
    4.  
    5.     // initialize cInput (unless it is being initialized elsewhere)
    6.     cInput.Init();
    7.     // wait a second for cInput to properly initialize
    8.     yield return new WaitForSeconds(1f);
    9.     // now update your UI texts
    10.     myText = cInput.GetText(myInput, 1);
    11. }
     
  48. SullyTheStrange

    SullyTheStrange

    Joined:
    May 17, 2013
    Posts:
    147
    Hey Deozaan! Since you happen to be online and responding right now, I figured I'd ask before delving into figuring this out myself... My game has been using cInput successfully for a long time now with 360 controllers, but it just came to my attention that the D-pad on Xbox One isn't working correctly at all. Left and Right don't seem to be registering, and Up registers as right and Down registers as left. Any idea what the issue there is? Tried searching through this thread but couldn't find anything... but then again it's a very long thread. :confused:
     
  49. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    My guess is that it has something to do with Xbox One controllers sometimes having different button mappings than Xbox 360 controllers. The Keys class tries to compensate for this, but the button mappings aren't always consistent. For example, I think on Windows 10, the Xbox One controllers mapped differently from Xbox 360 controllers, but then after the Anniversary Update, some of the button mappings (but not all!) changed again to match the 360 button mappings.

    They Keys class just can't detect all the possible differences in OS versions, etc., so it makes a best guess, which can be wrong.

    Try using this Gamepad Tester to see what the actual buttons/axes are mapped to, and use those values instead of the Keys.Xbox* entries:

    Gamepad Tester for Windows
    Gamepad Tester for MacOS
     
  50. SullyTheStrange

    SullyTheStrange

    Joined:
    May 17, 2013
    Posts:
    147
    Both controllers match for me in the Gamepad Tester on Windows 10, D-pad left/right is Axis 6 and up/down is Axis 7, which I see is also what the Keys entries are set to... So shouldn't it be working fine?

    I realized I was still on cInput v2.8.9 and updated to v2.9.0, but that didn't help. I'm running Unity 5.3.4p6 if that might make a difference.