public static void Update() { if (dllPresent) { //present = Available(); uint numControllersBound = 0; uint numControllersEnabled = 0; SixensePlugin.sixenseControllerData cd = new SixensePlugin.sixenseControllerData(); for (int i = 0; i < MAX_CONTROLLERS; i++) { if (m_Controllers[i] != null) { if (SixensePlugin.sixenseIsControllerEnabled(i) == 1) { status = Status.Tracking; SixensePlugin.sixenseGetNewestData(i, ref cd); m_Controllers[i].Update(ref cd); m_Controllers[i].m_Enabled = true; numControllersEnabled++; if (ControllerManagerEnabled && (m_Controllers[i].bodySide != Controller.BodySide.Unknown)) { numControllersBound++; } } else { m_Controllers[i].m_Enabled = false; } } } if (ControllerManagerEnabled) { if (numControllersEnabled < 2) { m_ControllerManagerState = ControllerManagerState.NONE; } switch (m_ControllerManagerState) { case ControllerManagerState.NONE: if (SixensePlugin.sixenseIsBaseConnected(0) != 0 && (numControllersEnabled > 1)) { if (numControllersBound == 0) { m_ControllerManagerState = ControllerManagerState.BIND_CONTROLLER_ONE; } else if (numControllersBound == 1) { m_ControllerManagerState = ControllerManagerState.BIND_CONTROLLER_TWO; } } break; case ControllerManagerState.BIND_CONTROLLER_ONE: if (numControllersBound > 0) { m_ControllerManagerState = ControllerManagerState.BIND_CONTROLLER_TWO; } else { for (int i = 0; i < MAX_CONTROLLERS; i++) { if ((m_Controllers[i] != null) && m_Controllers[i].GetButtonDown(HydraButtons.TRIGGER) && (m_Controllers[i].bodySide == Controller.BodySide.Unknown)) { m_Controllers[i].m_HandBind = Controller.BodySide.Left; SixensePlugin.sixenseAutoEnableHemisphereTracking(i); m_ControllerManagerState = ControllerManagerState.BIND_CONTROLLER_TWO; break; } } } break; case ControllerManagerState.BIND_CONTROLLER_TWO: if (numControllersBound > 1) { m_ControllerManagerState = ControllerManagerState.NONE; } else { for (int i = 0; i < MAX_CONTROLLERS; i++) { if ((m_Controllers[i] != null) && m_Controllers[i].GetButtonDown(HydraButtons.TRIGGER) && (m_Controllers[i].bodySide == Controller.BodySide.Unknown)) { m_Controllers[i].m_HandBind = Controller.BodySide.Right; SixensePlugin.sixenseAutoEnableHemisphereTracking(i); m_ControllerManagerState = ControllerManagerState.NONE; break; } } } break; } } } leftController = GetController(true); rightController = GetController(false); }
/// <summary> /// Update the static controller data once per frame. /// </summary> void Update() { // update controller data uint numControllersBound = 0; uint numControllersEnabled = 0; SixensePlugin.sixenseControllerData cd = new SixensePlugin.sixenseControllerData(); for (int i = 0; i < MAX_CONTROLLERS; i++) { if (m_Controllers[i] != null) { if (SixensePlugin.sixenseIsControllerEnabled(i) == 1) { SixensePlugin.sixenseGetNewestData(i, ref cd); m_Controllers[i].Update(ref cd); m_Controllers[i].SetEnabled(true); numControllersEnabled++; if (ControllerManagerEnabled && (SixenseInput.Controllers[i].Hand != SixenseHands.UNKNOWN)) { numControllersBound++; } } else { m_Controllers[i].SetEnabled(false); } } } // update controller manager if (ControllerManagerEnabled) { if (numControllersEnabled < 2) { m_ControllerManagerState = ControllerManagerState.NONE; } switch (m_ControllerManagerState) { case ControllerManagerState.NONE: { if (IsBaseConnected(0) && (numControllersEnabled > 1)) { if (numControllersBound == 0) { m_ControllerManagerState = ControllerManagerState.BIND_CONTROLLER_ONE; } else if (numControllersBound == 1) { m_ControllerManagerState = ControllerManagerState.BIND_CONTROLLER_TWO; } } } break; case ControllerManagerState.BIND_CONTROLLER_ONE: { if (numControllersBound > 0) { m_ControllerManagerState = ControllerManagerState.BIND_CONTROLLER_TWO; } else { for (int i = 0; i < MAX_CONTROLLERS; i++) { if ((m_Controllers[i] != null) && Controllers[i].GetButtonDown(SixenseButtons.TRIGGER) && (Controllers[i].Hand == SixenseHands.UNKNOWN)) { Controllers[i].HandBind = SixenseHands.LEFT; SixensePlugin.sixenseAutoEnableHemisphereTracking(i); m_ControllerManagerState = ControllerManagerState.BIND_CONTROLLER_TWO; break; } } } } break; case ControllerManagerState.BIND_CONTROLLER_TWO: { if (numControllersBound > 1) { m_ControllerManagerState = ControllerManagerState.NONE; } else { for (int i = 0; i < MAX_CONTROLLERS; i++) { if ((m_Controllers[i] != null) && Controllers[i].GetButtonDown(SixenseButtons.TRIGGER) && (Controllers[i].Hand == SixenseHands.UNKNOWN)) { Controllers[i].HandBind = SixenseHands.RIGHT; SixensePlugin.sixenseAutoEnableHemisphereTracking(i); m_ControllerManagerState = ControllerManagerState.NONE; break; } } } } break; default: break; } } }
/// <summary> /// Update the static controller data once per frame. /// </summary> void Update() { if (toggleRebind) { toggleRebind = false; RebindHands(); } // update controller data uint numControllersBound = 0; uint numControllersEnabled = 0; SixensePlugin.sixenseControllerData cd = new SixensePlugin.sixenseControllerData(); for (int i = 0; i < MAX_CONTROLLERS; i++) { if (m_Controllers[i] != null) { if (SixensePlugin.sixenseIsControllerEnabled(i) == 1) { SixensePlugin.sixenseGetNewestData(i, ref cd); m_Controllers[i].Update(ref cd); m_Controllers[i].SetEnabled(true); numControllersEnabled++; if (ControllerManagerEnabled && (SixenseInput.Controllers[i].Hand != SixenseHands.UNKNOWN)) { numControllersBound++; } } else { m_Controllers[i].SetEnabled(false); } } } // update controller manager if (ControllerManagerEnabled) { if (numControllersEnabled < 2) { m_ControllerManagerState = ControllerManagerState.NONE; } switch (m_ControllerManagerState) { case ControllerManagerState.NONE: { if (IsBaseConnected(0) && (numControllersEnabled > 1)) { if (numControllersBound == 0) { m_ControllerManagerState = ControllerManagerState.BIND_CONTROLLER_ONE; } else if (numControllersBound == 1) { m_ControllerManagerState = ControllerManagerState.BIND_CONTROLLER_TWO; } } } break; case ControllerManagerState.BIND_CONTROLLER_ONE: { m_ControllerManagerState = ControllerManagerState.BIND_CONTROLLER_TWO; } break; case ControllerManagerState.BIND_CONTROLLER_TWO: { if (numControllersBound > 1) { m_ControllerManagerState = ControllerManagerState.NONE; } else { //RebindHands(); for (int i = 0; i < MAX_CONTROLLERS; i++) { if ((m_Controllers[i] != null) && Input.GetKeyDown(KeyCode.P) && (Controllers[i].Hand == SixenseHands.UNKNOWN)) { // if ( ( m_Controllers[i] != null ) && Controllers[i].GetButtonDown( SixenseButtons.START ) && ( Controllers[i].Hand == SixenseHands.UNKNOWN ) ){ // //Hardcoded binding redirct // RebindHands(); } } } } break; default: break; } } }