public override void Load() { IsEnabled = true; try { _wiimote = new Wiimote(); _wiimote.Connect(); _wiimote.InitializeMotionPlus(); _wiimote.WiimoteChanged += wiimote_WiimoteChanged; _wiimote.SetRumble(true); _wiimote.SetLEDs(true, false, false, true); Thread.Sleep(40); _wiimote.SetRumble(false); RawPosition = new Vector3D(); } catch (Exception exc) { Logger.Instance.Error(exc.Message, exc); try { _wiimote.SetLEDs(false, false, false, false); } catch (Exception exception) { Logger.Instance.Error(exception.Message, exception); } IsEnabled = false; } }
public void SetRumbleHandler(SetRumble update) { // handle setting rumble state from outside world _state.Rumble = update.Body.Rumble; _wm.SetRumble(update.Body.Rumble); update.ResponsePort.Post(DefaultUpdateResponseType.Instance); }
/// <summary> /// Start the IR Server plugin. /// </summary> public override void Start() { LoadSettings(); _wiimote = new Wiimote(); try { _wiimote.WiimoteChanged += WiimoteChanged; _wiimote.WiimoteExtensionChanged += WiimoteExtensionChanged; _wiimote.Connect(); _wiimote.SetReportType(InputReport.IRAccel, true); _wiimote.SetLEDs(_led1, _led2, _led3, _led4); _wiimote.SetRumble(false); } catch { throw; } finally { _wiimote.Dispose(); _wiimote = null; } }
private void teardownWiimoteConnection(Wiimote pDevice) { if (pDevice != null) { pDeviceMutex.WaitOne(); pDevice.WiimoteChanged -= this.wiimoteChangedEventHandler; pDevice.WiimoteExtensionChanged -= this.wiimoteExtensionChangedEventHandler; int wiimoteid; if (pWiimoteMap.Keys.Contains(pDevice.HIDDevicePath)) { wiimoteid = this.pWiimoteMap[pDevice.HIDDevicePath].Status.ID; this.pWiimoteMap[pDevice.HIDDevicePath].Teardown(); this.pWiimoteMap.Remove(pDevice.HIDDevicePath); } else { wiimoteid = this.pWiimoteMap.Count + 1; } pDeviceMutex.ReleaseMutex(); pDevice.SetReportType(InputReport.Status, false); pDevice.SetRumble(false); pDevice.SetLEDs(true, true, true, true); // Close the connection and dispose of the device. pDevice.Disconnect(); pDevice.Dispose(); OnDisconnect(wiimoteid, this.pWiimoteMap.Count); } }
} // CalculateSensorsMiddlePoint #endregion #region Set Vibration /// <summary> /// Sets the vibration on or off. /// </summary> public void SetVibration(bool on) { wiimote.SetRumble(on); duration = 0; chronometer.Pause(); } // SetVibration