Пример #1
0
        public void onPenMoved(object i_WiiMote, WiimoteState i_State)
        {
            PointF coordinates       = getWarpedCoordinates(i_State);
            int    mouseActionsflags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
            int    CalculatedX       = CalculateDeltaX(coordinates.X);
            int    CalculatedY       = CalculateDeltaY(coordinates.Y);

            mouse_event(mouseActionsflags, CalculatedX, CalculatedY, 0, 0);
        }
Пример #2
0
        private void onPenAppeared(object i_WiiMote, WiimoteState i_State)
        {
            PointF coordinates = getWarpedCoordinates(i_State);

            m_Smoother.Reset();
            int mouseActionsflags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE | MOUSEEVENTF_LEFTDOWN;

            mouse_event(mouseActionsflags, CalculateDeltaX(coordinates.X), CalculateDeltaY(coordinates.Y), 0, 0);
        }
Пример #3
0
        public void onPenDisappeared(object i_WiiMote, WiimoteState i_State)
        {
            int deltaX            = 0;
            int deltaY            = 0;
            int mouseActionsflags = MOUSEEVENTF_LEFTUP;

            mouse_event(mouseActionsflags, deltaX, deltaY, 0, 0);
            m_Smoother.Reset();
        }
Пример #4
0
        private void wm_WiimoteChanged(object sender, WiimoteChangedEventArgs e)
        {
            if (e.WiimoteState.IRState.IRSensors[0].Found != lastSensor.on)
            {
                lastSensor = new SensorTime(e.WiimoteState.IRState.IRSensors[0].Found, lastSensor.date);
            }

            lastWMState = e.WiimoteState;
        }
Пример #5
0
        private PointF getWarpedCoordinates(WiimoteState i_State)
        {
            int    rawX        = i_State.IRState.RawX1;
            int    rawY        = i_State.IRState.RawY1;
            PointF coordinates = m_Warper.Warp(rawX, rawY);

            coordinates = m_Smoother.GetSmoothedCursor(coordinates);
            return(coordinates);
        }
Пример #6
0
        private int countVisibleIRDots(WiimoteState i_WiiMoteState)
        {
            int IRDotsCount = 0;

            IRDotsCount += i_WiiMoteState.IRState.Found1 ? 1 : 0;
            IRDotsCount += i_WiiMoteState.IRState.Found2 ? 1 : 0;
            IRDotsCount += i_WiiMoteState.IRState.Found3 ? 1 : 0;
            IRDotsCount += i_WiiMoteState.IRState.Found4 ? 1 : 0;
            return(IRDotsCount);
        }
Пример #7
0
        public WiimoteController(int screenWidth, int screenHeight)
        {
            this.lastState = new WiimoteState();

            EventHandler keyboardHandler  = new KeyboardHandler(null);
            EventHandler mouseUpHandler   = new MouseUpHandler(keyboardHandler, screenWidth, screenHeight);
            EventHandler mouseDragHandler = new MouseDragHandler(mouseUpHandler, screenWidth, screenHeight);

            this.eventHandler = new MouseDownHandler(mouseDragHandler, screenWidth, screenHeight);
        }
Пример #8
0
        public Calibrator(int screenWidth, int screenHeight)
        {
            data      = new CalibrationData();
            lastState = new WiimoteState();

            pointsAdded       = 0;
            hasChanged        = false;
            this.screenHeight = screenHeight;
            this.screenWidth  = screenWidth;
        }
Пример #9
0
 private void onWiimoteChanged(object i_WiiMote, WiimoteChangedEventArgs i_WiimoteChangedEventArgs)
 {
     m_StateChangedMutex.WaitOne();
     m_CurrentWiiMoteState = i_WiimoteChangedEventArgs.WiimoteState;
     fireInfraRedEvents();
     fireButtonsEvents();
     fireBattteryEvents();
     m_PreviousWiiMoteState = copyWiiMoteState(m_CurrentWiiMoteState);
     m_StateChangedMutex.ReleaseMutex();
 }
