Beispiel #1
0
 public void OnTouchesMoved(List <CCTouch> touches, CCEvent touchEvent)
 {
     JoyControl.OnTouchesMoved(touches, touchEvent);
     foreach (var button in Buttons)
     {
         button.OnTouchesMoved(touches, touchEvent);
     }
 }
        public DeviceStatus(DeviceInfo info, CommonStream stream = null)
        {
            InitializeComponent();

            Info = info;

            if (info.InstanceGUID.Equals(Guid.Empty))
            {
                if (stream == null)
                {
                    Ninty = new NintyControl(Info);
                }
                else
                {
                    Ninty = new NintyControl(Info, stream);
                }

                Ninty.OnTypeChange  += Ninty_OnTypeChange;
                Ninty.OnDisconnect  += Ninty_OnDisconnect;
                Ninty.OnPrefsChange += Ninty_OnPrefsChange;
                Ninty.OnRumbleSubscriptionChange += Ninty_OnRumbleSubscriptionChange;

                // Use saved icon if there is one
                var prefs = AppPrefs.Instance.GetDevicePreferences(Info.DevicePath);
                if (prefs != null && !string.IsNullOrWhiteSpace(prefs.icon))
                {
                    icon.Source      = new BitmapImage(new Uri("../Images/Icons/" + prefs.icon, UriKind.Relative));
                    nickname.Content = string.IsNullOrWhiteSpace(prefs.nickname) ? info.Type.ToName() : prefs.nickname;
                }
                else
                {
                    UpdateType(info.Type);
                }
            }
            else
            {
                Joy = new JoyControl(Info);
                Joy.OnDisconnect  += Ninty_OnDisconnect;
                Joy.OnPrefsChange += Ninty_OnPrefsChange;
                nickname.Content   = JoyControl.ToName(Joy.Type);
                if (info.VID == "057e" && info.PID == "2006")
                {
                    icon.Source = new BitmapImage(new Uri("../Images/Icons/switch_jcl_black.png", UriKind.Relative));
                }
                else if (info.VID == "057e" && info.PID == "2007")
                {
                    icon.Source = new BitmapImage(new Uri("../Images/Icons/switch_jcr_black.png", UriKind.Relative));
                }
                else if (info.VID == "057e" && info.PID == "2009")
                {
                    icon.Source = new BitmapImage(new Uri("../Images/Icons/switch_pro_black.png", UriKind.Relative));
                }
                else
                {
                    icon.Source = new BitmapImage(new Uri("../Images/Icons/joystick_icon.png", UriKind.Relative));
                }
            }
        }
Beispiel #3
0
 public CCPoint GetPlayerPosition(float dt, CCSize wSize)
 {
     if (JoyControl != null && Player != null)
     {
         return(JoyControl.GetNextPositionFromImage(Player, dt, wSize));
     }
     Console.WriteLine("SNEAKYCONTROL > GETPLAYERPOSITION() : ERROR. NOT PLAYER ASSIGNED");
     return(CCPoint.Zero);
 }
Beispiel #4
0
 public void OnTouchesBegan(List <CCTouch> touches, CCEvent touchEvent)
 {
     if (JoyControl != null)
     {
         JoyControl.OnTouchesBegan(touches, touchEvent);
     }
     foreach (var button in Buttons)
     {
         button.OnTouchesBegan(touches, touchEvent);
     }
 }
Beispiel #5
0
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            if (instance != this)
            {
                Destroy(gameObject);
            }
        }

        DontDestroyOnLoad(gameObject);
    }
Beispiel #6
0
 public void Draw()
 {
     if (IsDebug)
     {
         CCSize visibleBoundsSize = VisibleBoundsWorldspace.Size;
         drawNode.DrawRect(new CCRect(0, 0, visibleBoundsSize.Width, visibleBoundsSize.Height), CCColor4B.Blue);
         if (JoyControl != null)
         {
             JoyControl.Draw();
         }
         foreach (var button in Buttons)
         {
             button.Draw();
         }
     }
 }
