Game Development Reference
In-Depth Information
public byte[] Button
{
get { return _buttons; }
}
public int X
{
get { return _x; }
}
public int Y
{
get { return _y; }
}
public int Z
{
get { return _z; }
}
The initialization method instantiates the device, sets the cooperative level, and
sets the notification event that is used to control the polling thread.
The following code shows the initialization method.
public bool Initialize(System.Windows.Forms.Form context)
{
_context = context;
The next two lines create a new thread that asynchronously polls the mouse device
for state changes and dispatches them back to the user.
_threadData = new Thread(new ThreadStart(this.AsynchronousPolling));
_threadData.Start();
The _eventTrigger is used by DirectInput to notify threads when the mouse state
changes. We use this event to control the asynchronous polling thread.
_eventTrigger = new AutoResetEvent(false);
try
{
SystemGuid contains constant identifiers for system devices for use with DirectInput.
SystemGuid.Mouse is associated with a mouse that has up to four buttons, or another
device that is behaving like a mouse.
Search Nedrilad ::




Custom Search