Beispiel #1
0
 //-----------------------------------------------------------------------
 public override void Stop()
 {
     if (Motes != null)
     {
         for (int i = 0; i < Motes.Count; i++)
         {
             Wiimote wii = Motes.ElementAt(i);
             wii.SetLEDs(false, false, false, false);
             wii.Disconnect();
         }
         Motes = null;
     }
 }
Beispiel #2
0
        //-----------------------------------------------------------------------
        public override Action Start()
        {
            // This method is called just before script starts

            // Find and connect to all Wiimotes.  Wiimotes must have been
            // previously attached via a bluetooth manager
            var motes = new WiimoteCollection();

            motes.FindAllWiimotes();

            if (motes.Count > 0)
            {
                Buttons = new WiimoteLib.ButtonState[motes.Count];

                // Connect and start each wiimote
                for (int i = 0; i < motes.Count; i++)
                {
                    Wiimote wii = motes.ElementAt(i);
                    wii.Connect();
                    // set the wiimote leds to the wiimote number
                    wii.SetLEDs(i + 1);                            // set the wiimote leds to the wiimote number
                    Buttons[i]          = wii.WiimoteState.ButtonState;
                    wii.WiimoteChanged += OnWiimoteChanged;        // set the event handler
                    wii.SetReportType(InputReport.Buttons, false); // start the data callbacks
                }

                Motes = motes;
            }
            else
            {
                throw new Exception("No Wiimotes found");
            }

            return(null);
        }
Beispiel #3
0
        private Wiimote InitWiimote(int wiimoteIndex)
        {
            WiimoteCollection wiimoteCollection = new WiimoteCollection();
            Wiimote           wiimote;

            try
            {
                wiimoteCollection.FindAllWiimotes();
                wiimote = wiimoteCollection.ElementAt <Wiimote>(wiimoteIndex);
            }
            catch
            {
                wiimote = null;
            }

            if (wiimote != null)
            {
                try
                {
                    wiimote.Connect();
                    wiimote.SetReportType(InputReport.IRExtensionAccel, IRSensitivity.Maximum, true);
                    wiimote.SetLEDs(wiimoteIndex + 1);
                }
                catch
                {
                    wiimote = null;
                }
            }

            return(wiimote);
        }
Beispiel #4
0
        //-----------------------------------------------------------------------
        public override Action Start()
        {
            // This method is called just before script starts

             // Find and connect to all Wiimotes.  Wiimotes must have been
             // previously attached via a bluetooth manager
             WiimoteCollection motes = new WiimoteCollection();
            motes.FindAllWiimotes();

             if (motes.Count > 0) {

            Buttons = new WiimoteLib.ButtonState[motes.Count];

            // Connect and start each wiimote
            for (int i=0; i<motes.Count; i++) {
               Wiimote wii = motes.ElementAt(i);
               wii.Connect();
               // set the wiimote leds to the wiimote number
               wii.SetLEDs(i+1);   // set the wiimote leds to the wiimote number
               Buttons[i] = wii.WiimoteState.ButtonState;
               wii.WiimoteChanged += OnWiimoteChanged;        // set the event handler
               wii.SetReportType(InputReport.Buttons, false); // start the data callbacks
            }

            Motes = motes;
             }
             else {
            throw new Exception("No Wiimotes found");
             }

             return null;
        }