private void wm_WiimoteChanged(object sender, WiimoteChangedEventArgs e) { if (e.WiimoteState.IRState.IRSensors[0].Found != lastSensor.on) { lastSensor = new SensorTime(e.WiimoteState.IRState.IRSensors[0].Found, lastSensor.date); } lastWMState = e.WiimoteState; }
/// <summary> /// Constructs a new WiiMoteAccess object. If there is no wiimote attached to the computer (and I guarantee this will happen at least once) /// </summary> public WiimoteAccess() { try { lastSensor = new SensorTime(false, DateTime.Now, TimeSpan.Zero); wm = new Wiimote(); wm.SetLEDs(true, false, false, false); wm.WiimoteChanged += new EventHandler <WiimoteChangedEventArgs>(wm_WiimoteChanged); wm.WiimoteExtensionChanged += new EventHandler <WiimoteExtensionChangedEventArgs>(wm_WiimoteExtensionChanged); wm.Connect(); wm.SetReportType(InputReport.IRAccel, true); lastWMState = wm.WiimoteState; lastAState = wm.WiimoteState.ButtonState.A; } catch (Exception) { DialogResult result = MessageBox.Show("A HIM Wiimote device was not found. Please ensure the WiiMote is connected to your computer" + " by a Bluetooth connection."); } }