当前位置: 首页>>代码示例>>C++>>正文


C++ Joystick类代码示例

本文整理汇总了C++中Joystick的典型用法代码示例。如果您正苦于以下问题:C++ Joystick类的具体用法?C++ Joystick怎么用?C++ Joystick使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Joystick类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetJoystickButton

 int GetJoystickButton(const Joystick& joystick)
 {
     return joystick.GetPressedButton();
 }
开发者ID:alexribek,项目名称:apeengine2,代码行数:4,代码来源:InputSystem.cpp

示例2: GetJoystickPovIndexAndDirection

 bool GetJoystickPovIndexAndDirection(const Joystick& joystick, int& povIndex, int& direction)
 {
     return joystick.GetPressedPovIndexAndDirection(povIndex, direction);
 }
开发者ID:alexribek,项目名称:apeengine2,代码行数:4,代码来源:InputSystem.cpp

示例3: GetJoystickPovIndicesAndDirections

 void GetJoystickPovIndicesAndDirections(InputSourceVector& inputSources, const Joystick& joystick)
 {
     joystick.GetPressingPovIndicesAndDirections(inputSources);
 }
开发者ID:alexribek,项目名称:apeengine2,代码行数:4,代码来源:InputSystem.cpp

示例4: HandleDrive

void DropDrive::HandleDrive(Joystick& left, Joystick& right) {
	DriveTrain.TankDrive(left.GetRawAxis(1)*-1.0, right.GetRawAxis(1)*-1.0);
//	SmartDashboard::PutNumber("Gyro heading", gyro.GetAngle());
}
开发者ID:gitter-badger,项目名称:frc4646-2016-competition-code,代码行数:4,代码来源:DropDrive.cpp

示例5: GetJoystickAxisIndexAndDirection

 bool GetJoystickAxisIndexAndDirection(const Joystick& joystick, int& axisIndex, int& direction)
 {
     return joystick.GetPressedAxisIndexAndDirection(axisIndex, direction);
 }
开发者ID:alexribek,项目名称:apeengine2,代码行数:4,代码来源:InputSystem.cpp

示例6: GetJoystickButtons

 void GetJoystickButtons(InputSourceVector& inputSources, const Joystick& joystick)
 {
     joystick.GetPressedButtons(inputSources);
 }
开发者ID:alexribek,项目名称:apeengine2,代码行数:4,代码来源:InputSystem.cpp

示例7: getTrigger

   	float getTrigger()
	{
		return m_joy->GetRawAxis(3);
	}
开发者ID:QueensFRC,项目名称:KBot_2013,代码行数:4,代码来源:LogitechF310.hpp

示例8: DriverControl