Beispiel #7
0
        private void RightJoy_Click(object sender, EventArgs e)
        {
            JoyControl b = new JoyControl();

            Controls.Add(b);
            b.Location = new Point(10, 176);
            b.Size     = new Size(178, 174);
            b.IsLeft   = false;
            b.m_InputType_Box.SelectedIndex = (int)Preset.Current.m_BindList.RightJoyType;
            b.m_JoyPress_Ctrl.Key           = Preset.Current.m_BindList.RightJoyPress;
            b.m_BindUp.Key    = Preset.Current.m_BindList.RightJoyUp;
            b.m_BindDown.Key  = Preset.Current.m_BindList.RightJoyDown;
            b.m_BindRight.Key = Preset.Current.m_BindList.RightJoyRight;
            b.m_BindLeft.Key  = Preset.Current.m_BindList.RightJoyLeft;

            KeyPanelClass.CurrentPanel = b;
        }
        public void UpdateVisual(JoystickUpdate[] updates)
        {
            foreach (var update in updates)
            {
                switch (update.Offset)
                {
                case JoystickOffset.Buttons0: bBtn.Opacity = update.Value > 0 ? 1 : 0; break;

                case JoystickOffset.Buttons1: aBtn.Opacity = update.Value > 0 ? 1 : 0; break;

                case JoystickOffset.Buttons2: yBtn.Opacity = update.Value > 0 ? 1 : 0; break;

                case JoystickOffset.Buttons3: xBtn.Opacity = update.Value > 0 ? 1 : 0; break;

                case JoystickOffset.Buttons4: lBtn.Opacity = update.Value > 0 ? 1 : 0; break;

                case JoystickOffset.Buttons5: rBtn.Opacity = update.Value > 0 ? 1 : 0; break;

                case JoystickOffset.Buttons6: zlBtn.Opacity = update.Value > 0 ? 1 : 0; break;

                case JoystickOffset.Buttons7: zrBtn.Opacity = update.Value > 0 ? 1 : 0; break;

                case JoystickOffset.Buttons8: minusBtn.Opacity = update.Value > 0 ? 1 : 0; break;

                case JoystickOffset.Buttons9: plusBtn.Opacity = update.Value > 0 ? 1 : 0; break;

                case JoystickOffset.Buttons10: leftStickButton.Opacity = update.Value > 0 ? 1 : 0; break;

                case JoystickOffset.Buttons11: rightStickButton.Opacity = update.Value > 0 ? 1 : 0; break;

                case JoystickOffset.Buttons12: homeBtn.Opacity = update.Value > 0 ? 1 : 0; break;

                case JoystickOffset.Buttons13: shareBtn.Opacity = update.Value > 0 ? 1 : 0; break;

                case JoystickOffset.PointOfViewControllers0:
                    leftBtn.Opacity  = 0;
                    rightBtn.Opacity = 0;
                    upBtn.Opacity    = 0;
                    downBtn.Opacity  = 0;
                    center.Opacity   = 0;
                    if (update.Value == -1)
                    {
                        break;
                    }
                    else if (update.Value == 0)
                    {
                        upBtn.Opacity  = 1;
                        center.Opacity = 1;
                    }
                    else if (update.Value > 0 && update.Value < 9000)
                    {
                        upBtn.Opacity    = 1;
                        rightBtn.Opacity = 1;
                        center.Opacity   = 1;
                    }
                    else if (update.Value == 9000)
                    {
                        rightBtn.Opacity = 1;
                        center.Opacity   = 1;
                    }
                    else if (update.Value > 9000 && update.Value < 18000)
                    {
                        rightBtn.Opacity = 1;
                        downBtn.Opacity  = 1;
                        center.Opacity   = 1;
                    }
                    else if (update.Value == 18000)
                    {
                        downBtn.Opacity = 1;
                        center.Opacity  = 1;
                    }
                    else if (update.Value > 18000 && update.Value < 27000)
                    {
                        downBtn.Opacity = 1;
                        leftBtn.Opacity = 1;
                        center.Opacity  = 1;
                    }
                    else if (update.Value == 27000)
                    {
                        leftBtn.Opacity = 1;
                        center.Opacity  = 1;
                    }
                    else if (update.Value > 27000)
                    {
                        leftBtn.Opacity = 1;
                        upBtn.Opacity   = 1;
                        center.Opacity  = 1;
                    }
                    break;

                case JoystickOffset.X:
                    _calLeftJoystick.rawX = update.Value;
                    break;

                case JoystickOffset.Y:
                    _calLeftJoystick.rawY = 65535 - update.Value;
                    break;

                case JoystickOffset.RotationX:
                    _calRightJoystick.rawX = update.Value;
                    break;

                case JoystickOffset.RotationY:
                    _calRightJoystick.rawY = 65535 - update.Value;
                    break;
                }
            }

            var joyL = JoyControl.ConvertToNintyJoy(leftXCalibration, leftYCalibration);
            var joyR = JoyControl.ConvertToNintyJoy(rightXCalibration, rightYCalibration);

            joyL.rawX = _calLeftJoystick.rawX;
            joyL.rawY = _calLeftJoystick.rawY;
            joyR.rawX = _calRightJoystick.rawX;
            joyR.rawY = _calRightJoystick.rawY;

            joyL.Normalize();
            joyR.Normalize();

            leftStick.Margin        = new Thickness(146 + 30 * joyL.X, 291 - 30 * joyL.Y, 0, 0);
            rightStick.Margin       = new Thickness(507 + 30 * joyR.X, 412 - 30 * joyR.Y, 0, 0);
            leftStickButton.Margin  = leftStick.Margin;
            rightStickButton.Margin = rightStick.Margin;

            if (_openJoyWindow != null)
            {
                _openJoyWindow.Update(_leftCalibration ? _calLeftJoystick : _calRightJoystick);
            }
        }
Beispiel #9
0
 // Use this for initialization
 protected void Start()
 {
     //Debug.Log("Start");
     yAxis        = new Vector3(0, 1, 0);
     targetScript = UIObj.GetComponent <JoyControl>();
 }