Xbox LIVE Indie Games
Sort Discussions: Previous Discussion Next Discussion
Page 1 of 1 (9 posts)

Gamepad wrapper class with DirectInput

Last post 10/27/2010 5:40 PM by Charybdis. 8 replies.
  • 1/17/2010 6:35 PM

    Gamepad wrapper class with DirectInput

    This project will enable you to use any older gamepad controller with your game.
    Included are wraper classes so that you do not have to worry what kind of controller user has; it will all just work for you.
    Wraper classes suport Xbox controller, keyboard, and older gamepad controllers; and you can add your own!
    There are two projects in the zip file:
     - Configuration project - used to configure devices and save configs in an xml file
     - Sample Game Project - uses saved xmls to correctly use devices.

    Projects come in source files and with plenty of comments. It should be easy to modify for your own needs.


    What is needed:
    Visual Studio 2008
    XNA 3.1
    DirectX SDK


    when you start new XNA project:
    1)Open up Debug Menu and select Exceptions
    2)Select Managed Debugging Assistants and find LoaderLock
    3)Remove the selected value.
    and
    4)Add DirectX.DirectInput to your project references.


    When packaging this for end user, be sure that you include both XNA redistributable and directX redistributable.
    It is important that you place both game and configuration in the same folder, so that they can share Content folders since Configuration saves data there. The game loads configuration from the same folder.


    This has been tested with:
    wireless Xbox 360 controller, and recevier for PC
    Standard Keyboard
    Axis Pad, Gamepad
    Logitech Dual Action, Gamepad
    Logitech RumblePad, Gamepad

    Tested on XP Pro, Win 7 (PwnanOBrien), assumed to work on Vista.
    If you have any issues, pease post them here, so that we can continue to build upon this project.
    If you test other devices, please post your results here.

  • 1/18/2010 5:01 AM In reply to

    Re: Gamepad wrapper class with DirectInput

    I'm running Win7, and this project worked on my Logitech Dual Action, Gamepad

    Thanks for the code!
  • 1/18/2010 5:13 AM In reply to

    Re: Gamepad wrapper class with DirectInput

    daminator:
    When packaging this for end user, be sure that you include both XNA redistributable and directX redistributable.

    Since XNA 3.0 the XNA redist has include all the DirectX files you need so there is no need to include DirectX.

    However this project likely  needs at least DirectInput - it would be best to list the files needed rather than saying 'DirectX redist' becuase thats pretty big.

    You might also want to put the project up on sourceforge or codeplex... personal sebsites have a horrible history of not being around in 12 months when people need this code.
  • 1/19/2010 6:32 AM In reply to

    Re: Gamepad wrapper class with DirectInput

    The ZMan:
    daminator:
    When packaging this for end user, be sure that you include both XNA redistributable and directX redistributable.

    Since XNA 3.0 the XNA redist has include all the DirectX files you need so there is no need to include DirectX.

    However this project likely  needs at least DirectInput - it would be best to list the files needed rather than saying 'DirectX redist' becuase thats pretty big.

    I see two reasons to stay away from deploying such dlls: version control, and os control. Pulling down fresh directX redist and letting it install all dlls is safer, at least in my eyes.
    If someone was to create an example of how to safely deploy DirectInput dll, I am sure that XNA developers would use it.


    The ZMan:
    You might also want to put the project up on sourceforge or codeplex... personal websites have a horrible history of not being around in 12 months when people need this code.

    Agreed, file is now on sourceforge.

    Thanks for good advice!


  • 2/3/2010 5:16 PM In reply to

    Re: Gamepad wrapper class with DirectInput

    Im not sure I undestand this right... Are you saying that DirectX and thereby also DirectInput is included in XNA 3.0? cus I downloaded the entire DirectX SDK in order to just get DirectInput.dll, so it would be just lovely to find that it is allready avalible in XNA. I just cant seem to find it however... :(
  • 2/3/2010 6:10 PM In reply to

    Re: Gamepad wrapper class with DirectInput

    No DirectInput is NOT included with the XNA FX redist. If you use a wrapper like this you need XNA redist and part of the directx sdk. I suggested being more specific becuase XNA Redist includes the parts of DirectX that it requires so requiring that AND DX SDk duplicates many files and includes many that are not needed.

    You can package the parts of DirectX in your installer as you need (note that you can't just include the files - you MUST make an installation package). So becuase you ran the XNA Fx first you know that all the core stuff is there and all you need to include is dxsetup and dxinput files. See http://msdn.microsoft.com/en-us/library/ee416805(VS.85).aspx and http://msdn.microsoft.com/en-us/library/ee418267(VS.85).aspx
  • 10/26/2010 5:17 PM In reply to

    Re: Gamepad wrapper class with DirectInput

    This did not work with XNA 4.

    Any updates?
  • 10/26/2010 5:41 PM In reply to

    Re: Gamepad wrapper class with DirectInput

    You might want to check this post for an alternative that works with XNA 4.0.

  • 10/27/2010 5:40 PM In reply to

    Re: Gamepad wrapper class with DirectInput

    It is worth noting that this explictly uses Managed DirectX 1.1, which has been deprecated for some time.

    The current "DirectX End-User Runtime" includes the Managed DirectX 1.1 assemblies, but this will be removed in a future release.

    Managed DirectX 1.1 does not work with x64 or /anycpu (neither does XNA Game Studio 3.1).

    Managed DirectX 1.1 does not work with .NET 4.0 / VS 2010 (neither does XNA Game Studio 3.1).

    I'd recommend looking at using SlimDX or a custom interop DI wrapper to use DirectInput instead. Note that DirectInput8 itself (the native API) is built into the OS as of Windows XP SP2 and later, so you don't need the REDIST for that at all...
Page 1 of 1 (9 posts) Previous Discussion Next Discussion