コード例 #1
0
        private void AnalisisGait_Load(object sender, EventArgs e)
        {
            // find all wiimotes connected to the system
            mWC = new WiimoteCollection();
            int index = 1;

            try
            { mWC.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);
            }

            foreach (Wiimote wm in mWC)
            {
                // create a new tab
                TabPage tp = new TabPage("Wiimote " + index);
                tabWiimotes.TabPages.Add(tp);

                // create a new user control
                parameter wi = new parameter(wm);
                tp.Controls.Add(wi);

                // setup the map from this wiimote's ID to that control
                mWiimoteMap[wm.ID] = wi;

                // connect it and set it up as always
                wm.WiimoteChanged          += wm_WiimoteChanged;
                wm.WiimoteExtensionChanged += wm_WiimoteExtensionChanged;

                wm.Connect();
                if (wm.WiimoteState.ExtensionType != ExtensionType.BalanceBoard)
                {
                    wm.SetReportType(InputReport.IRExtensionAccel,
                                     IRSensitivity.Maximum, true);
                }

                wm.SetLEDs(index++);
            }
        }
コード例 #2
0
        void wm_WiimoteExtensionChanged(object sender, WiimoteExtensionChangedEventArgs e)
        {
            // find the control for this Wiimote
            parameter wi = mWiimoteMap[((Wiimote)sender).ID];

            wi.UpdateExtension(e);

            if (e.Inserted)
            {
                ((Wiimote)sender).SetReportType(InputReport.IRExtensionAccel, true);
            }
            else
            {
                ((Wiimote)sender).SetReportType(InputReport.IRAccel, true);
            }
        }
コード例 #3
0
        void wm_WiimoteChanged(object sender, WiimoteChangedEventArgs e)
        {
            parameter wi = mWiimoteMap[((Wiimote)sender).ID];

            wi.UpdateState(e);
        }