Now, it is time to create a simple game loop for our XBAP WPF application and to make the necessary changes to it in order to use our new joystick manager. This time, we will use it to read values from the steering wheel:
1. Stay in the
3DInvadersXBAP
project.2. Open
Page1.xaml.cs
.3. Add the following
private
variables in thepublic partial class Page1 : Page
, to hold an instance of theJoystick
class and the last time a frame finished its rendering:// Holds the time when the method finished rendering a frame private DateTime _LastTick; // The instance of the Joystick class to access the wrapper private Joystick _joystick;
4. Add the following lines of code before the end of the
Page
constructor:// Grab the joystick _joystick = new Joystick(); // Obtain the list of joystick style game input devices found string[] sticks = _joystick.FindJoysticks(); // Acquire the main joystick _joystick.AcquireJoystick(sticks[0]); // Save the current...