Exemplo n.º 1
0
 public void OnDisconnected(string deviceId)
 {
     log("OnDisconnected: " + deviceId);
     talonRing  = null;
     connecting = false;
     TalonSDK.Talon.Scan(); //retry?
 }
Exemplo n.º 2
0
 void Awake()
 {
     if (_instance != null)
     {
         Debug.LogError("More than one TalonConnect instance was found in your scene");
         enabled = false;
         return;
     }
     _instance  = this;
     connecting = false;
     talonRing  = null;
 }
Exemplo n.º 3
0
    private void AddTalonRing(string deviceId)
    {
        if (testObjects.ContainsKey(deviceId))
        {
            return;
        }
        TalonSDK.TalonRing ring    = TalonSDK.Talon.GetConnectedRing(deviceId);
        GameObject         testObj = Instantiate(ringObject) as GameObject;

        testObj.SetActive(false);
        testObj.GetComponent <TalonTester>().Init(ring);
        testObj.transform.SetParent(transform, false);
        testObjects.Add(deviceId, testObj);
        UpdateVisibleRing();
    }
Exemplo n.º 4
0
    void Update()
    {
        int buttonCount = buttons.Count;

        for (int i = 0; i < buttonCount; ++i)
        {
            if (i == selectedIndex)
            {
                buttons[i].Select();
            }
        }

        if (TalonConnect.TalonRing == null)
        {
            return;
        }

        TalonSDK.TalonRing ring = TalonConnect.TalonRing;

        if (ring.BottomButtonDown)
        {
            popup.SetActive(!popup.activeSelf);
        }

        if (popup.activeSelf)
        {
            return;
        }

        Vector3 forward = ring.Orientation * Vector3.forward;

        if (prevVector != Vector3.zero && !ring.Recentered)
        {
            if (currentCooldown > 0)
            {
                currentCooldown -= Time.deltaTime;
            }
            else
            {
                Vector3 speed = (forward - prevVector) / Time.deltaTime;

                float Xmag = Mathf.Abs(speed.x);
                float Ymag = Mathf.Abs(speed.y);

                if (Xmag > 2.5 || Ymag > 2.5)
                {
                    currentCooldown = swipeCooldown;
                    if (Xmag > Ymag)
                    {
                        if (speed.x < 0)
                        {
                            OnLeft();
                        }
                        else
                        {
                            OnRight();
                        }
                    }
                    else
                    {
                        if (speed.y > 0)
                        {
                            OnUp();
                        }
                        else
                        {
                            OnDown();
                        }
                    }
                }
            }
        }

        prevVector = forward;
    }
Exemplo n.º 5
0
 public void OnConnected(string deviceId)
 {
     log("OnConnected: " + deviceId);
     talonRing  = TalonSDK.Talon.GetConnectedRing(deviceId);
     connecting = false;
 }