Пример #10
0
        override protected bool InnerHandle(WiimoteState currentState, WiimoteState lastState)
        {
            bool handled = true;

            if (!lastState.ButtonState.A && currentState.ButtonState.A)
            {
                throw new UserTerminatedException();
            }
            else if (!lastState.ButtonState.B && currentState.ButtonState.B)
            {
                keybd_event(VK_SPACE, 0x45, 0, 0);
            }
            else if (lastState.ButtonState.B && !currentState.ButtonState.B)
            {
                keybd_event(VK_SPACE, 0x45, KEYEVENTF_KEYUP, 0);
            }
            else if (!lastState.ButtonState.Up && currentState.ButtonState.Up)
            {
                keybd_event(VK_UP, 0x45, 0, 0);
            }
            else if (lastState.ButtonState.Up && !currentState.ButtonState.Up)
            {
                keybd_event(VK_UP, 0x45, KEYEVENTF_KEYUP, 0);
            }
            else if (!lastState.ButtonState.Down && currentState.ButtonState.Down)
            {
                keybd_event(VK_DOWN, 0x45, 0, 0);
            }
            else if (lastState.ButtonState.Down && !currentState.ButtonState.Down)
            {
                keybd_event(VK_DOWN, 0x45, KEYEVENTF_KEYUP, 0);
            }
            else if (!lastState.ButtonState.Left && currentState.ButtonState.Left)
            {
                keybd_event(VK_LEFT, 0x45, 0, 0);
            }
            else if (lastState.ButtonState.Left && !currentState.ButtonState.Left)
            {
                keybd_event(VK_LEFT, 0x45, KEYEVENTF_KEYUP, 0);
            }
            else if (!lastState.ButtonState.Right && currentState.ButtonState.Right)
            {
                keybd_event(VK_RIGHT, 0x45, 0, 0);
            }
            else if (lastState.ButtonState.Right && !currentState.ButtonState.Right)
            {
                keybd_event(VK_RIGHT, 0x45, KEYEVENTF_KEYUP, 0);
            }
            else
            {
                handled = false;
            }

            return(handled);
        }
Пример #11
0
 private void SetLastState(WiimoteState currentState)
 {
     lastState.IRState.Found1    = currentState.IRState.Found1;
     lastState.IRState.RawX1     = currentState.IRState.RawX1;
     lastState.IRState.RawY1     = currentState.IRState.RawY1;
     lastState.ButtonState.A     = currentState.ButtonState.A;
     lastState.ButtonState.B     = currentState.ButtonState.B;
     lastState.ButtonState.Down  = currentState.ButtonState.Down;
     lastState.ButtonState.Up    = currentState.ButtonState.Up;
     lastState.ButtonState.Left  = currentState.ButtonState.Left;
     lastState.ButtonState.Right = currentState.ButtonState.Right;
 }
        public void GetValues()
        {
            // Initializing s with the current Wiimote state
            s = bb.WiimoteState;
            // Initailizing bbs with the current Balance Board state
            bbs = s.BalanceBoardState;
            // Initializing bbKg with the current weight distribution
            bbKg = bbs.SensorValuesKg;

            // Creating a new Coordinate Object and initializing it through a constructor
            coord = new Coordinate(bbs.CenterOfGravity.X, bbs.CenterOfGravity.Y);
        }
