public static void Start() { status = Status.Unavailable; SixensePlugin.sixenseInit(); for (int i = 0; i < MAX_CONTROLLERS; i++) { m_Controllers[i] = new Controller(); } dllPresent = true; started = true; bool baseConnected = SixensePlugin.sixenseIsBaseConnected(0) > 0; if (dllPresent && baseConnected) { status = Status.Present; } }
/// <summary> /// Returns true if the base for zero-based index i is connected. /// </summary> public static bool IsBaseConnected(int i) { return(SixensePlugin.sixenseIsBaseConnected(i) != 0); }
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); }
private static bool Available() { bool baseConnected = SixensePlugin.sixenseIsBaseConnected(0) > 0; return(dllPresent && baseConnected); }