Search Unity

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

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

  1. patricioaljndro

    patricioaljndro

    Joined:
    Mar 6, 2014
    Posts:
    12
    The issue is we have four joystick connected: a steering wheel, a genius Maxfighter F16, and two Logitech Attack -3. The Logitech joysticks when I set up on the menu each axis(up, right, left, down) work well, but the steering wheel and Maxfighter F16 don't, steering wheel reads only axis "Joy 1 Axis 1+" when I move it to right and left and when I press the pedal sets up in "Joy 1 Axis 2+", other pedal isn`t reading, in the other joystick(genius Maxfighter F16) happens the same, "Joy 4 Axis 1-" and "Joy 4 Axis 2-". for left and up, right and down don't.

    At the first everything was ok, but suddenly this issue began again, I tested to replace InputManager.asset for reboot and reimport all packages of project, when I did, this ran well for a moment, for one second really, but when I set up again, it happens again.

    Inside Windows and Games there are not problem.

    Thanks for you attention.
     
    Last edited: Mar 28, 2014
  2. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Posts:
    198
    Hey Patric,

    Can you please try the default unity inputmanager on the devices that don't work proper in cInput ?
    cInput uses the default inputhandling from unity and we build on that. So basicly, if unity can't read/use the inputdevice properly, we can't neither.

    So please try the default inputmanager on those steeringwheels. If they don't work there neither there is not much cInput can do there we don't provide any drivers of any kind, then the problem is with unity.
    If the steeringwheels do work fine though then we need to look closer into this to see what's going wrong.

    Please keep us updated...
     
  3. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    Good news, everyone!

    cInput v2.7.2 has been accepted on the Asset Store and should be available within the hour (if it isn't already).

    Here's a reminder of changes for this version:

     
  4. Erhune

    Erhune

    Joined:
    Sep 12, 2012
    Posts:
    7
    Hi there!

    Just wanted to report an issue with cInput 2. On the first run, when you have absolutely no PlayerPrefs at all for the project, _LoadInputs() exits immediately, so _cKeysLoaded will never be set to true in this run, and thus GetKey*() or GetButton*() with always return false. You have to re-start the game for your cInput to start working.

    One very dirty fix that solved the issue for my specific use-case was adding _cKeysLoaded = true; to the end of _SaveInputs().
     
  5. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    Thanks! This will be fixed in the next release of cInput. For now, anyone who encounters this issue can get around it by doing exactly what Erhune did. Or you can just place _cKeysLoaded = true; at the beginning of _LoadInputs()
     
  6. Deozaan

    Deozaan

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

    An update to cInput has been submitted to the Asset Store. If you bought cInput from the Asset Store then the update should be live within a few (business) days. If you bought cInput from our website, then the update is available immediately.

    cInput changes:

    v2.7.3
    • GetKey and GetButton functions now work on cInput's first run. (Thanks Erhune)
    • cInput now compares hashes instead of strings in many places. (Thanks Foxxis)
    • Make sure inversion status was saved before trying to load it. (Thanks nagisaki)
    • A debug warning is more clear and should show up less often.
    • Fixed a couple cases of redundant lookups. (Thanks Foxxis)
     
  7. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    cInput 2.7.3 should now be active on the Asset Store. Enjoy!
     
  8. Credd

    Credd

    Joined:
    Dec 4, 2013
    Posts:
    6
    I seem to have a strange problem where input is ignored completely.

    I have attached a reduced test case.
    It should log "HELLO" when space is pressed, but doesn't.
    (tested in both the newest and the previous version)

    Do you have any idea what's going wrong?
     

    Attached Files:

  9. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    I unzipped your project, opened it in the latest version of Unity, ran the "scene" scene and pressed spacebar.

    The console says "HELLO"

    $Hello.png

    So I'm not really sure what's wrong on your end. It's all working as it should on my end. Do you by chance have the editor paused?
     
  10. Credd

    Credd

    Joined:
    Dec 4, 2013
    Posts:
    6
    That is baffling..
    No it's not paused.

    I'm on win8.1 x64, surely that could not be related?


    [edit]
    I've created (another) new project and imported cInput and my Test.cs.
    And now it works.. Wtf.

    However, attempting to build it (or the demo scene) fails, with a bunch of

    Code (csharp):
    1. Assets/Plugins/cMonkeys/cInput.cs(340,29): error CS0116: A namespace can only contain types and namespace declarations
    2.  
    3. Assets/Plugins/cMonkeys/cInput.cs(355,29): error CS0116: A namespace can only contain types and namespace declarations
    4.  
    5. Assets/Plugins/cMonkeys/cInput.cs(396,28): error CS0116: A namespace can only contain types and namespace declarations
    6.  
    7. Assets/Plugins/cMonkeys/cInput.cs(401,28): error CS0116: A namespace can only contain types and namespace declarations
    8.  
    9. ...
    What the heck is going on o.o


    [edit 2]

    Ok, I've reinstalled unity, copied all the project settings from a new unity project to my project (but still using cInput's InputManager.asset of course), and now it works again.
    I have absolutely no clue what could have possibly been wrong with my project..

    Anyway, cInput works fine. Thanks!

    [edit 3]

    I believe my build problems are because of a misplaced #endif on line 343 in cInput.cs. This should be switched with the bracket on line 344.
     
    Last edited: Apr 9, 2014
  11. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    Indeed. I have no idea what that was all about. Very strange.

    Thanks for pointing that out! I'll have that fixed in the next version. Considering how important that tiny change is, I'll submit the update to the Asset Store right away!
     
    Last edited: Apr 9, 2014
  12. Yodzilla

    Yodzilla

    Joined:
    Mar 21, 2013
    Posts:
    48
    Just came here to ask about that issue. Thanks for the quick solution! :D
     
  13. Deozaan

    Deozaan

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

    cInput v2.7.4 is now live on the Asset Store and from the cInput website, and in addition to that, cInput is 50% off as today's Asset Store daily deal. Get it while it's hot. (c:

    cInput changes:

    v2.7.4
    • Fixed misplaced #endif which caused build problems. (Thanks Credd)
    NOTE: If you're having problems with cInput Dev Edition, please see this forum thread: Bug in cInput Dev Edition 2.7.2
     
    Last edited: Apr 12, 2014
  14. NeatWolf

    NeatWolf

    Joined:
    Sep 27, 2013
    Posts:
    924
    Hi,
    I'd like to know, is it possible to assign an analog axis to a button input(e.g.: Horizontal axis0+ -> right)? I was trying to configure my joypad on the online webdemo of cInput but wasn't able to do that.

    Also, is a NGUI/DFGUI custom redefine key-panel easily realizable with cInput2?

    Thanks for your time.
     
    Last edited: Apr 12, 2014
  15. Deozaan

    Deozaan

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

    Yes. you are able to assign analog axes (joysticks, triggers, steering wheels, etc.) to digital inputs. And you can even use digital inputs (keyboard keys, mouse buttons, gamepad buttons, etc.) in virtual analog axes. I'm not sure why you had troubles with the web demo. I just tried it and I was able to configure my Xbox 360 controller's left joystick and the left trigger to the up, down, left, right, and shoot actions.

    I don't have much experience with NGUI, and I have no experience with DFGUI. But I think if you're comfortable enough with either of those to dynamically create buttons that perform a unique function, then it should be possible to get working with cInput. The cInput GUI is designed such that you can iterate through an array to list all the elements necessary for displaying and rebinding the inputs.

    I hope this helps.
     
  16. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    Perfect timing! Bought this so I can provide support for it in my Asset.

    Thanks!

    jrDev.
     
  17. Sicco

    Sicco

    Joined:
    Jun 11, 2012
    Posts:
    1
    Hi Deozaan,

    I have a problem with the Unity3D axis. I am using a Logitech G940 and/or a sidewinder FFB 2. The input Unity detects is completely wrong. If I keep my joystick centred..Unity reads it as -1. If I push it left..Unity reads it as -1. Only when I push my stick to the right ..it reads the input from 0 to 1.

    Windows 7 reads the input without error outside Unity3D. Also..xbox controller seem to work properly in Unity3d. It seems a bug in Unity3d and I didn't find a sollution which fixed it for me yet.

    I read your tool is bypassing the Unity3D system. Can you tell me if your tool would fix this proble for me?? maybe?


    I was wondering
     
  18. Deozaan

    Deozaan

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

    cInput does not bypass Unity's Input Manager. Rather, it is a wrapper around the Input class which allows you to change keybindings at runtime. So I'm afraid that if Unity doesn't read your input correctly, cInput probably won't either.

    That said, you may want to consider submitting a bug report about your input issues if it is indeed a Unity error.

    I hope this clears things up.
     
  19. Hoeloe

    Hoeloe

    Joined:
    May 9, 2013
    Posts:
    31
    I'm having issues mapping my controls onto a controller. I have an Xbox controller connected to my computer (and the light is showing it is player 1). However, I can't seem to get any of the axes to work. I can supply buttons using JoystickButtonX, but none of the numbered controller inputs work, including buttons. Do you have any idea why this might be?
     
  20. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    Are you sure the Unity is detecting the gamepad properly? Note that even if the light shows player 1, Unity might still recognize it as something else. For example, my Xbox 360 controller has a light for player 1, but at the moment Unity sees it as Joystick2.

    But if Unity's Input Manager can see the controller, then cInput should also be able to see it.
     
  21. Hoeloe

    Hoeloe

    Joined:
    May 9, 2013
    Posts:
    31
    Well, I've done a bit of experimenting, and it seems that it's detecting the gamepad as controller 2, but also with the axes jumbled. For example, the triggers, which are apparently supposed to be axis 9 are detected as axis 3. This is a little concerning, as I'm not sure if it will remain consistent across machines, which it needs to do in order to work in the way I intend.
     
  22. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    Which platform are you developing on? Windows? Mac? Are you sure you have the proper drivers installed for the controller, and that your OS recognizes the device as an Xbox controller?

    Xbox 360 triggers are a little bit strange. They bind to both Axis 3 as well as something like Axis 9+ (LT) and Axis 10+ (RT). Axis 3 can be troublesome because the LT give a negative value and the RT gives a positive value, which means if you have them both pressed down, they cancel each other out and it's as if neither are down. So there's code in cInput that should detect the triggers and force them to bind to axes 9 and 10 as appropriate. The fact that it's not mapping correctly for you makes me believe the drivers aren't installed, so your OS isn't recognizing the gamepad as an Xbox controller. Or maybe you're on a Mac and it works differently than it does for me on Windows.
     
  23. Hoeloe

    Hoeloe

    Joined:
    May 9, 2013
    Posts:
    31
    I'm on Windows 8.1. I definitely have the drivers installed, since I use this controller for gaming generally. It seems that axis 3 works, but axis 9 and 10 don't. I'll have to experiment more.

    Also, I'm finding that there's another problem which is making this system essentially useless for my needs, and that is the response of GetButton. When I have this assigned to a key, then it works perfectly fine. However, when I have it assigned to an axis (Xbox triggers, for example), it produces some odd results, and looks to me (though I haven't confirmed this) to not respond at all. Here's a summary of what I'm trying to do: When you press a key, you perform an action. When you hold down the key, along with another key, you perform a variation on the action, that you can continue as long as you hold the key down (for reference, it is similar to the drifting mechanism in Mario Kart). When I do this with button presses, it all works fine. When I have the Xbox trigger assigned to the key, though, it always performs the first variation (for the Mario Kart reference, a small hop), rather than the action it should perform when held down (MKs drifting). I'll keep looking into exactly what it is doing, but this is extremely odd.

    EDIT: I've determined the source of the second issue, and it appears to be a bug. It seems that, when axes are involved, GetButtonDown returns the same value as GetButton, which makes holding the trigger down act as though it is being repeatedly pressed.

    EDIT EDIT: It also seems that GetButtonUp also returns the same value as GetButton.
     
    Last edited: Apr 15, 2014
  24. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    This is puzzling. As far as I can tell in my tests, the Xbox controller is working fine for me on Windows 7 x64. Have you tried something simple such as restarting Unity or even your OS?
     
  25. Hoeloe

    Hoeloe

    Joined:
    May 9, 2013
    Posts:
    31
    I haven't, I may well do that and report back. I've found a workaround for the other bug, which is to use !GetButton instead of GetButtonUp, and use booleans to mark when the button has been pressed myself. This bug, however, does limit me in one way, which is quite sad. I mentioned Mario Kart as my example for a reason, and that is that I'm making a similar kind of game. The drifting mechanic, however, is based on Crash Team Racing. In that game, you could drift with either of the shoulder buttons, and boost by pressing the other one. This would be possible with cInput without this bug, because GetButtonDown is called when the secondary input is pressed while the primary one is held (I checked). However, because this bug means that GetButtonDown is always called, and that I have to use !GetButton to approximate GetButtonUp, this second response from GetButtonDown never happens, so I'm unable to use this kind of input. Would it be possible to look into this and see if it's possible to mend?

    EDIT: In the mean time, I might augment the cInput class to allow me to check for primary and secondary inputs individually, which would allow me to handle the inputs properly. I'll also have a look and see if I can spot the source of the bug.

    EDIT EDIT: I think it might just be Unity's Input class' weirdness in using GetKey on joystick axes. If it is, it may be reasonably easy to sort out, by using the same trick I did previously, which was to treat a non-zero axis as a "press", and manually log when the axes were released. I'm not sure it will fix the issue with secondary inputs, but that should be possible by storing each input's previous value separately.
     
    Last edited: Apr 15, 2014
  26. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    I'm not sure I understand what you're trying to do or what the problem is.

    To be clear:
    GetButton: Should be true for every single frame as long as the button is pressed.
    GetButtonDown: Should be true only on the single frame when the button is first pressed.
    GetButtonUp: Should be true only on the single frame when the button is first released.

    Are you saying that GetButtonDown is returning true every frame when both triggers are pressed?

    Wouldn't it make sense to have your "hop" happen on GetButtonDown and the "drift" happen on GetButton (maybe after a short delay or after checking that the hop animation is over)?
     
  27. Hoeloe

    Hoeloe

    Joined:
    May 9, 2013
    Posts:
    31
    No, what I'm saying is that GetButtonDown and GetButtonUp are both returning true every frame when one trigger is pressed. That is, in fact, exactly how my hop works, but it also stops trying to "drift" when GetButtonUp receives a response, which it seems to be getting every frame.

    I seem to remember I had some issues with this a while ago when I was using Unity's built in Input system. My solution was to use a boolean array to store the last seen value of the trigger, and handle everything manually entirely based on GetButton. It should be possible to do a similar thing from inside cInput. The only reason I can't from outside it is that when a primary key is held, and the secondary key is pressed, GetButtonDown is called for the frame the secondary key is pressed, even though the primary key is already held down. This requires the value of each the primary and secondary key to be logged separately, which I can only do from inside cInput (I will probably edit it myself in order to sort this out).

    EDIT: Looking closer at the cInput code, it seems something like this is already implemented. It doesn't appear to be working though, going to do some testing of the cInput code to see what's going on.
     
    Last edited: Apr 16, 2014
  28. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    I have confirmed this bug. It seems when only one trigger is mapped to an input, GetButtonUp and GetButtonDown fire correctly, just once on their appropriate frame. But when both triggers are mapped to an input, GetButtonUp, GetButtonDown, and GetButton all return true every frame. I'll look into this more and fix it.
     
  29. Hoeloe

    Hoeloe

    Joined:
    May 9, 2013
    Posts:
    31
    I think I've actually worked out why. I think it's this section of code here:
    I believe that, because _axisTriggerArray is shared between primary and secondary inputs, what happens is that the code sets the value in the array to true in the GetKeyDown section of the code, then, because the secondary axis is not being pressed, immediately sets it to false again, which causes both GetKeyUp and GetKeyDown to return true continuously.

    There are two fixes. The first is to change the or in
    to an and. This will solve the bug, but will still result in slight different behaviour for tiggers. The best solution is to use two arrays, _axisTriggerArrayPrimary and _axisTriggerArraySecondary, which track the inputs individually. That way, you solve the problem, and also allows GetKeyDown to be called in obscure but correct circumstances, such as the one I described in my last post.


    EDIT: I believe swapping the code above out for this will fix the bug (as well as declaring the new arrays):

    EDIT EDIT: Some more testing has lead to that code causing some odd bugs, let me look at it in a bit more detail.

    EDIT EDIT EDIT: Have fixed those by removing the axisPrimaryDefined test at the start of the GetKeyDown section. If I'm right in my understanding, that line was there erroneously and was causing some problems.
     
    Last edited: Apr 16, 2014
  30. rbarbosa

    rbarbosa

    Joined:
    Jun 20, 2012
    Posts:
    61
    Hey folks...I'm sorry if this has been asked and answered already, but does this product "unify" input across different controller types?

    For example, the Xbox 360 controller has 4 main face buttons at 12, 3, 6, and 9 o'clock. The OUYA controller also has buttons in the exact same positions, but Unity's default input manager sees them as separate orientations, so pressing the 9 o'clock button on either controller behaves differently compared to the other.

    There is actually an OUYA community-provided solution, but it's really just for that issue. It doesn't offer any of the extra trim that cInput provides.

    If cInput unifies the settings of various controllers, then it's pretty much a no-brainer purchase.

    Thanks!
     
  31. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    Thanks Hoeloe,

    It seems you and I were both working on a solution at the same time. Here's mine:

    http://pastebin.com/AhCiwLRc

    The only potential problem I can see with this as it stands now is that if the primary input is still being pressed and the secondary input is released, then GetButtonUp will be triggered.

    I'm not sure if that's desired or not. . . Should I make it so that GetButtonDown only triggers on the first frame that either input is pressed, but not if one of them is already pressed? And similarly for GetButtonUp, should it only trigger on the first frame that neither input is being pressed?
     
  32. Hoeloe

    Hoeloe

    Joined:
    May 9, 2013
    Posts:
    31
    I was going for having it work as much like key presses as possible. For regular keys, GetButtonDown is called when either is pressed, regardless of the state of the other input (and this is sometimes desirable, particularly when using shared inputs). As for GetButtonUp, I assume that's the same, but I don't actually know. I feel it probably is the case, but worth checking. I think it's sensible to keep things consistent for the user.
     
  33. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    I only have an Xbox controller to test with, so I can't say for certain. But based on your description I would have to guess that the answer is no. cInput uses Unity's input manager to accomplish its tasks. So if JoystickButton1 is the 3 o'clock button on Xbox but the 12 o'clock button on OUYA, then that's how it will be in cInput as well.

    Though, I suppose if folks who had the controllers to test with could get the information to me, I could provide a work around in the Keys class.

    e.g., Keys.XboxButtonX could map to JoyStickButton1 while Keys.OUYAButtonO could map to JoyStickButton3. (I'm making those up just for the sake of an example because I don't know off hand what they should actually map to.)
     
  34. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    In that case, with my solution above, GetButtonDown will return true on the first frame that either input is pressed, even if the other one is currently still being pressed. And GetButtonUp will return true on the first frame that either input is released, even if the other one is still being pressed. So that sounds like how you want it. (c:
     
  35. Hoeloe

    Hoeloe

    Joined:
    May 9, 2013
    Posts:
    31
    I think our two solutions are semantically equivalent, so that all seems in order. Now I just have to work out why axes 9 and 10 aren't working...

    Hmm... seems this is to do with not using XInput. Can I just ask whether you used that or not? I'd quite like this game to be available on Linux and Mac, too, if at all possible, and as far as I can see, XInput isn't really adopted on those platforms.
     
    Last edited: Apr 16, 2014
  36. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    Have you tried using Keys.Xbox2TriggerLeft and Keys.Xbox2TriggerRight in your setup script?
     
  37. Hoeloe

    Hoeloe

    Joined:
    May 9, 2013
    Posts:
    31
    Yup. Does nothing.
     
  38. Hoeloe

    Hoeloe

    Joined:
    May 9, 2013
    Posts:
    31
    Not sure if this will interest you or not, but I've managed to get cInput to accept generic axis inputs (accepts axis inputs from any controller, as per the JoystickButtonN keys) by adding 20 (2 for each axis) special inputs, that are parsed in the same way as a regular axis, except when _GetCalibratedAxisInput is called, where it converts the axis to 4 separate strings (one for each controller) and iterates over the inputs for each.

    I think this feature could be incredibly useful for games with no local multiplayer, as it doesn't force the user to worry about which port their controller has been assigned to. It might be something worth considering for a later version.

    EDIT: On another note, I've encountered another bug. It seems that GetKeyDown returns true for all keys immediately after ChangeKey is called. This is irritating, as I'm trying to construct my own GUI for control input, and it's making it impossible to set any of the keys (as they are immediately reselected).
     
    Last edited: Apr 16, 2014
  39. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    I'm not getting that behavior in my tests. I wonder if it's a result of some of the customizations you've made to cInput, especially since we both made changes to GetKeyDown, though we did it in different ways. Or perhaps it's related to the new special inputs you added where it will accept input from any gamepad?

    Or maybe I'm just not testing in the correct way. If you can share some code with me (preferably a pastebin or the likes) so that I can see this behavior myself, then I'll be able to get a better idea of what's going wrong.
     
  40. Hoeloe

    Hoeloe

    Joined:
    May 9, 2013
    Posts:
    31
    Interesting. It's possible it may be related to the changes I've made, but I'll send you the code that caused the problem anyway. I have it set up with a workaround for now (just keeping a boolean that prevents the input from being registered until one frame after the change), but I'll send you a pastebin link anyway, with a simplified version of the code that caused the problem (I won't paste the full thing, because it's a little long, and a lot of it is irrelevant): http://pastebin.com/yp0h7J9T
     
  41. Credd

    Credd

    Joined:
    Dec 4, 2013
    Posts:
    6
    Hey,

    I'd like to be able to reset a single axis. How can I best achieve this? Is it simply setting _getAxis[axis] to 0?

    [edit]
    I believe the following is functional. Perhaps you could check/add it to cInput? :)

    Code (csharp):
    1.  
    2.     public static void SetAxisZero(string axisName) {
    3.         _cInputInit(); // if cInput doesn't exist, create it
    4.         int axis = _FindAxisByDescription(axisName);
    5.         if (axis == -1) {
    6.             // axis not defined!
    7.             Debug.LogError("Cannot set " + axisName + " to zero. Have you defined this axis with SetAxis() yet?");
    8.         } else {
    9.             // axis has been defined
    10.             int neg = _makeAxis[axis, 0];
    11.             if(neg != -1)
    12.                 _getAxis[neg] = 0f;
    13.            
    14.             int pos = _makeAxis[axis, 1];
    15.             if(pos != -1)  
    16.                 _getAxis[pos] = 0f;
    17.         }
    18.     }
    19.  
     
    Last edited: Apr 17, 2014
  42. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    I'm having trouble getting your example code to work. It won't compile as it is (which I fixed by adding a "using System;" at the top) but I'm having to make more and more changes to it to get it to run without errors. But in what I've been able to succeed in, I still don't get any GetKeyDown returning true when it shouldn't.

    I don't really understand this request. GetKey (and its variants) and GetAxis (and its variants) are supposed to be read-only. You're not supposed to be able to set the value of an axis or a key. If you want an input to give a zero value, stop pressing the input. If it's not giving you a zero value, then I think setting it to zero shouldn't do any good since cInput will poll the input on the next frame and give a non-zero value again.
     
  43. Hoeloe

    Hoeloe

    Joined:
    May 9, 2013
    Posts:
    31
    Well, it wasn't my actual code, just sample code based on my actual code. It seems that it might be my changes causing the problem. As long as it works for you, then there's no issue, as I've implemented a workaround that sorts everything out.
     
  44. Bradamante

    Bradamante

    Joined:
    Sep 27, 2012
    Posts:
    300
    Hi,

    I'm not sure if cInput is for me.

    In my game I'd like to have two-player local multiplayer support, i.e. two players playing on the same computer. One player could use the keyboard, the second player a gamepad. Can cInput help me with this?

    Additionally, I'd like to support all kinds of gamepads, the 360 controller, the Dualshock 3, the Logitech F310 etc. And I'd like to be able to rebind the controls in the game for both the keyboard and the gamepads. Can cInput help me here?
     
  45. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    Yes, this is exactly the kind of thing cInput was designed to do.
     
  46. Raveler

    Raveler

    Joined:
    Sep 24, 2012
    Posts:
    40
    Just wanted to say thanks for fixing this issue with the secondary inputs! I've been looking for the cause of the problem all day, and it only occured to me just now to check this thread and look for a fix. Thanks!
     
  47. Raveler

    Raveler

    Joined:
    Sep 24, 2012
    Posts:
    40
    I have another question. I want to detect half-way values for joysticks - ie, when the joystick is pressed halfway, I should get a 0.5 value, while I should get a 1.0 value when it is pressed all the way. This is different from the Axis system, which does not make a difference between pressing the joystick hard and pressing it softly - gravity and sensitivity just determine how long it takes to get to 1.0.

    I really want to detect soft and hard presses. Do you have an idea about how I can do this?

    Thanks!
     
  48. Deozaan

    Deozaan

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

    Hmm... I thought I had changed it so that it doesn't go all the way up to 1 or down to 0 if it wasn't pressed that far. But if not, I think you should at least be able to do this with GetAxisRaw.
     
  49. Tanshaydar

    Tanshaydar

    Joined:
    Apr 20, 2011
    Posts:
    33
    Hi;
    I'm using cInput for mouse x and mouse y axes. I'm using DeadZone, Gravity and Sensitivity settings exactly as Unity's own Input manager's settings, however when I change Input.GetAxis to cInput.GetAxis, mouse movement becomes very stiff and gets accelerated on time.

    I'm setting axes like this:
    cInput.SetAxis("Mouse X", "Mouse Left", "Mouse Right", 0.1f, 0, 0);
    cInput.SetAxis("Mouse Y", "Mouse Down", "Mouse Up", 0.1f, 0, 0);
    default values are from Unity's own Input manager.

    How can I solve this? By trial and error? Also, is it possible to assign a value from horizontal slider as sensitivity? Because when a joystick is plugged in, players should be able to use second analog stick instead of a mouse.

    Regards.
     
  50. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Posts:
    198
    hey Tanshaydar,

    I'm not sure i answered you allready on mail, but here we go...

    I think for mouse axis it's best to use cInput.GetAxisRaw(). That way you are sure to get the same results as unity's input. A mouse will always behave differend then a joystick axis, so it's hard to use the same input for both.

    about the sensitivity:
    This is explained in the manual:

    // sets the sensitivity of a previously defined axis

    cInput.SetAxisSensitivity("Horizontal", 0.5f);

    You need to code your own slider in your guiscript. It's not in the default guimenu. Just make a slider with a float from 0 to 1 and use that to set the sensitivity.