Exemplo n.º 1
0
        public void UpdateVisual(INintrollerState state)
        {
            _lastState = state;
            if (state is Wiimote)
            {
                if (viewNunchuk.Visibility == Visibility.Visible)
                {
                    viewNunchuk.Visibility = Visibility.Collapsed;
                }
                if (viewClassicController.Visibility == Visibility.Visible)
                {
                    viewClassicController.Visibility = Visibility.Collapsed;
                }
                if (viewClassicControllerPro.Visibility == Visibility.Visible)
                {
                    viewClassicControllerPro.Visibility = Visibility.Collapsed;
                }

                UpdateWiimoteVisual((Wiimote)state);
            }
            else if (state is Nunchuk)
            {
                if (viewNunchuk.Visibility != Visibility.Visible)
                {
                    viewNunchuk.Visibility = Visibility.Visible;
                }
                if (viewClassicController.Visibility == Visibility.Visible)
                {
                    viewClassicController.Visibility = Visibility.Collapsed;
                }
                if (viewClassicControllerPro.Visibility == Visibility.Visible)
                {
                    viewClassicControllerPro.Visibility = Visibility.Collapsed;
                }

                var nun = (Nunchuk)state;
                UpdateWiimoteVisual(nun.wiimote);

                nBtnC.Opacity = nun.C ? 1 : 0;
                nBtnZ.Opacity = nun.Z ? 1 : 0;
                nJoy.Margin   = new Thickness(70 + 30 * nun.joystick.X, 360 - 30 * nun.joystick.Y, 0, 0);

                if (_openJoyWindow != null && _calibrationTarget == App.CAL_NUN_JOYSTICK)
                {
                    _openJoyWindow.Update(nun.joystick);
                }
            }
            else if (state is ClassicController)
            {
                if (viewNunchuk.Visibility == Visibility.Visible)
                {
                    viewNunchuk.Visibility = Visibility.Collapsed;
                }
                if (viewClassicController.Visibility != Visibility.Visible)
                {
                    viewClassicController.Visibility = Visibility.Visible;
                }
                if (viewClassicControllerPro.Visibility == Visibility.Visible)
                {
                    viewClassicControllerPro.Visibility = Visibility.Collapsed;
                }

                var cc = (ClassicController)state;
                UpdateWiimoteVisual(cc.wiimote);

                ccBtnA.Opacity      = cc.A ? 1 : 0;
                ccBtnB.Opacity      = cc.B ? 1 : 0;
                ccBtnX.Opacity      = cc.X ? 1 : 0;
                ccBtnY.Opacity      = cc.Y ? 1 : 0;
                ccBtnUp.Opacity     = cc.Up ? 1 : 0;
                ccBtnDown.Opacity   = cc.Down ? 1 : 0;
                ccBtnRight.Opacity  = cc.Right ? 1 : 0;
                ccBtnLeft.Opacity   = cc.Left ? 1 : 0;
                ccPadCenter.Opacity = cc.Up || cc.Down || cc.Left || cc.Right ? 1 : 0;
                ccBtnHome.Opacity   = cc.Home ? 1 : 0;
                ccBtnSelect.Opacity = cc.Select ? 1 : 0;
                ccBtnStart.Opacity  = cc.Start ? 1 : 0;
                ccBtnZL.Opacity     = cc.ZL ? 1 : 0;
                ccBtnZR.Opacity     = cc.ZR ? 1 : 0;
                ccL.Opacity         = cc.L.value > 0 ? 1 : 0;
                ccR.Opacity         = cc.R.value > 0 ? 1 : 0;
                ccLeftStick.Margin  = new Thickness(208 + 30 * cc.LJoy.X, 210 - 30 * cc.LJoy.Y, 0, 0);
                ccRightStick.Margin = new Thickness(364 + 30 * cc.RJoy.X, 210 - 30 * cc.RJoy.Y, 0, 0);

                if (_openJoyWindow != null && _calibrationTarget.StartsWith("cc"))
                {
                    if (_calibrationTarget == App.CAL_CC_LJOYSTICK)
                    {
                        _openJoyWindow.Update(cc.LJoy);
                    }
                    else if (_calibrationTarget == App.CAL_CC_RJOYSTICK)
                    {
                        _openJoyWindow.Update(cc.RJoy);
                    }
                }
                else if (_openTrigWindow != null && _calibrationTarget.StartsWith("cc"))
                {
                    if (_calibrationTarget == "ccLT")
                    {
                        _openTrigWindow.Update(cc.L);
                    }
                    else if (_calibrationTarget == "ccRT")
                    {
                        _openTrigWindow.Update(cc.R);
                    }
                }
            }
            else if (state is ClassicControllerPro)
            {
                if (viewNunchuk.Visibility == Visibility.Visible)
                {
                    viewNunchuk.Visibility = Visibility.Collapsed;
                }
                if (viewClassicController.Visibility == Visibility.Visible)
                {
                    viewClassicController.Visibility = Visibility.Collapsed;
                }
                if (viewClassicControllerPro.Visibility != Visibility.Visible)
                {
                    viewClassicControllerPro.Visibility = Visibility.Visible;
                }

                var ccp = (ClassicControllerPro)state;
                UpdateWiimoteVisual(ccp.wiimote);

                ccpBtnA.Opacity      = ccp.A ? 1 : 0;
                ccpBtnB.Opacity      = ccp.B ? 1 : 0;
                ccpBtnX.Opacity      = ccp.X ? 1 : 0;
                ccpBtnY.Opacity      = ccp.Y ? 1 : 0;
                ccpBtnUp.Opacity     = ccp.Up ? 1 : 0;
                ccpBtnDown.Opacity   = ccp.Down ? 1 : 0;
                ccpBtnRight.Opacity  = ccp.Right ? 1 : 0;
                ccpBtnLeft.Opacity   = ccp.Left ? 1 : 0;
                ccpPadCenter.Opacity = ccp.Up || ccp.Down || ccp.Left || ccp.Right ? 1 : 0;
                ccpBtnHome.Opacity   = ccp.Home ? 1 : 0;
                ccpBtnSelect.Opacity = ccp.Select ? 1 : 0;
                ccpBtnStart.Opacity  = ccp.Start ? 1 : 0;
                ccpBtnZL.Opacity     = ccp.ZL ? 1 : 0;
                ccpBtnZR.Opacity     = ccp.ZR ? 1 : 0;
                ccpBtnL.Opacity      = ccp.L ? 1 : 0;
                ccpBtnR.Opacity      = ccp.R ? 1 : 0;
                ccpLeftStick.Margin  = new Thickness(255 + 30 * ccp.LJoy.X, 279 - 30 * ccp.LJoy.Y, 0, 0);
                ccpRightStick.Margin = new Thickness(485 + 30 * ccp.RJoy.X, 279 - 30 * ccp.RJoy.Y, 0, 0);

                if (_openJoyWindow != null && _calibrationTarget.StartsWith("ccp"))
                {
                    if (_calibrationTarget == App.CAL_CCP_LJOYSTICK)
                    {
                        _openJoyWindow.Update(ccp.LJoy);
                    }
                    else if (_calibrationTarget == App.CAL_CCP_RJOYSTICK)
                    {
                        _openJoyWindow.Update(ccp.RJoy);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void UpdateVisual(INintrollerState state)
        {
            if (state is GameCubeAdapter gcn)
            {
                _lastState = gcn;
                GameCubeController activePort;

                bool connecited = GetActivePort(out activePort);

                A.Opacity     = activePort.A ? 1 : 0;
                B.Opacity     = activePort.B ? 1 : 0;
                X.Opacity     = activePort.X ? 1 : 0;
                Y.Opacity     = activePort.Y ? 1 : 0;
                Z.Opacity     = activePort.Z ? 1 : 0;
                START.Opacity = activePort.Start ? 1 : 0;

                dpadUp.Opacity    = activePort.Up ? 1 : 0;
                dpadDown.Opacity  = activePort.Down ? 1 : 0;
                dpadLeft.Opacity  = activePort.Left ? 1 : 0;
                dpadRight.Opacity = activePort.Right ? 1 : 0;

                L.Opacity = activePort.L.value > 0 ? 1 : 0;
                R.Opacity = activePort.R.value > 0 ? 1 : 0;

                var lOpacityMask = L.OpacityMask as LinearGradientBrush;
                if (lOpacityMask != null && lOpacityMask.GradientStops.Count == 2)
                {
                    double offset = 1 - System.Math.Min(1, activePort.L.value);
                    lOpacityMask.GradientStops[0].Offset = offset;
                    lOpacityMask.GradientStops[1].Offset = offset;
                }

                var rOpacityMask = R.OpacityMask as LinearGradientBrush;
                if (rOpacityMask != null && rOpacityMask.GradientStops.Count == 2)
                {
                    double offset = 1 - System.Math.Min(1, activePort.R.value);
                    rOpacityMask.GradientStops[0].Offset = offset;
                    rOpacityMask.GradientStops[1].Offset = offset;
                }

                joystick.Margin = new Thickness(190 + 100 * activePort.joystick.X, 272 - 100 * activePort.joystick.Y, 0, 0);
                cStick.Margin   = new Thickness(887 + 100 * activePort.cStick.X, 618 - 100 * activePort.cStick.Y, 0, 0);

                connectionStatus.Content = connecited ? _connectedStatus : _disconnectedStatus;

                if (_openJoyWindow != null)
                {
                    if (_calibrationTarget == "joy")
                    {
                        _openJoyWindow.Update(activePort.joystick);
                    }
                    else if (_calibrationTarget == "cStk")
                    {
                        _openJoyWindow.Update(activePort.cStick);
                    }
                }
                else if (_openTrigWindow != null)
                {
                    if (_calibrationTarget == "L")
                    {
                        _openTrigWindow.Update(activePort.L);
                    }
                    else if (_calibrationTarget == "R")
                    {
                        _openTrigWindow.Update(activePort.R);
                    }
                }
            }
        }
        public void UpdateVisual(INintrollerState state)
        {
            _lastState = state;
            if (state is Wiimote)
            {
                if (viewNunchuk.Visibility == Visibility.Visible)
                {
                    viewNunchuk.Visibility = Visibility.Collapsed;
                }
                if (viewClassicController.Visibility == Visibility.Visible)
                {
                    viewClassicController.Visibility = Visibility.Collapsed;
                }
                if (viewClassicControllerPro.Visibility == Visibility.Visible)
                {
                    viewClassicControllerPro.Visibility = Visibility.Collapsed;
                }
                if (viewGuitar.Visibility == Visibility.Visible)
                {
                    viewGuitar.Visibility = Visibility.Collapsed;
                }
                if (viewTaikoDrum.Visibility == Visibility.Visible)
                {
                    viewTaikoDrum.Visibility = Visibility.Collapsed;
                }

                UpdateWiimoteVisual((Wiimote)state);
            }
            else if (state is Nunchuk)
            {
                if (viewNunchuk.Visibility != Visibility.Visible)
                {
                    viewNunchuk.Visibility = Visibility.Visible;
                }
                if (viewClassicController.Visibility == Visibility.Visible)
                {
                    viewClassicController.Visibility = Visibility.Collapsed;
                }
                if (viewClassicControllerPro.Visibility == Visibility.Visible)
                {
                    viewClassicControllerPro.Visibility = Visibility.Collapsed;
                }
                if (viewGuitar.Visibility == Visibility.Visible)
                {
                    viewGuitar.Visibility = Visibility.Collapsed;
                }
                if (viewTaikoDrum.Visibility == Visibility.Visible)
                {
                    viewTaikoDrum.Visibility = Visibility.Collapsed;
                }

                var nun = (Nunchuk)state;
                UpdateWiimoteVisual(nun.wiimote);

                nBtnC.Opacity = nun.C ? 1 : 0;
                nBtnZ.Opacity = nun.Z ? 1 : 0;
                nJoy.Margin   = new Thickness(70 + 30 * nun.joystick.X, 360 - 30 * nun.joystick.Y, 0, 0);

                if (_openJoyWindow != null && _calibrationTarget == App.CAL_NUN_JOYSTICK)
                {
                    _openJoyWindow.Update(nun.joystick);
                }
            }
            else if (state is ClassicController)
            {
                if (viewNunchuk.Visibility == Visibility.Visible)
                {
                    viewNunchuk.Visibility = Visibility.Collapsed;
                }
                if (viewClassicController.Visibility != Visibility.Visible)
                {
                    viewClassicController.Visibility = Visibility.Visible;
                }
                if (viewClassicControllerPro.Visibility == Visibility.Visible)
                {
                    viewClassicControllerPro.Visibility = Visibility.Collapsed;
                }
                if (viewGuitar.Visibility == Visibility.Visible)
                {
                    viewGuitar.Visibility = Visibility.Collapsed;
                }
                if (viewTaikoDrum.Visibility == Visibility.Visible)
                {
                    viewTaikoDrum.Visibility = Visibility.Collapsed;
                }

                var cc = (ClassicController)state;
                UpdateWiimoteVisual(cc.wiimote);

                ccBtnA.Opacity      = cc.A ? 1 : 0;
                ccBtnB.Opacity      = cc.B ? 1 : 0;
                ccBtnX.Opacity      = cc.X ? 1 : 0;
                ccBtnY.Opacity      = cc.Y ? 1 : 0;
                ccBtnUp.Opacity     = cc.Up ? 1 : 0;
                ccBtnDown.Opacity   = cc.Down ? 1 : 0;
                ccBtnRight.Opacity  = cc.Right ? 1 : 0;
                ccBtnLeft.Opacity   = cc.Left ? 1 : 0;
                ccPadCenter.Opacity = cc.Up || cc.Down || cc.Left || cc.Right ? 1 : 0;
                ccBtnHome.Opacity   = cc.Home ? 1 : 0;
                ccBtnSelect.Opacity = cc.Select ? 1 : 0;
                ccBtnStart.Opacity  = cc.Start ? 1 : 0;
                ccBtnZL.Opacity     = cc.ZL ? 1 : 0;
                ccBtnZR.Opacity     = cc.ZR ? 1 : 0;
                ccL.Opacity         = cc.L.value > 0 ? 1 : 0;
                ccR.Opacity         = cc.R.value > 0 ? 1 : 0;
                ccLeftStick.Margin  = new Thickness(208 + 30 * cc.LJoy.X, 210 - 30 * cc.LJoy.Y, 0, 0);
                ccRightStick.Margin = new Thickness(364 + 30 * cc.RJoy.X, 210 - 30 * cc.RJoy.Y, 0, 0);

                if (_openJoyWindow != null && _calibrationTarget.StartsWith("cc"))
                {
                    if (_calibrationTarget == App.CAL_CC_LJOYSTICK)
                    {
                        _openJoyWindow.Update(cc.LJoy);
                    }
                    else if (_calibrationTarget == App.CAL_CC_RJOYSTICK)
                    {
                        _openJoyWindow.Update(cc.RJoy);
                    }
                }
                else if (_openTrigWindow != null && _calibrationTarget.StartsWith("cc"))
                {
                    if (_calibrationTarget == "ccLT")
                    {
                        _openTrigWindow.Update(cc.L);
                    }
                    else if (_calibrationTarget == "ccRT")
                    {
                        _openTrigWindow.Update(cc.R);
                    }
                }
            }
            else if (state is ClassicControllerPro)
            {
                if (viewNunchuk.Visibility == Visibility.Visible)
                {
                    viewNunchuk.Visibility = Visibility.Collapsed;
                }
                if (viewClassicController.Visibility == Visibility.Visible)
                {
                    viewClassicController.Visibility = Visibility.Collapsed;
                }
                if (viewClassicControllerPro.Visibility != Visibility.Visible)
                {
                    viewClassicControllerPro.Visibility = Visibility.Visible;
                }
                if (viewGuitar.Visibility == Visibility.Visible)
                {
                    viewGuitar.Visibility = Visibility.Collapsed;
                }
                if (viewTaikoDrum.Visibility == Visibility.Visible)
                {
                    viewTaikoDrum.Visibility = Visibility.Collapsed;
                }

                var ccp = (ClassicControllerPro)state;
                UpdateWiimoteVisual(ccp.wiimote);

                ccpBtnA.Opacity      = ccp.A ? 1 : 0;
                ccpBtnB.Opacity      = ccp.B ? 1 : 0;
                ccpBtnX.Opacity      = ccp.X ? 1 : 0;
                ccpBtnY.Opacity      = ccp.Y ? 1 : 0;
                ccpBtnUp.Opacity     = ccp.Up ? 1 : 0;
                ccpBtnDown.Opacity   = ccp.Down ? 1 : 0;
                ccpBtnRight.Opacity  = ccp.Right ? 1 : 0;
                ccpBtnLeft.Opacity   = ccp.Left ? 1 : 0;
                ccpPadCenter.Opacity = ccp.Up || ccp.Down || ccp.Left || ccp.Right ? 1 : 0;
                ccpBtnHome.Opacity   = ccp.Home ? 1 : 0;
                ccpBtnSelect.Opacity = ccp.Select ? 1 : 0;
                ccpBtnStart.Opacity  = ccp.Start ? 1 : 0;
                ccpBtnZL.Opacity     = ccp.ZL ? 1 : 0;
                ccpBtnZR.Opacity     = ccp.ZR ? 1 : 0;
                ccpBtnL.Opacity      = ccp.L ? 1 : 0;
                ccpBtnR.Opacity      = ccp.R ? 1 : 0;
                ccpLeftStick.Margin  = new Thickness(255 + 30 * ccp.LJoy.X, 279 - 30 * ccp.LJoy.Y, 0, 0);
                ccpRightStick.Margin = new Thickness(485 + 30 * ccp.RJoy.X, 279 - 30 * ccp.RJoy.Y, 0, 0);

                if (_openJoyWindow != null && _calibrationTarget.StartsWith("ccp"))
                {
                    if (_calibrationTarget == App.CAL_CCP_LJOYSTICK)
                    {
                        _openJoyWindow.Update(ccp.LJoy);
                    }
                    else if (_calibrationTarget == App.CAL_CCP_RJOYSTICK)
                    {
                        _openJoyWindow.Update(ccp.RJoy);
                    }
                }
            }
            else if (state is Guitar)
            {
                if (viewNunchuk.Visibility == Visibility.Visible)
                {
                    viewNunchuk.Visibility = Visibility.Collapsed;
                }
                if (viewClassicController.Visibility == Visibility.Visible)
                {
                    viewClassicController.Visibility = Visibility.Collapsed;
                }
                if (viewClassicControllerPro.Visibility == Visibility.Visible)
                {
                    viewClassicControllerPro.Visibility = Visibility.Collapsed;
                }
                if (viewGuitar.Visibility != Visibility.Visible)
                {
                    viewGuitar.Visibility = Visibility.Visible;
                }
                if (viewTaikoDrum.Visibility == Visibility.Visible)
                {
                    viewTaikoDrum.Visibility = Visibility.Collapsed;
                }

                var gut = (Guitar)state;
                UpdateWiimoteVisual(gut.wiimote);

                gBtnGreen.Opacity     = gut.Green ? 1 : 0;
                gBtnRed.Opacity       = gut.Red ? 1 : 0;
                gBtnYellow.Opacity    = gut.Yellow ? 1 : 0;
                gBtnBlue.Opacity      = gut.Blue ? 1 : 0;
                gBtnOrange.Opacity    = gut.Orange ? 1 : 0;
                gBtnStrumUp.Opacity   = gut.StrumUp ? 1 : 0;
                gBtnStrumDown.Opacity = gut.StrumDown ? 1 : 0;
                gBtnPlus.Opacity      = gut.Plus ? 1 : 0;
                gBtnMinus.Opacity     = gut.Minus ? 1 : 0;
                gTouch1.Opacity       = gut.T1 ? 1 : 0;
                gTouch2.Opacity       = gut.T2 ? 1 : 0;
                gTouch3.Opacity       = gut.T3 ? 1 : 0;
                gTouch4.Opacity       = gut.T4 ? 1 : 0;
                gTouch5.Opacity       = gut.T5 ? 1 : 0;
                gStick.Margin         = new Thickness(1236 + 30 * gut.joystick.X, 283 - 30 * gut.joystick.Y, 0, 0);
                gStick.Margin         = new Thickness(1236 + 30 * gut.joystick.X, 283 - 30 * gut.joystick.Y, 0, 0);
                gWhammy.Margin        = new Thickness(345 + 60 * gut.whammyBar.value, 815 - 20 * gut.whammyBar.value, 0, 0);

                if (_openJoyWindow != null && _calibrationTarget == App.CAL_GUT_JOYSTICK)
                {
                    _openJoyWindow.Update(gut.joystick);
                }
                else if (_openTrigWindow != null && _calibrationTarget == App.CAL_GUT_WHAMMY)
                {
                    _openTrigWindow.Update(gut.whammyBar);
                }
            }
            else if (state is TaikoDrum)
            {
                if (viewNunchuk.Visibility == Visibility.Visible)
                {
                    viewNunchuk.Visibility = Visibility.Collapsed;
                }
                if (viewClassicController.Visibility == Visibility.Visible)
                {
                    viewClassicController.Visibility = Visibility.Collapsed;
                }
                if (viewClassicControllerPro.Visibility == Visibility.Visible)
                {
                    viewClassicControllerPro.Visibility = Visibility.Collapsed;
                }
                if (viewGuitar.Visibility == Visibility.Visible)
                {
                    viewGuitar.Visibility = Visibility.Collapsed;
                }
                if (viewTaikoDrum.Visibility != Visibility.Visible)
                {
                    viewTaikoDrum.Visibility = Visibility.Visible;
                }

                var tak = (TaikoDrum)state;
                UpdateWiimoteVisual(tak.wiimote);

                takL.Fill      = tak.centerLeft ? System.Windows.Media.Brushes.Red : System.Windows.Media.Brushes.White;
                takR.Fill      = tak.centerRight ? System.Windows.Media.Brushes.Red : System.Windows.Media.Brushes.White;
                takRimL.Stroke = tak.rimLeft ? System.Windows.Media.Brushes.Blue : System.Windows.Media.Brushes.White;
                takRimR.Stroke = tak.rimRight ? System.Windows.Media.Brushes.Blue : System.Windows.Media.Brushes.White;
            }
        }