// To determine which drive control type the robot to use
// In case user operator wants different controls
void Robot::DriverControl(int driveControl) {
	switch (driveControl) {
	// Arcade drive (think racing games) w/ 1 joysticks
	case ARCADE_1:
		// If the turn is outside the joystick's standard drift, robot will assume the robot is turning
		// If not, robot will assume it is pushed, or has naturally drifted
		if (fabs(rStick.GetRawAxis(X_AXIS)) > JOYSTICK_STANDARD_DRIFT) {
			myRobot.ArcadeDrive(rStick.GetRawAxis(Y_AXIS), -rStick.GetRawAxis(X_AXIS));
			gyro.Reset();
		} else {
			// The turn will be the opposite of what the gyro says the angle of unintentional drift is,
			// which will have the robot go straight
			myRobot.ArcadeDrive(rStick.GetRawAxis(Y_AXIS), editedGyroRate*GYRO_SCALE_FACTOR);
		}

		break;

	// Arcade drive w/ 2 joysticks
	case ARCADE_2:
		if (fabs(rStick.GetRawAxis(X_AXIS)) > JOYSTICK_STANDARD_DRIFT) {
			myRobot.ArcadeDrive(-lStick.GetRawAxis(Y_AXIS), -rStick.GetRawAxis(X_AXIS));
			gyro.Reset();
		} else {
			myRobot.ArcadeDrive(-lStick.GetRawAxis(Y_AXIS), editedGyroRate*GYRO_SCALE_FACTOR);
		}

		break;

	// Arcade drive w/ left stick on gamepad (the knockoff xbox controller)
	case ARCADE_GAMEPAD_1:
		if (fabs(gamePad.GetRawAxis(GAMEPAD_LEFT_STICK_X)) > JOYSTICK_STANDARD_DRIFT) {
			myRobot.ArcadeDrive(gamePad.GetRawAxis(GAMEPAD_LEFT_STICK_Y), -gamePad.GetRawAxis(GAMEPAD_LEFT_STICK_X));
			gyro.Reset();
		} else {
			myRobot.ArcadeDrive(gamePad.GetRawAxis(GAMEPAD_LEFT_STICK_Y), editedGyroRate*GYRO_SCALE_FACTOR);
		}

		break;

	// Arcade drive w/ BOTH gamepad
	case ARCADE_GAMEPAD_2:
		if (fabs(gamePad.GetRawAxis(GAMEPAD_RIGHT_STICK_X)) > JOYSTICK_STANDARD_DRIFT) {
			myRobot.ArcadeDrive(-gamePad.GetRawAxis(GAMEPAD_LEFT_STICK_Y), -gamePad.GetRawAxis(GAMEPAD_RIGHT_STICK_X));
			gyro.Reset();
		} else {
			myRobot.ArcadeDrive(-gamePad.GetRawAxis(GAMEPAD_LEFT_STICK_Y), editedGyroRate*GYRO_SCALE_FACTOR);
		}

		break;

	// Tank drive (requires 2 sticks; each stick controls its respective 'tread' or side;
	//			   Ex: moving the right stick moves only the wheels on the right) w/ gamepad
	case TANK_GAMEPAD:
		joystickDifference = gamePad.GetRawAxis(GAMEPAD_LEFT_STICK_Y) - gamePad.GetRawAxis(GAMEPAD_RIGHT_STICK_Y);
		joystickAverage = (gamePad.GetRawAxis(GAMEPAD_LEFT_STICK_Y) + gamePad.GetRawAxis(GAMEPAD_RIGHT_STICK_Y))/2;
		if (fabs(joystickDifference) > TANK_TURN_THRESHOLD) {
			myRobot.TankDrive(gamePad.GetRawAxis(GAMEPAD_LEFT_STICK_Y), gamePad.GetRawAxis(GAMEPAD_RIGHT_STICK_Y));
			gyro.Reset();
		} else {
			myRobot.ArcadeDrive(joystickAverage, editedGyroRate*GYRO_SCALE_FACTOR);
		}

		break;

	// Tank drive w/ joysticks
	case TANK_2:
		joystickDifference = lStick.GetRawAxis(LEFT_STICK_Y) - rStick.GetRawAxis(RIGHT_STICK_Y);
		joystickAverage = (lStick.GetRawAxis(LEFT_STICK_Y) + rStick.GetRawAxis(RIGHT_STICK_Y))/2;
		if (fabs(joystickDifference) > TANK_TURN_THRESHOLD) {
			myRobot.TankDrive(lStick.GetRawAxis(LEFT_STICK_Y), rStick.GetRawAxis(RIGHT_STICK_Y));
			gyro.Reset();
		} else {
			myRobot.ArcadeDrive(joystickAverage, -rStick.GetRawAxis(RIGHT_STICK_Y));
		}

		break;
	}
}
开发者ID:CCathFIre,项目名称:Komodo-4293-2016-Code,代码行数:80,代码来源:Robot.cpp

示例9: getjoyRightX

	float getjoyRightX()
	{
		return m_joy->GetRawAxis(3);
	}
开发者ID:QueensFRC,项目名称:KBot_2013,代码行数:4,代码来源:LogitechController.hpp