Пример #13
0
        public void Update(WiimoteState ws)
        {
            if (this.IsDisposed)
            {
                return;
            }

            // 赤外線
            var count = ws.IRState.IRSensors.Count(s => s.Found);

            irDetected      = (count != 0);
            labIrStat.Text  = irDetected ? "Detected" : "Not Detected";
            labIrCount.Text = count.ToString();
            if (irDetected)
            {
                irPoints.Clear();
                float sum_x = 0, sum_y = 0;
                foreach (var ir in ws.IRState.IRSensors)
                {
                    if (ir.Found)
                    {
                        irPoints.Add(new System.Drawing.PointF(ir.Position.X, ir.Position.Y));

                        sum_x += ir.Position.X;
                        sum_y += ir.Position.Y;
                    }
                }

                averagedIrPoint = new System.Drawing.PointF(sum_x / count, sum_y / count);
            }
            UpdateIRWindow();

            // ボタンの状態
            var buttonStateDic = GetDictionaryFromButton(ws);

            for (var i = 0; i < checkedListBox1.Items.Count; i++)
            {
                checkedListBox1.SetItemCheckState(i, buttonStateDic[(string)checkedListBox1.Items[i]] ? CheckState.Checked : CheckState.Unchecked);
            }

            // 加速度・ジョイスティック
            labAcc.Text = AccToString(ws.AccelState.Values.X, ws.AccelState.Values.Y, ws.AccelState.Values.Z);

            if (ws.ExtensionType == ExtensionType.Nunchuk)
            {
                labNunchukAcc.Text   = AccToString(ws.NunchukState.AccelState.Values.X, ws.NunchukState.AccelState.Values.Y, ws.NunchukState.AccelState.Values.Z);
                labNunchukStick.Text = ws.NunchukState.Joystick.X.ToString("0.000") + "/" + ws.NunchukState.Joystick.Y.ToString("0.000");
            }

            // バッテリー残量
            labBattery.Text = ws.Battery.ToString("00") + "%";
        }
Пример #14
0
        private void UpdateWiimoteState(WiimoteChangedEventArgs args)
        {
            WiimoteState ws = args.WiimoteState;

            for (int j = 0; j < 4; j++)
            {
                if (ws.IRState.IRSensors[j].Found)
                {
                    points[j] = ws.IRState.IRSensors[j].RawPosition;
                    //TODO: Sort points?
                }
            }
        }
Пример #15
0
        internal override void WiimoteChanged(WiimoteState ws)
        {
            x = CalibrateX(ws.IRState.Midpoint.X);
            y = CalibrateY(ws.IRState.Midpoint.Y);

            if (fps++ == 1)
            {
                fps = 0;


                UpdateView();
            }
        }
Пример #16
0
        private static void wm_WiimoteChanged(object sender, WiimoteChangedEventArgs e)
        {
            var          wiimote = (IWiimote)sender;
            WiimoteState ws      = e.WiimoteState;

            //if (ws.ButtonState.A) Console.WriteLine("A");
            //if (ws.ButtonState.B) Console.WriteLine("B");
            //if (ws.ButtonState.Down) Console.WriteLine("Down");
            //if (ws.ButtonState.Home) Console.WriteLine("Home");
            //if (ws.ButtonState.Left) Console.WriteLine("Left");
            //if (ws.ButtonState.Minus) Console.WriteLine("Minus");
            //if (ws.ButtonState.One) Console.WriteLine("One");
            //if (ws.ButtonState.Plus) Console.WriteLine("Plus");
            //if (ws.ButtonState.Right) Console.WriteLine("Right");
            //if (ws.ButtonState.Two) Console.WriteLine("Two");
            //if (ws.ButtonState.Up) Console.WriteLine("Up");

            if (ws.ButtonState.Home)
            {
                exit = true;
            }

            wiimote.SetRumble(ws.ButtonState.B);

            if (ws.ButtonState.Plus && leds < 8)
            {
                leds = leds << 1;
            }

            if (ws.ButtonState.Minus && leds > 1)
            {
                leds = leds >> 1;
            }

            wiimote.SetLEDs(leds);

            if (ws.ExtensionType == ExtensionType.Nunchuk)
            {
                var ns = ws.NunchukState;

                //if (ns.C) Console.WriteLine("C");
                //if (ns.Z) Console.WriteLine("Z");

                //Console.WriteLine(ns.Joystick);

                var xangle = ns.Joystick.X * -180;
                var yangle = ns.Joystick.Y * 180;

                hexy.SetNeck(xangle);
            }
        }
