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

XInput.NET - full support for Xbox 360 Controller (Windows)

Discussion in 'Made With Unity' started by speps, Dec 22, 2009.

  1. speps

    speps

    Joined:
    Oct 13, 2009
    Posts:
    22
    Hello,

    We developed this for a project we are currently making in our school. I hope you will find it useful, it became a must for us mostly because we will need vibrations.

    It's a plugin which makes available the XInput functions of Windows in an API similar to what you can find in XNA.

    I updated the Wiki page for Extensions and you can find more information about it here : http://speps.fr/xinputdotnet

    Cheers,
    Remi Gillig.
     
  2. m50

    m50

    Joined:
    Jul 26, 2009
    Posts:
    20
    I tested it out, and i love it! i just had one problem, and that was that the DLL's given in the Unity project were broken, so i had to download your source code and rebuild the DLL's. Other than that, it worked great. I couldn't figure out how to make it so that: "Oh, this camera is controlled by controller 1, this by controller 2, blah blah blah" without making seperate scripts for each, but oh well. Still, was great to see a more advanced xbox controller functionality! Also great to see an PC only plugin for unity for once (and finally!) instead of Mac only ones (grrr!).
     
  3. speps

    speps

    Joined:
    Oct 13, 2009
    Posts:
    22
    It seemed to work for me and for a friend as well. I'm glad that you managed to sort it out yourself. Thanks for the feedback!
     
  4. Bael

    Bael

    Joined:
    Jul 21, 2008
    Posts:
    106
    Thanks for this! Hopefully with the next release of Unity there will be full built-in support for the X-Box controller, but this will be nice to use in the meantime.
     
  5. speps

    speps

    Joined:
    Oct 13, 2009
    Posts:
    22
    Actually, the binaries on my website were Debug versions, not working on systems without Visual Studio 2008 installed. My mistake, it should be OK now, I updated the links on my website.
     
  6. ColossalDuck

    ColossalDuck

    Joined:
    Jun 6, 2009
    Posts:
    3,246
    It would be sweet if you could also get it working for mac!
     
  7. speps

    speps

    Joined:
    Oct 13, 2009
    Posts:
    22
    Unfortunately, this plugin relies on DirectX and thus can't work on Mac. Sorry, you'll have to head towards custom drivers for Mac.
     
  8. ColossalDuck

    ColossalDuck

    Joined:
    Jun 6, 2009
    Posts:
    3,246
    Aww, oh well.

    I don't personally have a mac, I just love cross-compatibility.

    Good job.
     
  9. KWright

    KWright

    Joined:
    May 8, 2010
    Posts:
    9
    Has anyone figured out how to use one script that assigns more than one controller? Currently I have two players using the same script, but the script assigns PlayerIndex.One to both controllers. I've tried setting a boolean to change a singe PlayerIndex class to either One or Two (considering I only need 2 players.) then checking the state of only that GamePad.

    My eventual goal is to check the state of two gamepads, if any of them are disconnected, a message will pop up. If one GamePad gets input it will move it's corresponding GameObject. This worked with Joystick[x]Button[x] but I can't figure out a similar route using this plugin.
     
  10. Bael

    Bael

    Joined:
    Jul 21, 2008
    Posts:
    106
    I don't have another controller handy, but at the barebones I believe you need something like the following:

    Code (csharp):
    1.  
    2. GamePadState Player1State;
    3. GamePadState Player2State;
    4.  
    5. PlayerIndex Player1Index = (PlayerIndex)0;
    6. PlayerIndex Player2Index = (PlayerIndex)1;
    7.  
    8. ...
    9.  
    10. Player1State = GamePad.GetState(Player1Index);
    11. Player2State = GamePad.GetState(Player2Index);
    12.  
    Then check the buttons for each player's controller using their specific GamePadState and handle accordingly.
     
  11. KWright

    KWright

    Joined:
    May 8, 2010
    Posts:
    9
    I guess I should have said the script was being applied to two different game objects, but I just turned it into a boolean to fix that. I've reworked the default input loop a bit but am still getting an error somewhere.

    It's not even a good error... I keep getting "expected ;" back, which I assume just means Unity can't think of anything better.

    Code (csharp):
    1.  
    2. if (bFirstPlayer)
    3.         {
    4.             iPlayerNumber = 0;
    5.             setPlayerIndex = PlayerIndex.One;
    6.             //sVertical = "Vertical";
    7.             //sHorizontal = "Horizontal";
    8.         }
    9.         else
    10.         {
    11.             iPlayerNumber = 1;
    12.             setPlayerIndex = PlayerIndex.Two;
    13.             //sVertical = "Vertical2";
    14.             //sHorizontal = "Horizontal2";
    15.         }
    16.  
    17. ...
    18.  
    19. if (!playerIndexSet || !prevState.IsConnected)
    20.         {
    21.            
    22.             PlayerIndex testPlayerIndex = PlayerIndex.One;
    23.             GamePadState testState = GamePad.GetState(testPlayerIndex);
    24.             for (int i; i < 4; i++; testPlayerIndex++)
    25.             {
    26.                 if (testState.IsConnected)
    27.                 {
    28.                        
    29.                     if (testPlayerIndex == setPlayerIndex)
    30.                     {
    31.                         Debug.Log(string.Format("GamePad found {0}", testPlayerIndex));
    32.                         playerIndex = testPlayerIndex;
    33.                         bPlayerIndexSet = true;
    34.                     }
    35.                     else
    36.                     {
    37.                         bPlayerIndexSet = false;
    38.                         Debug.Log("WHAAAAT");
    39.                     }
    40.                 }
    41.        
    42.             }
    43.         }
    44.  
    The error is apparently in the for loop, though doubtful.
     
  12. Bael

    Bael

    Joined:
    Jul 21, 2008
    Posts:
    106
    Ok, yea if you've got them on different objects each with the script than that could work.

    The error is this incorrect for loop:

    Code (csharp):
    1.  
    2. for (int i; i < 4; i++; testPlayerIndex++)
    3.  
     
  13. KWright

    KWright

    Joined:
    May 8, 2010
    Posts:
    9
    Thanks, I fixed the for loop and a few other errors that popped up later. After fixing everything it was still recognizing both controllers as player one, but I figured out why. Turns out one of my controllers was the wrong kind (XBCD or something), once I plugged in a different XBox controller it all worked fine.
     
  14. KWright

    KWright

    Joined:
    May 8, 2010
    Posts:
    9
    Hello again, same project, different question.

    I've hit a point where running a check on the GamePad state every frame, and in every script that requires input, is getting a little expensive.

    I've attempted to move the pad check into one script and just referencing it from each of the other scripts. At first I assumed that once the pads were assigned I could simply do (state = GamePad.GetState(One)) (or Two) and it would recognize the controller... this did not happen.

    I've now decided to create a function that returns the state and within each of the other scripts do something like (state = (Find("MainCamera").GetComponent("ControllerConnect") as ControllerConnect).RunCheck(One or Two)) but I'm not sure what to make the function. I know void doesn't work, and I've tried GamePad ControllerConnect() though that didn't work.

    Does anyone know either how to make a function like that work or a simpler way.

    Thanks
     
  15. AlexS

    AlexS

    Joined:
    Jun 30, 2010
    Posts:
    1
    Awesome plugin, works great. Except there is a quirky issue with calling Input.GetButtonDown and Up. they don't seem to work when using an input coming from the controller. I can't just use Input.GetButton because it makes my script perpetually execute when I only want it to once. Does anybody know what's going on with it or how to write a custom GetButtonDown script?
     
  16. almo

    almo

    Joined:
    Jul 14, 2010
    Posts:
    83
    I can't figure out everything in the state structure. I just tried

    Code (csharp):
    1. m_yPos = m_gamePad.state.ThumbSticks.Right.y;
    after hunting through pages of poorly indexed Microsoft documentation. But I get an access violation.

    How do I actually read the sticks using XInput?
     
  17. Minassian

    Minassian

    Joined:
    Nov 22, 2010
    Posts:
    40
    Hey.
    Is any way of making it work in the WebPlayer ?

    Thanks for the plugin !
     
  18. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    No, low level and system access is not possible in the webplayer
     
  19. HolBol

    HolBol

    Joined:
    Feb 9, 2010
    Posts:
    2,887
    NOw I'm really sorry to necropost, but can we have a JS version of this please? I have tried and tried and tried to get it working in JS, and just can't. I don't want to keep routing through another script in another language just to get inputs from the controller.
     
  20. Farfarer

    Farfarer

    Joined:
    Aug 17, 2010
    Posts:
    2,249
    This is the Javascript version I use, modified a bit from the regular C one (so I can simplify the code when referencing the pad state - i.e. if (XInput.buttonA) {}, but it should be simple enough to edit back.

    Code (csharp):
    1.  
    2. #pragma strict
    3.  
    4. import XInputDotNetPure;
    5.  
    6. var playerIndexSet : boolean = false;
    7. static var playerIndex : PlayerIndex;
    8. static var state : GamePadState;
    9.  
    10. // Static variables for
    11. static var h1 : float = 0.0;
    12. static var v1 : float = 0.0;
    13.    
    14. static var h2 : float = 0.0;
    15. static var v2 : float = 0.0;
    16.    
    17. static var buttonA : boolean = false;
    18. static var buttonB : boolean = false;
    19. static var buttonX : boolean = false;
    20. static var buttonY : boolean = false;
    21.    
    22. static var dpadUp : boolean = false;
    23. static var dpadDown : boolean = false;
    24. static var dpadLeft : boolean = false;
    25. static var dpadRight : boolean = false;
    26.    
    27. static var buttonStart : boolean = false;
    28. static var buttonBack : boolean = false;
    29.    
    30. static var shoulderL : boolean = false;
    31. static var shoulderR : boolean = false;
    32.    
    33. static var stickL : boolean = false;
    34. static var stickR : boolean = false;
    35.    
    36. static var triggerL : float = 0.0;
    37. static var triggerR : float = 0.0;
    38.  
    39. function Update () {
    40.     // Find a PlayerIndex, for a single player game
    41.     if ( !playerIndexSet ) {
    42.         for ( var i : int = 0; i < 4; ++i ) {
    43.             var testPlayerIndex : PlayerIndex;
    44.             switch ( i ) {
    45.                 case 0:
    46.                     testPlayerIndex = PlayerIndex.One;
    47.                     break;
    48.                 case 1:
    49.                     testPlayerIndex = PlayerIndex.Two;
    50.                     break;
    51.                 case 2:
    52.                     testPlayerIndex = PlayerIndex.Three;
    53.                     break;
    54.                 case 3:
    55.                     testPlayerIndex = PlayerIndex.Four;
    56.                     break;
    57.             }
    58.            
    59.             var testState : GamePadState = GamePad.GetState ( testPlayerIndex );
    60.             if ( testState.IsConnected ) {
    61.                 Debug.Log ( String.Format ( "GamePad found {0}", testPlayerIndex ) );
    62.                 playerIndex = testPlayerIndex;
    63.                 playerIndexSet = true;
    64.             }
    65.         }
    66.     }
    67.  
    68.     state = GamePad.GetState ( playerIndex );
    69.  
    70.     h1 = state.ThumbSticks.Left.X;
    71.     v1 = state.ThumbSticks.Left.Y;
    72.    
    73.     h2 = state.ThumbSticks.Right.X;
    74.     v2 = state.ThumbSticks.Right.Y;
    75.    
    76.     buttonA = ( state.Buttons.A == ButtonState.Pressed );
    77.     buttonB = ( state.Buttons.B == ButtonState.Pressed );
    78.     buttonX = ( state.Buttons.X == ButtonState.Pressed );
    79.     buttonY = ( state.Buttons.Y == ButtonState.Pressed );
    80.    
    81.     dpadUp = ( state.DPad.Up == ButtonState.Pressed );
    82.     dpadDown = ( state.DPad.Down == ButtonState.Pressed );
    83.     dpadLeft = ( state.DPad.Left == ButtonState.Pressed );
    84.     dpadRight = ( state.DPad.Right == ButtonState.Pressed );
    85.    
    86.     buttonStart = ( state.Buttons.Start == ButtonState.Pressed );
    87.     buttonBack = ( state.Buttons.Back == ButtonState.Pressed );
    88.    
    89.     shoulderL = ( state.Buttons.LeftShoulder == ButtonState.Pressed );
    90.     shoulderR = ( state.Buttons.RightShoulder == ButtonState.Pressed );
    91.    
    92.     stickL = ( state.Buttons.LeftStick == ButtonState.Pressed );
    93.     stickR = ( state.Buttons.RightStick == ButtonState.Pressed );
    94.    
    95.     triggerL = state.Triggers.Left;
    96.     triggerR = state.Triggers.Right;
    97. }
    98.  
    99. static function padVibration ( playerIndex : PlayerIndex, big : float, small : float ) {
    100.     GamePad.SetVibration ( playerIndex, big, small );
    101. }
    102.  
    103. static function stopPadVibration ( playerIndex : PlayerIndex ) {
    104.     GamePad.SetVibration( playerIndex, 0, 0 );
    105. }
    106.  
     
    Last edited: Jul 27, 2011
  21. HolBol

    HolBol

    Joined:
    Feb 9, 2010
    Posts:
    2,887
    WOW, thanks! Maybe this code should be sent to speps to include in the package?

    EDIT: Ok, I saved it as XInput.js- I'm now trying to call the static variable from another script..

    i have this :
    Code (csharp):
    1.     var v = XInput.v1;
    Yet I get this!
    Which is weird, because XInput is also in the scene, and yet this won't find it.
     
    Last edited: Jul 27, 2011
  22. Farfarer

    Farfarer

    Joined:
    Aug 17, 2010
    Posts:
    2,249
    Strange... it just worked for me. I stuck the XInput.js script on my main camera and it let me pull the static variables just by using XInput.v1 and similar calls.
     
  23. HolBol

    HolBol

    Joined:
    Feb 9, 2010
    Posts:
    2,887
    Yeah That's what I did. even If I reimport, refresh or even change the name of the script and change all the references accordingly, it still won't work.
     
  24. HolBol

    HolBol

    Joined:
    Feb 9, 2010
    Posts:
    2,887
    And also, if I try referencing it from the same GameObject, I STILL get an Unknown Identifier.

    EDIT: Screw it. I'll just use this to pick up triggers, I think. I can get everything else in the Input Manager.

    :(
     
    Last edited: Jul 27, 2011
  25. Farfarer

    Farfarer

    Joined:
    Aug 17, 2010
    Posts:
    2,249
    Might be a bit strange, but did you rename the .cs file to .js?

    If so, try deleting it and creating a blank javascript via the right click menu in Project pane, name it XInput.js then copy/paste the above code in and save it.

    I've seen some odd problems crop up before when renaming .cs files to another filetype.
     
  26. HolBol

    HolBol

    Joined:
    Feb 9, 2010
    Posts:
    2,887
    No, I copy and pasted your script in to a .js file, whith no errors. It's only trying to access it from other scripts that is the problem. As I said, I think this will only be useful now for the triggers, and for the rumble feature, because of this difficulty, and because of the lack of GetButtonDown support etc. It's either pressed or not, so it acts likeGetButton() all the time.
     
  27. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,458
    This is very interesting code... I wonder if I could get this working in Antares Universe when I script my characters... how do u install this into your current project
     
  28. Farfarer

    Farfarer

    Joined:
    Aug 17, 2010
    Posts:
    2,249
    I've updated the code so I can now have calls for button presses and releases.

    To use it, create a javascript file called XInput.js. Copy the big chunk of code below into it.

    Apply the script it to an object in your scene (I used the main camera as I know that'll always be in the scene).

    Then to get the values from any other script use XInput.one of those static vars.
    Code (csharp):
    1.  
    2. e.g.
    3. if ( XInput.buttonADown ) {
    4.     Debug.Log ( "The A button was pressed." );
    5. }
    6.  
    7. if ( XInput.buttonDPadUpUp ) {
    8.     Debug.Log ( "The up direction on the DPad was released." );
    9. }
    10.  
    11. Debug.Log ( "The vertical axis of left thumb stick is:" + XInput.v1 );
    12.  
    You'll need to have the files supplied by speps in the right place, too.
    XInputInterface.dll in [unity project directory]
    XInputDotNetPure.dll in [unity project directory]/Assets/Plugins

    If you're running Windows XP, you'll also need to install;
    http://www.microsoft.com/downloads/details.aspx?familyid=0E989B12-576B-42F2-B7C1-2A17CE25188B

    Updated code with button up/button down...
    Code (csharp):
    1.  
    2. import XInputDotNetPure;
    3.  
    4. var playerIndexSet : boolean = false;
    5. static var playerIndex : PlayerIndex;
    6. static var prevState : GamePadState;
    7. static var state : GamePadState;
    8.  
    9. // Static variables for
    10. static var h1 : float = 0.0;
    11. static var v1 : float = 0.0;
    12.  
    13. static var h2 : float = 0.0;
    14. static var v2 : float = 0.0;
    15.    
    16. static var buttonA : boolean = false;
    17. static var buttonB : boolean = false;
    18. static var buttonX : boolean = false;
    19. static var buttonY : boolean = false;
    20.  
    21. static var buttonADown : boolean = false;
    22. static var buttonBDown : boolean = false;
    23. static var buttonXDown : boolean = false;
    24. static var buttonYDown : boolean = false;
    25.  
    26. static var buttonAUp : boolean = false;
    27. static var buttonBUp : boolean = false;
    28. static var buttonXUp : boolean = false;
    29. static var buttonYUp : boolean = false;
    30.    
    31. static var dpadUp : boolean = false;
    32. static var dpadDown : boolean = false;
    33. static var dpadLeft : boolean = false;
    34. static var dpadRight : boolean = false;
    35.  
    36. static var dpadUpDown : boolean = false;
    37. static var dpadDownDown : boolean = false;
    38. static var dpadLeftDown : boolean = false;
    39. static var dpadRightDown : boolean = false;
    40.  
    41. static var dpadUpUp : boolean = false;
    42. static var dpadDownUp : boolean = false;
    43. static var dpadLeftUp : boolean = false;
    44. static var dpadRightUp : boolean = false;
    45.  
    46. static var buttonStart : boolean = false;
    47. static var buttonBack : boolean = false;
    48.  
    49. static var buttonStartDown : boolean = false;
    50. static var buttonBackDown : boolean = false;
    51.  
    52. static var buttonStartUp : boolean = false;
    53. static var buttonBackUp : boolean = false;
    54.        
    55. static var shoulderL : boolean = false;
    56. static var shoulderR : boolean = false;
    57.  
    58. static var shoulderLDown : boolean = false;
    59. static var shoulderRDown : boolean = false;
    60.  
    61. static var shoulderLUp : boolean = false;
    62. static var shoulderRUp : boolean = false;
    63.                
    64. static var stickL : boolean = false;
    65. static var stickR : boolean = false;
    66.  
    67. static var stickLDown : boolean = false;
    68. static var stickRDown : boolean = false;
    69.  
    70. static var stickLUp : boolean = false;
    71. static var stickRUp : boolean = false;
    72.  
    73. static var triggerL : float = 0.0;
    74. static var triggerR : float = 0.0;
    75.  
    76. function Update () {
    77.     // Find a PlayerIndex, for a single player game
    78.     if ( !playerIndexSet ) {
    79.         for ( var i : int = 0; i < 4; ++i ) {
    80.             var testPlayerIndex : PlayerIndex;
    81.             switch ( i ) {
    82.                 case 0:
    83.                     testPlayerIndex = PlayerIndex.One;
    84.                     break;
    85.                 case 1:
    86.                     testPlayerIndex = PlayerIndex.Two;
    87.                     break;
    88.                 case 2:
    89.                     testPlayerIndex = PlayerIndex.Three;
    90.                     break;
    91.                 case 3:
    92.                     testPlayerIndex = PlayerIndex.Four;
    93.                     break;
    94.             }
    95.            
    96.             var testState : GamePadState = GamePad.GetState ( testPlayerIndex );
    97.             if ( testState.IsConnected ) {
    98.                 Debug.Log ( String.Format ( "GamePad found {0}", testPlayerIndex ) );
    99.                 playerIndex = testPlayerIndex;
    100.                 playerIndexSet = true;
    101.             }
    102.         }
    103.     }
    104.  
    105.     prevState = state;
    106.     state = GamePad.GetState ( playerIndex );
    107.  
    108.     h1 = state.ThumbSticks.Left.X;
    109.     v1 = state.ThumbSticks.Left.Y;
    110.    
    111.     h2 = state.ThumbSticks.Right.X;
    112.     v2 = state.ThumbSticks.Right.Y;
    113.    
    114.     buttonA = ( state.Buttons.A == ButtonState.Pressed );
    115.     buttonB = ( state.Buttons.B == ButtonState.Pressed );
    116.     buttonX = ( state.Buttons.X == ButtonState.Pressed );
    117.     buttonY = ( state.Buttons.Y == ButtonState.Pressed );
    118.    
    119.     buttonADown = ( buttonA  prevState.Buttons.A != ButtonState.Pressed );
    120.     buttonBDown = ( buttonB  prevState.Buttons.B != ButtonState.Pressed );
    121.     buttonXDown = ( buttonX  prevState.Buttons.X != ButtonState.Pressed );
    122.     buttonYDown = ( buttonY  prevState.Buttons.Y != ButtonState.Pressed );
    123.    
    124.     buttonAUp = ( !buttonA  prevState.Buttons.A == ButtonState.Pressed );
    125.     buttonBUp = ( !buttonB  prevState.Buttons.B == ButtonState.Pressed );
    126.     buttonXUp = ( !buttonX  prevState.Buttons.X == ButtonState.Pressed );
    127.     buttonYUp = ( !buttonY  prevState.Buttons.Y == ButtonState.Pressed );
    128.    
    129.     dpadUp = ( state.DPad.Up == ButtonState.Pressed );
    130.     dpadDown = ( state.DPad.Down == ButtonState.Pressed );
    131.     dpadLeft = ( state.DPad.Left == ButtonState.Pressed );
    132.     dpadRight = ( state.DPad.Right == ButtonState.Pressed );
    133.    
    134.     dpadUpDown = ( dpadUp  prevState.DPad.Up != ButtonState.Pressed );
    135.     dpadDownDown = ( dpadDown  prevState.DPad.Down != ButtonState.Pressed );
    136.     dpadLeftDown = ( dpadLeft  prevState.DPad.Left != ButtonState.Pressed );
    137.     dpadRightDown = ( dpadRight  prevState.DPad.Right != ButtonState.Pressed );
    138.  
    139.     dpadUpUp = ( !dpadUp  prevState.DPad.Up == ButtonState.Pressed );
    140.     dpadDownUp = ( !dpadDown  prevState.DPad.Down == ButtonState.Pressed );
    141.     dpadLeftUp = ( !dpadLeft  prevState.DPad.Left == ButtonState.Pressed );
    142.     dpadRightUp = ( !dpadRight  prevState.DPad.Right == ButtonState.Pressed );
    143.        
    144.     buttonStart = ( state.Buttons.Start == ButtonState.Pressed );
    145.     buttonBack = ( state.Buttons.Back == ButtonState.Pressed );
    146.  
    147.     buttonStartDown = ( buttonStart  prevState.Buttons.Start != ButtonState.Pressed );
    148.     buttonBackDown = ( buttonBack  prevState.Buttons.Back != ButtonState.Pressed );
    149.  
    150.     buttonStartUp = ( !buttonStart  prevState.Buttons.Start == ButtonState.Pressed );
    151.     buttonBackUp = ( !buttonBack  prevState.Buttons.Back == ButtonState.Pressed );
    152.        
    153.     shoulderL = ( state.Buttons.LeftShoulder == ButtonState.Pressed );
    154.     shoulderR = ( state.Buttons.RightShoulder == ButtonState.Pressed );
    155.    
    156.     shoulderLDown = ( shoulderL  prevState.Buttons.LeftShoulder != ButtonState.Pressed );
    157.     shoulderRDown = ( shoulderR  prevState.Buttons.RightShoulder != ButtonState.Pressed );
    158.    
    159.     shoulderLUp = ( !shoulderL  prevState.Buttons.LeftShoulder == ButtonState.Pressed );
    160.     shoulderRUp = ( !shoulderR  prevState.Buttons.RightShoulder == ButtonState.Pressed );
    161.    
    162.     stickL = ( state.Buttons.LeftStick == ButtonState.Pressed );
    163.     stickR = ( state.Buttons.RightStick == ButtonState.Pressed );
    164.    
    165.     stickLDown = ( stickL  prevState.Buttons.LeftStick != ButtonState.Pressed );
    166.     stickRDown = ( stickR  prevState.Buttons.RightStick != ButtonState.Pressed );
    167.    
    168.     stickLUp = ( !stickL  prevState.Buttons.LeftStick == ButtonState.Pressed );
    169.     stickRUp = ( !stickR  prevState.Buttons.RightStick == ButtonState.Pressed );
    170.    
    171.     triggerL = state.Triggers.Left;
    172.     triggerR = state.Triggers.Right;
    173. }
    174.  
    175. static function padVibration ( big : float, small : float ) {
    176.     GamePad.SetVibration ( XInput.playerIndex, big, small );
    177. }
    178.  
    179. static function stopPadVibration ( ) {
    180.     GamePad.SetVibration( XInput.playerIndex, 0, 0 );
    181. }
    182.  
     
    Last edited: Aug 26, 2011
  29. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,458
    This is pretty cool...but i am hoping this will work with Antares... could I also apply this to the character model as well...?
     
  30. Farfarer

    Farfarer

    Joined:
    Aug 17, 2010
    Posts:
    2,249
    I have no idea how Antares works.

    You'd be better off asking whoever develops it how it can be integrated.

    You can apply it to the character model rather than the camera if you like. Or even just to an empty game object in the scene. It doesn't matter what - so long as it's applied to something in the scene.
     
  31. TheAssassin

    TheAssassin

    Joined:
    Jan 13, 2011
    Posts:
    51
    Is there a way to get the raw input without the deadzone effects? disable the deadzone maybe?
    Using the ThumbSticks.Left.X it doesn't send the raw data you can tell because the packet number increases when you wiggle the stick but there are no input changes.

    An interesting thing to note is that when you press the big Xbox button (you know the one that only microsoft can use) the packet number increases. Unfortunately you get the same effect when you wiggle the joysticks.
    So if it were possible to get the raw data of all the axis and buttons, wouldn't it be possible to make a toggle based on when there was a packet increase without any other inputs being recorded?

    Of course I would have to write my own deadzone code but I would rather do that myself anyway.
     
  32. TheAssassin

    TheAssassin

    Joined:
    Jan 13, 2011
    Posts:
    51
    Ok I figured out that you can get the raw input from the analog sticks by calling getstate(playerindex,GamePadDeadZone.None) unfortunately that does not give me the raw values for the triggers :S Any ideas where the problem is? I've been looking through the source code but haven't found where the plugin takes into account the deadzone for the triggers.
     
  33. Nathan Frost

    Nathan Frost

    Joined:
    Feb 11, 2013
    Posts:
    3
    XInputInterface.dll appears not to work on 64 bit Windows.

    Is the fix as simple as just rebuilding XInputInterface.dll in 64-bit, or are there other pitfalls?
     
  34. poofdragon

    poofdragon

    Joined:
    Aug 23, 2012
    Posts:
    36
    This helped me so much.

    I'm not sure what problem you're running into, but I'm running Windows7-x64 and these DLLs work fine. I would try making sure you have XInputInterface.dll in the proper location before trying to rebuild them (probably a little late on this, but for future's sake).
     
  35. PAEvenson

    PAEvenson

    Joined:
    Nov 12, 2009
    Posts:
    47
    I have a bizarre issue... I have 2 computers running windows7 64-bit professional. One runs with no issues what so ever, the other, I get a DLLNOTFOUND Exception for XInputInterface.

    The one that runs fine is the one building the project. I have no idea what I am missing on the other. Any suggestions?

    I've checked to make sure both DLLs are in the correct folders, root exe for XInputInterface.dll and data/Plugins for the XInputDotNetPure.dll. Both computers have the drivers for the controller as well.
     
  36. LCe

    LCe

    Joined:
    Jun 1, 2013
    Posts:
    38
    Hello,

    is it possible to make it work on Mac Unity Version ?
    I already installed tattiebogle.net driver witch recognize my controller.

    Any ideas ? I've got the error :
    DllNotFoundException: XInputInterface
    XInputDotNetPure.GamePad.GetState

    I'm using Unity Pro 5.0.2f1

    thx for your help