示例10: OperatorControl

	void OperatorControl()
	{
		if(!m_FromAutonomous){
			init();
		}
		m_FromAutonomous = false;
		driveTrain.SetSafetyEnabled(true);
		
		int printDelay = 0;
		int shootDelay = 0;
		//bool SavePreferencesToFlash = false;
		
		while (IsOperatorControl() && IsEnabled())
		{
			/*
		    bool SavePreferences = gamePad.GetRawButton(8);
			if (SavePreferences){
				double elevatorAngleValue = SmartDashboard::GetNumber("Angle");
				dashboardPreferences->PutDouble("Angle", elevatorAngleValue);
				SavePreferencesToFlash = true;
			}
			*/
			printDelay ++;
			
			float rJoyStick = limitSpeed(rightJoyStick.GetY());
			float lJoyStick = limitSpeed(leftJoyStick.GetY());
			bool button6 = gamePad.GetRawButton(6);
			
			//speedLimiter.SetMaxOutput(SmartDashboard::GetNumber("Slider 1"));
			driveTrain.TankDrive(lJoyStick, rJoyStick);
			
			//manual mode(no PID) for elevator
			//float dPadThumbstick = TestMode::GetThumbstickWithZero(&gamePad);
			//ballGrabber.DriveElevatorTestMode(dPadThumbstick);
			//Sets motor equal to the elevator sensor.

			//TODO Probably don't need but want to test because called inside operate grabber.
			ballGrabber.OperatePIDLoop();

			if(printDelay == 100){
				lcd->Clear();
				if(m_display_page_1)
				{
					lcd->PrintfLine(DriverStationLCD::kUser_Line1, "Teleop pg1");
					lcd->PrintfLine(DriverStationLCD::kUser_Line2, "FR %4.0f, BA %4.0f",
							        frontUltrasonic.GetAverageDistance(),
							        backUltrasonic.GetAverageDistance());
					shooter.PrintShooterState(DriverStationLCD::kUser_Line3, lcd);
					SmartDashboard::PutNumber("UltrasonicF", 1);
					SmartDashboard::PutNumber("UltrasonicB", 1);                                         
					SmartDashboard::PutNumber("ElvatorAngle", 2);//Change keyname to ElavatorAngle from (ElvatorAngle)
																										 //^^
					if(button6){
						m_display_page_1 = false;
					}
				}
				else{
					lcd->PrintfLine(DriverStationLCD::kUser_Line1, "Teleop pg2 %c", button6 ? '1':'0');
					ballGrabber.DisplayDebugInfo(DriverStationLCD::kUser_Line2,lcd);
					//lcd->PrintfLine(DriverStationLCD::kUser_Line3, "G%f", ballGrabber.ballDetector.GetDistance());
					//ballGrabber.UpDateWithState(DriverStationLCD::kUser_Line3,lcd);
					shooter.PrintShooterState(DriverStationLCD::kUser_Line3, lcd);
					//lcd->PrintfLine(DriverStationLCD::kUser_Line4, "EV%6.2f", ballGrabber.elevatorAngleSensor.GetVoltage());
					shooter.DisplayDebugInfo(DriverStationLCD::kUser_Line4, lcd);
					//lcd->PrintfLine(DriverStationLCD::kUser_Line4, "%5.3f %5.3f %5.3f", lJoyStick, rJoyStick, SmartDashboard::GetNumber("Slider 1"));
					lcd->PrintfLine(DriverStationLCD::kUser_Line5, "DEV=%6.3f", ballGrabber.m_desiredElevatorVoltage);
					lcd->PrintfLine(DriverStationLCD::kUser_Line6, "CEV=%5.2f",
									ballGrabber.elevatorAngleSensor.GetVoltage());
					if(button6){
						m_display_page_1 = true;
					}
				}
				
				lcd->UpdateLCD();
				printDelay = 0;
			}
			//int rotation = elevation.Get();
			//the above is commented because we are not using it yet
			bool shooterButton = gamePad.GetRawButton(7) || gamePad.GetRawButton(8);//TODO make constants
			bool automaticAimButton = gamePad.GetRawButton(1);
			//float distanceToWall = frontUltrasonic.GetAverageDistance();
			//bool loadShooterButton = gamePad.GetRawButton(8);
			if (shooterButton && shootDelay == 0){
				shootDelay++;
			}
			if(shootDelay>0){
				shootDelay++;
			}
			bool ReadyToShoot = (shootDelay>PHOENIX2014_LOOP_COUNT_FOR_SHOOT_DELAY);
			shooter.OperateShooter(ReadyToShoot);
			if (ReadyToShoot){
				shootDelay = 0;
			}
			bool okToGrab = (shootDelay == 0);//Normaly 0 unless delaying
			ballGrabber.OperateGrabber(shooterButton, okToGrab);
			//Trying to make some things happen automatically during teleoperated
			if(automaticAimButton){
				ballGrabber.m_desiredElevatorVoltage = PHOENIX2014_TELEOP_ELEVATOR_ANGLE;
			}
			//((distanceToWall > (12.0*11.0)) && distanceToWall < (12.0*13.0)){
//.........这里部分代码省略.........
开发者ID:phoenixfrc,项目名称:Phoenix2014,代码行数:101,代码来源:MyRobot.cpp

示例11:

	bool get2()
	{
		return m_joy->GetRawButton(2);
	}
开发者ID:QueensFRC,项目名称:KBot_2013,代码行数:4,代码来源:LogitechController.hpp

示例12: getjoyLeftY

	float getjoyLeftY()
	{
		return m_joy->GetRawAxis(2);
	}
开发者ID:QueensFRC,项目名称:KBot_2013,代码行数:4,代码来源:LogitechController.hpp

示例13: getjoyLeftX

	float getjoyLeftX()
	{
		return m_joy->GetRawAxis(1);
	}
开发者ID:QueensFRC,项目名称:KBot_2013,代码行数:4,代码来源:LogitechController.hpp

示例14: getDPADX

    	float getDPADX()
	{
		return m_joy->GetRawAxis(6);
	}
开发者ID:QueensFRC,项目名称:KBot_2013,代码行数:4,代码来源:LogitechF310.hpp

示例15: getStart

	bool getStart()
	{
		return m_joy->GetRawButton(10);
	}
开发者ID:QueensFRC,项目名称:KBot_2013,代码行数:4,代码来源:LogitechController.hpp


注:本文中的Joystick类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。