public SetReportType ( InputReport type, IRSensitivity irSensitivity, bool continuous ) : void | ||
type | InputReport | Report type |
irSensitivity | IRSensitivity | IR sensitivity |
continuous | bool | Continuous data |
return | void |
/// <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); }
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(); }
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); }
/// <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); }
} // Wiimote /// <summary> /// Assign the wiimoteLib object to the correct Wiimote object. /// </summary> private void AssignWiimote(WiimoteLib.Wiimote _wiimote) { wiimote = _wiimote; // Init the IR camera if (wiimote.WiimoteState.ExtensionType != ExtensionType.BalanceBoard) { wiimote.SetReportType(InputReport.IRExtensionAccel, IRSensitivity.Maximum, true); } // Display the player number using the wiimote's lights wiimote.SetLEDs(playerIndex); isConnected = true; } // AssignWiimote
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(); }
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); }
/// <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; } }
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); } }
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); }
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; } } }
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; }
private void Form1_Load(object sender, EventArgs e) { wm = wms[0]; if (wms.Count > 1) { checkBox3.Checked = true; remote2 = wms[1]; remote2.WiimoteChanged += new WiimoteChangedEventHandler(remote2_OnWiimoteChanged); } lblBattery2.Text = "---"; //add event listeners to changes in the wiiremote //fired for every input report - usually 100 times per second if acclerometer is enabled wm.WiimoteChanged += new WiimoteChangedEventHandler(wm_OnWiimoteChanged); try { //connect to wii remote ////set what features you want to enable for the remote, look at Wiimote.InputReport for options wm.SetReportType(Wiimote.InputReport.IRAccel, true); //set wiiremote LEDs with this enumerated ID wm.SetLEDs(true, false, false, false); if (wms.Count > 1) { ////set what features you want to enable for the remote, look at Wiimote.InputReport for options remote2.SetReportType(Wiimote.InputReport.IRAccel, true); //set wiiremote LEDs with this enumerated ID remote2.SetLEDs(false, true, false, false); //fired when the extension is attached on unplugged remote2.WiimoteExtensionChanged += new WiimoteExtensionChangedEventHandler(wm_OnWiimoteExtensionChanged); } } catch (Exception x) { MessageBox.Show("Exception: " + x.Message); //this.Close(); } loadCalibrationData(); done = new bool[Form2.NUMBOXES]; for (int i = 0; i < Form2.NUMBOXES - 1; i++) done[i] = false; }
//will try to connect to a second wiimote if checked private void checkBox3_CheckedChanged(object sender, EventArgs e) { secondwiimote = checkBox3.Checked; if (checkBox3.Checked) { wms = Wiimote.GetConnectedWiimotes(); if (wms.Count > 1) { remote2 = wms[1]; remote2.WiimoteChanged += new WiimoteChangedEventHandler(remote2_OnWiimoteChanged); remote2.SetReportType(Wiimote.InputReport.IRAccel, true); remote2.SetLEDs(false, true, false, false); } else { MessageBox.Show("There is no second Wiimote connected"); checkBox3.Checked = false; } } if (!checkBox3.Checked) { if (wms.Count > 1) { remote2.SetLEDs(true, true, true, true); remote2.Disconnect(); } lblBattery2.Text = "---"; pbBattery2.Value = 0; } }
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; } //} }