Пример #17
0
        } // Update

        /// <summary>
        /// Clones the Wiimote state. A simple assignation doesn’t work.
        /// </summary>
        public void CloneState(ref WiimoteState wiimoteStateDestination, WiimoteState wiimoteStateOrigin)
        {
            // Buttons //
            wiimoteStateDestination = new WiimoteState
            {
                ButtonState =
                {
                    A     = wiimoteStateOrigin.ButtonState.A,
                    B     = wiimoteStateOrigin.ButtonState.B,
                    One   = wiimoteStateOrigin.ButtonState.One,
                    Two   = wiimoteStateOrigin.ButtonState.Two,
                    Minus = wiimoteStateOrigin.ButtonState.Minus,
                    Plus  = wiimoteStateOrigin.ButtonState.Plus,
                    Home  = wiimoteStateOrigin.ButtonState.Home,
                    Left  = wiimoteStateOrigin.ButtonState.Left,
                    Right = wiimoteStateOrigin.ButtonState.Right,
                    Up    = wiimoteStateOrigin.ButtonState.Up,
                    Down  = wiimoteStateOrigin.ButtonState.Down
                }
            };
            // DPad //
            // Accelerometers //
            wiimoteStateDestination.AccelState.Values.X = wiimoteStateOrigin.AccelState.Values.X;
            wiimoteStateDestination.AccelState.Values.Y = wiimoteStateOrigin.AccelState.Values.Y;
            wiimoteStateDestination.AccelState.Values.Z = wiimoteStateOrigin.AccelState.Values.Z;
            // Nunchuk //
            wiimoteStateDestination.NunchukState.C          = wiimoteStateOrigin.NunchukState.C;
            wiimoteStateDestination.NunchukState.Z          = wiimoteStateOrigin.NunchukState.Z;
            wiimoteStateDestination.NunchukState.Joystick.X = wiimoteStateOrigin.NunchukState.Joystick.X;
            wiimoteStateDestination.NunchukState.Joystick.Y = wiimoteStateOrigin.NunchukState.Joystick.Y;
            // IR //
            wiimoteStateDestination.IRState.IRSensors[0].Position    = wiimoteStateOrigin.IRState.IRSensors[0].Position;
            wiimoteStateDestination.IRState.IRSensors[0].RawPosition = wiimoteStateOrigin.IRState.IRSensors[0].RawPosition;
            wiimoteStateDestination.IRState.IRSensors[0].Found       = wiimoteStateOrigin.IRState.IRSensors[0].Found;
            wiimoteStateDestination.IRState.IRSensors[0].Size        = wiimoteStateOrigin.IRState.IRSensors[0].Size;

            wiimoteStateDestination.IRState.IRSensors[1].Position    = wiimoteStateOrigin.IRState.IRSensors[1].Position;
            wiimoteStateDestination.IRState.IRSensors[1].RawPosition = wiimoteStateOrigin.IRState.IRSensors[1].RawPosition;
            wiimoteStateDestination.IRState.IRSensors[1].Found       = wiimoteStateOrigin.IRState.IRSensors[1].Found;
            wiimoteStateDestination.IRState.IRSensors[1].Size        = wiimoteStateOrigin.IRState.IRSensors[1].Size;

            wiimoteStateDestination.IRState.IRSensors[2].Position    = wiimoteStateOrigin.IRState.IRSensors[2].Position;
            wiimoteStateDestination.IRState.IRSensors[2].RawPosition = wiimoteStateOrigin.IRState.IRSensors[2].RawPosition;
            wiimoteStateDestination.IRState.IRSensors[2].Found       = wiimoteStateOrigin.IRState.IRSensors[2].Found;
            wiimoteStateDestination.IRState.IRSensors[2].Size        = wiimoteStateOrigin.IRState.IRSensors[2].Size;

            wiimoteStateDestination.IRState.IRSensors[3].Position    = wiimoteStateOrigin.IRState.IRSensors[3].Position;
            wiimoteStateDestination.IRState.IRSensors[3].RawPosition = wiimoteStateOrigin.IRState.IRSensors[3].RawPosition;
            wiimoteStateDestination.IRState.IRSensors[3].Found       = wiimoteStateOrigin.IRState.IRSensors[3].Found;
            wiimoteStateDestination.IRState.IRSensors[3].Size        = wiimoteStateOrigin.IRState.IRSensors[3].Size;
        } // CloneState
Пример #18
0
        public void wm_WiimoteChanged(object sender, WiimoteChangedEventArgs args)
        {
            WiimoteState ws = args.WiimoteState;

            ws.IRState.Mode = IRMode.Basic;
            float x = 0, y = 0;

            x = ws.IRState.IRSensors[0].Position.X;
            y = ws.IRState.IRSensors[0].Position.Y;
            if (ws.IRState.IRSensors[0].Found)
            {
                if ((x < 0.3f || x > 0.7f || y < 0.3f || y > 0.7f) && (((x < 0.3f && (y > 0.3f && y < 0.7f)) || (x > 0.7f && (y < 0.7f && y > 0.3f))) || ((y < 0.3f && (x > 0.3f && x < 0.7f)) || (y > 0.7f && (x < 0.7f && x > 0.3f)))))
                {
                    if (x > 0.7f)
                    {
                        //Izq
                        if (pelota.iquierda != null)
                        {
                            pelota = l.moverIzquierda(pelota);
                        }
                    }
                    else if (x < 0.3f)
                    {
                        //der
                        if (pelota.derecha != null)
                        {
                            pelota = l.moverDerecha(pelota);
                        }
                    }
                    else if (y > 0.7f)
                    {
                        //arriba
                        if (pelota.arriba != null)
                        {
                            pelota = l.moverArriba(pelota);
                        }
                    }
                    else if (y < 0.3f)
                    {
                        //abajo
                        if (pelota.abajo != null)
                        {
                            pelota = l.moverAbajo(pelota);
                        }
                    }
                    pcbPelota.Location = pelota.p;
                    Thread.Sleep(500);
                }
            }
        }
Пример #19
0
        void wm_WiimoteChanged(object sender, WiimoteChangedEventArgs args)
        {
            //WiimoteStateの値を取得
            if (wiiBBFrameCount % 10 == 0)
            {
                WiimoteState ws = args.WiimoteState;

                //ここでWiiからアレがアレ
                vertex.x = ws.BalanceBoardState.CenterOfGravity.X;
                vertex.y = ws.BalanceBoardState.CenterOfGravity.Y;
                weight   = ws.BalanceBoardState.WeightKg;
                // Debug.WriteLine("vartex : {0} {1}", vartex.x, vartex.y);
            }
            wiiBBFrameCount++;
        }
Пример #20
0
        void wm_WiimoteChanged(object sender, WiimoteChangedEventArgs args)
        {
            // current state information
            WiimoteState ws = args.WiimoteState;


            // If you want to try either the comments to the console or the key presses, you
            // can uncomment the relevant parts of the code, below.

            if (ws.DrumsState.Blue)
            {
                // Console.WriteLine("Blue");
                // pressKey(VK_a);

                blue.Play();
            }
            if (ws.DrumsState.Red)
            {
                // Console.WriteLine("Red");
                //pressKey(VK_b);

                red.Play();
            }
            if (ws.DrumsState.Green)
            {
                //Console.WriteLine("Green");


                green.Play();
                //pressKey(VK_c);
            }
            if (ws.DrumsState.Orange)
            {
                //Console.WriteLine("Orange");

                orange.Play();
                // pressKey(VK_d);
            }
            if (ws.DrumsState.Yellow)
            {
                //Console.WriteLine("Yellow");

                yellow.Play();
                // pressKey(VK_e);
            }
        }
Пример #21
0
        void Wiimote_WiimoteChanged(object sender, WiimoteChangedEventArgs e)
        {
            // get the current Wiimote state
            WiimoteState ws = e.WiimoteState;

            // if button 1 is pressed, toggle the Forward output
            _interfaceKit.outputs[0] = ws.ButtonState.One;

            // if button 2 is pressed, toggle the Backward output
            _interfaceKit.outputs[1] = ws.ButtonState.Two;

            // if the Wiimote is tilted far enough to the left, toggle the Left output
            _interfaceKit.outputs[2] = (ws.AccelState.Values.Y < -0.07f);

            // if the Wiimote is tilted far enough to the right, toggle the Reft output
            _interfaceKit.outputs[3] = (ws.AccelState.Values.Y > 0.07f);
        }
Пример #22
0
 /// <summary>
 /// Constructs a new WiiMoteAccess object. If there is no wiimote attached to the computer (and I guarantee this will happen at least once)
 /// </summary>
 public WiimoteAccess()
 {
     try {
         lastSensor = new SensorTime(false, DateTime.Now, TimeSpan.Zero);
         wm         = new Wiimote();
         wm.SetLEDs(true, false, false, false);
         wm.WiimoteChanged          += new EventHandler <WiimoteChangedEventArgs>(wm_WiimoteChanged);
         wm.WiimoteExtensionChanged += new EventHandler <WiimoteExtensionChangedEventArgs>(wm_WiimoteExtensionChanged);
         wm.Connect();
         wm.SetReportType(InputReport.IRAccel, true);
         lastWMState = wm.WiimoteState;
         lastAState  = wm.WiimoteState.ButtonState.A;
     } catch (Exception) {
         DialogResult result = MessageBox.Show("A HIM Wiimote device was not found. Please ensure the WiiMote is connected to your computer" +
                                               " by a Bluetooth connection.");
     }
 }
Пример #23
0
        internal static bool GetState()
        {
            if (Wiimote == null)
            {
                return(false);
            }

            State = Wiimote.WiimoteState;

            if (rumbleTimeout > 0 && rumbleTimeout <= GameBase.Time)
            {
                rumbleTimeout = -1;
                Wiimote.SetRumble(false);
            }

            return(State != null);
        }
Пример #24
0
        /// <summary>
        /// This one will keep calling the capture loop
        /// </summary>
        private void captureLoop()
        {
            // Infinite loop until end of program, running on different thread
            while (true)
            {
                // Get the current ticks
                long ticks = DateTime.Now.Ticks;

                // Check if we need to sample again
                if (ticks >= lastUpdate + sampInterval)
                {
                    // Loop through the collection to see if we're capturing data from any of the WiiMotes
                    for (int i = 0; i < collection.Count; i++)
                    {
                        if (capturingList[i])
                        {
                            // Get the current WiiMote state
                            state = collection[i].WiimoteState;

                            // Get a vector from the list
                            Vector3 target;
                            int     cVec = curVec[i];

                            if (cVec < vecAmount)
                            {
                                target   = vecList[i][curVec[i]];
                                target.x = state.AccelState.Values.X;
                                target.y = state.AccelState.Values.Y;
                                target.z = state.AccelState.Values.Z;
                            }
                            else
                            {
                                target = new Vector3(state.AccelState.Values.X, state.AccelState.Values.Y, state.AccelState.Values.Z);
                            }
                            // Just get the values from the WiiMote, don't really need the raw ones since they'll require more processing
                            gestureList[i].Add(target);
                            curVec[i]++;
                        }
                    }

                    // Set the last update to the current ticks
                    lastUpdate = ticks;
                }
            }
        }
Пример #25
0
 void controller_StatusInfoChanged(object sender, EventArgs <WiimoteState> e)
 {
     if (Visible)
     {
         BeginInvoke((MethodInvoker) delegate() {
             WiimoteState state = e.Value;
             if (pbBattery.Value != (int)state.Battery)
             {
                 pbBattery.Value = (int)state.Battery;
                 lblBattery.Text = state.Battery.ToString("0\\%");
             }
             lblPoint1.Visible = state.IRState.IRSensors[0].Found;
             lblPoint2.Visible = state.IRState.IRSensors[1].Found;
             lblPoint3.Visible = state.IRState.IRSensors[2].Found;
             lblPoint4.Visible = state.IRState.IRSensors[3].Found;
         });
     }
 }
Пример #26
0
        private void UpdateWiimoteChanged(object args)
        {
            var eventArgs = args as WiimoteChangedEventArgs;

            if (args == null)
            {
                return;
            }

            WiimoteState ws = eventArgs.WiimoteState;

            if (ws == null)
            {
                return;
            }

            Cursor.SetPosition(eventArgs);
            Button.AnalyzeButton(ws); //button controller
        }
