コード例 #1
0
	//-----------------------------------------------------------------------------
	void Controller::update( const osScalar currentTime, const osScalar elapsedTime )
	{
		// note: this will also call a custom update in case present
		//       debug for the local player to see the effect
		BaseClass::update( currentTime, elapsedTime );

		float backwardForward = 
			getActionValue( EControllerAction_Forward ) - 
			getActionValue( EControllerAction_Backward );
		float leftRight = 
			getActionValue(EControllerAction_Left) - 
			getActionValue(EControllerAction_Right);

		backwardForward = clamp( backwardForward, -1.0f, 1.0f );
		leftRight = clamp( leftRight, -1.0f, 1.0f );
#if 0 // debugging
		if( (backwardForward + leftRight) != 0.0f)	{
			bool test(true);
			test = false;
		}
#endif

		// default implementation
		// pass backwardForward value to move axis
		setAxisValue(EControllerAction_Move,backwardForward);
		setActionValue(EControllerAction_Move,backwardForward);

		// pass leftRight value to yaw axis
		setAxisValue(EControllerAction_Yaw,leftRight);
		setActionValue(EControllerAction_Yaw,leftRight);
	}
コード例 #2
0
/** @brief Set a two D axis value
 *
 * Sets the value of an axis cell in a table. This is used when configuring
 * the table via a comms interface.
 *
 * @author Fred Cooke
 *
 * @param RPageValue The page of RAM that the table is in.
 * @param Table is a pointer to the table to adjust.
 * @param axisIndex The position of the axis cell to adjust.
 * @param axisValue The value to set the axis cell to.
 *
 * @return An error code. Zero means success, anything else is a failure.
 */
unsigned short setPagedTwoDTableAxisValue(unsigned char RPageValue, twoDTableUS* Table, unsigned short axisIndex, unsigned short axisValue){
	unsigned char oldRPage = RPAGE;
	RPAGE = RPageValue;
	unsigned short errorID = setAxisValue(axisIndex, axisValue, Table->Axis, 16, errorBaseTwoDTableAxis);
	RPAGE = oldRPage;
	return errorID;
}
コード例 #3
0
/** @brief Set a load axis value
 *
 * Sets the value of a load axis cell in a table. This is used when configuring
 * the table via a comms interface.
 *
 * @author Fred Cooke
 *
 * @param RPageValue The page of RAM that the table is in.
 * @param Table is a pointer to the table to adjust.
 * @param LoadIndex The load position of the cell to adjust.
 * @param LoadValue The value to set the load axis cell to.
 *
 * @return An error code. Zero means success, anything else is a failure.
 */
unsigned short setPagedMainTableLoadValue(unsigned char RPageValue, mainTable* Table, unsigned short LoadIndex, unsigned short LoadValue){
	unsigned char oldRPage = RPAGE;
	RPAGE = RPageValue;
	unsigned short errorID = setAxisValue(LoadIndex, LoadValue, Table->Load, Table->LoadLength, errorBaseMainTableLoad);
	RPAGE = oldRPage;
	return errorID;
}
コード例 #4
0
/** @brief Set an RPM axis value
 *
 * Sets the value of an RPM axis cell in a table. This is used when configuring
 * the table via a comms interface.
 *
 * @author Fred Cooke
 *
 * @param RPageValue The page of RAM that the table is in.
 * @param Table is a pointer to the table to adjust.
 * @param RPMIndex The RPM position of the cell to adjust.
 * @param RPMValue The value to set the RPM axis cell to.
 *
 * @return An error code. Zero means success, anything else is a failure.
 */
