Sign in to follow this  
FenrirWolf

Interfacing with USB devices

Recommended Posts

Hmm, not sure what's a good place for this, so I am dumping it here... I'd like to know if anyone has any experience with interfacing with HID devices via USB. I've got a dance pad I would like to hook up to my game, and it's USB. I have no clue how to access the USB APIs in Windows. I've tried searching around on the net, but I mostly find references to USB driver toolkits. Any tips or just a nudge in the right direction would be appreciated. My dev environment is MSVC v6.0.

Share this post


Link to post
Share on other sites
Try to use DirectInput. If the device is supported by the HID subsystem, it will be enumerated in the DI device list.
If you have access to the DX8 or DX9 SDK try the %DXSDK_DIR%Samples\C++\DirectInput\Bin\DeviceView.exe sample.
The source code is located at %DXSDK_DIR%Samples\C++\DirectInput\DeviceView.
If you don't have the SDK, I can provide you with a link where you can download the sample app. Your pad should get listed in the sample app and you can toy a little with it. In case it doesn't get listed you will need to obtain a proper driver first.

Hope this helps,
Pat.

Share this post


Link to post
Share on other sites
If you need examples of this I am sure that you can download one ofe the games that uses a dance pad because most of them are open source. Try going to stepmania.com and downloading its code though I warn you that it will probably be pretty complex. For a slightly simpler project you may be able to get the source to dance with intensity(search for it).

Share this post


Link to post
Share on other sites
Darookie, good suggestion, I forgot that DI can enumerate HID devices. I tried that app, but unfortunately it crashes when it reaches the EnumDevicesBySemantics call. I'm not sure if this is a failing of the action map stuff, or something else. (It doesn't crash if the USB pad is unplugged.)

Yohumbus, I will check that out. I wasn't sure if any of them used the Pump it Up USB pads. But it's worth a shot!

PS: Thanks for the fast reponse. :) Oh, and I tried StepMania -- it does pick up his pad and works fine. So he'll check out the source.

[Edited by - FenrirWolf on November 24, 2004 9:32:25 PM]

Share this post


Link to post
Share on other sites
Okay! Got it to work. One thing that is required is the HID interface for MSVC. You can get it out of the Windows DDK. (All you really need is the HID interface library, hid.lib.)

And in that, the only thing you need is the calls to get handles to the HID devices. Then it's just a matter of opening it as a regular pipe and reading in using overlapped IO. Pretty dang simple.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this