Esempio n. 1
0
 internal void Update(ref SixensePlugin.sixenseControllerData cd)
 {
     m_Docked          = (cd.is_docked != 0);
     m_Hand            = ( SixenseHands )cd.which_hand;
     m_ButtonsPrevious = m_Buttons;
     m_Buttons         = ( SixenseButtons )cd.buttons;
     m_Trigger         = cd.trigger;
     m_JoystickX       = cd.joystick_x;
     m_JoystickY       = cd.joystick_y;
     m_Position.Set(cd.pos[0], cd.pos[1], cd.pos[2]);
     m_Rotation.Set(cd.rot_quat[0], cd.rot_quat[1], cd.rot_quat[2], cd.rot_quat[3]);
     if (m_Trigger > TriggerButtonThreshold)
     {
         m_Buttons |= SixenseButtons.TRIGGER;
     }
 }
Esempio n. 2
0
 internal void Update(ref SixensePlugin.sixenseControllerData cd)
 {
     m_Docked          = (cd.is_docked != 0);
     m_Hand            = (BodySide)cd.which_hand;
     m_ButtonsPrevious = m_Buttons;
     m_Buttons         = (HydraDevice.HydraButtons)cd.buttons;
     m_Trigger         = cd.trigger;
     m_JoystickX       = cd.joystick_x;
     m_JoystickY       = cd.joystick_y;
     m_Position        = new Vector(cd.pos[0], cd.pos[1], cd.pos[2]);
     m_Rotation        = new Rotation(cd.rot_quat[0], cd.rot_quat[1], cd.rot_quat[2], cd.rot_quat[3]);
     if (m_Trigger > m_TriggerButtonThreshold)
     {
         m_Buttons |= HydraDevice.HydraButtons.TRIGGER;
     }
 }
Esempio n. 3
0
	/// <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.DONE;
                        actuallyInitializedForReals = true;
                    }
                    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.DONE;
                                actuallyInitializedForReals = true;
                                break;
                            }
                        }
                    }
                }
                break;
			default:
				break;
			}
		}
	}
Esempio n. 4
0
    /// <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;
            }
        }
    }
Esempio n. 5
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);
        }
Esempio n. 6
0
    /// <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;
            }
        }
    }
Esempio n. 7
0
    /// <summary>
    /// Update the static controller data once per frame.
    /// </summary>
    void Update()
    {
        //LUKA CODE
        if (Input.GetKeyDown(KeyCode.R)){
            finishRec = Time.time + recordTime;
            record = true;
            //StartRecording();
        }
        //ENDOF LUKA CODE

        // 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 )
                {
                    //LUKA CODE
                    if(record) {
                        m_Controllers[i].recording = true;
                        m_Controllers[i].finishRecTime = finishRec;
                    }

                    //ENDOF LUKA CODE
                    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 );
                }
            }
        }
        //LUKA CODE
        if (record)	record = false;

        //ENDOF LUKA CODE

        // 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;
            }
        }
    }