unsigned short setPagedMainTableRPMValue(unsigned char RPageValue, mainTable* Table, unsigned short RPMIndex, unsigned short RPMValue){
	unsigned char oldRPage = RPAGE;
	RPAGE = RPageValue;
	unsigned short errorID = setAxisValue(RPMIndex, RPMValue, Table->RPM, Table->RPMLength, errorBaseMainTableRPM);
	RPAGE = oldRPage;
	return errorID;
}
コード例 #5
0
ファイル: Controller.cpp プロジェクト: simongeilfus/Cinder-VR
void Controller::processAxes( const ::vr::VRControllerState_t& state )
{
	const uint64_t buttonMasdk = ::vr::ButtonMaskFromId( ::vr::k_EButton_SteamVR_Touchpad );
	const bool isTouched = ( buttonMasdk == ( state.ulButtonTouched & buttonMasdk ) );
	ci::vec2 value = ci::vec2( 0.0f );
	if(  isTouched ) {
		value.x = state.rAxis[ci::vr::openvr::Controller::AXIS_INDEX_TOUCHPAD].x;
		value.y = state.rAxis[ci::vr::openvr::Controller::AXIS_INDEX_TOUCHPAD].y;
	}
	if( isTouched != mTrackPadTouched ) {
		mTrackPadTouched = isTouched;
		setAxisValue( mAxes[0].get(), value );
	}
}
コード例 #6
0
void PointerCoords::applyOffset(float xOffset, float yOffset) {
    setAxisValue(AMOTION_EVENT_AXIS_X, getX() + xOffset);
    setAxisValue(AMOTION_EVENT_AXIS_Y, getY() + yOffset);
}
コード例 #7
0
ファイル: motion.c プロジェクト: zozo825117/stm32f429ev_1
////////////////////////////////////////////////////////////////////////////////
/// \brief			Multi Finger Gesture
/// \param			none
/// \return 			none
/// \deprecated Multi finger use mouse move and primary buttom message
////////////////////////////////////////////////////////////////////////////////
void MultiFingerGesture(void)
{
  int16_t dlt_x,dlt_y;
	static uint32_t scroll_state;
	static int16_t dlt_x_buf[2],dlt_y_buf[2];

	if(MajorFingerMove.moving)
		{
			dlt_x = abs(MajorFingerMove.Dlt_x);
			dlt_y = abs(MajorFingerMove.Dlt_y);

			if(dlt_x > dlt_y)
				{
					if( MajorFingerMove.Dlt_x > 0)
						{
							scroll_state &=~ MOVE_1_MASK;
							scroll_state |= MOVE_1_RIGHT;
						}
					else if(MajorFingerMove.Dlt_x < 0)
						{
							scroll_state &=~ MOVE_1_MASK;
							scroll_state |= MOVE_1_LEFT;
						}
					dlt_x_buf[0] = MajorFingerMove.Dlt_x;
				}
			else
				{
					if( MajorFingerMove.Dlt_y > 0)
						{
							scroll_state &=~ MOVE_1_MASK;
							scroll_state |= MOVE_1_UP;
						}
					else if(MajorFingerMove.Dlt_y < 0)
						{
							scroll_state &=~ MOVE_1_MASK;
							scroll_state |= MOVE_1_DOWN;
						}
					dlt_y_buf[0] = MajorFingerMove.Dlt_y;
				}

		}
	
	if(MinorFingerMove.moving)
		{
			dlt_x = abs(MinorFingerMove.Dlt_x);
			dlt_y = abs(MinorFingerMove.Dlt_y);

			if(dlt_x > dlt_y)
				{
					if( MinorFingerMove.Dlt_x > 0)
						{
							scroll_state &=~ MOVE_2_MASK;
							scroll_state |= MOVE_2_RIGHT;
						}
					else if(MinorFingerMove.Dlt_x < 0)
						{
							scroll_state &=~ MOVE_2_MASK;
							scroll_state |= MOVE_2_LEFT;
						}
					dlt_x_buf[1] = MinorFingerMove.Dlt_x;
				}
			else
				{
					if( MinorFingerMove.Dlt_y > 0)
						{
							scroll_state &=~ MOVE_2_MASK;
							scroll_state |= MOVE_2_UP;
						}
					else if(MinorFingerMove.Dlt_y < 0)
						{
							scroll_state &=~ MOVE_2_MASK;
							scroll_state |= MOVE_2_DOWN;
						}
					dlt_y_buf[1] = MinorFingerMove.Dlt_y;
				}

		}

	switch(scroll_state & MOVE_UP_DOWN_MASK)
	{
		case (MOVE_1_DOWN):
			break;
			
		case (MOVE_2_DOWN):
			break;	
			
		case (MOVE_3_DOWN):
			break;	
			
		case (MOVE_1_UP):
			break;	
			
		case (MOVE_2_UP):
			break;	

		case (MOVE_3_UP):
			break;	

		case (MOVE_1_DOWN|MOVE_2_DOWN):

		case (MOVE_1_UP|MOVE_2_UP):
        //SCROLL down
        dlt_y = abs(dlt_y_buf[0]);
        if(dlt_y < abs(dlt_y_buf[1]))
          {
            dlt_y = dlt_y_buf[1];
          }
        else
          {
             dlt_y = dlt_y_buf[0];
          }
        Motion.MotionMsg.Action = ACTION_SCROLL;
        setAxisValue(AXIS_VSCROLL, dlt_y);
        setAxisValue(AXIS_HSCROLL, 0);
        dlt_y_buf[0] = dlt_y_buf[1] = 0;
        scroll_state &=~ MOVE_UP_DOWN_MASK;

			break;

		case (MOVE_1_DOWN|MOVE_2_UP):
        // zoom
				dlt_y_buf[0] = dlt_y_buf[1] = 0;
				scroll_state &=~ MOVE_UP_DOWN_MASK;
			break;

		default:
				dlt_y_buf[0] = dlt_y_buf[1] = 0;
				scroll_state &=~ MOVE_UP_DOWN_MASK;
			break;

	}

	switch(scroll_state & MOVE_RIGHT_LEFT_MASK)
	{
		case (MOVE_1_LEFT):
			break;
			
		case (MOVE_2_LEFT):
			break;	
			
		case (MOVE_3_LEFT):
			break;	
			
		case (MOVE_1_RIGHT):
			break;	
			
		case (MOVE_2_RIGHT):
			break;	

		case (MOVE_3_RIGHT):
			break;	

		case (MOVE_1_LEFT|MOVE_2_LEFT):

		case (MOVE_1_RIGHT|MOVE_2_RIGHT):
        //SCROLL down
        dlt_x= abs(dlt_x_buf[0]);
        if(dlt_x < abs(dlt_x_buf[1]))
          {
            dlt_x = dlt_x_buf[1];
          }
        else
        {
           dlt_x = dlt_x_buf[0];
        }
        Motion.MotionMsg.Action = ACTION_SCROLL;
        setAxisValue(AXIS_HSCROLL, dlt_x);
        setAxisValue(AXIS_VSCROLL, 0);
        dlt_x_buf[0] = dlt_x_buf[1] = 0;
        scroll_state &=~ MOVE_RIGHT_LEFT_MASK;
			break;


		case (MOVE_1_LEFT|MOVE_2_RIGHT):
			// zoom
				dlt_x_buf[0] = dlt_x_buf[1] = 0;
				scroll_state &=~ MOVE_RIGHT_LEFT_MASK;
			break;

		default:
				dlt_x_buf[0] = dlt_x_buf[1] = 0;
				scroll_state &=~ MOVE_RIGHT_LEFT_MASK;
			break;

	}


}
コード例 #8
0
ファイル: motion.c プロジェクト: zozo825117/stm32f429ev_1
void MajorFingerPocess(void)
{
	uint32_t now_major_time = Tmr1Cnt,temp_time;
	int16_t x,y;
	uint8_t now_index;

	 if(FingerMsg.SFI[0].finger_state == STATE_DOWN)
		{
			MajorFingerMove.finger_down_time = now_major_time;

			/* inital move*/
			MajorFingerMove.Last_x = FingerMsg.SFI[0].Xpos[FingerMsg.SFI[0].use_idx];
			MajorFingerMove.Last_y = FingerMsg.SFI[0].Ypos[FingerMsg.SFI[0].use_idx];
			MajorFingerMove.average_cnt = 0;
			MajorFingerMove.index = 0;
			MajorFingerMove.moved = 0;
			MajorFingerMove.moving = 0;
			MajorFingerMove.MoveThres = NO_MOVE_HYSTERE_THRES; //first move threshold is larger than moved

			/*set message*/
			Motion.MotionMsg.Action= ACTION_DOWN;
			setAxisValue(AXIS_X, MajorFingerMove.Last_x);
			setAxisValue(AXIS_Y, MajorFingerMove.Last_y);
			last_x1=MajorFingerMove.Last_x;
			last_y1=MajorFingerMove.Last_y;
			
		}
	 else if(FingerMsg.SFI[0].finger_state == STATE_PRESSED)
		{
		 temp_time = now_major_time - MajorFingerMove.finger_down_time;
		 if(temp_time > BUTTON_TIMES_MAX)
			 {
				 MajorFingerMove.MoveThres = MOVE_HYSTERE_THRES;
			 }
 
		 now_index = FingerMsg.SFI[0].use_idx;
		 x = FingerMsg.SFI[0].Xpos[now_index];
		 y = FingerMsg.SFI[0].Ypos[now_index];
#if 1
		 if(isMoving(x,y,&MajorFingerMove))
			 {
				 MajorFingerMove.MoveThres = MOVE_HYSTERE_THRES;
				 MajorFingerMove.moved = 1;
				 MajorFingerMove.moving = 1; 
			 }
		 else
			 {
				 MajorFingerMove.moving = 0;
			 }
#endif

			/*set message*/
			Motion.MotionMsg.Action = ACTION_MOVE;
			setAxisValue(AXIS_X, x);
			setAxisValue(AXIS_Y, y);
		}
	 else if(FingerMsg.SFI[0].finger_state == STATE_UP)
		{

			step=0;
			
		 temp_time = now_major_time - MajorFingerMove.finger_down_time;
		 if((temp_time > BUTTON_TIMES_MIN)&&(temp_time < BUTTON_TIMES_MAX)&&
				(MajorFingerMove.moved == 0))
		 {
			 Motion.MotionMsg.ButtonFlags = BUTTON_PRIMARY;
		 }
			
			 MajorFingerMove.index = 0;
			 MajorFingerMove.moved = 0;
			 MajorFingerMove.moving = 0;

			/*set message*/
			Motion.MotionMsg.Action = ACTION_UP;
			setAxisValue(AXIS_X, MajorFingerMove.Last_x);
			setAxisValue(AXIS_Y, MajorFingerMove.Last_y);
			FingerMsg.SFI[0].finger_state = STATE_NOFINGER;
	 
		}
	 


}