Пример #27
0
        //---------------------------------------------------------------------------------------------
        #region AnalyzeButton
        // Read and interpret the WiiMote data, acquired via Bluetooth;  basic work is done in
        // the library (Brian Peek-MVP C#/Coding4Fun). We are using the its interfaces:

        public static void AnalyzeButton(WiimoteState ws)
        {
            if (ws.ButtonState.A)
            {
                ButtonEvent(nWII_BUTTON_A, nWII_EVENT_DOWN, ref myButtons.ButtonA); // EventDown == '1'
            }
            else
            {
                ButtonEvent(nWII_BUTTON_A, nWII_EVENT_UP, ref myButtons.ButtonA); // EventDown == '2'
            }
            if (ws.ButtonState.B)
            {
                ButtonEvent(nWII_BUTTON_B, nWII_EVENT_DOWN, ref myButtons.ButtonB); // EventDown == '1'
            }
            else
            {
                ButtonEvent(nWII_BUTTON_B, nWII_EVENT_UP, ref myButtons.ButtonB); // EventDown == '2'
            }
        }
Пример #28
0
        //wiimoteのステータスが変わったのを検知して起動するイベント
        void wm_WiimoteChanged(object sender, WiimoteChangedEventArgs e)
        {
            //表示系(Form)の情報更新
            WiimoteInfo wi = mWiimoteMap[((Wiimote)sender).ID];

            wi.UpdateState(e);

            //WiimoteStateの値を取得
            wiimoteState = e.WiimoteState;

            switch (wiimoteState.ExtensionType)
            {
            //接続相手がbalanceboardであれば
            case ExtensionType.BalanceBoard:

                //デバッグ表示用
                //重さ(Kg)
                string weight = wiimoteState.BalanceBoardState.WeightKg + "kg";
                //重心のX座標
                string posX = "X:" +
                              wiimoteState.BalanceBoardState.CenterOfGravity.X;
                //重心のY座標
                string posY = "Y:" +
                              wiimoteState.BalanceBoardState.CenterOfGravity.Y;

                //送信用データリストを更新する
                //ここで横流しするデータを更新している
                WiimoteMessage message = new WiimoteMessage();                                                          //データ用意
                message.index   = wi.index;
                message.weight  = wiimoteState.BalanceBoardState.WeightKg;
                message.copPosX = wiimoteState.BalanceBoardState.CenterOfGravity.X;
                message.copPosY = wiimoteState.BalanceBoardState.CenterOfGravity.Y;

                message.loadTopRight    = wiimoteState.BalanceBoardState.SensorValuesKg.TopRight;
                message.loadTopLeft     = wiimoteState.BalanceBoardState.SensorValuesKg.TopLeft;
                message.loadBottomRight = wiimoteState.BalanceBoardState.SensorValuesKg.BottomRight;
                message.loadBottomLeft  = wiimoteState.BalanceBoardState.SensorValuesKg.BottomLeft;

                server.UpdateMessage(wi.index, message);                                                                //更新

                break;
            }
        }
Пример #29
0
        private void finelizeWiiMoteConnection()
        {
            if (!m_Connected)
            {
                m_WiiMote.Connect();
                m_Connected = true;
                m_WiiMote.SetReportType(Wiimote.InputReport.IRAccel, true);
                m_WiiMote.SetLEDs(true, false, false, false);
                m_CurrentWiiMoteState     = m_WiiMote.WiimoteState;
                m_PreviousWiiMoteState    = copyWiiMoteState(m_CurrentWiiMoteState);
                m_WiiMote.WiimoteChanged += onWiimoteChanged;
                fireConnectionStateChangeEvent(eWiiConnectivityState.Connected);
            }

            if (ConnectionEstablishedEvent != null)
            {
                ConnectionEstablishedEvent.Invoke(this, null);
            }
        }
