Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- Wiimote.cs-revBASE.svn000.tmp.cs Fri Mar 15 21:18:19 2013
- +++ Wiimote.cs Fri Mar 15 21:03:20 2013
- @@ -33,6 +33,11 @@
- /// </summary>
- public event EventHandler<WiimoteExtensionChangedEventArgs> WiimoteExtensionChanged;
- + /// <summary>
- + /// Event raised when a Wiimote is disconnected.
- + /// </summary>
- + public event EventHandler<EventArgs> WiimoteDisconnect;
- +
- // VID = Nintendo, PID = Wiimote
- private const int VID = 0x057e;
- private const int PID = 0x0306;
- @@ -307,26 +312,30 @@
- // grab the byte buffer
- byte[] buff = (byte[])ar.AsyncState;
- - try
- - {
- - // end the current read
- - mStream.EndRead(ar);
- + try {
- + // end the current read
- + mStream.EndRead(ar);
- - // parse it
- - if(ParseInputReport(buff))
- - {
- - // post an event
- - if(WiimoteChanged != null)
- - WiimoteChanged(this, new WiimoteChangedEventArgs(mWiimoteState));
- - }
- + // parse it
- + if (ParseInputReport(buff)) {
- + // post an event
- + if (WiimoteChanged != null)
- + WiimoteChanged(this, new WiimoteChangedEventArgs(mWiimoteState));
- + }
- - // start reading again
- - BeginAsyncRead();
- - }
- - catch(OperationCanceledException)
- - {
- - Debug.WriteLine("OperationCanceledException");
- - }
- + // start reading again
- + BeginAsyncRead();
- + }
- + catch (IOException) {
- + Debug.WriteLine("IOException");
- +
- + if (WiimoteDisconnect != null) {
- + WiimoteDisconnect(this, new EventArgs());
- + }
- + }
- + catch (OperationCanceledException) {
- + Debug.WriteLine("OperationCanceledException");
- + }
- }
- /// <summary>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement