Ejemplo n.º 1
0
        public void SearchWiiBoard()
        {
            Console.WriteLine("searching...");
            WiimoteCollection wiimoteCollection = new WiimoteCollection();

            try
            {
                wiimoteCollection.FindAllWiimotes();
            }
            catch (WiimoteNotFoundException ex)
            {
                LOG.Error("Wiimote not found error", ex);
                return;
            }
            catch (WiimoteException ex)
            {
                LOG.Error("Wiimote error", ex);
                return;
            }
            catch (Exception ex)
            {
                LOG.Error("Unknown error", ex);
                return;
            }

            Console.WriteLine("found " + wiimoteCollection.ToList().Count);
            foreach (Wiimote current in wiimoteCollection)
            {
                try
                {
                    current.Connect();
                    current.SetLEDs(true, false, false, false);
                    var founded = current.WiimoteState.ExtensionType == ExtensionType.BalanceBoard;
                    current.Disconnect();
                    if (founded)
                    {
                        Console.WriteLine("Hola");
                        wiiboard = current;
                        return;
                    }
                }
                catch (Exception ex)
                {
                    LOG.Error(string.Format("Error durring access to Wiimote {0}.", current.HIDDevicePath), ex);
                }
            }
        }