Пример #30
0
        private WiimoteState copyWiiMoteState(WiimoteState i_WiiMoteState)
        {
            WiimoteState resultState = new WiimoteState();

            resultState.AccelCalibrationInfo.X0 = i_WiiMoteState.AccelCalibrationInfo.X0;
            resultState.AccelCalibrationInfo.XG = i_WiiMoteState.AccelCalibrationInfo.XG;
            resultState.AccelCalibrationInfo.Y0 = i_WiiMoteState.AccelCalibrationInfo.Y0;
            resultState.AccelCalibrationInfo.YG = i_WiiMoteState.AccelCalibrationInfo.Y0;
            resultState.AccelState.RawX         = i_WiiMoteState.AccelState.RawX;
            resultState.AccelState.RawY         = i_WiiMoteState.AccelState.RawY;
            resultState.AccelState.RawZ         = i_WiiMoteState.AccelState.RawZ;
            resultState.AccelState.X            = i_WiiMoteState.AccelState.X;
            resultState.AccelState.Y            = i_WiiMoteState.AccelState.Y;
            resultState.AccelState.Z            = i_WiiMoteState.AccelState.Z;
            resultState.Battery           = i_WiiMoteState.Battery;
            resultState.ButtonState.A     = i_WiiMoteState.ButtonState.A;
            resultState.ButtonState.B     = i_WiiMoteState.ButtonState.B;
            resultState.ButtonState.Down  = i_WiiMoteState.ButtonState.Down;
            resultState.ButtonState.Up    = i_WiiMoteState.ButtonState.Up;
            resultState.ButtonState.Left  = i_WiiMoteState.ButtonState.Left;
            resultState.ButtonState.Right = i_WiiMoteState.ButtonState.Right;
            resultState.ButtonState.Minus = i_WiiMoteState.ButtonState.Minus;
            resultState.ButtonState.Plus  = i_WiiMoteState.ButtonState.Plus;
            resultState.ButtonState.Home  = i_WiiMoteState.ButtonState.Home;
            resultState.ButtonState.One   = i_WiiMoteState.ButtonState.One;
            resultState.ButtonState.Two   = i_WiiMoteState.ButtonState.Two;
            resultState.Extension         = i_WiiMoteState.Extension;
            resultState.ExtensionType     = i_WiiMoteState.ExtensionType;
            resultState.IRState.Found1    = i_WiiMoteState.IRState.Found1;
            resultState.IRState.RawX1     = i_WiiMoteState.IRState.RawX1;
            resultState.IRState.RawY1     = i_WiiMoteState.IRState.RawY1;
            resultState.IRState.Found2    = i_WiiMoteState.IRState.Found2;
            resultState.IRState.RawX2     = i_WiiMoteState.IRState.RawX2;
            resultState.IRState.RawY2     = i_WiiMoteState.IRState.RawY2;
            resultState.IRState.Found3    = i_WiiMoteState.IRState.Found3;
            resultState.IRState.RawX3     = i_WiiMoteState.IRState.RawX3;
            resultState.IRState.RawY3     = i_WiiMoteState.IRState.RawY3;
            resultState.IRState.Found4    = i_WiiMoteState.IRState.Found4;
            resultState.IRState.RawX4     = i_WiiMoteState.IRState.RawX4;
            resultState.IRState.RawY4     = i_WiiMoteState.IRState.RawY4;
            return(resultState);
        }
Пример #31
0
 private void handleWiimoteConnectError(WiimoteState state)
 {
     disconnectWiimotes();
        stopCheckingWiimoteStatus();
 }
 public WiimoteConnectionException(Exception p_InnerException,WiimoteState p_State)
     : base(p_InnerException.Message, p_InnerException)
 {
     State = p_State;
 }
        private void handleWiimoteConnectError(WiimoteState state)
        {
            this.m_parent.SetTextWiimoteStatus(WIIMOTES_DISCONNECTED_STRING);
            this.m_parent.SetWiimoteButtonState((object)Form1.WiimoteButtonState.DISCONNECTED);

            string msg;
            if (state == WiimoteState.wiimoteDisconnectedState)
                msg = ProjectConstants.WIIMOTE_DISCONNECTED_MESSAGE;
            else if (state == WiimoteState.wiimoteBadDataState)
                msg = ProjectConstants.WIIMOTE_INVALID_DATA_MESSAGE;
            else
                msg = ProjectConstants.GENERAL_WIIMOTE_CONNECTION_ISSUE_MESSAGE;

            MessageBox.Show(msg,
                    "Wiimote Connection Issue", MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
        }
 public void onWiimoteStateIssue(WiimoteState state)
 {
     handleWiimoteConnectError(state);
 }
 public WiimoteConnectionException(string p_Message, WiimoteState p_State)
     : base(p_Message)
 {
 }