Search Unity

  1. Unity 2017.2 beta is now available for download.
    Dismiss Notice
  2. Unity 2017.1 is now released.
    Dismiss Notice
  3. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  4. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  5. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    Dismiss Notice

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

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

  1. SullyTheStrange

    SullyTheStrange

    Joined:
    May 17, 2013
    Posts:
    146
    Okay, it seems the problem was that I was using the Keys.Xbox1* entries for everything... I took the 1 out of all of them and now it seems to be working perfectly for both 360 and Xbox One controllers. Does that make sense? o_O
     
  2. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    521
    Yes, that makes sense.

    The Keys class should return different values for the D-Pad between Xbox One and Xbox 360 controllers. That would be why it was working for one, but not for the other.

    But, since the Keys.Xbox[Button] (without any number immediately following "Xbox") checks any and all connected controllers and can't distinguish between 360 or One controllers when checking all connected controllers, since there may be one or more of both types of controllers connected simultaneously, it doesn't even try and just returns all values as if they were Xbox 360 gamepads.

    So that's why it makes sense and that's why it's working after you made that change.

    Maybe it's time for me to run more tests and see if 360 and One controllers match up, and stop supporting versions of Windows 10 before the Anniversary Update where the button/axis mappings didn't match up.
     
  3. Anguis

    Anguis

    Joined:
    Oct 17, 2013
    Posts:
    46
    Hi,

    For me binding slash is not working, it calls the slash binding when I press semicolon. I use a non-US keyboard.

    Any way to get this working?
     
  4. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    521
    What is bound when you press the slash using the cInput GUI menu?

    There isn't much we can do to support non-US keyboards since Unity itself doesn't support them very well. cInput uses Unity's keyboard mappings. So the trick is to figure out what Unity thinks the slash is on your keyboard and use that binding instead.

    But that's one of the nice things about having the controls be rebindable during gameplay. If some default mapping doesn't work, you can just pop open the menu and change it.
     
  5. Anguis

    Anguis

    Joined:
    Oct 17, 2013
    Posts:
    46
    Alright, I think you used something different than unity keycodes, they have the same problem using them directlly. The problem is not yours is from unity, but thank you anyway for the answer.
     
    Last edited: Jan 24, 2017
  6. Labyrith-Studios

    Labyrith-Studios

    Joined:
    Mar 3, 2014
    Posts:
    1,257
    @Deozaan I have imported System.Windows.Forms into my project and want to be able to control Cursor.Position using cInput, but the stick vertical and horizontal outputs are floats, not ints, do you have any tips on allowing me to do this?
     
  7. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    521
    I'm not sure I understand the problem entirely.

    If you're asking how to move the mouse cursor with cInput, then cInput doesn't work that way. cInput only reads values from hardware inputs such as mice, keyboards, gamepads, steering wheels, etc. It doesn't set the values or set the position of the mouse cursor.

    But if all you need is for cInput to give you ints instead of floats you can cast the floats to ints or round them to an int.

    Code (csharp):
    1. float myFloat;
    2.  
    3. void Update() {
    4.     myFloat = cInput.GetAxis("Horizontal");
    5.     // I believe this truncates past the decimal, so if myFloat is 0.7f, castToInt will be 0
    6.     int castToInt = (int)myFloat;
    7.     // this rounds to the nearest integer, so if myFloat is 0.7f, roundToInt will be 1
    8.     int roundToInt = Mathf.RoundToInt(myFloat);
    9. }

    You could then use these cast/rounded ints where you need an int. You can also cast/round in-place, for example:

    Code (csharp):
    1. int myInt = (int)cInput.GetAxis("Horizontal");
    2. int myRoundedInt = Mathf.RoundToInt(cInput.GetAxis("Horizontal"));
     
  8. CaptainChristian

    CaptainChristian

    Joined:
    Apr 3, 2013
    Posts:
    96
    I am experiencing this issue with two xbox 360 controllers, using cInput 2.9 and the latest Unity beta. If I push RT or LT on both gamepads at the same time it somewhat works.
     
  9. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    521
    Sadly, this is a problem with Unity itself. Unity has had a longstanding bug (or series of bugs) with Xbox controllers. This affects more than just cInput. And since cInput is just a wrapper around Unity's Input Manager, it unfortunately provides no workaround for this issue.

    See: https://forum.unity3d.com/threads/still-xbox-360-joypads-bug-on-windows-unbelievable.296519/
    And: http://www.gallantgames.com/posts/27/details-on-the-xbox-360-controller-bug-in-unity

    For more details about the Xbox controller bug(s).
     
  10. CaptainChristian

    CaptainChristian

    Joined:
    Apr 3, 2013
    Posts:
    96
    Ok. Is there any asset on the assetstore which is directly supported by cInput and circumvents the issue?
     
  11. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    521
    No, not that I'm aware of. Sorry.

    Rewired supposedly circumvents the issue by accessing DirectInput or XInput directly as needed instead of relying on Unity to do it correctly. But I've never used it and obviously don't provide support for it, so your mileage may vary.
     
  12. yumianhuli1

    yumianhuli1

    Joined:
    Mar 14, 2015
    Posts:
    55
    Hi,deozaan!
    Does your plugin support to set G27/G29 wheel,and how to do it,Is there a example?
    And I have a question with unity input,I used float Acc = Input.GetAxis("Acc"); in update
    function.First I got 1 in the debug console,but When I clicked clear or waited for about 20 seconds then I got 0!!!What is the problem?
    The Setting is Type:Joystick
    Axis:3rd axis

    Best Regards
     
    Last edited: Mar 25, 2017
  13. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    521
    Hi yumianhuli1,

    First of all, I am so sorry for not having responded earlier. For some reason I was not notified of your post.

    Yes, cInput should support G27 and G29 steering wheels, just like any other kind of input device. The basic rule of thumb is this: If Unity's built-in Input Manager supports it, then cInput should too. If you want to test out a device to make sure it is detected, you can try our WebGL demo. You can even download a trial "Dev Edition" of cInput which can be found on our Itch.io store page to make sure it will integrate into your project.

    I'm not sure I understand your question about "Acc" but it looks like you're using Unity's built-in Input Manager instead of cInput in the example code you wrote. We don't provide support for Unity, since we have no control over what the folks at Unity do with their engine.

    If you have further questions about or need help with cInput, we're happy to help you out. Under normal circumstances we are really good at responding within about 24-48 hours, but if for some reason we don't respond in a timely manner, try contacting us through our contact form or ping me on my personal Twitter account to see if I received your inquiry.
     
    Last edited: Aug 31, 2017