locked
XInput or DirectInput?

    Question

  • I need to interface a Playstation 2 controller through USB adapter with my application. A group of us are recreating Guitar Hero (kinda) as our final project in our Software Engineering course. I would just use the 360 Version of the guitar but it's not yet released. I was wondering whether I should use XInput or DirectInput. I've read that XInput is best for the 360 Controller, but what about a joystick through USB?
    Thursday, November 30, 2006 1:32 PM

Answers

  • As things move forward, game controllers for PC probably won't be sold as DirectInput devices. They will be sold as XInput devices. In which case, you won't need DirectInput for them because the XNA Gamepad device will do that. At that point, you won't need to maintain the old DirectInput code any longer. I fully expect the game controllers to declare their XInput-ness quite a while before Microsoft drops the DirectInput API.

     

    Thursday, November 30, 2006 8:04 PM

All replies

  • XInput is strictly for the 360 controller. I would like to see XInput's devices inside of DirectInput because the average user does not have a 360 controller. They should have a choice, but as you can tell XNA is quite dedicated towards the 360 rather than the PC which will still run the programs, but not to what the user expects. Maybe this will change in the near future. Right now, it's basically XInput for a 360 controller and DirectInput (if you're using C++) for everything else. Managed DirectX's DirectInput reference can be added if you're using C#, but it is no longer being updated on the managed side of things.
    Thursday, November 30, 2006 5:30 PM
  •  redshock wrote:
    Managed DirectX's DirectInput reference can be added if you're using C#, but it is no longer being updated on the managed side of things.

    Just to be fair about this, DirectInput isn't being updated for the unmanaged side of things, either. It's still 8.1 in both managed and unmanaged and MS doesn't seem to have any plans for an update.

    For Windows games, there is no reason not to use DirectInput for joysticks. Since you have to do separate compiles for Windows and Xbox with XNA anyway, you can just use DirectInput in your Windows version and stick with the Gamepad device for Xbox. A little creative wrapping will allow both versions to share a common, generic input architecture, while hiding the implementation details under the hood.

     

    Thursday, November 30, 2006 6:25 PM
  • Hmm, I never thought about that. Although that is true, Managed DirectX has been let go though, so I don't know if the current version of the Managed DirectInput reference is going to still work in later versions of .NET. I assume it will, but there's no telling kinda like DirectDraw. Microsoft can not afford not updating the native DirectInput COM file due to competative gaming on the Windows platform. I'm sure they will when they see the need, but I don't see them updating Managed DirectX's DirectInput simply because Managed DirectX was isolated all together, and definitely with little cost in the marketplace. Native DirectX is completely different. But if he's just using it for one project, I don't think it matters. I always look in the long run of things.
    Thursday, November 30, 2006 7:08 PM
  • As things move forward, game controllers for PC probably won't be sold as DirectInput devices. They will be sold as XInput devices. In which case, you won't need DirectInput for them because the XNA Gamepad device will do that. At that point, you won't need to maintain the old DirectInput code any longer. I fully expect the game controllers to declare their XInput-ness quite a while before Microsoft drops the DirectInput API.

     

    Thursday, November 30, 2006 8:04 PM
  • I tend to stay away from words like "probably" etc. because it's too beyond standards right now.  Right now it's DirectInput with XInput for a seperate controller. I can see DirectInput in the forseeable future much due to the vast majority of controllers out there. Developers have another COM file that does basically the same thing but for another set of controllers. Remember that XInput is compatable not just on the PC but the XBox 360. I highly doubt it will go beyond the 360 controllers because the XBox 360 just simply doesn't need to know about average Joe's PC gamepad, but most likely for the PC, a more broader COM file like DirectInput would. I enjoy XInput when it comes to the XBox 360, but saying I have to deal with two COM files now just for input is too tedious and error-prone to work with. XInput is there if you want to include support for the 360 controller, and surely gamers will experiment using it and see if it works, but that's the only reason why I would have to include XInput right now as a substitute for DirectInput. How that will change in the future is just not a concern right now. I'm just concerned about getting my game done now and worry about the future later. 
    Thursday, November 30, 2006 8:29 PM
  • DirectInput is likely to be supported for the life of Vista since DirectX9 is part of Vista. Sure its not been updated but thats becuase it does everything it needs to do. Sometimes you don't need to add to an API every 2 months.

    Back to your question. Does the USB adapter show the controller as a DirectInput device? If so then use it.

    XInput is great for its simplicity but there is no value in forcing a particlar API if its a lot of work.

    Friday, December 01, 2006 7:05 PM