   DirectInput and Joystick
  I''m writing input engine for my game but get stuck in understanding how to use joystick in DirectInput. I look at the DXSDK tutorial, search the web, and find out that you basically enumerate joysticks attached to the computer. If you find one, you create the device, stop enumerating, and start using it.But, what about if there are two or more joystick attached to the computer? Aren''t we supposed to let users choose which joystick they want to use? If using the code from DXSDK, you don''t give such option. You just use the joystick that gets enumerated first and "force" users to use it.So, I''m kind of confused here...Any help is good.    My compiler generates one error message: "does not compile."
  I suspect you are having problems understanding the enumeration.  The enumeration calls the callback function once for each joystick.  Within the callback function you create the device for that joystick.  Therefore, if there are two joysticks the callback function will be called twice - and, in turn, two devices will be created.  Make sure you are using an array of device pointers, and not overwriting the same one.In the SDK sample they return DIENUM_STOP after the first valid joystick is found.  You would want to return DIENUM_CONTINUE to ensure all attached joysticks are found.  But, as I mentioned, you will need to store an array of pointers and not just have one global pointer, as they do in the sample.So, if you have two joysticks you will have two device pointers after they have been enumerated.You can then let the user choose which joystick they wish to use, and use the respective device pointer in the game.I hope this clears things up.John    John ReynoldsCreative Asylum Ltdwww.creative-asylum.com[edited by - John Reynolds on November 21, 2002 4:36:17 AM];  Thanks for the help. I know what a callback function is. I also think what you said. I just get confused with DIENUM_STOP, because it will stop the enumerating process where it shouldn''t. I browse the web, hoping to find an example that will continue enumerating even you find one, but what I found are exactly the same in SDK.    My compiler generates one error message: "does not compile.";  As John had mentioned, never return the DIENUM_STOP value, only return DIENUM_CONTINUE. For every time the enumeration function is called, just store the joystick name and GUID, then return DIENUM_CONTINUE. Once enumeration is done, let the user pick from the list of joystick names you stored and use the appropriate GUID.