Game Development Reference
In-Depth Information
{
System.Diagnostics.Debug.WriteLine("PRODUCT
NAME: " + device.ProductName);
}
}
}
First, we create a variable named deviceList , get the list of game controllers, and
store it in this new variable. For the first parameter of the GetDevices() meth-
od, we pass in the value DeviceClass.GameController to tell it that we are
only interested in game controllers. For the second parameter, we give it the value
DeviceEnumerationFlags.AttachedOnly because we only want devices that
are actually installed and connected to the PC.
Next, we have an if statement that checks to see if the list of game controllers is
empty. If so, it prints a debug message to let you know that no game controllers are
connected to your computer. In the else clause of this if statement, we have a
foreach loop that iterates through the list of game controllers that we just retrieved
and stored in the deviceList variable. Inside the foreach loop, we have a single
line of code. This line simply writes a single line of debug output into Visual Studio's
Output pane for each game controller in the list. The Output pane is generally found
at the bottom of the Visual Studio window. You may have to click on the Output tab
in the lower-left corner of the window to display it if autohide is on. You can also ac-
cess it by going to the View menu and selecting Output .
By default, Visual Studio automatically displays the Output pane while you are run-
ning your program so that you can see your program's debug output, as shown in the
following screenshot. If it does not show the Output pane, see the preceding para-
graph for how to access it.
Next, go to the InitDirectInput() method and add the following line of code to
the end of the function:
GetJoysticks();
Search WWH ::




Custom Search