Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Trying to workout XInput.NET

Discussion in 'Scripting' started by votekick, Jan 30, 2011.

  1. votekick

    votekick

    Joined:
    Mar 27, 2010
    Posts:
    104
    Hey all, I'm trying to workout how to utilize XInput.NET and sadly I'm fairly new to unity, and I'm not finding any useful documentation. It would be nice to get my Controller working using this.

    From what I've managed to figure out keeping in mind I'm not actually a programmer, and what programming I do is in JS. I've managed to get it detecting the Triggers and Thumbsticks

    Code (csharp):
    1.  
    2.     //R Stick X axis
    3.     if(state.ThumbSticks.Right.X > 0.5){
    4.     Debug.Log("StickR = Right");
    5.     }
    6.     if(state.ThumbSticks.Right.X < -0.5){
    7.     Debug.Log("StickR = Left");
    8.     }
    9.     //R Stick Y axis
    10.     if(state.ThumbSticks.Right.Y > 0.5){
    11.     Debug.Log("StickR = Up");
    12.     }
    13.     if(state.ThumbSticks.Right.Y < -0.5){
    14.     Debug.Log("StickR = Down");
    15.     }      
    16.     //Triggers 
    17.     if(state.Triggers.Right > 0.5){
    18.     Debug.Log("Right Trigger");
    19.     }
    20.     if(state.Triggers.Left > 0.5){
    21.     Debug.Log("Left Trigger");
    22.     }
    23.  
    That's all well and good but I'm having issues making the Buttons work, it would, triggering vibration would also be helpful but not overly necessary.

    For those who haven't seen this before but think its cool, (and chances are, you're smarter than I am and could solve my problem). You can get XInput.Net from here
    http://speps.fr/xinputdotnet
     
  2. Cameron_SM

    Cameron_SM

    Joined:
    Jun 1, 2009
    Posts:
    915
    You can use a 360 controller in Unity without XInput. The built in input manager joystick buttons and axis (WTF is the plural of axis? axii? meh) can be mapped any which way you want.

    The only thing you ~need~ XInput for is vibration as MS in their retarded wisdom have never seen fit to add any kind of haptic feedback API methods to DirectInput.
     
    Last edited: Jan 30, 2011
  3. votekick

    votekick

    Joined:
    Mar 27, 2010
    Posts:
    104
    Then I still have a question don't I?