public WiimoteInput(Wiimote wiimote) : base() { wiimote.WiimoteChanged += wiimote_WiimoteChanged; wiimote.WiimoteExtensionChanged += wiimote_WiimoteExtensionChanged; wiimote.Connect(); if (wiimote.WiimoteState.ExtensionType != ExtensionType.BalanceBoard) { wiimote.SetReportType(InputReport.IRExtensionAccel, IRSensitivity.Maximum, true); } this.wiimote = wiimote; List<String> validAxes = new List<String>(); foreach (Axis axis in Enum.GetValues(typeof(Axis))) { validAxes.Add(axis.ToString()); } List<String> validButtons = new List<String>(); foreach (Button button in Enum.GetValues(typeof(Button))) { validButtons.Add(button.ToString()); } CreateMapping(validButtons, validAxes); }
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 Form1() { foreach (Process p in Process.GetProcessesByName("googleearth")) { p.Kill(); } InitializeComponent(); ge = new EARTHLib.ApplicationGE(); ShowWindowAsync(ge.GetMainHwnd(), 0); SetParent(ge.GetRenderHwnd(), this.Handle.ToInt32()); Wiimote wm = new Wiimote(); // setup the event to handle state changes wm.WiimoteChanged += wm_WiimoteChanged; // connect to the Wiimote wm.Connect(); // set the report type to return the IR sensor and accelerometer data (buttons always come back) wm.SetReportType(InputReport.IRAccel, true); ResizeGoogleControl(); }
/// <summary>Creates a 800x600 window with the specified title.</summary> public Game() : base(800, 600, GraphicsMode.Default, "OpenTK Quick Start Sample") { VSync = VSyncMode.On; _wm = new Wiimote(); _wm.WiimoteChanged += wm_WiimoteChanged; _wm.Connect(); _wm.SetReportType(InputReport.IRAccel, true); _wm.SetLEDs(false, true, true, false); }
private void button_Connect_Click(object sender, EventArgs e) { try { // Find all connected Wii devices. var deviceCollection = new WiimoteCollection(); deviceCollection.FindAllWiimotes(); for (int i = 0; i < deviceCollection.Count; i++) { wiiDevice = deviceCollection[i]; // Device type can only be found after connection, so prompt for multiple devices. if (deviceCollection.Count > 1) { var devicePathId = new Regex("e_pid&.*?&(.*?)&").Match(wiiDevice.HIDDevicePath).Groups[1].Value.ToUpper(); var response = MessageBox.Show("Connect to HID " + devicePathId + " device " + (i + 1) + " of " + deviceCollection.Count + " ?", "Multiple Wii Devices Found", MessageBoxButtons.YesNoCancel); if (response == DialogResult.Cancel) return; if (response == DialogResult.No) continue; } // Setup update handlers. wiiDevice.WiimoteChanged += wiiDevice_WiimoteChanged; wiiDevice.WiimoteExtensionChanged += wiiDevice_WiimoteExtensionChanged; // Connect and send a request to verify it worked. wiiDevice.Connect(); wiiDevice.SetReportType(InputReport.IRAccel, false); // FALSE = DEVICE ONLY SENDS UPDATES WHEN VALUES CHANGE! wiiDevice.SetLEDs(true, false, false, false); // Enable processing of updates. infoUpdateTimer.Enabled = true; // Prevent connect being pressed more than once. button_Connect.Enabled = false; //button_BluetoothAddDevice.Enabled = false; break; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Init() { try { Wiimote wm = new Wiimote(); wm.WiimoteChanged += wm_WiimoteChanged; wm.Connect(); wm.SetReportType(InputReport.IRAccel, true); } catch (Exception) { MessageBox.Show("Balance Board not connected", "Error", MessageBoxButton.OK, MessageBoxImage.Error); App.Current.Shutdown(); } }
public MarathonForm() { AutoScaleDimensions = new SizeF(6F, 13F); AutoScaleMode = AutoScaleMode.Font; FormBorderStyle = FormBorderStyle.None; WindowState = FormWindowState.Maximized; Name = "Marathon des millions"; // Rajout des choix à la grammaire du prog var grammar = new GrammarBuilder(); grammar.Append(new Choices("1", "2", "3", "4", "Yes", "No")); recognizer = new SpeechRecognitionEngine(); recognizer.SetInputToDefaultAudioDevice(); recognizer.UnloadAllGrammars(); recognizer.LoadGrammar(new Grammar(grammar)); recognizer.SpeechRecognized += SpeechRecognized; recognizer.AudioLevelUpdated += AudioLevelUpdated; recognizer.RecognizeAsync(RecognizeMode.Multiple); // create a new instance of the Wiimote wm = new Wiimote(); scorePanel = new ScorePanel(); gamePanel = new GamePanel(wm); questionPanel = new QuestionPanel(gamePanel); // setup the event to handle state changes wm.WiimoteChanged += WiimoteChanged; // setup the event to handle insertion/removal of extensions wm.WiimoteExtensionChanged += WiimoteExtensionChanged; // connect to the Wiimote wm.Connect(); // set the report type to return the IR sensor and accelerometer data (buttons always come back) wm.SetReportType(InputReport.IRAccel, IRSensitivity.WiiLevel5, true); Layout += MarathonLayout; Controls.Add(questionPanel); Controls.Add(scorePanel); Controls.Add(gamePanel); questionPanel.Start(); }
/// <summary> /// Service Start /// </summary> protected override void Start() { base.Start(); // setup internal notifications when we receive a OnWiimoteChanged event Activate(Arbiter.Receive(true, _internalStateChangedPort, InternalWiimoteChangedHandler)); // hookup event handlers _wm.OnWiimoteChanged += new WiimoteChangedEventHandler(wm_OnWiimoteChanged); _wm.OnWiimoteExtensionChanged += new WiimoteExtensionChanged(wm_OnWiimoteExtensionChanged); // connect to wiimote and setup standard params _wm.Connect(); _wm.SetReportType(Wiimote.InputReport.IRAccel, true); _wm.SetLEDs(false, true, false, true); }
/// <summary> /// Initialization of all active Wiimotes. /// </summary> public static void InitWiimotes() { try { // Find all wiimotes connected to the system WiimoteCollection wiimoteCollection = new WiimoteCollection(); wiimoteCollection.FindAllWiimotes(); // For each Wiimote founded int index = 1; foreach (WiimoteLib.Wiimote wiimote in wiimoteCollection) { // Connect to Wiimote bool error = false; try { wiimote.Connect(); } catch (WiimoteException) { error = true; } if (!error) // If the connection was a success { switch (index) { case 1: wiimotePlayerOne.AssignWiimote(wiimote); break; case 2: wiimotePlayerTwo.AssignWiimote(wiimote); break; case 3: wiimotePlayerThree.AssignWiimote(wiimote); break; case 4: wiimotePlayerFour.AssignWiimote(wiimote); break; } index++; } } } catch { // If it can't connect to any Wiimote we do nothing. // All problems with connections need to be address outside the application. } // Creates the texture wiimoteSensorsTexture = new Texture("WiimoteSensors"); } // Wiimote
public Form1() { InitializeComponent(); //soundplayer Stream str = JetFighter2D.Resource2.Lost_Woods_Dubstep_Remix___Ephixa_Download_at_www; sp = new SoundPlayer(str); wm = new Wiimote(); wm.Connect(); wm.SetLEDs(true, false, true, false); wm.SetReportType(InputReport.Buttons, true); //connect Wiimote GV.wm.Connect(); GV.wm.SetLEDs(true, false, true, false); GV.wm.WiimoteChanged += new EventHandler<WiimoteChangedEventArgs>(Wiimote_changed); }
public WiiMotePlayer(LevelChangedEventArgs eventArgs, int id) : base(eventArgs, id, false) { while (true) { try { _wiimote = new Wiimote(); _wiimote.Connect(); break; } catch (WiimoteNotFoundException) { MessageBox.Show("Please ensure a wiimote is paired to your computer via Bluetooth, then press OK to try again"); } } _wiimote.SetLEDs(id + 1); }
/// <summary> /// Initialize the wiimote and nunchuk if it plugged /// </summary> public bool Initialize() { if (_wiimote == null) { try { _wiimote = new Wiimote(); _wiimote.WiimoteChanged += wiimote_WiimoteChanged; _wiimote.WiimoteExtensionChanged += wiimote_WiimoteExtensionChanged; _wiimote.Connect(); _wiimote.SetReportType(InputReport.IRAccel, true); _wiimote.SetLEDs(true, false, false, true); IsAvailable = true; } catch (Exception ex) { Console.Error.WriteLine(ex.Message); _wiimote = null; IsAvailable = false; } } return IsAvailable; }
void MainWindowLoaded(object sender, System.Windows.RoutedEventArgs e) { try { wm = new Wiimote(); wm.WiimoteChanged += OnWiimoteChanged; wm.Connect(); wm.SetReportType(InputReport.IRAccel, true); wm.SetLEDs(false, false, false, false); } catch { wm = null; } }
/// <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; } }
// Fin VOZ //WiiMOTE public void FuncionalidadWiiMote() { wiiMote = new Wiimote(); gestureCapturer = new GestureCapturer(); gestureRecognizer = new GestureRecognizer(); cargarFicheroGestos(); wiiMote.WiimoteChanged += new EventHandler<WiimoteChangedEventArgs>(wm_WiimoteChanged); gestureCapturer.GestureCaptured += new GestureCapturedEventHandler(gc_GestureCaptured); gestureRecognizer.GestureRecognized += new GestureRecognizedEventHandler(gr_GestureRecognized); wiiMote.Connect(); }
private void connectWiimote(Wiimote wiimote) { Console.WriteLine("Trying to connect " + wiimote.HIDDevicePath); // Try to establish a connection, enable the IR reader and flag some LEDs. wiimote.Connect(); wiimote.SetReportType(InputReport.IRExtensionAccel, IRSensitivity.Maximum, true); new Timer(new TimerCallback(connectRumble), wiimote, 0, Timeout.Infinite); int id = this.getFirstFreeId(); wiimote.SetLEDs(id == 1, id == 2, id == 3, id == 4); WiimoteControl control = new WiimoteControl(id, wiimote); pDeviceMutex.WaitOne(); //Don't mess with the list of wiimotes if it is enumerating in an update pWiimoteMap[wiimote.HIDDevicePath] = control; pDeviceMutex.ReleaseMutex(); // Hook up device event handlers. wiimote.WiimoteChanged += this.wiimoteChangedEventHandler; wiimote.WiimoteExtensionChanged += this.wiimoteExtensionChangedEventHandler; OnConnect(id, this.pWiimoteMap.Count); }
private void seachWiimote() { // find all wiimotes connected to the system WiimoteCollection wiimoteCollection = new WiimoteCollection(); //while (canSearch) //{ try { wiimoteCollection.FindAllWiimotes(); } catch (WiimoteNotFoundException ex) { //MessageBox.Show(ex.Message, "Wiimote not found error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (WiimoteException ex) { //MessageBox.Show(ex.Message, "Wiimote error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { //MessageBox.Show(ex.Message, "Unknown error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (wiimoteCollection.Count == 1) { Connected = true; wiimote = wiimoteCollection[0]; // connect it and set it up as always wiimote.WiimoteChanged += wiimoteChanged; wiimote.WiimoteExtensionChanged += wiimoteExtensionChanged; wiimote.Connect(); if (wiimote.WiimoteState.ExtensionType != ExtensionType.BalanceBoard) wiimote.SetReportType(InputReport.IRExtensionAccel, IRSensitivity.Maximum, true); wiimote.SetLEDs(false, true, true, false); } else { Connected = false; } //} }
public void OnCreateDevice(object sender, EventArgs e) { Device dev = (Device)sender; textSprite = new Sprite(dev); statsFont = ResourceCache.GetGlobalInstance().CreateFont(dev, 15, 0, FontWeight.Bold, 1, false, CharacterSet.Default,Precision.Default, FontQuality.Default, PitchAndFamily.FamilyDoNotCare | PitchAndFamily.DefaultPitch, "Arial"); //init cursors mouseCursor = new CrosshairCursor(dev, 0x00ff00, .04f); wiiCursor1 = new CrosshairCursor(dev, 0x00ff00, .04f); wiiCursor2 = new CrosshairCursor(dev, 0x0000ff, .04f); wiiCursor3 = new CrosshairCursor(dev, 0xff0000, .04f); wiiCursor4 = new CrosshairCursor(dev, 0xffff00, .04f); CreateGridGeometry(dev); CreateBackgroundGeometry(dev); CreateTargetGeometry(dev); InitTargets(); LoadTexture(); LoadBackground(); if (doWiimote) { try { if (doWiimote2) { showMouseCursor = true; remote2 = new Wiimote(); remote2.Connect(); remote2.SetReportType(Wiimote.InputReport.IRAccel, true); remote2.GetBatteryLevel(); remote2.SetLEDs(true, true, false, false); remote2.OnWiimoteChanged += new WiimoteChangedEventHandler(wm_OnWiimoteChanged2); } remote = new Wiimote(); remote.Connect(); remote.SetReportType(Wiimote.InputReport.IRAccel, true); remote.GetBatteryLevel(); remote.SetLEDs(true, false, false, false); remote.OnWiimoteChanged += new WiimoteChangedEventHandler(wm_OnWiimoteChanged); } catch (Exception x) { MessageBox.Show("Cannot find a wii remote: " + x.Message); doWiimote = false; } } }
static void ConnectWiimote() { wiimote = new Wiimote(); wiimote.Connect(); wiimote.SetLEDs(1); }
private void InitWiimote(Wiimote wiimote) { wiimote.Connect(); wiimote.WiimoteChanged += wiimote_WiimoteChanged; wiimote.WiimoteExtensionChanged += wiimote_WiimoteExtensionChanged; if (wiimote.WiimoteState.ExtensionType != ExtensionType.BalanceBoard) { wiimote.SetReportType(InputReport.IRExtensionAccel, IRSensitivity.Maximum, true); } this.wiimote = wiimote; }