Game Development Reference
In-Depth Information
}
private void MainForm_Load(object sender, EventArgs e)
{
if (!_mouse.Initialize(this))
{
MessageBox.Show(“Error initializing asynchronous mouse. Exiting.”);
Application.Exit();
}
if (!_keyboard.Initialize(this))
{
MessageBox.Show(“Error initializing async device. Exiting.”);
Application.Exit();
}
}
private void MainForm_Activated(object sender, EventArgs e)
{
if (_mouse != null)
{
_mouse.Acquire();
}
if (_keyboard != null)
{
_keyboard.Acquire();
}
}
}
Conclusion
This chapter briefly discussed DirectInput and some advantages of using DirectInput
over the standard Microsoft Windows message pump. A solution was later pre-
sented that shows how to read input device data asynchronously from the mouse
or keyboard. This technique is very useful for graphic-intensive programs where
smooth input is required.
Search Nedrilad ::




Custom Search