Beispiel #1
0
 private void processJoystick()
 {
     try
     {
         dfControl activeControl = dfGUIManager.ActiveControl;
         if (!(activeControl == null) && activeControl.transform.IsChildOf(base.transform))
         {
             float axis   = this.adapter.GetAxis(this.horizontalAxis);
             float single = this.adapter.GetAxis(this.verticalAxis);
             if (Mathf.Abs(axis) < 0.5f && Mathf.Abs(single) <= 0.5f)
             {
                 this.lastAxisCheck = Time.deltaTime - this.axisPollingInterval;
             }
             if (Time.realtimeSinceStartup - this.lastAxisCheck > this.axisPollingInterval)
             {
                 if (Mathf.Abs(axis) >= 0.5f)
                 {
                     this.lastAxisCheck = Time.realtimeSinceStartup;
                     activeControl.OnKeyDown(new dfKeyEventArgs(activeControl, (axis <= 0f ? KeyCode.LeftArrow : KeyCode.RightArrow), false, false, false));
                 }
                 if (Mathf.Abs(single) >= 0.5f)
                 {
                     this.lastAxisCheck = Time.realtimeSinceStartup;
                     activeControl.OnKeyDown(new dfKeyEventArgs(activeControl, (single <= 0f ? KeyCode.DownArrow : KeyCode.UpArrow), false, false, false));
                 }
             }
             if (this.joystickClickButton != KeyCode.None)
             {
                 if (this.adapter.GetKeyDown(this.joystickClickButton))
                 {
                     Vector3          center          = activeControl.GetCenter();
                     Camera           camera          = activeControl.GetCamera();
                     Ray              ray             = camera.ScreenPointToRay(camera.WorldToScreenPoint(center));
                     dfMouseEventArgs dfMouseEventArg = new dfMouseEventArgs(activeControl, dfMouseButtons.Left, 0, ray, center, 0f);
                     activeControl.OnMouseDown(dfMouseEventArg);
                     this.buttonDownTarget = activeControl;
                 }
                 if (this.adapter.GetKeyUp(this.joystickClickButton))
                 {
                     if (this.buttonDownTarget == activeControl)
                     {
                         activeControl.DoClick();
                     }
                     Vector3          vector3          = activeControl.GetCenter();
                     Camera           camera1          = activeControl.GetCamera();
                     Ray              ray1             = camera1.ScreenPointToRay(camera1.WorldToScreenPoint(vector3));
                     dfMouseEventArgs dfMouseEventArg1 = new dfMouseEventArgs(activeControl, dfMouseButtons.Left, 0, ray1, vector3, 0f);
                     activeControl.OnMouseUp(dfMouseEventArg1);
                     this.buttonDownTarget = null;
                 }
             }
             for (KeyCode i = KeyCode.Joystick1Button0; i <= KeyCode.Joystick1Button19; i++)
             {
                 if (this.adapter.GetKeyDown(i))
                 {
                     activeControl.OnKeyDown(new dfKeyEventArgs(activeControl, i, false, false, false));
                 }
             }
         }
     }
     catch (UnityException unityException)
     {
         Debug.LogError(unityException.ToString(), this);
         this.useJoystick = false;
     }
 }